C++ mpi module for stochmagnet_main Package
types.h
1 #ifndef TYPES_H
2 #define TYPES_H
3 
4 //define the types used in the program
5 
6 //include the complex type
7 #include <complex>
8 
9 //include the memset header
10 #include <cstring>
11 
12 //include the string type
13 #include <string>
14 
15 //include the limits for types
16 #include <limits>
17 
18 //include the C standart definition
19 #include <cstddef>
20 
21 
22 //standart library
23 #include <stdlib.h>
24 
25 //for type name
26 #include <cxxabi.h>
27 
28 //include the Template condition
29 #include<type_traits>
30 #include<concepts>
31 
32 
33 
34 //include the chrono header
35 #include <chrono>
36 //C time header
37 #include <ctime>
38 
39 #ifdef DEBUG
40 //define the assert method
41 #include<cassert>
42 #endif
43 
44 
45 //redefined the standart type
46 //===========================
47 
48 //[0,2^8[=[0,256[ 1 byte
49 #define tUChar unsigned char
50 #define tUCInt uint8_t
51 
52 //[-2^7,2^7[=[-128,127[ 1 bytes
53 //#define tChar char16_t for unicode UTF-16
54 //#define tChar char32_t for unicode UTF-32
55 //#define tChar char for unicode UTF-8
56 
57 #define tChar char
58 #define tCInt int8_t
59 
60 
61 //[0,2^16[=[0,65 536[ 2 bytes
62 #define tUSInt unsigned short int
63 
64 //[-2^15,2^15[=[-32 768,32 768[ 2 bytes
65 #define tSInt short int
66 
67 //[0,2^32[=[0,4 294 967 296[ 4 bytes
68 #define tUInt unsigned int
69 
70 //[-2^31,2^31[=[-2 147 483 648,2 147 483 648[ 4 bytes
71 #define tInt int
72 
73 //[0,2^32[=[-2 147 483 648,2 147 483 648[ 8 bytes on 32 bits machine
74 //[0,2^64[=[0,1,844674407×10^19[ 16 bytes on 64 bits machine
75 #define tULInt unsigned long int
76 
77 //[-2^32,2^32[=[-2 147 483 648,2 147 483 648[ 8 bytes on 32 bits machine
78 //[_2^63,2^63[=[-9,223372037×10^18,9,223372037×10^18[ 16 bytes on 64 bits machine
79 #define tLInt long int
80 
81 //[0,2^64[=[0,1,844674407×10^19[ 16 bits
82 #define tULLInt unsigned long long int
83 
84 //[_2^63,2^63[=[-9,223372037×10^18,9,223372037×10^18[ 16 bytes on 64 bits machine
85 #define tLLInt long long int
86 
87 //define real on 4 bits
88 #define tFloat float
89 
90 //define real on 8 bits
91 #define tDouble double
92 
93 //define real on 16 bits
94 #define tLDouble long double
95 
96 //define complex on 2 x 4 bits
97 #define tFComplex std::complex<float>
98 
99 //define complex on 2 x 8 bits
100 #define tDComplex std::complex<double>
101 
102 //define complex on 2 x 16 bits
103 #define tLDComplex std::complex<long double>
104 
105 //define complex on 2 x 16 bits
106 #define tLComplex std::complex<long double>
107 
108 
109 
110 //defult types used depending on compilation
111 //===========================================
112 // - flag
113 
114 //define a flag
115 #define tFlag tUChar
116 
117 // The mathematical corpse :
118 // - N : the natural integer numbers
119 // - Z : the relative integer numbers
120 // - R : the real numbers
121 // - C : the complex number based on real numbers
122 
123 #if defined(USE_SINT)
124 #define tRelativeInteger tSInt
125 #define tInteger tUSInt
126 #elif defined(USE_INT)
127 #define tRelativeInteger tInt
128 #define tInteger tUInt
129 #elif defined(USE_LINT)
130 #define tRelativeInteger tLInt
131 #define tInteger tULInt
132 #elif defined(USE_LLINT)
133 #define tRelativeInteger tLLInt
134 #define tInteger tULLInt
135 
136 #else
137 #define tRelativeInteger tLLInt
138 #define tInteger tULLInt
139 #endif
140 
141 #if defined(USE_DOUBLE)
142 
143 #define tReal tDouble
144 #define tRealFormat "%lg"
145 #define tComplex tDComplex
146 
147 #elif defined(USE_FLOAT)
148 
149 #define tReal tFloat
150 #define tRealFormat "%f"
151 #define tComplex tFComplex
152 
153 #elif defined(USE_LDOUBLE)
154 
155 #define tReal tLDouble
156 #define tRealFormat "%Lg"
157 #define tComplex tLDComplex
158 
159 #else
160 
161 #define tReal tLDouble
162 #define tRealFormat "%Lg"
163 #define tComplex tLDComplex
164 
165 #endif
166 
167 //string type
168 //============
169 #define tString std::string
170 
171 //define boolean type
172 // 0:false 1:true
173 #define tBoolean bool
174 
175 //array index type
176 //================
177 
178 //NULL Index
179 #define null_index std::numeric_limits<tIndex>::max()
180 
181 //define a unsigned
182 #define tIndex size_t
183 
184 //define difference between indices
185 #define tRelativeIndex ptrdiff_t
186 
187 //3D space dimension
188 #define tDimension tUCInt
189 
190 //memory types
191 //===========
192 
193 //null pointer
194 //#define null NULL
195 #define null nullptr
196 
197 //define a memory size
198 #define tMemSize size_t
199 
200 //define a pointer substraction
201 #define tMemDiff ptrdiff_t
202 
203 //time types
204 //===========
205 #define tTime time_t
206 
207 //profiled routines name->(total duration, index of call -> start time )
208 typedef std::chrono::time_point<std::chrono::high_resolution_clock> tWallTime;
209 
210 //debug command
211 //==============
212 //if the program has been compiled with -DDEBUG, the assert command is executed
213 #ifdef DEBUG
214 
215 #define ASSERT(a) {assert(a);}
216 #define ASSERT_IN(a) {assert(a);}
217 #define ASSERT_OUT(a) {assert(a);}
218 #define ASSERT_EXCEPTION(T,P,F,C) { if (!(T)) throw CORE_Exception(P,F,C);}
219 
220 #else
221 
222 #define ASSERT(a) {}
223 #define ASSERT_IN(a) {}
224 #define ASSERT_OUT(a) {}
225 #define ASSERT_EXCEPTION(T,P,F,C)
226 
227 //endif DEBUG
228 #endif
229 
230 //end declarations of types
231 #endif