1 | /* |
---|
2 | * ----------------------------------------------------------------- |
---|
3 | * $Revision$ |
---|
4 | * $Date$ |
---|
5 | * ----------------------------------------------------------------- |
---|
6 | * Programmer(s): Scott D. Cohen, Alan C. Hindmarsh and |
---|
7 | * Aaron Collier @ LLNL |
---|
8 | * ----------------------------------------------------------------- |
---|
9 | * LLNS Copyright Start |
---|
10 | * Copyright (c) 2014, Lawrence Livermore National Security |
---|
11 | * This work was performed under the auspices of the U.S. Department |
---|
12 | * of Energy by Lawrence Livermore National Laboratory in part under |
---|
13 | * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344. |
---|
14 | * Produced at the Lawrence Livermore National Laboratory. |
---|
15 | * All rights reserved. |
---|
16 | * For details, see the LICENSE file. |
---|
17 | * LLNS Copyright End |
---|
18 | * ----------------------------------------------------------------- |
---|
19 | * This is the header file for a simple C-language math library. The |
---|
20 | * routines listed here work with the type realtype as defined in |
---|
21 | * the header file sundials_types.h. |
---|
22 | * ----------------------------------------------------------------- |
---|
23 | */ |
---|
24 | |
---|
25 | #ifndef _SUNDIALSMATH_H |
---|
26 | #define _SUNDIALSMATH_H |
---|
27 | |
---|
28 | #include <sundials/sundials_types.h> |
---|
29 | |
---|
30 | #ifdef __cplusplus /* wrapper to enable C++ usage */ |
---|
31 | extern "C" { |
---|
32 | #endif |
---|
33 | |
---|
34 | /* |
---|
35 | * ----------------------------------------------------------------- |
---|
36 | * Macros : MIN and MAX |
---|
37 | * ----------------------------------------------------------------- |
---|
38 | * MIN(A,B) returns the minimum of A and B |
---|
39 | * |
---|
40 | * MAX(A,B) returns the maximum of A and B |
---|
41 | * |
---|
42 | * SQR(A) returns A^2 |
---|
43 | * ----------------------------------------------------------------- |
---|
44 | */ |
---|
45 | |
---|
46 | #ifndef SUNMIN |
---|
47 | #define SUNMIN(A, B) ((A) < (B) ? (A) : (B)) |
---|
48 | #endif |
---|
49 | |
---|
50 | #ifndef SUNMAX |
---|
51 | #define SUNMAX(A, B) ((A) > (B) ? (A) : (B)) |
---|
52 | #endif |
---|
53 | |
---|
54 | #ifndef SUNSQR |
---|
55 | #define SUNSQR(A) ((A)*(A)) |
---|
56 | #endif |
---|
57 | |
---|
58 | |
---|
59 | /* |
---|
60 | * ----------------------------------------------------------------- |
---|
61 | * Function : SUNRpowerI |
---|
62 | * ----------------------------------------------------------------- |
---|
63 | * Usage : int exponent; |
---|
64 | * realtype base, ans; |
---|
65 | * ans = SUNRpowerI(base,exponent); |
---|
66 | * ----------------------------------------------------------------- |
---|
67 | * SUNRpowerI returns the value of base^exponent, where base is of type |
---|
68 | * realtype and exponent is of type int. |
---|
69 | * ----------------------------------------------------------------- |
---|
70 | */ |
---|
71 | |
---|
72 | SUNDIALS_EXPORT realtype SUNRpowerI(realtype base, int exponent); |
---|
73 | |
---|
74 | /* |
---|
75 | * ----------------------------------------------------------------- |
---|
76 | * Function : SUNRpowerR |
---|
77 | * ----------------------------------------------------------------- |
---|
78 | * Usage : realtype base, exponent, ans; |
---|
79 | * ans = SUNRpowerR(base,exponent); |
---|
80 | * ----------------------------------------------------------------- |
---|
81 | * SUNRpowerR returns the value of base^exponent, where both base and |
---|
82 | * exponent are of type realtype. If base < ZERO, then SUNRpowerR |
---|
83 | * returns ZERO. |
---|
84 | * ----------------------------------------------------------------- |
---|
85 | */ |
---|
86 | |
---|
87 | SUNDIALS_EXPORT realtype SUNRpowerR(realtype base, realtype exponent); |
---|
88 | |
---|
89 | /* |
---|
90 | * ----------------------------------------------------------------- |
---|
91 | * Function : SUNRsqrt |
---|
92 | * ----------------------------------------------------------------- |
---|
93 | * Usage : realtype sqrt_x; |
---|
94 | * sqrt_x = SUNRsqrt(x); |
---|
95 | * ----------------------------------------------------------------- |
---|
96 | * SUNRsqrt(x) returns the square root of x. If x < ZERO, then |
---|
97 | * SUNRsqrt returns ZERO. |
---|
98 | * ----------------------------------------------------------------- |
---|
99 | */ |
---|
100 | |
---|
101 | SUNDIALS_EXPORT realtype SUNRsqrt(realtype x); |
---|
102 | |
---|
103 | /* |
---|
104 | * ----------------------------------------------------------------- |
---|
105 | * Function : SUNRabs |
---|
106 | * ----------------------------------------------------------------- |
---|
107 | * Usage : realtype abs_x; |
---|
108 | * abs_x = SUNRabs(x); |
---|
109 | * ----------------------------------------------------------------- |
---|
110 | * SUNRabs(x) returns the absolute value of x. |
---|
111 | * ----------------------------------------------------------------- |
---|
112 | */ |
---|
113 | |
---|
114 | SUNDIALS_EXPORT realtype SUNRabs(realtype x); |
---|
115 | |
---|
116 | /* |
---|
117 | * ----------------------------------------------------------------- |
---|
118 | * Function : SUNRexp |
---|
119 | * ----------------------------------------------------------------- |
---|
120 | * Usage : realtype exp_x; |
---|
121 | * exp_x = SUNRexp(x); |
---|
122 | * ----------------------------------------------------------------- |
---|
123 | * SUNRexp(x) returns e^x (base-e exponential function). |
---|
124 | * ----------------------------------------------------------------- |
---|
125 | */ |
---|
126 | |
---|
127 | SUNDIALS_EXPORT realtype SUNRexp(realtype x); |
---|
128 | |
---|
129 | #ifdef __cplusplus |
---|
130 | } |
---|
131 | #endif |
---|
132 | |
---|
133 | #endif |
---|