Skip to content

Commit

Permalink
Reinstate dir[] naming work-around; translate Sign[] to isgn()
Browse files Browse the repository at this point in the history
  • Loading branch information
eschnett committed Aug 16, 2012
1 parent 9c55ecd commit 8f377c5
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 4 deletions.
11 changes: 11 additions & 0 deletions Auxiliary/Cactus/KrancNumericalTools/GenericFD/src/GenericFD.h
Expand Up @@ -63,6 +63,17 @@ KRANC_WHERE static inline CCTK_REAL sgn(CCTK_REAL x)
return x==(CCTK_REAL)0.0 ? (CCTK_REAL)0.0 : copysign((CCTK_REAL)1.0, x);
}

KRANC_WHERE static inline int isgn(CCTK_REAL x)
{
if (x == (CCTK_REAL)0.0) return 0;
#ifdef __cplusplus
int s = std::signbit(x);
#else
int s = signbit(x);
#endif
return s ? -1 : +1;
}

int GenericFD_GetBoundaryWidth(cGH const * restrict const cctkGH);

void GenericFD_GetBoundaryInfo(cGH const * restrict cctkGH,
Expand Down
2 changes: 1 addition & 1 deletion Tools/CodeGen/CalculationFunction.m
Expand Up @@ -269,7 +269,7 @@ pathalogical enough (e.g. {s1 -> s2, s2 -> s1} would not be
(* Return a CodeGen block which assigns dest by evaluating expr *)
assignVariableFromExpression[dest_, expr_, declare_, vectorise_, noSimplify:Boolean : False] :=
Module[{type, cleanExpr, code},
type = DataType[];
type = If[StringMatchQ[ToString[dest], "dir*"], "ptrdiff_t", DataType[]];
cleanExpr = ReplacePowers[expr, vectorise, noSimplify];

If[SOURCELANGUAGE == "C",
Expand Down
3 changes: 2 additions & 1 deletion Tools/CodeGen/CodeGenCactus.m
Expand Up @@ -568,6 +568,7 @@
fabs[x_] -> kfabs[x],
fmax[x_,y_] -> kfmax[x,y],
fmin[x_,y_] -> kfmin[x,y],
isgn[x_] -> kisgn[x],
log[x_] -> klog[x],
pow[x_,y_] -> kpow[x,y],
sgn[x_] -> ksgn[x],
Expand Down Expand Up @@ -810,7 +811,7 @@
rhs = rhs //. Max[xx_, yy__] -> fmax[xx, Max[yy]];
rhs = rhs //. Min[xx_, yy__] -> fmin[xx, Min[yy]];
rhs = rhs //. Abs[x_] -> fabs[x];
rhs = rhs //. Sign[x_] -> sgn[x];
rhs = rhs //. Sign[x_] -> isgn[x];
rhs = rhs //. IntAbs[x_] -> abs[x];

If[vectorise === True,
Expand Down
4 changes: 2 additions & 2 deletions Tools/CodeGen/Kranc.m
Expand Up @@ -25,10 +25,10 @@
{INV, SQR, CUB, QAD, ScalarINV, ScalarSQR, ScalarCUB, ScalarQAD,
IfThen, Parenthesis, Scalar, ToReal,
sqrt, exp, log, pow, atan2, cos, sin, tan, acos, asin, atan,
cosh, sinh, tanh, acosh, asinh, atanh, fmax, fmin, fabs,
cosh, sinh, tanh, acosh, asinh, atanh, fmax, fmin, fabs, isgn, sgn,
kmadd, kmsub, knmadd, knmsub, kpos, kneg, kadd, ksub, kmul, kdiv,
kacos, kacosh, kasin, kasinh, katan, katanh, kcopysign, kcos, kcosh, kfabs,
kfmax, kfmin, ksqrt, kexp, klog, kpow, ksgn, ksin, ksinh, ktan, ktanh,
kfmax, kfmin, kisgn, ksqrt, kexp, klog, kpow, ksgn, ksin, ksinh, ktan, ktanh,
dir1, dir2, dir3, dt, dx, dy, dz,
khalf, kthird, ktwothird, kfourthird, keightthird};

Expand Down

0 comments on commit 8f377c5

Please sign in to comment.