aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorschnetter <schnetter@d60812e6-3970-4df4-986e-c251b06effeb>2005-01-23 11:33:24 +0000
committerschnetter <schnetter@d60812e6-3970-4df4-986e-c251b06effeb>2005-01-23 11:33:24 +0000
commitd01bd250a08175c54dfaf8d3b4d7ebb4a0ee7519 (patch)
treea7898c07e71f0071dc079e9fe9176ad7aa1dbb14
parentff13b6ad74100dd0adf82e9fc22a41c0279e9b00 (diff)
Correct L3 and L4 norms for complex numbers.
git-svn-id: http://svn.cactuscode.org/arrangements/CactusPUGH/PUGHReduce/trunk@62 d60812e6-3970-4df4-986e-c251b06effeb
-rw-r--r--src/ReductionNorm3.c14
-rw-r--r--src/ReductionNorm4.c5
2 files changed, 15 insertions, 4 deletions
diff --git a/src/ReductionNorm3.c b/src/ReductionNorm3.c
index 65af154..86191d4 100644
--- a/src/ReductionNorm3.c
+++ b/src/ReductionNorm3.c
@@ -313,15 +313,19 @@ static int ReductionNorm3 (const cGH *GH,
#endif
case CCTK_VARIABLE_COMPLEX:
+#define CUBE(x) ((x) * (x) * (x))
#undef REDUCTION_OPERATION
-#define REDUCTION_OPERATION(norm3, scalar) norm3 += CUBE_ABS ((scalar).Re) +\
- CUBE_ABS ((scalar).Im)
+#define REDUCTION_OPERATION(norm1, scalar) \
+ norm1 += CUBE (CCTK_CmplxAbs (scalar))
ITERATE_ARRAY (CCTK_COMPLEX, num_dims, inarrays[i],
from, to, iterator, points_per_dim,
CCTK_REAL, outvals, num_outvals, total_outvals);
break;
#ifdef CCTK_REAL4
+#undef REDUCTION_OPERATION
+#define REDUCTION_OPERATION(norm1, scalar) \
+ norm1 += CUBE (CCTK_Cmplx8Abs (scalar))
ITERATE_ARRAY (CCTK_COMPLEX8, num_dims, inarrays[i],
from, to, iterator, points_per_dim,
CCTK_REAL4, outvals, num_outvals, total_outvals);
@@ -329,6 +333,9 @@ static int ReductionNorm3 (const cGH *GH,
#endif
#ifdef CCTK_REAL8
+#undef REDUCTION_OPERATION
+#define REDUCTION_OPERATION(norm1, scalar) \
+ norm1 += CUBE (CCTK_Cmplx16Abs (scalar))
ITERATE_ARRAY (CCTK_COMPLEX16, num_dims, inarrays[i],
from, to, iterator, points_per_dim,
CCTK_REAL8, outvals, num_outvals, total_outvals);
@@ -336,6 +343,9 @@ static int ReductionNorm3 (const cGH *GH,
#endif
#ifdef CCTK_REAL16
+#undef REDUCTION_OPERATION
+#define REDUCTION_OPERATION(norm1, scalar) \
+ norm1 += CUBE (CCTK_Cmplx32Abs (scalar))
ITERATE_ARRAY (CCTK_COMPLEX32, num_dims, inarrays[i],
from, to, iterator, points_per_dim,
CCTK_REAL16, outvals, num_outvals, total_outvals);
diff --git a/src/ReductionNorm4.c b/src/ReductionNorm4.c
index 21eae29..2bf4a51 100644
--- a/src/ReductionNorm4.c
+++ b/src/ReductionNorm4.c
@@ -228,6 +228,7 @@ static int ReductionNorm4 (const cGH *GH,
/* macros to complete the ITERATE_ARRAY macro */
#define INITIAL_REDUCTION_VALUE(array) 0
+#define POWER2(x) ((x) * (x))
#define POWER4(x) ((x) * (x) * (x) * (x))
@@ -312,8 +313,8 @@ static int ReductionNorm4 (const cGH *GH,
case CCTK_VARIABLE_COMPLEX:
#undef REDUCTION_OPERATION
-#define REDUCTION_OPERATION(norm4, scalar) norm4 += POWER4 ((scalar).Re) + \
- POWER4 ((scalar).Im)
+#define REDUCTION_OPERATION(norm4, scalar) \
+ norm4 += POWER2 (POWER2 ((scalar).Re) + POWER2 ((scalar).Im))
ITERATE_ARRAY (CCTK_COMPLEX, num_dims, inarrays[i],
from, to, iterator, points_per_dim,
CCTK_REAL, outvals, num_outvals, total_outvals);