Skip to content

Commit

Permalink
MathematicaCompat.h: Add Min3 and VanLeer macros
Browse files Browse the repository at this point in the history
  • Loading branch information
ianhinder committed Sep 30, 2010
1 parent 92ce7d1 commit 360447e
Showing 1 changed file with 9 additions and 6 deletions.
Expand Up @@ -6,6 +6,7 @@
#ifdef KRANC_C
#define Abs(x) (fabs(x))
#define Min(x, y) (fmin((x), (y)))
#define Min3(x, y, z) (fmin(fmin((x), (y)), (z)))
#define Max(x, y) (fmax((x), (y)))
#define IfThen(x,y,z) ((x) ? (y) : (z))
#else
Expand All @@ -15,8 +16,16 @@
/* IfThen cannot be expressed in Fortran */
#endif

#ifdef KRANC_C
#define Sign(x) (signbit(x)?-1:+1)
#else
#define Sign(x) (sgn(x))
#endif

#define MinMod(x, y) ((x) * (y) < 0 ? 0 : (fabs((x)) < fabs((y)) ? (x) : (y)))

#define VanLeer(x, y) ((x) * (y) < 0 ? 0 : (Min3(2*fabs(x),2*fabs(y),0.5*(fabs(x)+fabs(y)))*Sign((x)+(y))))

#define Exp(x) (exp(x))
#define Log(x) (log(x))

Expand All @@ -32,12 +41,6 @@
#define Cosh(x) (cosh(x))
#define Tanh(x) (tanh(x))

#ifdef KRANC_C
#define Sign(x) (signbit(x)?-1:+1)
#else
#define Sign(x) (sgn(x))
#endif

#ifdef KRANC_C
#define E M_E
#define Pi M_PI
Expand Down

0 comments on commit 360447e

Please sign in to comment.