GremlinEq
teukolskydefs.h
1 //---------------------------------------------------------------------------
2 //
3 // $Id: teukolskydefs.h,v 1.2 2014/04/08 19:22:54 sahughes Exp $
4 //
5 //---------------------------------------------------------------------------
6 
7 
8 /* teukolskydefs.h
9  * general definitions for the Teukolsky project
10  */
11 
12 #ifndef TEUKOLSKYDEFS_H_SEEN
13 #define TEUKOLSKYDEFS_H_SEEN
14 
15 #include <cfloat>
16 #include <complex>
17 #include "complex_ops.h"
18 
19 //extern "C" int isnan(double);
20 
21 using namespace std;
22 
23 /* The precision to use
24  * 0 float
25  * 1 double
26  * 2 long double
27  */
28 #ifndef REAL_TYPE
29 # define REAL_TYPE 1
30 #endif
31 
32 #if REAL_TYPE == 0
33 typedef float Real;
34 #define REAL_MANT_DIG FLT_MANT_DIG
35 #if DBL_MANT_DIG > FLT_MANT_DIG
36 typedef double LongReal;
37 #define LREAL_MANT_DIG DBL_MANT_DIG
38 #else
39 typedef long double LongReal;
40 #define LREAL_MANT_DIG LDBL_MANT_DIG
41 #endif
42 
43 #define fsRe "hf"
44 #define REAL_EPSILON FLT_EPSILON
45 #define PREC_FUNCSUFFIX f
46 
47 #elif REAL_TYPE == 1
48 typedef double Real;
49 #define REAL_MANT_DIG DBL_MANT_DIG
50 typedef long double LongReal;
51 #define LREAL_MANT_DIG LDBL_MANT_DIG
52 
53 #define fsRe "f"
54 #define REAL_EPSILON DBL_EPSILON
55 #define PREC_FUNCSUFFIX
56 
57 #elif REAL_TYPE == 2
58 typedef long double Real;
59 #define REAL_MANT_DIG LDBL_MANT_DIG
60 typedef long double LongReal;
61 #define LREAL_MANT_DIG LDBL_MANT_DIG
62 
63 #define fsRe "Lf"
64 #define REAL_EPSILON LDBL_EPSILON
65 #define PREC_FUNCSUFFIX l
66 
67 #else
68 #error "Bad REAL_TYPE"
69 #endif /* REAL_TYPE */
70 
71 typedef std::complex<Real> Complex;
72 typedef std::complex<LongReal> LongComplex;
73 #define I (Complex(0,1))
74 
75 /* precision dependent functions */
76 #define MAKE_PRECFUNC(func) FUNC_CONCAT(func,PREC_FUNCSUFFIX)
77 #define FUNC_CONCAT(a,b) FUNC_CONCAT_INNER(a,b)
78 #define FUNC_CONCAT_INNER(a,b) a ## b
79 
80 #define Fmax MAKE_PRECFUNC(fmax)
81 #define Fmin MAKE_PRECFUNC(fmin)
82 #define Fabs MAKE_PRECFUNC(fabs)
83 #define Sqrt MAKE_PRECFUNC(sqrt)
84 
85 /* useful utilities */
86 #define CNAN Complex(NAN,NAN)
87 
88 #define Cisnan(x) (isnan(real(x)) || isnan(imag(x)))
89 #define Cmaxpart(x) (Fmax(Fabs(real(x)),Fabs(imag(x))))
90 
91 #endif /* TEUKOLSKYDEFS_H_SEEN */
Definition: complex_ops.h:15