C++ main module for stochmagnet Package  1.0
types.h
Go to the documentation of this file.
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 //redefined the standart type
22 //===========================
23 
24 //[0,2^8[=[0,256[ 1 byte
25 #define tUChar unsigned char
26 #define tUCInt uint8_t
27 
28 //[-2^7,2^7[=[-128,127[ 1 bytes
29 //#define tChar char16_t for unicode UTF-16
30 //#define tChar char32_t for unicode UTF-32
31 //#define tChar char for unicode UTF-8
32 
33 #define tChar char
34 #define tCInt int8_t
35 
36 
37 //[0,2^16[=[0,65 536[ 2 bytes
38 #define tUSInt unsigned short int
39 
40 //[-2^15,2^15[=[-32 768,32 768[ 2 bytes
41 #define tSInt short int
42 
43 //[0,2^32[=[0,4 294 967 296[ 4 bytes
44 #define tUInt unsigned int
45 
46 //[-2^31,2^31[=[-2 147 483 648,2 147 483 648[ 4 bytes
47 #define tInt int
48 
49 //[0,2^32[=[-2 147 483 648,2 147 483 648[ 8 bytes on 32 bits machine
50 //[0,2^64[=[0,1,844674407×10^19[ 16 bytes on 64 bits machine
51 #define tULInt unsigned long int
52 
53 //[-2^32,2^32[=[-2 147 483 648,2 147 483 648[ 8 bytes on 32 bits machine
54 //[_2^63,2^63[=[-9,223372037×10^18,9,223372037×10^18[ 16 bytes on 64 bits machine
55 #define tLInt long int
56 
57 //[0,2^64[=[0,1,844674407×10^19[ 16 bits
58 #define tULLInt unsigned long long int
59 
60 //[_2^63,2^63[=[-9,223372037×10^18,9,223372037×10^18[ 16 bytes on 64 bits machine
61 #define tLLInt long long int
62 
63 //define real on 4 bits
64 #define tFloat float
65 
66 //define real on 8 bits
67 #define tDouble double
68 
69 //define real on 16 bits
70 #define tLDouble long double
71 
72 //define complex on 2 x 4 bits
73 #define tFComplex std::complex<float>
74 
75 //define complex on 2 x 8 bits
76 #define tDComplex std::complex<double>
77 
78 //define complex on 2 x 16 bits
79 #define tLDComplex std::complex<long double>
80 
81 //define complex on 2 x 16 bits
82 #define tLComplex std::complex<long double>
83 
84 
85 
86 //defult types used depending on compilation
87 //===========================================
88 // - flag
89 
90 //define a flag
91 #define tFlag tUChar
92 
93 // The mathematical corpse :
94 // - N : the natural integer numbers
95 // - Z : the relative integer numbers
96 // - R : the real numbers
97 // - C : the complex number based on real numbers
98 
99 #if defined(USE_SINT)
100 #define tRelativeInteger tSInt
101 #define tInteger tUSInt
102 #elif defined(USE_INT)
103 #define tRelativeInteger tInt
104 #define tInteger tUInt
105 #elif defined(USE_LINT)
106 #define tRelativeInteger tSLnt
107 #define tInteger tULInt
108 #elif defined(USE_LLINT)
109 #define tRelativeInteger tLLInt
110 #define tInteger tULLInt
111 
112 #else
113 #define tRelativeInteger tLLInt
114 #define tInteger tULLInt
115 #endif
116 
117 #if defined(USE_DOUBLE)
118 
119 #define tReal tDouble
120 #define tRealFormat "%lg"
121 #define tComplex tDComplex
122 
123 #elif defined(USE_FLOAT)
124 
125 #define tReal tFloat
126 #define tRealFormat "%f"
127 #define tComplex tFComplex
128 
129 #elif defined(USE_LDOUBLE)
130 
131 #define tReal tLDouble
132 #define tRealFormat "%Lg"
133 #define tComplex tLDComplex
134 
135 #else
136 
137 #define tReal tLDouble
138 #define tRealFormat "%Lg"
139 #define tComplex tLDComplex
140 
141 #endif
142 
143 #define tNaturalInteger tInteger
144 
145 //string type
146 //============
147 #define tString std::string
148 
149 //define boolean type
150 // 0:false 1:true
151 #define tBoolean bool
152 
153 //array index type
154 //================
155 
156 //define a unsigned
157 #define tIndex size_t
158 
159 //define difference between indices
160 #define tRelativeIndex ptrdiff_t
161 
162 //memory types
163 //===========
164 
165 //define a memory size
166 #define tMemSize size_t
167 
168 //define a pointer substraction
169 #define tMemDiff ptrdiff_t
170 
171 //time types
172 //===========
173 #define tTime time_t
174 
175 
176 
177 
178 
179 //end declarations of types
180 #endif