Ajout de l'ensemble du workspace.
[GPU.git] / WCudaMSE / BilatTools_CPP / src / core / tools / header / MathTools.h
1 #ifndef MATH_TOOLS_
2 #define MATH_TOOLS_
3
4 #define PI_FLOAT 3.141592653589793f
5
6 #ifndef PI
7 #define PI 3.1415926535897932384626433832795028841971693993751
8 #endif
9
10 #ifndef MIN
11 #define MIN(X,Y) ((X)<(Y)?(X):(Y))
12 #endif
13
14 #ifndef MAX
15 #define MAX(X,Y) ((X)>(Y)?(X):(Y))
16 #endif
17
18 class MathTools
19 {
20 public:
21
22 /*--------------------------------------*\
23 |* Constructor *|
24 \*-------------------------------------*/
25
26 MathTools();
27
28 /*--------------------------------------*\
29 |* Destructor *|
30 \*-------------------------------------*/
31
32 virtual ~MathTools();
33
34 /*--------------------------------------*\
35 |* Methodes Static *|
36 \*-------------------------------------*/
37
38 /*---------------*\
39 |* Float *|
40 \*---------------*/
41
42 /**
43 * Relatif au max(x1,x2)
44 */
45 static bool isEquals(float x1, float x2, float epsilon = 0);
46
47 /**
48 * Relatif a reference
49 * epsilon pas de valeur par default, sinon meme signature que autre methode (overload)
50 */
51 static bool isEquals(float a, float b, float reference, float epsilon); //
52
53 /**
54 * Relatif, un a un (au max des 2)
55 * Hyp: tab de meme size n
56 */
57 static bool isEquals(float* tabA, float* tabB, int n, float epsilon = 0);
58
59 /**
60 * Relatif par rapport au max de la série
61 * Hyp: tab de meme size n
62 */
63 static bool isEqualsRelatifMax(float* tabA, float* tabB, int n, float epsilon = 0);
64
65 /*---------------*\
66 |* Double *|
67 \*---------------*/
68
69 /**
70 * Relatif au max(x1,x2)
71 */
72 static bool isEquals(double x1, double x2, double epsilon = 0);
73
74
75 /*---------------*\
76 |* Long *|
77 \*---------------*/
78
79 /**
80 * Absolu
81 */
82 static bool isEquals(long x1, long x2);
83
84 /*---------------*\
85 |* isPower2 *|
86 \*---------------*/
87
88 static bool isPower2(long i);
89 static bool isPower2(int i);
90 static bool isPower2(unsigned int i);
91
92 private:
93
94 /*--------------------------------------*\
95 |* Methodes *|
96 \*-------------------------------------*/
97
98 static float maxAbs(float a, float b);
99
100 /**
101 * Hyp: tab de meme size n
102 */
103 static float maxAbs(float* tabA, float* tabB, int n);
104
105 /*--------------------------------------*\
106 |* Attributs *|
107 \*-------------------------------------*/
108
109 };
110
111 #endif