X-Git-Url: http://git.euphorik.ch/index.cgi?a=blobdiff_plain;f=WCudaMSE%2FStudent_OMP%2Fsrc%2Fcpp%2Fcore%2Fomp%2F02_pi%2F01_pi_sequentiel.cpp;fp=WCudaMSE%2FStudent_OMP%2Fsrc%2Fcpp%2Fcore%2Fomp%2F02_pi%2F01_pi_sequentiel.cpp;h=5978a09162ad647d79b09eff24cd0a7af36cb190;hb=8d08c12b29c2a14684f35c023ee39e694bb80d25;hp=0000000000000000000000000000000000000000;hpb=226de81f7e1f1fbf4ac79d0d089e8a05ec7159a0;p=GPU.git diff --git a/WCudaMSE/Student_OMP/src/cpp/core/omp/02_pi/01_pi_sequentiel.cpp b/WCudaMSE/Student_OMP/src/cpp/core/omp/02_pi/01_pi_sequentiel.cpp new file mode 100755 index 0000000..5978a09 --- /dev/null +++ b/WCudaMSE/Student_OMP/src/cpp/core/omp/02_pi/01_pi_sequentiel.cpp @@ -0,0 +1,59 @@ +#include "00_pi_tools.h" + +/*----------------------------------------------------------------------*\ + |* Declaration *| + \*---------------------------------------------------------------------*/ + +/*--------------------------------------*\ + |* Imported *| + \*-------------------------------------*/ + + +/*--------------------------------------*\ + |* Public *| + \*-------------------------------------*/ + +bool isPiSequentiel_OK(int n); + +/*--------------------------------------*\ + |* Private *| + \*-------------------------------------*/ + +static double piSequentiel(int n); + +/*----------------------------------------------------------------------*\ + |* Implementation *| + \*---------------------------------------------------------------------*/ + +/*--------------------------------------*\ + |* Public *| + \*-------------------------------------*/ + +bool isPiSequentiel_OK(int n) + { + return isAlgoPI_OK(piSequentiel, n, "Pi Sequentiel"); + } + +/*--------------------------------------*\ + |* Private *| + \*-------------------------------------*/ + +double piSequentiel(int n) + { + double sum = 0; + double xi; + const double DX = 1.0/(double)n; + + for (int i = 0; i < n; i++) + { + xi = i*DX; + sum += fpi(xi); + } + + return sum * DX; + } + +/*----------------------------------------------------------------------*\ + |* End *| + \*---------------------------------------------------------------------*/ +