Ajout de l'ensemble du workspace.
[GPU.git] / WCudaMSE / Student_OMP / src / cpp / core / omp / 02_pi / 01_pi_sequentiel.cpp
1 #include "00_pi_tools.h"
2
3 /*----------------------------------------------------------------------*\
4 |* Declaration *|
5 \*---------------------------------------------------------------------*/
6
7 /*--------------------------------------*\
8 |* Imported *|
9 \*-------------------------------------*/
10
11
12 /*--------------------------------------*\
13 |* Public *|
14 \*-------------------------------------*/
15
16 bool isPiSequentiel_OK(int n);
17
18 /*--------------------------------------*\
19 |* Private *|
20 \*-------------------------------------*/
21
22 static double piSequentiel(int n);
23
24 /*----------------------------------------------------------------------*\
25 |* Implementation *|
26 \*---------------------------------------------------------------------*/
27
28 /*--------------------------------------*\
29 |* Public *|
30 \*-------------------------------------*/
31
32 bool isPiSequentiel_OK(int n)
33 {
34 return isAlgoPI_OK(piSequentiel, n, "Pi Sequentiel");
35 }
36
37 /*--------------------------------------*\
38 |* Private *|
39 \*-------------------------------------*/
40
41 double piSequentiel(int n)
42 {
43 double sum = 0;
44 double xi;
45 const double DX = 1.0/(double)n;
46
47 for (int i = 0; i < n; i++)
48 {
49 xi = i*DX;
50 sum += fpi(xi);
51 }
52
53 return sum * DX;
54 }
55
56 /*----------------------------------------------------------------------*\
57 |* End *|
58 \*---------------------------------------------------------------------*/
59