PIPS
exp.c
Go to the documentation of this file.
1
/*
2
3
$Id: exp.c 1669 2019-06-26 17:24:57Z coelho $
4
5
Copyright 1989-2016 MINES ParisTech
6
7
This file is part of Linear/C3 Library.
8
9
Linear/C3 Library is free software: you can redistribute it and/or modify it
10
under the terms of the GNU Lesser General Public License as published by
11
the Free Software Foundation, either version 3 of the License, or
12
any later version.
13
14
Linear/C3 Library is distributed in the hope that it will be useful, but WITHOUT ANY
15
WARRANTY; without even the implied warranty of MERCHANTABILITY or
16
FITNESS FOR A PARTICULAR PURPOSE.
17
18
See the GNU Lesser General Public License for more details.
19
20
You should have received a copy of the GNU Lesser General Public License
21
along with Linear/C3 Library. If not, see <http://www.gnu.org/licenses/>.
22
23
*/
24
25
/* package arithmetique
26
*/
27
28
/*LINTLIBRARY*/
29
/* no overflow is checked
30
*/
31
32
#ifdef HAVE_CONFIG_H
33
#include "config.h"
34
#endif
35
#include <stdlib.h>
36
#include <stdio.h>
37
38
#include "
arithmetique.h
"
39
#include "
linear_assert.h
"
40
41
/* int exponentiate(x,n): raise x to the power n
42
*
43
* Precondition: n => 0
44
*/
45
Value
exponentiate
(
Value
x
,
int
n)
46
{
47
Value
y;
48
49
/* validation - n is positive
50
*/
51
assert
(n >= 0);
52
if
(n == 0)
return
VALUE_ONE
;
53
54
/* FI: la complexite pourrait etre reduite de O(n) a O(log n)
55
*/
56
for
(y=
VALUE_ONE
; n>0; n--)
57
value_product
(y,
x
);
58
59
return
y;
60
}
Value
int Value
Definition:
arithmetique-local.h:296
value_product
#define value_product(v, w)
Definition:
arithmetique-local.h:447
VALUE_ONE
#define VALUE_ONE
Definition:
arithmetique-local.h:303
arithmetique.h
exponentiate
Value exponentiate(Value x, int n)
package arithmetique
Definition:
exp.c:45
linear_assert.h
assert
#define assert(ex)
Definition:
newgen_assert.h:41
x
static char * x
Definition:
split_file.c:159
linear
src
arithmetique
exp.c
Generated on Thu Sep 26 2024 22:11:28 for PIPS by
1.9.1