X-Git-Url: http://git.euphorik.ch/?a=blobdiff_plain;f=WCudaMSE%2FStudent_OMP%2Fsrc%2Fcpp%2Fcore%2Fomp%2F02_pi%2F00_pi_tools.cpp;fp=WCudaMSE%2FStudent_OMP%2Fsrc%2Fcpp%2Fcore%2Fomp%2F02_pi%2F00_pi_tools.cpp;h=41a02f62fd9cb61865c5f83a4e4056d9e9c2f32d;hb=8d08c12b29c2a14684f35c023ee39e694bb80d25;hp=0000000000000000000000000000000000000000;hpb=226de81f7e1f1fbf4ac79d0d089e8a05ec7159a0;p=GPU.git diff --git a/WCudaMSE/Student_OMP/src/cpp/core/omp/02_pi/00_pi_tools.cpp b/WCudaMSE/Student_OMP/src/cpp/core/omp/02_pi/00_pi_tools.cpp new file mode 100755 index 0000000..41a02f6 --- /dev/null +++ b/WCudaMSE/Student_OMP/src/cpp/core/omp/02_pi/00_pi_tools.cpp @@ -0,0 +1,51 @@ +#include "00_pi_tools.h" +#include +#include "Chronos.h" +#include "MathTools.h" + +using std::cout; +using std::endl; + +/*----------------------------------------------------------------------*\ + |* Implementation *| + \*---------------------------------------------------------------------*/ + +/*--------------------------------------*\ + |* Public *| + \*-------------------------------------*/ + +double fpi(double x) + { + return 4 / (1 + x * x); + } + +bool isAlgoPI_OK(AlgoPI algoPI, int n, string title) + { + cout << endl << "[" << title << " running ...]" << endl; + cout << "n=" << n << endl; + + Chronos chrono; + double piHat = algoPI(n); + chrono.stop(); + + cout.precision(8); + cout << "Pi hat = " << piHat << endl; + cout << "Pi true = " << PI << endl; + + bool isOk = MathTools::isEquals(piHat, PI, 1e-6); + cout << "isOk = " << isOk << endl; + + cout.precision(3); + chrono.print("time : "); + + return isOk; + } + +/*--------------------------------------*\ + |* Private *| + \*-------------------------------------*/ + +/*----------------------------------------------------------------------*\ + |* End *| + \*---------------------------------------------------------------------*/ +