aboutsummaryrefslogtreecommitdiff
path: root/Auxiliary/Cactus/KrancNumericalTools/GenericFD/src/MathematicaCompat.h
blob: 86b70ebbefb2940dadda3c2e6afd266597acf52a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
 
#define Power(x, y)   (pow((x), (y)))
#define Sqrt(x)       (sqrt(x))


#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
#define Abs(x)        (abs(x))
#define Min(x, y)     (min((x), (y)))
#define Max(x, y)     (max((x), (y)))
/* 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))

#define Sin(x)        (sin(x))
#define Cos(x)        (cos(x))
#define Tan(x)        (tan(x))

#define ArcSin(x)     (asin(x))
#define ArcCos(x)     (acos(x))
#define ArcTan(x)     (atan(x))

#define Sinh(x)       (sinh(x))
#define Cosh(x)       (cosh(x))
#define Tanh(x)       (tanh(x))

#ifdef KRANC_C
#define E               M_E
#define Pi              M_PI
#else
#define E               2.71828182845904523536029d0
#define Pi              3.14159265358979323846264d0
#endif

#define StepFunction(x) ( (x) > 0 ? 1 : 0 )