Commit fb5cedd0 authored by BRAMAS Berenger's avatar BRAMAS Berenger

use drand48

parent aee66b84
......@@ -90,10 +90,9 @@ int main(int argc, char* argv[])
std::cout << ", finished in " << time.tacAndElapsed() << "s." << std::endl;
// generate right hand side vector
FReal *const w = new FReal [nnodes];
const FReal FRandMax = FReal(RAND_MAX);
FReal *const w = new FReal [nnodes];
for (unsigned int j=0; j<nnodes; ++j)
w[j] = FReal(rand())/FRandMax;
w[j] = FReal(drand48());
// compute f0 = Kw
FReal *const f0 = new FReal [nnodes];
......
......@@ -23,7 +23,7 @@
#include "../../Src/Utils/FBlas.hpp"
FReal FRandom() { return (FReal(rand()) / FReal(RAND_MAX)); }
FReal FRandom() { return (FReal(drand48())); }
/**
* Test functionality of C - interfaced BLAS functions
......
......@@ -59,8 +59,7 @@ int main(int, char **){
std::cout << " direct computation.\n" << std::endl;
//////////////////////////////////////////////////////////////
MatrixKernelClass MatrixKernel;
const FReal FRandMax = FReal(RAND_MAX);
MatrixKernelClass MatrixKernel;
FTic time;
......@@ -75,10 +74,10 @@ int main(int, char **){
<< " centered at cx=" << cx << " with M=" << M << " target particles" << std::endl;
{
for(unsigned long i=0; i<M; ++i){
FReal x = (FReal(rand())/FRandMax - FReal(.5)) * width + cx.getX();
FReal y = (FReal(rand())/FRandMax - FReal(.5)) * width + cx.getY();
FReal z = (FReal(rand())/FRandMax - FReal(.5)) * width + cx.getZ();
X.push(FPoint(x, y, z), FReal(rand())/FRandMax);
FReal x = (FReal(drand48()) - FReal(.5)) * width + cx.getX();
FReal y = (FReal(drand48()) - FReal(.5)) * width + cx.getY();
FReal z = (FReal(drand48()) - FReal(.5)) * width + cx.getZ();
X.push(FPoint(x, y, z), FReal(drand48()));
}
}
......@@ -91,10 +90,10 @@ int main(int, char **){
<< " centered at cy=" << cy << " with N=" << N << " target particles" << std::endl;
{
for(unsigned long i=0; i<N; ++i){
FReal x = (FReal(rand())/FRandMax - FReal(.5)) * width + cy.getX();
FReal y = (FReal(rand())/FRandMax - FReal(.5)) * width + cy.getY();
FReal z = (FReal(rand())/FRandMax - FReal(.5)) * width + cy.getZ();
Y.push(FPoint(x, y, z), FReal(rand())/FRandMax);
FReal x = (FReal(drand48()) - FReal(.5)) * width + cy.getX();
FReal y = (FReal(drand48()) - FReal(.5)) * width + cy.getY();
FReal z = (FReal(drand48()) - FReal(.5)) * width + cy.getZ();
Y.push(FPoint(x, y, z), FReal(drand48()));
}
}
......
......@@ -57,11 +57,10 @@ int main(int, char **){
std::cout << ">> and how to use the Octree\n";
//////////////////////////////////////////////////////////////
const long NbPart = 100000;
const FReal FRandMax = FReal(RAND_MAX);
const long NbPart = 100000;
FTic counter;
srand( static_cast<unsigned int>(time(NULL)) );
srand48( static_cast<unsigned int>(time(NULL)) );
const FReal BoxWidth = 1.;
const FPoint BoxCenter(.5, .5, .5);
......@@ -73,7 +72,7 @@ int main(int, char **){
counter.tic();
{
for(long idxPart = 0 ; idxPart < NbPart ; ++idxPart){
tree.insert(FPoint(FReal(rand())/FRandMax,FReal(rand())/FRandMax,FReal(rand())/FRandMax));
tree.insert(FPoint(FReal(drand48()),FReal(drand48()),FReal(drand48())));
}
}
counter.tac();
......
......@@ -60,13 +60,12 @@ int main(int argc, char* argv[])
std::cout << " direct computation.\n" << std::endl;
//////////////////////////////////////////////////////////////
MatrixKernelClass MatrixKernel;
const FReal FRandMax = FReal(RAND_MAX);
MatrixKernelClass MatrixKernel;
FTic time;
// Leaf size
FReal width(FReal(rand()) / FRandMax * FReal(10.));
FReal width(FReal(drand48()) * FReal(10.));
////////////////////////////////////////////////////////////////////
LeafClass X;
......@@ -77,9 +76,9 @@ int main(int argc, char* argv[])
<< "] with M=" << M << " target particles" << std::endl;
{
for(long i=0; i<M; ++i){
FReal x = (FReal(rand())/FRandMax - FReal(.5)) * width + cx.getX();
FReal y = (FReal(rand())/FRandMax - FReal(.5)) * width + cx.getY();
FReal z = (FReal(rand())/FRandMax - FReal(.5)) * width + cx.getZ();
FReal x = (FReal(drand48()) - FReal(.5)) * width + cx.getX();
FReal y = (FReal(drand48()) - FReal(.5)) * width + cx.getY();
FReal z = (FReal(drand48()) - FReal(.5)) * width + cx.getZ();
X.push(FPoint(x,y,z));
}
}
......@@ -94,10 +93,10 @@ int main(int argc, char* argv[])
<< "] with N=" << N << " target particles" << std::endl;
{
for(long i=0; i<N; ++i){
FReal x = (FReal(rand())/FRandMax - FReal(.5)) * width + cy.getX();
FReal y = (FReal(rand())/FRandMax - FReal(.5)) * width + cy.getY();
FReal z = (FReal(rand())/FRandMax - FReal(.5)) * width + cy.getZ();
Y.push(FPoint(x, y, z),FReal(rand())/FRandMax);
FReal x = (FReal(drand48()) - FReal(.5)) * width + cy.getX();
FReal y = (FReal(drand48()) - FReal(.5)) * width + cy.getY();
FReal z = (FReal(drand48()) - FReal(.5)) * width + cy.getZ();
Y.push(FPoint(x, y, z),FReal(drand48()));
}
}
......
......@@ -183,13 +183,12 @@ int main(int argc, char* argv[])
FPoint lp[M];
FReal equivW[nnodes];
{ ////////////////////////////////////////////////////////
const FReal FRandMax = FReal(RAND_MAX);
{ ////////////////////////////////////////////////////////
for(unsigned int p=0; p<M; ++p){
points[0][p] = (FReal(rand())/FRandMax - FReal(.5)) * FReal(2.);
points[1][p] = (FReal(rand())/FRandMax - FReal(.5)) * FReal(2.);
points[2][p] = (FReal(rand())/FRandMax - FReal(.5)) * FReal(2.);
weights[p] = FReal(rand())/FRandMax;
points[0][p] = (FReal(drand48()) - FReal(.5)) * FReal(2.);
points[1][p] = (FReal(drand48()) - FReal(.5)) * FReal(2.);
points[2][p] = (FReal(drand48()) - FReal(.5)) * FReal(2.);
weights[p] = FReal(drand48());
lp[p].setX(points[0][p]);
lp[p].setY(points[1][p]);
lp[p].setZ(points[2][p]);
......
......@@ -39,7 +39,6 @@ int main(int argc, char ** argv){
// Nb of particles
const FSize NbParticles = FParameters::getValue(argc,argv,"-nb", FSize(20000));
const FReal FRandMax = FReal(RAND_MAX);
// Center of the box
const FReal XCenter = 0.5;
......@@ -68,9 +67,9 @@ int main(int argc, char ** argv){
// Generate particles
for( long idx = 0 ; idx < NbParticles ; ++idx ){
const FReal px = ((FReal(rand())/FRandMax) * BoxWidth) + XCenter - (BoxWidth/FReal(2.0));
const FReal py = ((FReal(rand())/FRandMax) * BoxWidth) + YCenter - (BoxWidth/FReal(2.0));
const FReal pz = ((FReal(rand())/FRandMax) * BoxWidth) + ZCenter - (BoxWidth/FReal(2.0));
const FReal px = ((FReal(drand48())) * BoxWidth) + XCenter - (BoxWidth/FReal(2.0));
const FReal py = ((FReal(drand48())) * BoxWidth) + YCenter - (BoxWidth/FReal(2.0));
const FReal pz = ((FReal(drand48())) * BoxWidth) + ZCenter - (BoxWidth/FReal(2.0));
myfile << " \n" << px << " " << py << " " << pz;
}
......
......@@ -66,7 +66,6 @@ int main(int argc, char ** argv){
// System properties
const int sizeOfFreal = int(sizeof(FReal));
const FReal FRandMax = FReal(RAND_MAX);
fwrite(&sizeOfFreal, sizeof(int), 1, myfile);
fwrite(&NbParticles, sizeof(FSize), 1, myfile);
......@@ -83,9 +82,9 @@ int main(int argc, char ** argv){
data[3] = physicalValue;
// Generate particles
for( FSize idx = 0 ; idx < NbParticles ; ++idx ){
data[0] = ((FReal(rand())/FRandMax) * LimitedBoxWidth * 2) + XCenter - BoxWidth + Limite;
data[1] = ((FReal(rand())/FRandMax) * LimitedBoxWidth * 2) + YCenter - BoxWidth + Limite;
data[2] = ((FReal(rand())/FRandMax) * LimitedBoxWidth * 2) + ZCenter - BoxWidth + Limite;
data[0] = ((FReal(drand48())) * LimitedBoxWidth * 2) + XCenter - BoxWidth + Limite;
data[1] = ((FReal(drand48())) * LimitedBoxWidth * 2) + YCenter - BoxWidth + Limite;
data[2] = ((FReal(drand48())) * LimitedBoxWidth * 2) + ZCenter - BoxWidth + Limite;
fwrite(&data, sizeof(FReal), 4, myfile);
}
......
......@@ -65,7 +65,6 @@ int main(int argc, char ** argv){
// System properties
const int sizeOfFreal = int(sizeof(FReal));
const FReal FRandMax = FReal(RAND_MAX);
fwrite(&sizeOfFreal, sizeof(int), 1, myfile);
fwrite(&NbParticles, sizeof(FSize), 1, myfile);
......@@ -86,12 +85,12 @@ int main(int argc, char ** argv){
// Generate particles
for( long idx = 0 ; idx < NbParticles ; ++idx ){
const FReal theta = (FReal(rand())/FRandMax) * FMath::FPi;
const FReal omega = (FReal(rand())/FRandMax) * FMath::FPi * FReal(2);
const FReal theta = (FReal(drand48())) * FMath::FPi;
const FReal omega = (FReal(drand48())) * FMath::FPi * FReal(2);
data[0] = rayon * FMath::Cos(omega) * FMath::Sin(theta) + XCenter + thresh * (FReal(rand())/FRandMax) - threshDiv2;
data[1] = rayon * FMath::Sin(omega) * FMath::Sin(theta) + YCenter + thresh * (FReal(rand())/FRandMax) - threshDiv2;
data[2] = rayon * FMath::Cos(theta) + ZCenter + thresh * (FReal(rand())/FRandMax) - threshDiv2;
data[0] = rayon * FMath::Cos(omega) * FMath::Sin(theta) + XCenter + thresh * (FReal(drand48())) - threshDiv2;
data[1] = rayon * FMath::Sin(omega) * FMath::Sin(theta) + YCenter + thresh * (FReal(drand48())) - threshDiv2;
data[2] = rayon * FMath::Cos(theta) + ZCenter + thresh * (FReal(drand48())) - threshDiv2;
fwrite(&data, sizeof(FReal), 4, myfile);
}
......@@ -105,23 +104,23 @@ int main(int argc, char ** argv){
// Generate particles
for( long idx = 0 ; idx < NbParticles/2 ; ++idx ){
const FReal theta = (FReal(rand())/FRandMax) * FMath::FPi;
const FReal omega = (FReal(rand())/FRandMax) * FMath::FPi * FReal(2);
const FReal theta = (FReal(drand48())) * FMath::FPi;
const FReal omega = (FReal(drand48())) * FMath::FPi * FReal(2);
data[0] = rayon * FMath::Cos(omega) * FMath::Sin(theta) + XCenter - offset + thresh * (FReal(rand())/FRandMax) - threshDiv2;
data[1] = rayon * FMath::Sin(omega) * FMath::Sin(theta) + YCenter - offset + thresh * (FReal(rand())/FRandMax) - threshDiv2;
data[2] = rayon * FMath::Cos(theta) + ZCenter - offset + thresh * (FReal(rand())/FRandMax) - threshDiv2;
data[0] = rayon * FMath::Cos(omega) * FMath::Sin(theta) + XCenter - offset + thresh * (FReal(drand48())) - threshDiv2;
data[1] = rayon * FMath::Sin(omega) * FMath::Sin(theta) + YCenter - offset + thresh * (FReal(drand48())) - threshDiv2;
data[2] = rayon * FMath::Cos(theta) + ZCenter - offset + thresh * (FReal(drand48())) - threshDiv2;
fwrite(&data, sizeof(FReal), 4, myfile);
}
for( long idx = 0 ; idx < NbParticles/2 ; ++idx ){
const FReal theta = (FReal(rand())/FRandMax) * FMath::FPi;
const FReal omega = (FReal(rand())/FRandMax) * FMath::FPi * FReal(2);
const FReal theta = (FReal(drand48())) * FMath::FPi;
const FReal omega = (FReal(drand48())) * FMath::FPi * FReal(2);
data[0] = rayon * FMath::Cos(omega) * FMath::Sin(theta) + XCenter + offset + thresh * (FReal(rand())/FRandMax) - threshDiv2;
data[1] = rayon * FMath::Sin(omega) * FMath::Sin(theta) + YCenter + offset + thresh * (FReal(rand())/FRandMax) - threshDiv2;
data[2] = rayon * FMath::Cos(theta) + ZCenter + offset + thresh * (FReal(rand())/FRandMax) - threshDiv2;
data[0] = rayon * FMath::Cos(omega) * FMath::Sin(theta) + XCenter + offset + thresh * (FReal(drand48())) - threshDiv2;
data[1] = rayon * FMath::Sin(omega) * FMath::Sin(theta) + YCenter + offset + thresh * (FReal(drand48())) - threshDiv2;
data[2] = rayon * FMath::Cos(theta) + ZCenter + offset + thresh * (FReal(drand48())) - threshDiv2;
fwrite(&data, sizeof(FReal), 4, myfile);
}
......
......@@ -41,8 +41,6 @@ int main(int argc, char ** argv){
const long NbParticles = FParameters::getValue(argc,argv,"-nb", long(20000));
const FReal physicalValue = FParameters::getValue(argc,argv,"-pv", FReal(0.1));
const FReal FRandMax = FReal(RAND_MAX);
// Box width
const FReal BoxWidth = FParameters::getValue(argc,argv,"-width", FReal(1.0/2.0));
......@@ -76,9 +74,9 @@ int main(int argc, char ** argv){
// Generate particles
for( long idx = 0 ; idx < NbParticles ; ++idx ){
const FReal px = ((FReal(rand())/FRandMax) * LimitedBoxWidth * 2) + XCenter - BoxWidth + Limite;
const FReal py = ((FReal(rand())/FRandMax) * LimitedBoxWidth * 2) + YCenter - BoxWidth + Limite;
const FReal pz = ((FReal(rand())/FRandMax) * LimitedBoxWidth * 2) + ZCenter - BoxWidth + Limite;
const FReal px = ((FReal(drand48())) * LimitedBoxWidth * 2) + XCenter - BoxWidth + Limite;
const FReal py = ((FReal(drand48())) * LimitedBoxWidth * 2) + YCenter - BoxWidth + Limite;
const FReal pz = ((FReal(drand48())) * LimitedBoxWidth * 2) + ZCenter - BoxWidth + Limite;
myfile << "\n" << px << "\t" << py << "\t" << pz << "\t" << physicalValue;
}
......
......@@ -60,7 +60,6 @@ int main(int argc, char ** argv){
std::cout << "Creating " << NbParticles << " particles at " << Output << "\n";
std::cout << "Working...\n";
const FReal FRandMax = FReal(RAND_MAX);
// Center of the box
const FReal XCenter = 0.;
const FReal YCenter = 0.;
......@@ -78,12 +77,12 @@ int main(int argc, char ** argv){
// Generate particles
for( long idx = 0 ; idx < NbParticles ; ++idx ){
const FReal theta = (FReal(rand())/FRandMax) * FMath::FPi;
const FReal omega = (FReal(rand())/FRandMax) * FMath::FPi * FReal(2);
const FReal theta = (FReal(drand48())) * FMath::FPi;
const FReal omega = (FReal(drand48())) * FMath::FPi * FReal(2);
const FReal px = rayon * FMath::Cos(omega) * FMath::Sin(theta) + XCenter + thresh * (FReal(rand())/FRandMax) - threshDiv2;
const FReal py = rayon * FMath::Sin(omega) * FMath::Sin(theta) + YCenter + thresh * (FReal(rand())/FRandMax) - threshDiv2;
const FReal pz = rayon * FMath::Cos(theta) + ZCenter + thresh * (FReal(rand())/FRandMax) - threshDiv2;
const FReal px = rayon * FMath::Cos(omega) * FMath::Sin(theta) + XCenter + thresh * (FReal(drand48())) - threshDiv2;
const FReal py = rayon * FMath::Sin(omega) * FMath::Sin(theta) + YCenter + thresh * (FReal(drand48())) - threshDiv2;
const FReal pz = rayon * FMath::Cos(theta) + ZCenter + thresh * (FReal(drand48())) - threshDiv2;
myfile << " \n" << px << " " << py << " " << pz << " " << physicalValue;
}
......@@ -97,23 +96,23 @@ int main(int argc, char ** argv){
// Generate particles
for( long idx = 0 ; idx < NbParticles/2 ; ++idx ){
const FReal theta = (FReal(rand())/FRandMax) * FMath::FPi;
const FReal omega = (FReal(rand())/FRandMax) * FMath::FPi * FReal(2);
const FReal theta = (FReal(drand48())) * FMath::FPi;
const FReal omega = (FReal(drand48())) * FMath::FPi * FReal(2);
const FReal px = rayon * FMath::Cos(omega) * FMath::Sin(theta) + XCenter - offset + thresh * (FReal(rand())/FRandMax) - threshDiv2;
const FReal py = rayon * FMath::Sin(omega) * FMath::Sin(theta) + YCenter - offset + thresh * (FReal(rand())/FRandMax) - threshDiv2;
const FReal pz = rayon * FMath::Cos(theta) + ZCenter - offset + thresh * (FReal(rand())/FRandMax) - threshDiv2;
const FReal px = rayon * FMath::Cos(omega) * FMath::Sin(theta) + XCenter - offset + thresh * (FReal(drand48())) - threshDiv2;
const FReal py = rayon * FMath::Sin(omega) * FMath::Sin(theta) + YCenter - offset + thresh * (FReal(drand48())) - threshDiv2;
const FReal pz = rayon * FMath::Cos(theta) + ZCenter - offset + thresh * (FReal(drand48())) - threshDiv2;
myfile << " \n" << px << " " << py << " " << pz << " " << physicalValue;
}
for( long idx = 0 ; idx < NbParticles/2 ; ++idx ){
const FReal theta = (FReal(rand())/FRandMax) * FMath::FPi;
const FReal omega = (FReal(rand())/FRandMax) * FMath::FPi * FReal(2);
const FReal theta = (FReal(drand48())) * FMath::FPi;
const FReal omega = (FReal(drand48())) * FMath::FPi * FReal(2);
const FReal px = rayon * FMath::Cos(omega) * FMath::Sin(theta) + XCenter + offset + thresh * (FReal(rand())/FRandMax) - threshDiv2;
const FReal py = rayon * FMath::Sin(omega) * FMath::Sin(theta) + YCenter + offset + thresh * (FReal(rand())/FRandMax) - threshDiv2;
const FReal pz = rayon * FMath::Cos(theta) + ZCenter + offset + thresh * (FReal(rand())/FRandMax) - threshDiv2;
const FReal px = rayon * FMath::Cos(omega) * FMath::Sin(theta) + XCenter + offset + thresh * (FReal(drand48())) - threshDiv2;
const FReal py = rayon * FMath::Sin(omega) * FMath::Sin(theta) + YCenter + offset + thresh * (FReal(drand48())) - threshDiv2;
const FReal pz = rayon * FMath::Cos(theta) + ZCenter + offset + thresh * (FReal(drand48())) - threshDiv2;
myfile << " \n" << px << " " << py << " " << pz << " " << physicalValue;
}
......
......@@ -40,8 +40,6 @@ int main(int argc, char ** argv){
const long NbParticles = FParameters::getValue(argc,argv,"-nb", long(20000));
const FReal physicalValue = FParameters::getValue(argc,argv,"-pv", FReal(0.1));
const FReal FRandMax = FReal(RAND_MAX);
// Center of the box
const FReal XCenter = 0.5;
const FReal YCenter = 0.5;
......@@ -71,11 +69,11 @@ int main(int argc, char ** argv){
// Generate particles
for( long idx = 0 ; idx < NbParticles ; ++idx ){
const FReal px = ((FReal(rand())/FRandMax) * BoxWidth * FReal(2)) + XCenter - BoxWidth;
const FReal py = ((FReal(rand())/FRandMax) * BoxWidth * FReal(2)) + YCenter - BoxWidth;
const FReal pz = ((FReal(rand())/FRandMax) * BoxWidth * FReal(2)) + ZCenter - BoxWidth;
const FReal px = ((FReal(drand48())) * BoxWidth * FReal(2)) + XCenter - BoxWidth;
const FReal py = ((FReal(drand48())) * BoxWidth * FReal(2)) + YCenter - BoxWidth;
const FReal pz = ((FReal(drand48())) * BoxWidth * FReal(2)) + ZCenter - BoxWidth;
const int isTarget = rand() > RAND_MAX/2 ? 1 : 0;
const int isTarget = srand48() > 0.5 ? 1 : 0;
myfile << "\n" << px << "\t" << py << "\t" << pz << "\t" << physicalValue << "\t" << isTarget;
}
......
......@@ -66,11 +66,10 @@ int main(int argc, char ** argv){
const int SizeSubLevels = FParameters::getValue(argc,argv,"-sh", 3);
const int NbPart = FParameters::getValue(argc,argv,"-nb", 2000000);
const int DevP = FParameters::getValue(argc,argv,"-p", 5);
const FReal FRandMax = FReal(RAND_MAX);
const FPoint centerOfBox = FPoint(0.5,0.5,0.5);
FTic counter;
srand ( 1 ); // volontary set seed to constant
srand48 ( 1 ); // volontary set seed to constant
//////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////
......@@ -90,7 +89,7 @@ int main(int argc, char ** argv){
FPoint particlePosition;
FReal physicalValue = 0.10;
for(int idxPart = 0 ; idxPart < NbPart ; ++idxPart){
particlePosition.setPosition(FReal(rand())/FRandMax,FReal(rand())/FRandMax,FReal(rand())/FRandMax);
particlePosition.setPosition(FReal(drand48()),FReal(drand48()),FReal(drand48()));
tree.insert(particlePosition, physicalValue);
}
}
......
......@@ -53,11 +53,10 @@ int main(int argc, char ** argv){
const int NbLevels = FParameters::getValue(argc,argv,"-h", 9);
const int NbSubLevels = FParameters::getValue(argc,argv,"-sh", 3);
const int NbPart = FParameters::getValue(argc,argv,"-nb", 2000000);
const FReal FRandMax = FReal(RAND_MAX);
FTic counterTime;
srand ( 1 ); // volontary set seed to constant
srand48 ( 1 ); // volontary set seed to constant
// -----------------------------------------------------
OctreeClass tree(NbLevels, NbSubLevels, 1.0, FPoint(0.5,0.5,0.5));
......@@ -68,7 +67,7 @@ int main(int argc, char ** argv){
{
FPoint particle;
for(long idxPart = 0 ; idxPart < NbPart ; ++idxPart){
particle.setPosition(FReal(rand())/FRandMax,FReal(rand())/FRandMax,FReal(rand())/FRandMax);
particle.setPosition(FReal(drand48()),FReal(drand48()),FReal(drand48()));
tree.insert(particle);
}
}
......
......@@ -75,11 +75,10 @@ int main(int argc, char ** argv){
const int NbLevels = FParameters::getValue(argc,argv,"-h", 7);
const int SizeSubLevels = FParameters::getValue(argc,argv,"-sh", 3);
const int NbPart = FParameters::getValue(argc,argv,"-nb", 2000000);
const FReal FRandMax = FReal(RAND_MAX);
FTic counter;
srand ( 1 ); // volontary set seed to constant
srand48 ( 1 ); // volontary set seed to constant
//////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////
......@@ -102,9 +101,9 @@ int main(int argc, char ** argv){
FPoint particleToFill;
for(int idxPart = 0 ; idxPart < NbPart ; ++idxPart){
particleToFill.setPosition(
(BoxWidth*FReal(rand())/FRandMax) + (BoxCenter-(BoxWidth/2)),
(BoxWidth*FReal(rand())/FRandMax) + (BoxCenter-(BoxWidth/2)),
(BoxWidth*FReal(rand())/FRandMax) + (BoxCenter-(BoxWidth/2)));
(BoxWidth*FReal(drand48())) + (BoxCenter-(BoxWidth/2)),
(BoxWidth*FReal(drand48())) + (BoxCenter-(BoxWidth/2)),
(BoxWidth*FReal(drand48())) + (BoxCenter-(BoxWidth/2)));
tree.insert(particleToFill);
}
}
......@@ -124,9 +123,9 @@ int main(int argc, char ** argv){
do{
ContainerClass* particles = octreeIterator.getCurrentListTargets();
for(int idxPart = 0; idxPart < particles->getNbParticles() ; ++idxPart){
particles->getWPositions()[0][idxPart] = (BoxWidth*FReal(rand())/FRandMax) + (BoxCenter-(BoxWidth/2));
particles->getWPositions()[1][idxPart] = (BoxWidth*FReal(rand())/FRandMax) + (BoxCenter-(BoxWidth/2));
particles->getWPositions()[2][idxPart] = (BoxWidth*FReal(rand())/FRandMax) + (BoxCenter-(BoxWidth/2));
particles->getWPositions()[0][idxPart] = (BoxWidth*FReal(drand48())) + (BoxCenter-(BoxWidth/2));
particles->getWPositions()[1][idxPart] = (BoxWidth*FReal(drand48())) + (BoxCenter-(BoxWidth/2));
particles->getWPositions()[2][idxPart] = (BoxWidth*FReal(drand48())) + (BoxCenter-(BoxWidth/2));
}
} while(octreeIterator.moveRight());
}
......
......@@ -87,11 +87,10 @@ int main(int argc, char ** argv){
const int NbLevels = FParameters::getValue(argc,argv,"-h", 7);
const int SizeSubLevels = FParameters::getValue(argc,argv,"-sh", 3);
const int NbPart = FParameters::getValue(argc,argv,"-nb", 20000);
const FReal FRandMax = FReal(RAND_MAX);
FTic counter;
srand ( 1 ); // volontary set seed to constant
srand48 ( 1 ); // volontary set seed to constant
//////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////
......@@ -112,9 +111,9 @@ int main(int argc, char ** argv){
TestParticle* particles = new TestParticle[NbPart];
for(int idxPart = 0 ; idxPart < NbPart ; ++idxPart){
particles[idxPart].position.setPosition(
(BoxWidth*FReal(rand())/FRandMax) + (BoxCenter-(BoxWidth/FReal(2.0))),
(BoxWidth*FReal(rand())/FRandMax) + (BoxCenter-(BoxWidth/FReal(2.0))),
(BoxWidth*FReal(rand())/FRandMax) + (BoxCenter-(BoxWidth/FReal(2.0))));
(BoxWidth*FReal(drand48())) + (BoxCenter-(BoxWidth/FReal(2.0))),
(BoxWidth*FReal(drand48())) + (BoxCenter-(BoxWidth/FReal(2.0))),
(BoxWidth*FReal(drand48())) + (BoxCenter-(BoxWidth/FReal(2.0))));
}
FVector<TestParticle> finalParticles;
......@@ -145,9 +144,9 @@ int main(int argc, char ** argv){
do{
ContainerClass* particles = octreeIterator.getCurrentListTargets();
for(int idxPart = 0; idxPart < particles->getNbParticles() ; ++idxPart){
particles->getWPositions()[0][idxPart] = (BoxWidth*FReal(rand())/FRandMax) + (BoxCenter-(BoxWidth/2));
particles->getWPositions()[1][idxPart] = (BoxWidth*FReal(rand())/FRandMax) + (BoxCenter-(BoxWidth/2));
particles->getWPositions()[2][idxPart] = (BoxWidth*FReal(rand())/FRandMax) + (BoxCenter-(BoxWidth/2));
particles->getWPositions()[0][idxPart] = (BoxWidth*FReal(drand48())) + (BoxCenter-(BoxWidth/2));
particles->getWPositions()[1][idxPart] = (BoxWidth*FReal(drand48())) + (BoxCenter-(BoxWidth/2));
particles->getWPositions()[2][idxPart] = (BoxWidth*FReal(drand48())) + (BoxCenter-(BoxWidth/2));
}
} while(octreeIterator.moveRight());
}
......
......@@ -37,7 +37,7 @@ class TestQuickSort : public FUTester<TestQuickSort> {
void manyThreads(){
const long Size = 100000;
long long* const array = new long long[Size];
srand(0);
srand48(0);
const int originalThreadsNumber = omp_get_num_threads();
for(int idxThread = 1 ; idxThread <= omp_get_max_threads() ; idxThread *= 2){
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment