From d01bd250a08175c54dfaf8d3b4d7ebb4a0ee7519 Mon Sep 17 00:00:00 2001 From: schnetter Date: Sun, 23 Jan 2005 11:33:24 +0000 Subject: 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 --- src/ReductionNorm3.c | 14 ++++++++++++-- src/ReductionNorm4.c | 5 +++-- 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); -- cgit v1.2.3