Ajout de l'ensemble du workspace.
[GPU.git] / WCudaMSE / Student_OMP / src / cpp / core / omp / 02_pi / 00_pi_tools.cpp
1 #include "00_pi_tools.h"
2 #include <iostream>
3 #include "Chronos.h"
4 #include "MathTools.h"
5
6 using std::cout;
7 using std::endl;
8
9 /*----------------------------------------------------------------------*\
10 |* Implementation *|
11 \*---------------------------------------------------------------------*/
12
13 /*--------------------------------------*\
14 |* Public *|
15 \*-------------------------------------*/
16
17 double fpi(double x)
18 {
19 return 4 / (1 + x * x);
20 }
21
22 bool isAlgoPI_OK(AlgoPI algoPI, int n, string title)
23 {
24 cout << endl << "[" << title << " running ...]" << endl;
25 cout << "n=" << n << endl;
26
27 Chronos chrono;
28 double piHat = algoPI(n);
29 chrono.stop();
30
31 cout.precision(8);
32 cout << "Pi hat = " << piHat << endl;
33 cout << "Pi true = " << PI << endl;
34
35 bool isOk = MathTools::isEquals(piHat, PI, 1e-6);
36 cout << "isOk = " << isOk << endl;
37
38 cout.precision(3);
39 chrono.print("time : ");
40
41 return isOk;
42 }
43
44 /*--------------------------------------*\
45 |* Private *|
46 \*-------------------------------------*/
47
48 /*----------------------------------------------------------------------*\
49 |* End *|
50 \*---------------------------------------------------------------------*/
51