X-Git-Url: http://git.euphorik.ch/index.cgi?a=blobdiff_plain;f=WCudaMSE%2FBilatTools_CPP%2Fsrc%2Fcore%2Ftools%2Fheader%2FMathTools.h;fp=WCudaMSE%2FBilatTools_CPP%2Fsrc%2Fcore%2Ftools%2Fheader%2FMathTools.h;h=fb4b55b39412bbe6eeb75864c48584ddbd237a6c;hb=8d08c12b29c2a14684f35c023ee39e694bb80d25;hp=0000000000000000000000000000000000000000;hpb=226de81f7e1f1fbf4ac79d0d089e8a05ec7159a0;p=GPU.git diff --git a/WCudaMSE/BilatTools_CPP/src/core/tools/header/MathTools.h b/WCudaMSE/BilatTools_CPP/src/core/tools/header/MathTools.h new file mode 100755 index 0000000..fb4b55b --- /dev/null +++ b/WCudaMSE/BilatTools_CPP/src/core/tools/header/MathTools.h @@ -0,0 +1,111 @@ +#ifndef MATH_TOOLS_ +#define MATH_TOOLS_ + +#define PI_FLOAT 3.141592653589793f + +#ifndef PI +#define PI 3.1415926535897932384626433832795028841971693993751 +#endif + +#ifndef MIN +#define MIN(X,Y) ((X)<(Y)?(X):(Y)) +#endif + +#ifndef MAX +#define MAX(X,Y) ((X)>(Y)?(X):(Y)) +#endif + +class MathTools + { + public: + + /*--------------------------------------*\ + |* Constructor *| + \*-------------------------------------*/ + + MathTools(); + + /*--------------------------------------*\ + |* Destructor *| + \*-------------------------------------*/ + + virtual ~MathTools(); + + /*--------------------------------------*\ + |* Methodes Static *| + \*-------------------------------------*/ + + /*---------------*\ + |* Float *| + \*---------------*/ + + /** + * Relatif au max(x1,x2) + */ + static bool isEquals(float x1, float x2, float epsilon = 0); + + /** + * Relatif a reference + * epsilon pas de valeur par default, sinon meme signature que autre methode (overload) + */ + static bool isEquals(float a, float b, float reference, float epsilon); // + + /** + * Relatif, un a un (au max des 2) + * Hyp: tab de meme size n + */ + static bool isEquals(float* tabA, float* tabB, int n, float epsilon = 0); + + /** + * Relatif par rapport au max de la série + * Hyp: tab de meme size n + */ + static bool isEqualsRelatifMax(float* tabA, float* tabB, int n, float epsilon = 0); + + /*---------------*\ + |* Double *| + \*---------------*/ + + /** + * Relatif au max(x1,x2) + */ + static bool isEquals(double x1, double x2, double epsilon = 0); + + + /*---------------*\ + |* Long *| + \*---------------*/ + + /** + * Absolu + */ + static bool isEquals(long x1, long x2); + + /*---------------*\ + |* isPower2 *| + \*---------------*/ + + static bool isPower2(long i); + static bool isPower2(int i); + static bool isPower2(unsigned int i); + + private: + + /*--------------------------------------*\ + |* Methodes *| + \*-------------------------------------*/ + + static float maxAbs(float a, float b); + + /** + * Hyp: tab de meme size n + */ + static float maxAbs(float* tabA, float* tabB, int n); + + /*--------------------------------------*\ + |* Attributs *| + \*-------------------------------------*/ + + }; + +#endif