summaryrefslogtreecommitdiff
path: root/src/include/cctk_Complex.h
diff options
context:
space:
mode:
authortradke <tradke@17b73243-c579-4c4c-a9d2-2d5706c11dac>2001-02-20 18:53:25 +0000
committertradke <tradke@17b73243-c579-4c4c-a9d2-2d5706c11dac>2001-02-20 18:53:25 +0000
commit5cd66dad570d4f429f77ceb50d9188e1cba2db83 (patch)
tree155017c4933782f2646d8e5183b7a291e5a0da60 /src/include/cctk_Complex.h
parent57e3467fd24c7ff123b13864fdf26c50f7ef7978 (diff)
Added CCTK complex functions for all possible precisions.
This closes PR Cactus 411. git-svn-id: http://svn.cactuscode.org/flesh/trunk@2032 17b73243-c579-4c4c-a9d2-2d5706c11dac
Diffstat (limited to 'src/include/cctk_Complex.h')
-rw-r--r--src/include/cctk_Complex.h67
1 files changed, 56 insertions, 11 deletions
diff --git a/src/include/cctk_Complex.h b/src/include/cctk_Complex.h
index d8307b85..b6ba59d3 100644
--- a/src/include/cctk_Complex.h
+++ b/src/include/cctk_Complex.h
@@ -11,25 +11,70 @@
#ifndef _CCTK_COMPLEX_H_
#define _CCTK_COMPLEX_H_
-#ifdef __cplusplus
+#ifdef __cplusplus
extern "C"
{
#endif
-CCTK_COMPLEX CCTK_Cmplx(CCTK_REAL Re, CCTK_REAL Im);
-CCTK_REAL CCTK_CmplxReal(CCTK_COMPLEX complex_number);
-CCTK_REAL CCTK_CmplxImag(CCTK_COMPLEX complex_number);
+/* a macro which expands to nothing */
+#ifdef NOTHING
+#undef NOTHING
+#endif
+#define NOTHING
+
+/* 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);
+
+
+/* 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
+
+
+/* get the default precision for complex numbers */
+#ifdef CCTK_REAL_PRECISION_4
+#define CCTK_COMPLEX_PRECISION 8
+#elif CCTK_REAL_PRECISION_8
+#define CCTK_COMPLEX_PRECISION 16
+#elif CCTK_REAL_PRECISION_16
+#define CCTK_COMPLEX_PRECISION 32
+#endif
+
+/* finally declare the default precision complex functions */
+#define CCTK_Cmplx CCTK_Cmplx_(CCTK_COMPLEX_PRECISION, NOTHING)
+#define CCTK_CmplxReal CCTK_Cmplx_(CCTK_COMPLEX_PRECISION, Real)
+#define CCTK_CmplxImag CCTK_Cmplx_(CCTK_COMPLEX_PRECISION, Imag)
+#define CCTK_CmplxConjg CCTK_Cmplx_(CCTK_COMPLEX_PRECISION, Conjg)
+#define CCTK_CmplxAbs CCTK_Cmplx_(CCTK_COMPLEX_PRECISION, Abs)
+#define CCTK_CmplxAdd CCTK_Cmplx_(CCTK_COMPLEX_PRECISION, Add)
+#define CCTK_CmplxSub CCTK_Cmplx_(CCTK_COMPLEX_PRECISION, Sub)
+#define CCTK_CmplxMul CCTK_Cmplx_(CCTK_COMPLEX_PRECISION, Mul)
+#define CCTK_CmplxDiv CCTK_Cmplx_(CCTK_COMPLEX_PRECISION, Div)
-CCTK_COMPLEX CCTK_CmplxConjg(CCTK_COMPLEX in);
-CCTK_REAL CCTK_CmplxAbs(CCTK_COMPLEX in);
+#define CCTK_Cmplx_(precision, function) CCTK_Cmplx__(precision, function)
+#define CCTK_Cmplx__(precision, function) CCTK_Cmplx##precision##function
-CCTK_COMPLEX CCTK_CmplxAdd(CCTK_COMPLEX a,CCTK_COMPLEX b);
-CCTK_COMPLEX CCTK_CmplxSub(CCTK_COMPLEX a,CCTK_COMPLEX b);
-CCTK_COMPLEX CCTK_CmplxMul(CCTK_COMPLEX a,CCTK_COMPLEX b);
-CCTK_COMPLEX CCTK_CmplxDiv(CCTK_COMPLEX a,CCTK_COMPLEX b);
-#ifdef __cplusplus
+#ifdef __cplusplus
}
#endif