1 | /* ----------------------------------------------------------------- |
---|
2 | * Programmer(s): Scott Cohen, Alan Hindmarsh, Radu Serban, |
---|
3 | * Aaron Collier, and Slaven Peles @ LLNL |
---|
4 | * ----------------------------------------------------------------- |
---|
5 | * LLNS Copyright Start |
---|
6 | * Copyright (c) 2014, Lawrence Livermore National Security |
---|
7 | * This work was performed under the auspices of the U.S. Department |
---|
8 | * of Energy by Lawrence Livermore National Laboratory in part under |
---|
9 | * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344. |
---|
10 | * Produced at the Lawrence Livermore National Laboratory. |
---|
11 | * All rights reserved. |
---|
12 | * For details, see the LICENSE file. |
---|
13 | * LLNS Copyright End |
---|
14 | * ----------------------------------------------------------------- |
---|
15 | * This header file exports three types: realtype, sunindextype and |
---|
16 | * booleantype, as well as the constants SUNTRUE and SUNFALSE. |
---|
17 | * |
---|
18 | * Users should include the header file sundials_types.h in every |
---|
19 | * program file and use the exported name realtype instead of |
---|
20 | * float, double or long double. |
---|
21 | * |
---|
22 | * The constants SUNDIALS_SINGLE_PRECISION, SUNDIALS_DOUBLE_PRECISION |
---|
23 | * and SUNDIALS_LONG_DOUBLE_PRECISION indicate the underlying data |
---|
24 | * type of realtype. |
---|
25 | * |
---|
26 | * The legal types for realtype are float, double and long double. |
---|
27 | * |
---|
28 | * The constants SUNDIALS_INT64_T and SUNDIALS_INT32_T indicate |
---|
29 | * the underlying data type of sunindextype -- the integer data type |
---|
30 | * used for vector and matrix indices. |
---|
31 | * |
---|
32 | * Data types are set at the configuration stage. |
---|
33 | * |
---|
34 | * The macro RCONST gives the user a convenient way to define |
---|
35 | * real-valued literal constants. To use the constant 1.0, for example, |
---|
36 | * the user should write the following: |
---|
37 | * |
---|
38 | * #define ONE RCONST(1.0) |
---|
39 | * |
---|
40 | * If realtype is defined as a double, then RCONST(1.0) expands |
---|
41 | * to 1.0. If realtype is defined as a float, then RCONST(1.0) |
---|
42 | * expands to 1.0F. If realtype is defined as a long double, |
---|
43 | * then RCONST(1.0) expands to 1.0L. There is never a need to |
---|
44 | * explicitly cast 1.0 to (realtype). The macro can be used for |
---|
45 | * literal constants only. It cannot be used for expressions. |
---|
46 | * -----------------------------------------------------------------*/ |
---|
47 | |
---|
48 | #ifndef _SUNDIALSTYPES_H |
---|
49 | #define _SUNDIALSTYPES_H |
---|
50 | |
---|
51 | #ifndef _SUNDIALS_CONFIG_H |
---|
52 | #define _SUNDIALS_CONFIG_H |
---|
53 | #include <sundials/sundials_config.h> |
---|
54 | #endif |
---|
55 | |
---|
56 | #include <float.h> |
---|
57 | #include <stdint.h> |
---|
58 | |
---|
59 | #ifdef __cplusplus /* wrapper to enable C++ usage */ |
---|
60 | extern "C" { |
---|
61 | #endif |
---|
62 | |
---|
63 | /* |
---|
64 | *------------------------------------------------------------------ |
---|
65 | * Type realtype |
---|
66 | * Macro RCONST |
---|
67 | * Constants BIG_REAL, SMALL_REAL, and UNIT_ROUNDOFF |
---|
68 | *------------------------------------------------------------------ |
---|
69 | */ |
---|
70 | |
---|
71 | #if defined(SUNDIALS_SINGLE_PRECISION) |
---|
72 | |
---|
73 | typedef float realtype; |
---|
74 | # define RCONST(x) x##F |
---|
75 | # define BIG_REAL FLT_MAX |
---|
76 | # define SMALL_REAL FLT_MIN |
---|
77 | # define UNIT_ROUNDOFF FLT_EPSILON |
---|
78 | |
---|
79 | #elif defined(SUNDIALS_DOUBLE_PRECISION) |
---|
80 | |
---|
81 | typedef double realtype; |
---|
82 | # define RCONST(x) x |
---|
83 | # define BIG_REAL DBL_MAX |
---|
84 | # define SMALL_REAL DBL_MIN |
---|
85 | # define UNIT_ROUNDOFF DBL_EPSILON |
---|
86 | |
---|
87 | #elif defined(SUNDIALS_EXTENDED_PRECISION) |
---|
88 | |
---|
89 | typedef long double realtype; |
---|
90 | # define RCONST(x) x##L |
---|
91 | # define BIG_REAL LDBL_MAX |
---|
92 | # define SMALL_REAL LDBL_MIN |
---|
93 | # define UNIT_ROUNDOFF LDBL_EPSILON |
---|
94 | |
---|
95 | #endif |
---|
96 | |
---|
97 | |
---|
98 | /* |
---|
99 | *------------------------------------------------------------------ |
---|
100 | * Type : sunindextype |
---|
101 | *------------------------------------------------------------------ |
---|
102 | * Defines integer type to be used for vector and matrix indices. |
---|
103 | * User can build sundials to use 32- or 64-bit signed integers. |
---|
104 | * If compiler does not support portable data types, the SUNDIALS |
---|
105 | * CMake build system tries to find a type of the desired size. |
---|
106 | *------------------------------------------------------------------ |
---|
107 | */ |
---|
108 | |
---|
109 | typedef SUNDIALS_INDEX_TYPE sunindextype; |
---|
110 | |
---|
111 | /* |
---|
112 | *------------------------------------------------------------------ |
---|
113 | * Type : booleantype |
---|
114 | *------------------------------------------------------------------ |
---|
115 | * Constants : SUNFALSE and SUNTRUE |
---|
116 | *------------------------------------------------------------------ |
---|
117 | * ANSI C does not have a built-in boolean data type. Below is the |
---|
118 | * definition for a new type called booleantype. The advantage of |
---|
119 | * using the name booleantype (instead of int) is an increase in |
---|
120 | * code readability. It also allows the programmer to make a |
---|
121 | * distinction between int and boolean data. Variables of type |
---|
122 | * booleantype are intended to have only the two values SUNFALSE and |
---|
123 | * SUNTRUE which are defined below to be equal to 0 and 1, |
---|
124 | * respectively. |
---|
125 | *------------------------------------------------------------------ |
---|
126 | */ |
---|
127 | |
---|
128 | #ifndef booleantype |
---|
129 | #define booleantype int |
---|
130 | #endif |
---|
131 | |
---|
132 | #ifndef SUNFALSE |
---|
133 | #define SUNFALSE 0 |
---|
134 | #endif |
---|
135 | |
---|
136 | #ifndef SUNTRUE |
---|
137 | #define SUNTRUE 1 |
---|
138 | #endif |
---|
139 | |
---|
140 | |
---|
141 | #ifdef __cplusplus |
---|
142 | } |
---|
143 | #endif |
---|
144 | |
---|
145 | #endif /* _SUNDIALSTYPES_H */ |
---|
146 | |
---|
147 | |
---|