blob: f2bf441492fbecfaf2e1c1c9423ccc38b12473e5 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
|
#ifndef TYPEPROPS_HH
#define TYPEPROPS_HH
#include <cctk.h>
template <typename T>
struct typeprops {
typedef T complex;
typedef T real;
// Create a complex number from a real number
static inline complex const& fromreal (real const& x) { return x; }
};
#ifdef HAVE_CCTK_COMPLEX8
template <>
struct typeprops <CCTK_COMPLEX8> {
typedef CCTK_COMPLEX8 complex;
typedef CCTK_REAL4 real;
static inline complex fromreal (real const x) { return CCTK_Cmplx8 (x, 0); }
};
#endif
#ifdef HAVE_CCTK_COMPLEX16
template <>
struct typeprops <CCTK_COMPLEX16> {
typedef CCTK_COMPLEX16 complex;
typedef CCTK_REAL8 real;
static inline complex fromreal (real const x) { return CCTK_Cmplx16 (x, 0); }
};
#endif
#ifdef HAVE_CCTK_COMPLEX32
template <>
struct typeprops <CCTK_COMPLEX32> {
typedef CCTK_COMPLEX32 complex;
typedef CCTK_REAL16 real;
static inline complex fromreal (real const x) { return CCTK_Cmplx32 (x, 0); }
};
#endif
// Return the specific Cactus variable type for a Cactus variable type
static inline int specific_cactus_type (int const vartype)
{
switch (vartype) {
case CCTK_VARIABLE_INT:
#ifdef CCTK_INTEGER_PRECISION_1
return CCTK_VARIABLE_INT1;
#endif
#ifdef CCTK_INTEGER_PRECISION_2
return CCTK_VARIABLE_INT2;
#endif
#ifdef CCTK_INTEGER_PRECISION_4
return CCTK_VARIABLE_INT4;
#endif
#ifdef CCTK_INTEGER_PRECISION_8
return CCTK_VARIABLE_INT8;
#endif
return -1;
case CCTK_VARIABLE_REAL:
#ifdef CCTK_REAL_PRECISION_4
return CCTK_VARIABLE_REAL4;
#endif
#ifdef CCTK_REAL_PRECISION_8
return CCTK_VARIABLE_REAL8;
#endif
#ifdef CCTK_REAL_PRECISION_16
return CCTK_VARIABLE_REAL16;
#endif
return -1;
case CCTK_VARIABLE_COMPLEX:
#ifdef CCTK_REAL_PRECISION_4
return CCTK_VARIABLE_COMPLEX8;
#endif
#ifdef CCTK_REAL_PRECISION_8
return CCTK_VARIABLE_COMPLEX16;
#endif
#ifdef CCTK_REAL_PRECISION_16
return CCTK_VARIABLE_COMPLEX32;
#endif
return -1;
}
return vartype;
}
#endif // #ifndef TYPEPROPS_HH
|