-
Notifications
You must be signed in to change notification settings - Fork 25
Expand file tree
/
Copy pathreal_types.hpp
More file actions
69 lines (57 loc) · 1.55 KB
/
real_types.hpp
File metadata and controls
69 lines (57 loc) · 1.55 KB
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
// ***********************************************************************************
// Idefix MHD astrophysical code
// Copyright(C) Geoffroy R. J. Lesur <geoffroy.lesur@univ-grenoble-alpes.fr>
// and other code contributors
// Licensed under CeCILL 2.1 License, see COPYING for more information
// ***********************************************************************************
#ifndef REAL_TYPES_HPP_
#define REAL_TYPES_HPP_
#include <math.h>
#ifdef SINGLE_PRECISION
using real = float;
#ifdef WITH_MPI
#define realMPI MPI_FLOAT
#endif
#else
using real = double;
#ifdef WITH_MPI
#define realMPI MPI_DOUBLE
#endif
#endif // SINGLE_PRECISION
// math function
#ifdef SINGLE_PRECISION
#define FMAX(x,y) fmaxf(x,y)
#define FMIN(x,y) fminf(x,y)
#define FABS(x) fabsf(x)
#define TAN(x) tanf(x)
#define SIN(x) sinf(x)
#define COS(x) cosf(x)
#define COPYSIGN(x,y) copysignf(x,y)
#define ISNAN(x) isnanf(x)
#define FMOD(x,y) fmodf(x,y)
#define ZERO_F (0.0f)
#define HALF_F (0.5f)
#define ONE_FOURTH_F (0.25f)
#define ONE_F (1.0f)
#define TWO_F (2.0f)
#define THREE_F (3.0f)
#define FOUR_F (4.0f)
#else
#define FMAX(x,y) fmax(x,y)
#define FMIN(x,y) fmin(x,y)
#define FABS(x) fabs(x)
#define TAN(x) tan(x)
#define SIN(x) sin(x)
#define COS(x) cos(x)
#define COPYSIGN(x,y) copysign(x,y)
#define ISNAN(x) isnan(x)
#define FMOD(x,y) fmod(x,y)
#define ZERO_F (0.0)
#define HALF_F (0.5)
#define ONE_FOURTH_F (0.25)
#define ONE_F (1.0)
#define TWO_F (2.0)
#define THREE_F (3.0)
#define FOUR_F (4.0)
#endif // SINGLE_PRECISION
#endif // REAL_TYPES_HPP_