Commit 1032efb7 authored by berenger-bramas's avatar berenger-bramas

Add the compilation directive : -Wconversion

Now there is possible "auto" cast.

git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/scalfmm/scalfmm/trunk@189 2616d619-271b-44dc-8df4-d4a8f33a7222
parent 524af421
......@@ -39,7 +39,7 @@ if( SCALFMM_USE_CBLAS )
endif()
# Compile option
ADD_DEFINITIONS(-O2 -Wall -Wshadow -Wpointer-arith -Wcast-qual)
ADD_DEFINITIONS(-O2 -Wall -Wshadow -Wpointer-arith -Wcast-qual -Wconversion)
CONFIGURE_FILE( ${CMAKE_SOURCE_DIR}/Src/ScalFmmConfig.h.cmake
${CMAKE_BINARY_DIR}/Src/ScalFmmConfig.h )
......
......@@ -76,8 +76,8 @@ class FOctree {
*/
long getTreeCoordinate(const FReal inRelativePosition) const {
const FReal indexFReal = inRelativePosition / this->boxWidthAtLevel[this->leafIndex];
const long index = FMath::dfloor(indexFReal);
if( index && FMath::LookEqual(inRelativePosition, this->boxWidthAtLevel[this->leafIndex] * index ) ){
const long index = long(FMath::dfloor(indexFReal));
if( index && FMath::LookEqual(inRelativePosition, this->boxWidthAtLevel[this->leafIndex] * FReal(index) ) ){
return index - 1;
}
return index;
......@@ -99,7 +99,7 @@ public:
// pre compute box width for each level
for(int indexLevel = 0; indexLevel < this->height; ++indexLevel ){
this->boxWidthAtLevel[indexLevel] = tempWidth;
tempWidth /= 2.0;
tempWidth /= FReal(2.0);
}
}
......@@ -674,7 +674,7 @@ public:
// compute the leaf index
const MortonIndex fullIndex = inIndex >> 3 * (inLevel + 1 - (workingTree.tree->getSubOctreeHeight() + workingTree.tree->getSubOctreePosition()) );
// point to next suboctree
workingTree.tree = workingTree.middleTree->leafs(treeMiddleMask & fullIndex);
workingTree.tree = workingTree.middleTree->leafs(int(treeMiddleMask & fullIndex));
if(!workingTree.tree) return 0;
}
......@@ -774,13 +774,13 @@ public:
// compute the leaf index
const MortonIndex fullIndex = inIndex >> (3 * (leafIndex + 1 - (workingTree.tree->getSubOctreeHeight() + workingTree.tree->getSubOctreePosition()) ) );
// point to next suboctree
workingTree.tree = workingTree.middleTree->leafs(treeSubLeafMask & fullIndex);
workingTree.tree = workingTree.middleTree->leafs(int(treeSubLeafMask & fullIndex));
if(!workingTree.tree) return 0;
}
// compute correct index in the array
const MortonIndex treeLeafMask = ~(~0x00LL << (3 * (leafIndex + 1 - workingTree.tree->getSubOctreePosition()) ));
return workingTree.leafTree->getLeafSrc(treeLeafMask & inIndex);
return workingTree.leafTree->getLeafSrc(int(treeLeafMask & inIndex));
}
/** This function fill an array with the neighbors of a cell
......
......@@ -88,9 +88,9 @@ protected:
const int realLevel = indexLevel + this->getSubOctreePosition();
const FReal widthAtLevel = inBoxWidthAtLevel[realLevel];
newNode->setPosition(F3DPosition(
treePosition.getX() * widthAtLevel + widthAtLevel/2.0,
treePosition.getY() * widthAtLevel + widthAtLevel/2.0,
treePosition.getZ() * widthAtLevel + widthAtLevel/2.0));
FReal(treePosition.getX()) * widthAtLevel + widthAtLevel/ FReal(2.0),
FReal(treePosition.getY()) * widthAtLevel + widthAtLevel/ FReal(2.0),
FReal(treePosition.getZ()) * widthAtLevel + widthAtLevel/ FReal(2.0) ));
this->cells[indexLevel][arrayIndex] = newNode;
......@@ -324,7 +324,7 @@ public:
if( !this->leafs[arrayIndex] ){
this->leafs[arrayIndex] = new LeafClass();
FAbstractSubOctree<ParticleClass,CellClass,ContainerClass,LeafClass>::newLeafInserted( arrayIndex , index, host, inBoxWidthAtLevel);
FAbstractSubOctree<ParticleClass,CellClass,ContainerClass,LeafClass>::newLeafInserted( long(arrayIndex) , index, host, inBoxWidthAtLevel);
}
// add particle to leaf list
this->leafs[arrayIndex]->push(inParticle);
......@@ -439,11 +439,11 @@ public:
// Next suboctree is a middle suboctree
if(inTreeHeight > nextSubOctreeHeight + nextSubOctreePosition){
this->subleafs[arrayIndex] = new FSubOctree(this,arrayIndex,nextSubOctreeHeight,nextSubOctreePosition);
this->subleafs[arrayIndex] = new FSubOctree(this,long(arrayIndex),nextSubOctreeHeight,nextSubOctreePosition);
}
// Or next suboctree contains the reail leaf!
else{
this->subleafs[arrayIndex] = new FSubOctreeWithLeafs<ParticleClass,CellClass,ContainerClass,LeafClass>(this,arrayIndex,nextSubOctreeHeight,nextSubOctreePosition);
this->subleafs[arrayIndex] = new FSubOctreeWithLeafs<ParticleClass,CellClass,ContainerClass,LeafClass>(this,long(arrayIndex),nextSubOctreeHeight,nextSubOctreePosition);
}
const FTreeCoordinate hostAtLevel(
......@@ -452,7 +452,7 @@ public:
host.getZ() >> (inTreeHeight - nextSubOctreePosition ));
// We need to inform parent class
FAbstractSubOctree<ParticleClass,CellClass,ContainerClass,LeafClass>::newLeafInserted( arrayIndex, index >> (3 * (inTreeHeight-nextSubOctreePosition) ), hostAtLevel, inBoxWidthAtLevel);
FAbstractSubOctree<ParticleClass,CellClass,ContainerClass,LeafClass>::newLeafInserted( long(arrayIndex), index >> (3 * (inTreeHeight-nextSubOctreePosition) ), hostAtLevel, inBoxWidthAtLevel);
}
// Ask next suboctree to insert the particle
this->subleafs[arrayIndex]->insert( index, host, inParticle, inTreeHeight, inBoxWidthAtLevel);
......
......@@ -159,11 +159,11 @@ public:
this->z = 0;
for(int indexLevel = 0; indexLevel < inLevel ; ++indexLevel){
z |= (inIndex & mask);
z |= long(inIndex & mask);
inIndex >>= 1;
y |= (inIndex & mask);
y |= long(inIndex & mask);
inIndex >>= 1;
x |= (inIndex & mask);
x |= long(inIndex & mask);
mask <<= 1;
}
......
......@@ -67,7 +67,7 @@ public:
if(other.getSize() > this->capacity){
delete [] reinterpret_cast< char* >(this->array);
this->capacity = other.getSize() * 1.5;
this->capacity = int(other.getSize() * 1.5);
array = reinterpret_cast< T* >( new char[SizeOfT*this->capacity]);
}
this->index = other.index;
......@@ -165,7 +165,7 @@ public:
*/
void push( const T & inValue ){
if( this->index == this->capacity ){
setCapacity(this->capacity * 1.5);
setCapacity(int(this->capacity * 1.5));
}
new((void*)&this->array[this->index]) T;
this->array[this->index] = inValue;
......
......@@ -323,9 +323,9 @@ public:
#pragma omp parallel
{
const float step = (float(this->leafsNumber) / omp_get_num_threads());
const int start = int(FMath::Ceil(step * omp_get_thread_num()));
const int tempEnd = int(FMath::Ceil(step * (omp_get_thread_num()+1)));
const float step = float(this->leafsNumber) / float(omp_get_num_threads());
const int start = int(FMath::Ceil(step * float(omp_get_thread_num())));
const int tempEnd = int(FMath::Ceil(step * float(omp_get_thread_num()+1)));
const int end = (tempEnd > this->leafsNumber ? this->leafsNumber : tempEnd);
typename OctreeClass::Iterator octreeIterator(tree);
......
......@@ -355,7 +355,7 @@ public:
if( child[idxChild] && workingIntervalsPerLevel[(idxLevel+1) * nbProcess + idProcess].min <= child[idxChild]->getMortonIndex() ){
child[idxChild]->serializeUp(&sendBuffer[idxBuff]);
idxBuff += CellClass::SerializedSizeUp;
state |= (0x1 << idxChild);
state |= char(0x1 << idxChild);
}
}
sendBuffer[0] = state;
......@@ -418,7 +418,7 @@ public:
// retreive data and merge my child and the child from others
for(int idxProc = firstProcThatSend ; idxProc < endProcThatSend ; ++idxProc){
char state = recvBuffer[idxProc * recvBufferOffset];
int state = int(recvBuffer[idxProc * recvBufferOffset]);
int position = 0;
int bufferIndex = 1;
......
......@@ -17,8 +17,8 @@ class FMpiTreeBuilder{
*/
static long getTreeCoordinate(const FReal inRelativePosition, const FReal boxWidthAtLeafLevel) {
const FReal indexFReal = inRelativePosition / boxWidthAtLeafLevel;
const long index = FMath::dfloor(indexFReal);
if( index && FMath::LookEqual(inRelativePosition, boxWidthAtLeafLevel * index ) ){
const long index = long(FMath::dfloor(indexFReal));
if( index && FMath::LookEqual(inRelativePosition, boxWidthAtLeafLevel * FReal(index) ) ){
return index - 1;
}
return index;
......@@ -48,14 +48,14 @@ class FMpiTreeBuilder{
template< class T >
static T GetLeft(const T inSize) {
const float step = (float(inSize) / MpiGetNbProcs());
return T(FMath::Ceil(step * MpiGetRank()));
const float step = (float(inSize) / float(MpiGetNbProcs()));
return T(FMath::Ceil(step * float(MpiGetRank())));
}
template< class T >
static T GetRight(const T inSize) {
const float step = (float(inSize) / MpiGetNbProcs());
const T res = T(FMath::Ceil(step * (MpiGetRank()+1)));
const float step = (float(inSize) / float(MpiGetNbProcs()));
const T res = T(FMath::Ceil(step * float(MpiGetRank()+1)));
if(res > inSize) return inSize;
else return res;
}
......@@ -132,7 +132,7 @@ public:
F3DPosition boxCorner(loader.getCenterOfBox() - (loader.getBoxWidth()/2));
FTreeCoordinate host;
const FReal boxWidthAtLeafLevel = loader.getBoxWidth() / (1 << (NbLevels - 1) );
const FReal boxWidthAtLeafLevel = loader.getBoxWidth() / FReal(1 << (NbLevels - 1) );
for(long idxPart = 0 ; idxPart < loader.getNumberOfParticles() ; ++idxPart){
loader.fillParticle(realParticlesIndexed[idxPart].particle);
host.setX( getTreeCoordinate( realParticlesIndexed[idxPart].particle.getPosition().getX() - boxCorner.getX(), boxWidthAtLeafLevel ));
......
This diff is collapsed.
This diff is collapsed.
......@@ -33,6 +33,7 @@
///////////////////////////////////////////////////////
typedef float FReal;
typedef long long FIndex;
///////////////////////////////////////////////////////
// Restrict
......
......@@ -2,8 +2,8 @@
// Constant values
const double FMath::FPi = M_PI;
const double FMath::FPiDiv2 = M_PI_2;
const double FMath::Epsilon = 0.00000000000000000001;
const FReal FMath::FPi = FReal(M_PI);
const FReal FMath::FPiDiv2 = FReal(M_PI_2);
const FReal FMath::Epsilon = FReal(0.00000000000000000001);
......@@ -13,9 +13,9 @@
* Propose basic math functions or indirections to std math.
*/
struct FMath{
static const double FPi; //< Pi constant
static const double FPiDiv2; //< Pi/2 constant
static const double Epsilon; //< Epsilon
static const FReal FPi; //< Pi constant
static const FReal FPiDiv2; //< Pi/2 constant
static const FReal Epsilon; //< Epsilon
/** To get absolute value */
template <class NumType>
......@@ -38,19 +38,25 @@ struct FMath{
/** To know if 2 values seems to be equal */
template <class NumType>
static bool LookEqual(const NumType inV1, const NumType inV2){
const FReal relTol = 0.00001;
const FReal absTol = 0.00001;
const FReal relTol = FReal(0.00001);
const FReal absTol = FReal(0.00001);
return (Abs(inV1 - inV2) <= Max(absTol, relTol * Max(Abs(inV1), Abs(inV2))));
//return Abs(inV1 - inV2) <= ((Abs(inV1) < Abs(inV2) ? Abs(inV2) : Abs(inV1)) * 0.00001);
}
/** To get floor of a FReal */
static FReal dfloor(const FReal inValue){
static float dfloor(const float inValue){
return floorf(inValue);
}
static double dfloor(const double inValue){
return floor(inValue);
}
/** To get ceil of a FReal */
static FReal Ceil(const FReal inValue){
static float Ceil(const float inValue){
return ceilf(inValue);
}
static double Ceil(const double inValue){
return ceil(inValue);
}
......@@ -69,32 +75,50 @@ struct FMath{
}
/** To get sqrt of a FReal */
static FReal Sqrt(const FReal inValue){
static float Sqrt(const float inValue){
return sqrtf(inValue);
}
static double Sqrt(const double inValue){
return sqrt(inValue);
}
/** To get atan2 of a 2 FReal */
static FReal Atan2(const FReal inValue1,const FReal inValue2){
static float Atan2(const float inValue1,const float inValue2){
return atan2f(inValue1,inValue2);
}
static double Atan2(const double inValue1,const double inValue2){
return atan2(inValue1,inValue2);
}
/** To get sqrt of a FReal */
static FReal Sin(const FReal inValue){
static float Sin(const float inValue){
return sinf(inValue);
}
static double Sin(const double inValue){
return sin(inValue);
}
/** To get cos of a FReal */
static FReal Cos(const FReal inValue){
static float Cos(const float inValue){
return cosf(inValue);
}
static double Cos(const double inValue){
return cos(inValue);
}
/** To get acos of a FReal */
static FReal ACos(const FReal inValue){
static float ACos(const float inValue){
return acosf(inValue);
}
static double ACos(const double inValue){
return acos(inValue);
}
/** To get atan2 of a 2 FReal */
static FReal Fmod(const FReal inValue1,const FReal inValue2){
static float Fmod(const float inValue1,const float inValue2){
return fmodf(inValue1,inValue2);
}
static double Fmod(const double inValue1,const double inValue2){
return fmod(inValue1,inValue2);
}
};
......
......@@ -248,22 +248,22 @@ public:
template< class T >
T getLeft(const T inSize) {
const float step = (float(inSize) / processCount());
return T(FMath::Ceil(step * processId()));
const float step = (float(inSize) / float(processCount()));
return T(FMath::Ceil(step * float(processId())));
}
template< class T >
T getRight(const T inSize) {
const float step = (float(inSize) / processCount());
const T res = T(FMath::Ceil(step * (processId()+1)));
const float step = (float(inSize) / float(processCount()));
const T res = T(FMath::Ceil(step * float(processId()+1)));
if(res > inSize) return inSize;
else return res;
}
template< class T >
T getOtherRight(const T inSize, const int other) {
const float step = (float(inSize) / processCount());
const T res = T(FMath::Ceil(step * (other+1)));
const float step = (float(inSize) / float(processCount()));
const T res = T(FMath::Ceil(step * float(other+1)));
if(res > inSize) return inSize;
else return res;
}
......
......@@ -30,7 +30,7 @@ namespace FParameters{
*
*/
char toLower(const char c){
return ('A' <= c && c <= 'Z' ? (c - 'A') + 'a' : c);
return char('A' <= c && c <= 'Z' ? (c - 'A') + 'a' : c);
}
/** To know if two char are equals
......
......@@ -53,7 +53,7 @@ class FQuickSort {
else return res;
}
static int getProc(const int position, const long inSize, const int inNbProc) {
static int getProc(const long position, const long inSize, const int inNbProc) {
const double step = (double(inSize) / inNbProc);
return int(position/step);
}
......@@ -183,7 +183,7 @@ class FQuickSort {
template <class SortType, class PivotType>
static void QsLocal(SortType array[], const PivotType& pivot,
long myLeft, long myRight,
int& prefix, int& sufix){
long& prefix, long& sufix){
long leftIter = myLeft;
long rightIter = myRight;
......@@ -221,8 +221,8 @@ public:
template <class SortType, class PivotType>
static void QsOmp(SortType array[], const long size){
struct Fix{
int pre;
int suf;
long pre;
long suf;
};
const int NbOfThreads = omp_get_max_threads();
......@@ -287,7 +287,7 @@ public:
memcpy(&array[startIndex + fixesSum[myThreadId].pre], &temporaryArray[myLeft], sizeof(SortType) * fixes[myThreadId].pre);
// copy my result where it belong (> pivot)
const int sufoffset = fixesSum[lastProc + 1].pre + startIndex;
const long sufoffset = fixesSum[lastProc + 1].pre + startIndex;
memcpy(&array[sufoffset + fixesSum[myThreadId].suf], &temporaryArray[myLeft + fixes[myThreadId].pre ], sizeof(SortType) * fixes[myThreadId].suf);
OmpBarrier( mutex, firstProc, lastProc, myThreadId);
......@@ -322,8 +322,8 @@ public:
static void QsMpi(const SortType originalArray[], long size, SortType* & outputArray, long& outputSize, MPI_Comm originalComm = MPI_COMM_WORLD){
// We need a structure see the algorithm detail to know more
struct Fix{
int pre;
int suf;
long pre;
long suf;
};
// first we copy data into our working buffer : outputArray
......@@ -391,15 +391,15 @@ public:
if( fixes[currentRank].suf ){
const int procsInSuf = currentNbProcs - 1 - splitProc;
const int firstProcInSuf = splitProc + 1;
const int elementsInSuf = fixesSum[currentNbProcs].suf;
const long elementsInSuf = fixesSum[currentNbProcs].suf;
const int firstProcToSend = getProc(fixesSum[currentRank].suf, elementsInSuf, procsInSuf) + firstProcInSuf;
const int lastProcToSend = getProc(fixesSum[currentRank + 1].suf - 1, elementsInSuf, procsInSuf) + firstProcInSuf;
int sent = 0;
long sent = 0;
for(int idxProc = firstProcToSend ; idxProc <= lastProcToSend ; ++idxProc){
const int thisProcRight = getRight(elementsInSuf, idxProc - firstProcInSuf, procsInSuf);
int sendToProc = thisProcRight - fixesSum[currentRank].suf - sent;
long sendToProc = thisProcRight - fixesSum[currentRank].suf - sent;
if(sendToProc + sent > fixes[currentRank].suf){
sendToProc = fixes[currentRank].suf - sent;
......@@ -414,15 +414,15 @@ public:
// under pivot (left part)
if( fixes[currentRank].pre ){
const int procsInPre = splitProc + 1;
const int elementsInPre = fixesSum[currentNbProcs].pre;
const long elementsInPre = fixesSum[currentNbProcs].pre;
const int firstProcToSend = getProc(fixesSum[currentRank].pre, elementsInPre, procsInPre);
const int lastProcToSend = getProc(fixesSum[currentRank + 1].pre - 1, elementsInPre, procsInPre);
int sent = 0;
long sent = 0;
for(int idxProc = firstProcToSend ; idxProc <= lastProcToSend ; ++idxProc){
const int thisProcRight = getRight(elementsInPre, idxProc, procsInPre);
int sendToProc = thisProcRight - fixesSum[currentRank].pre - sent;
long sendToProc = thisProcRight - fixesSum[currentRank].pre - sent;
if(sendToProc + sent > fixes[currentRank].pre){
sendToProc = fixes[currentRank].pre - sent;
......@@ -441,7 +441,7 @@ public:
if( currentRank <= splitProc ){
// I am in S-Part (smaller than pivot)
const int procsInPre = splitProc + 1;
const int elementsInPre = fixesSum[currentNbProcs].pre;
const long elementsInPre = fixesSum[currentNbProcs].pre;
long myLeft = getLeft(elementsInPre, currentRank, procsInPre);
long myRightLimit = getRight(elementsInPre, currentRank, procsInPre);
......@@ -458,11 +458,11 @@ public:
++idxProc;
}
int indexArray = 0;
long indexArray = 0;
while( idxProc < currentNbProcs && indexArray < myRightLimit - myLeft){
const int firstIndex = Max(myLeft , (long int) fixesSum[idxProc].pre );
const int endIndex = Min((long int)fixesSum[idxProc + 1].pre, myRightLimit);
const long firstIndex = Max(myLeft , (long int) fixesSum[idxProc].pre );
const long endIndex = Min((long int)fixesSum[idxProc + 1].pre, myRightLimit);
if( (endIndex - firstIndex) ){
mpiassert( MPI_Irecv(&buffer[indexArray], (endIndex - firstIndex) * sizeof(SortType), MPI_BYTE, idxProc, 0, currentComm, &requests[iterRequest++]), __LINE__ );
}
......@@ -475,7 +475,7 @@ public:
else{
// I am in L-Part (larger than pivot)
const int procsInSuf = currentNbProcs - 1 - splitProc;
const int elementsInSuf = fixesSum[currentNbProcs].suf;
const long elementsInSuf = fixesSum[currentNbProcs].suf;
const int rankInL = currentRank - splitProc - 1;
long myLeft = getLeft(elementsInSuf, rankInL, procsInSuf);
......@@ -493,11 +493,11 @@ public:
++idxProc;
}
int indexArray = 0;
long indexArray = 0;
while( idxProc < currentNbProcs && indexArray < myRightLimit - myLeft){
const int firstIndex = Max(myLeft , (long int)fixesSum[idxProc].suf );
const int endIndex = Min((long int)fixesSum[idxProc + 1].suf, myRightLimit);
const long firstIndex = Max(myLeft , (long int)fixesSum[idxProc].suf );
const long endIndex = Min((long int)fixesSum[idxProc + 1].suf, myRightLimit);
if( (endIndex - firstIndex) ){
mpiassert( MPI_Irecv(&buffer[indexArray], (endIndex - firstIndex) * sizeof(SortType), MPI_BYTE, idxProc, 0, currentComm, &requests[iterRequest++]), __LINE__ );
}
......
......@@ -98,6 +98,7 @@ int main(int argc, char ** argv){
const long NbPart = 200000;//2000000
const double BoxWidth = 1.0;
const F3DPosition CenterOfBox(0.5,0.5,0.5);
const FReal FRandMax = FReal(RAND_MAX);
// -----------------------------------------------------
......@@ -108,9 +109,9 @@ int main(int argc, char ** argv){
std::cout << "Inserting particles ..." << std::endl;
counter.tic();
for(long idxPart = 0 ; idxPart < NbPart ; ++idxPart){
const double x = FReal(rand())/RAND_MAX;
const double y = FReal(rand())/RAND_MAX;
const double z = FReal(rand())/RAND_MAX;
const FReal x = FReal(rand())/FRandMax;
const FReal y = FReal(rand())/FRandMax;
const FReal z = FReal(rand())/FRandMax;
ParticleClass particles;
ParticleClassTyped particlesTyped;
......
......@@ -51,6 +51,7 @@ int main(int argc, char ** argv){
const int NbLevels = FParameters::getValue(argc,argv,"-h", 9);
const int SizeSubLevels = FParameters::getValue(argc,argv,"-sh", 3);
const long NbPart = 2000000;//2000000
const FReal FRandMax = FReal(RAND_MAX);
FTic counter;
......@@ -71,7 +72,7 @@ int main(int argc, char ** argv){
{
FTestParticle particleToFill;
for(int idxPart = 0 ; idxPart < NbPart ; ++idxPart){
particleToFill.setPosition(FReal(rand())/RAND_MAX,FReal(rand())/RAND_MAX,FReal(rand())/RAND_MAX);
particleToFill.setPosition(FReal(rand())/FRandMax,FReal(rand())/FRandMax,FReal(rand())/FRandMax);
tree.insert(particleToFill);
}
}
......
......@@ -59,6 +59,7 @@ int main(int argc, char ** argv){
const int NbLevels = FParameters::getValue(argc,argv,"-h", 9);
const int SizeSubLevels = FParameters::getValue(argc,argv,"-sh", 3);
const long NbPart = 2000000;//2000000
const FReal FRandMax = FReal(RAND_MAX);
FTic counter;
srand ( 1 ); // volontary set seed to constant
......@@ -76,7 +77,7 @@ int main(int argc, char ** argv){
{
ParticleClassTyped particle;
for(long idxPart = 0 ; idxPart < NbPart ; ++idxPart){
particle.setPosition(FReal(rand())/RAND_MAX,FReal(rand())/RAND_MAX,FReal(rand())/RAND_MAX);
particle.setPosition(FReal(rand())/FRandMax,FReal(rand())/FRandMax,FReal(rand())/FRandMax);
if(rand() > RAND_MAX/2) particle.setAsTarget();
else particle.setAsSource();
......
......@@ -124,6 +124,7 @@ int main(int argc, char ** argv){
const int NbLevels = FParameters::getValue(argc,argv,"-h", 5);
const int SizeSubLevels = FParameters::getValue(argc,argv,"-sh", 3);
const long NbPart = FParameters::getValue(argc,argv,"-pn", 20L);
const FReal FRandMax = FReal(RAND_MAX);
FTic counter;
......@@ -145,7 +146,7 @@ int main(int argc, char ** argv){
{
ParticleClass particleToFill;
for(int idxPart = 0 ; idxPart < NbPart ; ++idxPart){
particleToFill.setPosition(FReal(rand())/RAND_MAX,FReal(rand())/RAND_MAX,FReal(rand())/RAND_MAX);
particleToFill.setPosition(FReal(rand())/FRandMax,FReal(rand())/FRandMax,FReal(rand())/FRandMax);
particleToFill.setIndex(idxPart);
tree.insert(particleToFill);
......
......@@ -24,6 +24,7 @@ int main(int argc, char ** argv){
// Nb of particles
const long NbParticles = 200000;
const FReal FRandMax = FReal(RAND_MAX);
// Center of the box
const FReal XCenter = 0.5;
......@@ -62,9 +63,9 @@ int main(int argc, char ** argv){
// Generate particles
for( long idx = 0 ; idx < NbParticles ; ++idx ){
const FReal px = ((FReal(rand())/RAND_MAX) * BoxWidth) + XCenter - (BoxWidth/2);
const FReal py = ((FReal(rand())/RAND_MAX) * BoxWidth) + YCenter - (BoxWidth/2);
const FReal pz = ((FReal(rand())/RAND_MAX) * BoxWidth) + ZCenter - (BoxWidth/2);
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));
myfile << " \n" << px << " " << py << " " << pz;
}
......
......@@ -61,6 +61,7 @@ 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(int), 1, myfile);
......@@ -71,12 +72,12 @@ int main(int argc, char ** argv){
fwrite(&ZCenter, sizeof(FReal), 1, myfile);
FReal data[4];
data[3] = 0.1;
data[3] = FReal(0.1);
// Generate particles
for( long idx = 0 ; idx < NbParticles ; ++idx ){
data[0] = ((FReal(rand())/RAND_MAX) * BoxWidth * 2) + XCenter - BoxWidth;
data[1] = ((FReal(rand())/RAND_MAX) * BoxWidth * 2) + YCenter - BoxWidth;
data[2] = ((FReal(rand())/RAND_MAX) * BoxWidth * 2) + ZCenter - BoxWidth;
data[0] = ((FReal(rand())/FRandMax) * BoxWidth * 2) + XCenter - BoxWidth;
data[1] = ((FReal(rand())/FRandMax) * BoxWidth * 2) + YCenter - BoxWidth;
data[2] = ((FReal(rand())/FRandMax) * BoxWidth * 2) + ZCenter - BoxWidth;
/*data[0] = ((FReal(idx)/NbParticles) * BoxWidth * 2) + XCenter - BoxWidth;
data[1] = ((FReal(idx)/NbParticles) * BoxWidth * 2) + YCenter - BoxWidth;
......
......@@ -25,6 +25,8 @@ int main(int argc, char ** argv){
// Nb of particles
const long NbParticles = 50000;
const FReal FRandMax = FReal(RAND_MAX);
const FReal f2 = 2;
// Center of the box
const FReal XCenter = 0.5;
......@@ -66,9 +68,9 @@ int main(int argc, char ** argv){
// Generate particles
for( long idx = 0 ; idx < NbParticles ; ++idx ){
const FReal px = ((FReal(rand())/RAND_MAX) * BoxWidth * 2) + XCenter - BoxWidth;
const FReal py = ((FReal(rand())/RAND_MAX) * BoxWidth * 2) + YCenter - BoxWidth;
const FReal pz = ((FReal(rand())/RAND_MAX) * BoxWidth * 2) + ZCenter - BoxWidth;
const FReal px = ((FReal(rand())/FRandMax) * BoxWidth * f2) + XCenter - BoxWidth;
const FReal py = ((FReal(rand())/FRandMax) * BoxWidth * f2) + YCenter - BoxWidth;
const FReal pz = ((FReal(rand())/FRandMax) * BoxWidth * f2) + ZCenter - BoxWidth;