H2Lib  3.0
settings.h
Go to the documentation of this file.
1 
2 /* ------------------------------------------------------------
3  * This is the file "settings.h" of the H2Lib package.
4  * All rights reserved, Steffen Boerm 2009
5  * ------------------------------------------------------------ */
6 
11 #ifndef SETTINGS_H
12 #define SETTINGS_H
13 
18 #include <math.h>
19 #include <stddef.h>
20 #ifdef USE_COMPLEX
21 #include <complex.h>
22 #endif
23 
24 #ifdef USE_SIMD
25 #include "simd.h"
26 #endif
27 
28 /* ------------------------------------------------------------
29  * Compilation settings
30  * ------------------------------------------------------------ */
31 
33 #ifdef __cplusplus
34 #define INLINE_PREFIX static extern "C"
35 #else
36 #define INLINE_PREFIX static
37 #endif
38 
40 #ifdef __cplusplus
41 #define HEADER_PREFIX extern "C"
42 #else
43 #define HEADER_PREFIX
44 #endif
45 
47 #ifdef __cplusplus
48 #define IMPORT_PREFIX extern "C"
49 #else
50 #define IMPORT_PREFIX
51 #endif
52 
53 /* ------------------------------------------------------------
54  * Types
55  * ------------------------------------------------------------ */
56 
58 typedef unsigned short bool;
59 
61 extern const bool true;
62 
64 extern const bool false;
65 
70 typedef unsigned uint;
71 
73 extern const int i_zero;
74 
76 extern const int i_one;
77 
79 extern const uint u_zero;
80 
82 extern const uint u_one;
83 
88 typedef size_t longindex;
89 
94 #ifdef USE_FLOAT
95 typedef float real;
96 #else
97 typedef double real;
98 #endif
99 
103 #ifndef VFLOAT
104 #define VFLOAT 1
105 #endif
106 
110 #ifndef VDOUBLE
111 #define VDOUBLE 1
112 #endif
113 
117 #ifndef VREAL
118 #define VREAL 1
119 #endif
120 
121 #ifdef USE_FLOAT
122 
123 #define H2_CHECK_TOLERANCE 1.0e-6
124 
126 #define H2_ALMOST_ZERO 1e-30
127 #else
128 
129 #define H2_CHECK_TOLERANCE 1.0e-12
130 
132 #define H2_ALMOST_ZERO 1e-300
133 #endif
134 
138 #ifdef USE_FLOAT
139 #define SCANF_PREFIX ""
140 #else
141 #define SCANF_PREFIX "l"
142 #endif
143 
145 typedef real *preal;
146 
148 typedef const real *pcreal;
149 
151 extern const real r_zero;
152 
154 extern const real r_one;
155 
157 extern const real r_minusone;
158 
163 #ifdef USE_FLOAT
164 #ifdef USE_COMPLEX
165 typedef float _Complex field;
166 #else
167 typedef float field;
168 #endif
169 #else
170 #ifdef USE_COMPLEX
171 typedef double _Complex field;
172 #else
173 typedef double field;
174 #endif
175 #endif
176 
180 #ifndef VFIELD
181 #define VFIELD 1
182 #endif
183 
185 typedef field *pfield;
186 
188 typedef const field *pcfield;
189 
191 extern const field f_zero;
192 
194 extern const field f_one;
195 
197 extern const field f_minusone;
198 
199 #ifdef USE_COMPLEX
200 
201 extern const field f_i;
202 #endif
203 
204 #ifndef USE_COMPLEX
205 #ifdef I
206 #undef I
207 #endif
208 #define I 0.0
209 #endif
210 
213 extern const char *_h2_ntrans;
214 
216 extern const char *_h2_trans;
217 
221 extern const char *_h2_adj;
222 
225 extern const char *_h2_left;
226 
229 extern const char *_h2_right;
230 
233 extern const char *_h2_lower;
234 
237 extern const char *_h2_upper;
238 
241 extern const char *_h2_unit;
242 
245 extern const char *_h2_nonunit;
246 
249 extern const char *_h2_vectors;
250 
253 extern const char *_h2_skinnyvectors;
254 
257 extern const char *_h2_novectors;
258 
259 /****************************************************
260  * Define conversion specifier and argument macros
261  * for different @ref field types.
262  ****************************************************/
263 
268 #ifdef USE_FLOAT
269 #ifdef USE_COMPLEX
270 #define FIELD_CS(format, cs) "%" #format #cs " + %" #format #cs "i"
271 #else
272 #define FIELD_CS(format, cs) "%" #format #cs
273 #endif
274 #else
275 #ifdef USE_COMPLEX
276 #define FIELD_CS(format, cs) "%" #format #cs " + %" #format #cs "i"
277 #else
278 #define FIELD_CS(format, cs) "%" #format #cs
279 #endif
280 #endif
281 
286 #ifdef USE_FLOAT
287 #ifdef USE_COMPLEX
288 #define FIELD_SCANF_CS(format, cs) "%" #format #cs " + %" #format #cs "i"
289 #else
290 #define FIELD_SCANF_CS(format, cs) "%" #format #cs
291 #endif
292 #else
293 #ifdef USE_COMPLEX
294 #define FIELD_SCANF_CS(format, cs) "%l" #format #cs " + %l" #format #cs "i"
295 #else
296 #define FIELD_SCANF_CS(format, cs) "%l" #format #cs
297 #endif
298 #endif
299 
303 #ifdef USE_FLOAT
304 #ifdef USE_COMPLEX
305 #define FIELD_ARG(z) crealf(z), cimagf(z)
306 #else
307 #define FIELD_ARG(z) z
308 #endif
309 #else
310 #ifdef USE_COMPLEX
311 #define FIELD_ARG(z) creal(z), cimag(z)
312 #else
313 #define FIELD_ARG(z) z
314 #endif
315 #endif
316 
321 #ifdef USE_FLOAT
322 #ifdef USE_COMPLEX
323 #define FIELD_ADDR(z) (real*)(z), ((real*)(z)+1)
324 #else
325 #define FIELD_ADDR(z) (real*)(z)
326 #endif
327 #else
328 #ifdef USE_COMPLEX
329 #define FIELD_ADDR(z) (real*)(z), ((real*)(z)+1)
330 #else
331 #define FIELD_ADDR(z) (real*)(z)
332 #endif
333 #endif
334 
340 typedef enum {
342  AMATRIX = 0,
343 
344  HMATRIX = 1,
345 
346  H2MATRIX = 2,
347 
349 
351 } matrixtype;
352 
355 #endif
size_t longindex
Unsigned long type.
Definition: settings.h:88
const field f_zero
field constant zero
const uint u_zero
Unsigned integer constant zero.
unsigned uint
Unsigned integer type.
Definition: settings.h:70
unsigned short bool
Boolean type.
Definition: settings.h:58
const real r_zero
real constant zero
const int i_zero
Signed integer constant zero.
double _Complex field
Field type.
Definition: settings.h:171
Enum value representing an sparsematrix.
Definition: settings.h:348
const field f_i
field constant for the imaginary number.
const uint u_one
Unsigned integer constant one.
Enum value representing an dh2matrix.
Definition: settings.h:350
const int i_one
Signed integer constant one.
const field f_minusone
field constant minus one.
double real
real floating point type.
Definition: settings.h:97
Enum value representing an amatrix.
Definition: settings.h:342
const field f_one
field constant one.
real * preal
Pointer to real array.
Definition: settings.h:145
Enum value representing an h2matrix.
Definition: settings.h:346
const real r_minusone
real constant minus one.
const real r_one
real constant one.
field * pfield
Pointer to field array.
Definition: settings.h:185
Enum value representing an hmatrix.
Definition: settings.h:344
const field * pcfield
Pointer to constant field array.
Definition: settings.h:188
matrixtype
All possible types of matrices.
Definition: settings.h:340
const real * pcreal
Pointer to constant real array.
Definition: settings.h:148