Remplacement des 'powf(a, 2)' par 'a*a'.
[GPU.git] / WCudaMSE / Student_Cuda_Image / src / cpp / core / 03_Newton / moo / host / Newton.cu
1 #include <iostream>\r
2 #include <assert.h>\r
3 #include <stdio.h>\r
4 using namespace std;\r
5 \r
6 #include "Newton.h"\r
7 #include "Device.h"\r
8 #include "NewtonDevice.h"\r
9 \r
10 Newton::Newton(int w, int h)\r
11     : variateurN(IntervalI(5, 1000), 1),\r
12       variateurEpsilon(IntervalF(0.01, 10), 0.01),\r
13       w(w), h(h),\r
14       dg(8, 8, 1),\r
15       db(32, 32, 1),\r
16       ptrDomaineMathInit(new DomaineMath(-2, -2, 2, 2)),\r
17       title("Fractal Newton")\r
18     {\r
19     Device::assertDim(dg, db);\r
20     }\r
21 \r
22 Newton::~Newton()\r
23     {\r
24     delete this->ptrDomaineMathInit;\r
25     }\r
26 \r
27 void Newton::runGPU(uchar4* ptrDevPixels, const DomaineMath& domaineMath)\r
28     {\r
29     newton<<<dg,db>>>(ptrDevPixels, this->w, this->h, domaineMath, this->t, this->epsilon);\r
30 \r
31     HANDLE_ERROR(cudaDeviceSynchronize()); // Pour flusher les 'printf' (pour le DEBUG).\r
32     }\r
33 \r
34 void Newton::animationStep()\r
35     {\r
36     this->t = this->variateurN.varierAndGet();\r
37     this->epsilon = this->variateurEpsilon.varierAndGet();\r
38     }\r
39 \r
40 int Newton::getW()\r
41     {\r
42     return this->w;\r
43     }\r
44 \r
45 int Newton::getH()\r
46     {\r
47     return this->h;\r
48     }\r
49 \r
50 DomaineMath* Newton::getDomaineMathInit()\r
51     {\r
52     return this->ptrDomaineMathInit;\r
53     }\r
54 \r
55 float Newton::getT()\r
56     {\r
57     return this->t;\r
58     }\r
59 \r
60 string Newton::getTitle()\r
61     {\r
62     return this->title;\r
63     }\r
64 \r