summaryrefslogtreecommitdiff
path: root/src/include/cctk_Complex.h
blob: 79a7b00b7e60f8816486c13d1328fb0d3bc90cf2 (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
92
93
94
95
96
97
98
99
100
 /*@@
   @header    cctk_Complex.h
   @date      Tue Dec 14 12:28:05 1999
   @author    Tom Goodale
   @desc
              Prototypes for complex numbers.
   @enddesc
   @version   $Header$
 @@*/

#ifndef _CCTK_COMPLEX_H_
#define _CCTK_COMPLEX_H_

#ifdef __cplusplus
extern "C"
{
#endif


/* macro to declare a set of complex functions for a given precision */
#define DECLARE_CMPLX_FUNCTIONS(CCTK_Cmplx, cctk_real, cctk_complex)          \
cctk_complex CCTK_Cmplx        (cctk_real Re, cctk_real Im);                  \
cctk_real    CCTK_Cmplx##Real  (cctk_complex complex_number);                 \
cctk_real    CCTK_Cmplx##Imag  (cctk_complex complex_number);                 \
cctk_complex CCTK_Cmplx##Conjg (cctk_complex complex_number);                 \
cctk_real    CCTK_Cmplx##Abs   (cctk_complex complex_number);                 \
cctk_complex CCTK_Cmplx##Add   (cctk_complex a, cctk_complex b);              \
cctk_complex CCTK_Cmplx##Sub   (cctk_complex a, cctk_complex b);              \
cctk_complex CCTK_Cmplx##Mul   (cctk_complex a, cctk_complex b);              \
cctk_complex CCTK_Cmplx##Div   (cctk_complex a, cctk_complex b);              \
cctk_complex CCTK_Cmplx##Sin   (cctk_complex complex_number);                 \
cctk_complex CCTK_Cmplx##Cos   (cctk_complex complex_number);                 \
cctk_complex CCTK_Cmplx##Exp   (cctk_complex complex_number);                 \
cctk_complex CCTK_Cmplx##Sqrt  (cctk_complex complex_number);


/* declare complex functions for all available precisions */
#ifdef CCTK_REAL4
DECLARE_CMPLX_FUNCTIONS (CCTK_Cmplx8, CCTK_REAL4, CCTK_COMPLEX8)
#endif

#ifdef CCTK_REAL8
DECLARE_CMPLX_FUNCTIONS (CCTK_Cmplx16, CCTK_REAL8, CCTK_COMPLEX16)
#endif

#ifdef CCTK_REAL16
DECLARE_CMPLX_FUNCTIONS (CCTK_Cmplx32, CCTK_REAL16, CCTK_COMPLEX32)
#endif


/* declare the default precision complex functions as #define'd macros */
#ifdef CCTK_REAL_PRECISION_4
#define CCTK_Cmplx      CCTK_Cmplx8
#define CCTK_CmplxReal  CCTK_Cmplx8Real
#define CCTK_CmplxImag  CCTK_Cmplx8Imag
#define CCTK_CmplxConjg CCTK_Cmplx8Conjg
#define CCTK_CmplxAbs   CCTK_Cmplx8Abs
#define CCTK_CmplxAdd   CCTK_Cmplx8Add
#define CCTK_CmplxSub   CCTK_Cmplx8Sub
#define CCTK_CmplxMul   CCTK_Cmplx8Mul
#define CCTK_CmplxDiv   CCTK_Cmplx8Div
#define CCTK_CmplxDiv   CCTK_Cmplx8Sin
#define CCTK_CmplxDiv   CCTK_Cmplx8Cos
#define CCTK_CmplxDiv   CCTK_Cmplx8Exp
#define CCTK_CmplxDiv   CCTK_Cmplx8Sqrt
#elif CCTK_REAL_PRECISION_8
#define CCTK_Cmplx      CCTK_Cmplx16
#define CCTK_CmplxReal  CCTK_Cmplx16Real
#define CCTK_CmplxImag  CCTK_Cmplx16Imag
#define CCTK_CmplxConjg CCTK_Cmplx16Conjg
#define CCTK_CmplxAbs   CCTK_Cmplx16Abs
#define CCTK_CmplxAdd   CCTK_Cmplx16Add
#define CCTK_CmplxSub   CCTK_Cmplx16Sub
#define CCTK_CmplxMul   CCTK_Cmplx16Mul
#define CCTK_CmplxDiv   CCTK_Cmplx16Div
#define CCTK_CmplxDiv   CCTK_Cmplx16Sin
#define CCTK_CmplxDiv   CCTK_Cmplx16Cos
#define CCTK_CmplxDiv   CCTK_Cmplx16Exp
#define CCTK_CmplxDiv   CCTK_Cmplx16Sqrt
#elif CCTK_REAL_PRECISION_16
#define CCTK_Cmplx      CCTK_Cmplx32
#define CCTK_CmplxReal  CCTK_Cmplx32Real
#define CCTK_CmplxImag  CCTK_Cmplx32Imag
#define CCTK_CmplxConjg CCTK_Cmplx32Conjg
#define CCTK_CmplxAbs   CCTK_Cmplx32Abs
#define CCTK_CmplxAdd   CCTK_Cmplx32Add
#define CCTK_CmplxSub   CCTK_Cmplx32Sub
#define CCTK_CmplxMul   CCTK_Cmplx32Mul
#define CCTK_CmplxDiv   CCTK_Cmplx32Div
#define CCTK_CmplxDiv   CCTK_Cmplx32Sin
#define CCTK_CmplxDiv   CCTK_Cmplx32Cos
#define CCTK_CmplxDiv   CCTK_Cmplx32Exp
#define CCTK_CmplxDiv   CCTK_Cmplx32Sqrt
#endif

#ifdef __cplusplus
}
#endif

#endif /* __CCTK_COMPLEX_H_ */