C++ main module for emicrom Package
1.0
include
common
core
types.h
Go to the documentation of this file.
1
#ifndef TYPES_H
2
#define TYPES_H
3
#include <algorithm>
4
#include <string>
5
#include <complex>
6
#include <assert.h>
7
#include <stdlib.h>
8
9
10
11
using namespace
std
;
12
13
14
15
//int, real, complex type definitions
16
//=======================================
17
18
19
//[0,2^8[=[0,256[ 1 byte
20
#define tUChar unsigned char
21
#define tUCInt uint8_t
22
//[-2^7,2^7[=[-128,127[ 1 bytes
23
#define tChar char
24
#define tCInt int8_t
25
26
27
//[0,2^16[=[0,65 536[ 2 bytes
28
#define tUSInt unsigned short int
29
//[-2^15,2^15[=[-32 768,32 768[ 2 bytes
30
#define tSInt short int
31
32
//[0,2^32[=[0,4 294 967 296[ 4 bytes
33
#define tUInt unsigned int
34
//[-2^31,2^31[=[-2 147 483 648,2 147 483 648[ 4 bytes
35
#define tInt int
36
37
//[0,2^32[=[-2 147 483 648,2 147 483 648[ 8 bytes on 32 bits machine
38
//[0,2^64[=[0,1,844674407×10^19[ 16 bytes on 64 bits machine
39
#define tULInt unsigned long int
40
//[-2^32,2^32[=[-2 147 483 648,2 147 483 648[ 8 bytes on 32 bits machine
41
//[_2^63,2^63[=[-9,223372037×10^18,9,223372037×10^18[ 16 bytes on 64 bits machine
42
#define tLInt long int
43
44
//[0,2^64[=[0,1,844674407×10^19[ 16 bits
45
#define tULLInt unsigned long long int
46
//[_2^63,2^63[=[-9,223372037×10^18,9,223372037×10^18[ 16 bytes on 64 bits machine
47
#define tLLInt long long int
48
49
//define real on 4 bits
50
#define tFloat float
51
//define real on 8 bits
52
#define tDouble double
53
//define real on 16 bits
54
#define tLDouble long double
55
56
//define complex on 2 x 4 bits
57
#define tFComplex complex<float>
58
59
//define complex on 2 x 8 bits
60
#define tDComplex complex<double>
61
62
//define complex on 2 x 16 bits
63
#define tLDComplex complex<long double>
64
65
//define complex on 2 x 16 bits
66
#define tLComplex complex<long double>
67
68
69
70
//types used in program
71
//=====================
72
73
//define a flag
74
#define tFlag tUChar
75
76
//define an relative integer
77
#if defined(USE_SINT)
78
#define tInteger tSInt
79
#define tUInteger tUSInt
80
#elif defined(USE_INT)
81
#define tInteger tInt
82
#define tUInteger tUInt
83
#elif defined(USE_LINT)
84
#define tInteger tSLnt
85
#define tUInteger tULInt
86
#elif defined(USE_LLINT)
87
#define tInteger tLLInt
88
#define tUInteger tULLInt
89
#else
90
#define tInteger tLInt
91
#define tUInteger tULInt
92
#endif
93
94
//define a real & complex
95
#if defined(USE_DOUBLE)
96
97
#define tReal tDouble
98
#define tRealFormat "%lg"
99
#define tComplex tDComplex
100
#define EPS 1.e-18
101
102
#elif defined(USE_FLOAT)
103
104
#define tReal tFloat
105
#define tRealFormat "%f"
106
#define tComplex tFComplex
107
#define EPS 1.e-6
108
109
#elif defined(USE_LDOUBLE)
110
111
#define tReal tLDouble
112
#define tRealFormat "%Lg"
113
#define tComplex tLDComplex
114
#define EPS 1.e-24
115
116
#else
117
118
#define tReal tLDouble
119
#define tRealFormat "%Lg"
120
#define tComplex tLDComplex
121
#define EPS 1.e-24
122
123
#endif
124
125
//define a unsigned index on array or vector
126
#define tUIndex size_t
127
128
//define a signed index on array or vector
129
#define tIndex ptrdiff_t
130
131
//define time type
132
#define tTime time_t
133
134
//define string type
135
#define tString string
136
137
//define boolean type
138
// 0:false 1:true
139
#define tBoolean bool
140
141
142
//constant varables
143
//=================
144
#define null NULL
145
146
147
#if defined(WIN32) || defined(WIN64)
148
#undef M_PI
149
#define M_PI 3.14159265358979323846
150
#endif
151
152
//bitwise operators
153
//================
154
// a | b | iand
155
// 0 | 0 | 0
156
// 0 | 1 | 0
157
// 1 | 0 | 0
158
// 1 | 1 | 1
159
#define iand(a,b) ( (a) & (b) )
160
161
// a | b | ior
162
// 0 | 0 | 0
163
// 0 | 1 | 1
164
// 1 | 0 | 1
165
// 1 | 1 | 1
166
#define ior(a,b) ( (a) | (b) )
167
168
// a | b | inor
169
// 0 | 0 | 1
170
// 0 | 1 | 0
171
// 1 | 0 | 0
172
// 1 | 1 | 0
173
#define inor(a,b) ( ~( (a) | (b) ) )
174
175
// a | b | ixor
176
// 0 | 0 | 0
177
// 0 | 1 | 1
178
// 1 | 0 | 1
179
// 1 | 1 | 0
180
#define ixor(a,b) ( (a) ^ (b) ) )
181
182
// a | inot
183
// 0 | 1
184
// 1 | 0
185
#define inot(a) ( 256 - (~(a)) )
186
187
188
189
//assert command
190
//==============
191
192
//if the program has been compiled with -DDEBUG, the assert command is executed
193
#ifdef DEBUG
194
#define ASSERT_IN(a) {assert(a);}
195
#else
196
#define ASSERT_IN(a) {}
197
#endif
198
199
#ifdef DEBUG
200
#define ASSERT_OUT(a) {assert(a);}
201
#else
202
#define ASSERT_OUT(a) {}
203
#endif
204
205
206
207
208
#endif
std
Generated on Mon May 3 2021 14:50:21 for C++ main module for emicrom Package by
1.8.13