projects
/
GPU.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
8d08c12
)
Implémentation de RipplingMath.h
author
gburri
<gregory.burri@master.hes-so.ch>
Wed, 1 Oct 2014 20:09:41 +0000
(22:09 +0200)
committer
gburri
<gregory.burri@master.hes-so.ch>
Wed, 1 Oct 2014 20:09:41 +0000
(22:09 +0200)
WCudaMSE/Student_OMP/src/cpp/core/omp/02_pi/07_pi_for_promotionTab.cpp
patch
|
blob
|
history
WCudaMSE/Student_OMP_Image/src/cpp/core/01_Rippling/c_math/RipplingMath.h
patch
|
blob
|
history
WCudaMSE/Tuto_Image/src/cpp/core/01_Vague/c_math/VagueMath.h
patch
|
blob
|
history
diff --git
a/WCudaMSE/Student_OMP/src/cpp/core/omp/02_pi/07_pi_for_promotionTab.cpp
b/WCudaMSE/Student_OMP/src/cpp/core/omp/02_pi/07_pi_for_promotionTab.cpp
index
8240aa3
..
9fcaf87
100755
(executable)
--- a/
WCudaMSE/Student_OMP/src/cpp/core/omp/02_pi/07_pi_for_promotionTab.cpp
+++ b/
WCudaMSE/Student_OMP/src/cpp/core/omp/02_pi/07_pi_for_promotionTab.cpp
@@
-1,4
+1,5
@@
#include <omp.h>
\r
#include <omp.h>
\r
+#include <cstring>
\r
#include "00_pi_tools.h"
\r
#include "MathTools.h"
\r
#include "OmpTools.h"
\r
#include "00_pi_tools.h"
\r
#include "MathTools.h"
\r
#include "OmpTools.h"
\r
@@
-55,7
+56,7
@@
double piOMPforPromotionTab(int n)
const double DX = 1.0/(double)n;
\r
\r
double sums[NB_THREAD];
\r
const double DX = 1.0/(double)n;
\r
\r
double sums[NB_THREAD];
\r
- memset(sums, 0, sizeof(sums));
// TODO
\r
+ memset(sums, 0, sizeof(sums));
\r
\r
#pragma omp parallel for private(xi)
\r
for (int i = 0; i < n; i++)
\r
\r
#pragma omp parallel for private(xi)
\r
for (int i = 0; i < n; i++)
\r
diff --git
a/WCudaMSE/Student_OMP_Image/src/cpp/core/01_Rippling/c_math/RipplingMath.h
b/WCudaMSE/Student_OMP_Image/src/cpp/core/01_Rippling/c_math/RipplingMath.h
index
e57ccbe
..
4baf76e
100755
(executable)
--- a/
WCudaMSE/Student_OMP_Image/src/cpp/core/01_Rippling/c_math/RipplingMath.h
+++ b/
WCudaMSE/Student_OMP_Image/src/cpp/core/01_Rippling/c_math/RipplingMath.h
@@
-1,7
+1,8
@@
#ifndef RIPPLING_MATH_H_
\r
#define RIPPLING_MATH_H_
\r
\r
#ifndef RIPPLING_MATH_H_
\r
#define RIPPLING_MATH_H_
\r
\r
-#include <math>
\r
+#include "MathTools.h"
\r
+#include <cmath>
\r
using namespace std;
\r
\r
/*----------------------------------------------------------------------*\
\r
using namespace std;
\r
\r
/*----------------------------------------------------------------------*\
\r
@@
-23,13
+24,12
@@
class RipplingMath
\*-------------------------------------*/
\r
\r
public:
\r
\*-------------------------------------*/
\r
\r
public:
\r
-
\r
- RipplingMath(unsigned int w, unsigned int h))
\r
+ RipplingMath(unsigned int w, unsigned int h)
\r
+ : dim2 { w / 2.0 }
\r
{
\r
{
\r
- this->dim2 = w / 2;
\r
}
\r
\r
}
\r
\r
- virtual ~RipplingMath(
void
)
\r
+ virtual ~RipplingMath()
\r
{
\r
//rien
\r
}
\r
{
\r
//rien
\r
}
\r
@@
-39,20
+39,23
@@
class RipplingMath
\*-------------------------------------*/
\r
\r
public:
\r
\*-------------------------------------*/
\r
\r
public:
\r
-
\r
void colorIJ(uchar4* ptrColor, int i, int j, float t)
\r
{
\r
void colorIJ(uchar4* ptrColor, int i, int j, float t)
\r
{
\r
- // TODO
\r
- math::sin(9.1);
\r
-asda
\r
- double a { 4 / 3 };
\r
+ const double dxy10 = dxy(j, i) / 10.0;
\r
+ const double grayLevelFloat = 128.0 + 127.0 * cos(dxy10 - t / 7.0) / (dxy10 + 1);
\r
+ const uchar grayLevel = (uchar)(long(grayLevelFloat) % 256);
\r
+
\r
+ ptrColor->x = grayLevel;
\r
+ ptrColor->y = grayLevel;
\r
+ ptrColor->z = grayLevel;
\r
+
\r
+ ptrColor->w = 255; // Opaque.
\r
}
\r
\r
private:
\r
}
\r
\r
private:
\r
-
\r
- void dxy(int i, int j, float* ptrResult) // par exmple
\r
+ inline double dxy(int x, int y) // par exmple
\r
{
\r
{
\r
- //TODO
\r
+ return sqrt(pow(x - this->dim2, 2.0) + pow(y - this->dim2, 2.0));
\r
}
\r
\r
private:
\r
}
\r
\r
private:
\r
@@
-62,10
+65,7
@@
asda
\*-------------------------------------*/
\r
\r
private:
\r
\*-------------------------------------*/
\r
\r
private:
\r
-
\r
- // Tools
\r
- double dim2; //=dim/2
\r
-
\r
+ const double dim2; // = dim / 2.
\r
};
\r
\r
#endif
\r
};
\r
\r
#endif
\r
diff --git
a/WCudaMSE/Tuto_Image/src/cpp/core/01_Vague/c_math/VagueMath.h
b/WCudaMSE/Tuto_Image/src/cpp/core/01_Vague/c_math/VagueMath.h
index
aabd5dd
..
f8a8888
100755
(executable)
--- a/
WCudaMSE/Tuto_Image/src/cpp/core/01_Vague/c_math/VagueMath.h
+++ b/
WCudaMSE/Tuto_Image/src/cpp/core/01_Vague/c_math/VagueMath.h
@@
-51,7
+51,7
@@
class VagueMath
{
\r
unsigned char levelGris;
\r
\r
{
\r
unsigned char levelGris;
\r
\r
- f(levelGris,i, j, t); // update levelGris
\r
+ f(levelGris,
i, j, t); // update levelGris
\r
\r
ptrColorIJ->x = levelGris;
\r
ptrColorIJ->y = levelGris;
\r
\r
ptrColorIJ->x = levelGris;
\r
ptrColorIJ->y = levelGris;
\r