aboutsummaryrefslogtreecommitdiff
path: root/Carpet/CarpetLib
diff options
context:
space:
mode:
authorErik Schnetter <schnetter@gmail.com>2013-03-08 15:33:39 -0500
committerErik Schnetter <schnetter@gmail.com>2013-03-08 15:33:39 -0500
commit235533f662769910df4d6cc32605cc317a3306a1 (patch)
treeabda0de249832f6f872568412639c7171a5ce5e8 /Carpet/CarpetLib
parent45077d797fb6e86e2b172156c899ee3be6f97424 (diff)
Replace Cactus complex number type with C/C++ complex numbers
Map CCTK_COMPLEX to "double complex" in C, and "complex<double>" in C++. (It is already mapped to "double complex" in Fortran.) Update type definitions. Re-implement Cactus complex number math functions by calling the respective C functions. Update thorn that access real and imaginary parts of complex numbers to use standard-conforming methods instead.
Diffstat (limited to 'Carpet/CarpetLib')
-rw-r--r--Carpet/CarpetLib/src/dist.cc71
1 files changed, 20 insertions, 51 deletions
diff --git a/Carpet/CarpetLib/src/dist.cc b/Carpet/CarpetLib/src/dist.cc
index 49b73a078..8546ca6ca 100644
--- a/Carpet/CarpetLib/src/dist.cc
+++ b/Carpet/CarpetLib/src/dist.cc
@@ -63,16 +63,16 @@ namespace dist {
#define CARPET_NO_COMPLEX
#include "typecase.hh"
#undef TYPECASE
-#define TYPECASE(N,T) \
- if (datatype == mpi_datatype<T>()) { \
- assert(not done); \
- done = true; \
- T *restrict const invec = (T*)invec_; \
- T *restrict const inoutvec = (T*)inoutvec_; \
- for (int n=0; n<len; ++n) { \
- inoutvec[n].Re = max(inoutvec[n].Re, invec[n].Re); \
- inoutvec[n].Im = max(inoutvec[n].Im, invec[n].Im); \
- } \
+#define TYPECASE(N,T) \
+ if (datatype == mpi_datatype<T>()) { \
+ assert(not done); \
+ done = true; \
+ T *restrict const invec = (T*)invec_; \
+ T *restrict const inoutvec = (T*)inoutvec_; \
+ for (int n=0; n<len; ++n) { \
+ inoutvec[n] = T(max(real(inoutvec[n]), real(invec[n])), \
+ max(imag(inoutvec[n]), imag(invec[n]))); \
+ } \
}
#define CARPET_COMPLEX
#include "typecase.hh"
@@ -101,16 +101,16 @@ namespace dist {
#define CARPET_NO_COMPLEX
#include "typecase.hh"
#undef TYPECASE
-#define TYPECASE(N,T) \
- if (datatype == mpi_datatype<T>()) { \
- assert(not done); \
- done = true; \
- T *restrict const invec = (T*)invec_; \
- T *restrict const inoutvec = (T*)inoutvec_; \
- for (int n=0; n<len; ++n) { \
- inoutvec[n].Re = min(inoutvec[n].Re, invec[n].Re); \
- inoutvec[n].Im = min(inoutvec[n].Im, invec[n].Im); \
- } \
+#define TYPECASE(N,T) \
+ if (datatype == mpi_datatype<T>()) { \
+ assert(not done); \
+ done = true; \
+ T *restrict const invec = (T*)invec_; \
+ T *restrict const inoutvec = (T*)inoutvec_; \
+ for (int n=0; n<len; ++n) { \
+ inoutvec[n] = T(min(real(inoutvec[n]), real(invec[n])), \
+ min(imag(inoutvec[n]), imag(invec[n]))); \
+ } \
}
#define CARPET_COMPLEX
#include "typecase.hh"
@@ -136,22 +136,6 @@ namespace dist {
inoutvec[n] *= invec[n]; \
} \
}
-#define CARPET_NO_COMPLEX
-#include "typecase.hh"
-#undef TYPECASE
-#define TYPECASE(N,T) \
- if (datatype == mpi_datatype<T>()) { \
- assert(not done); \
- done = true; \
- T *restrict const invec = (T*)invec_; \
- T *restrict const inoutvec = (T*)inoutvec_; \
- for (int n=0; n<len; ++n) { \
- complex<T>& inout = *(complex<T>*)&inoutvec[n]; \
- complex<T>& in = *(complex<T>*)&invec[n]; \
- inout *= in; \
- } \
- }
-#define CARPET_COMPLEX
#include "typecase.hh"
#undef TYPECASE
assert(done);
@@ -175,21 +159,6 @@ namespace dist {
inoutvec[n] += invec[n]; \
} \
}
-#define CARPET_NO_COMPLEX
-#include "typecase.hh"
-#undef TYPECASE
-#define TYPECASE(N,T) \
- if (datatype == mpi_datatype<T>()) { \
- assert(not done); \
- done = true; \
- T *restrict const invec = (T*)invec_; \
- T *restrict const inoutvec = (T*)inoutvec_; \
- for (int n=0; n<len; ++n) { \
- inoutvec[n].Re += invec[n].Re; \
- inoutvec[n].Im += invec[n].Im; \
- } \
- }
-#define CARPET_COMPLEX
#include "typecase.hh"
#undef TYPECASE
assert(done);