Add the precision of double in the ouput of moSampling

git-svn-id: svn://scm.gforge.inria.fr/svnroot/paradiseo@2044 331e1502-861f-0410-8da2-ba01fb791d7f
This commit is contained in:
verel 2010-12-29 10:49:17 +00:00
commit a22f1e58d7

View file

@ -74,6 +74,8 @@ public:
{ {
checkpoint = new moCheckpoint<Neighbor>(*continuator); checkpoint = new moCheckpoint<Neighbor>(*continuator);
add(_stat, _monitoring); add(_stat, _monitoring);
// precision of the output by default
precisionOutput = std::cout.precision();
} }
/** /**
@ -128,6 +130,14 @@ public:
localSearch->setContinuator(*continuator); localSearch->setContinuator(*continuator);
} }
/**
* to set the precision of the output file
* @param _precision precision of the output (number of digit)
*/
void precision(unsigned int _precision) {
precisionOutput = _precision;
}
/** /**
* to export the vectors of values into one file * to export the vectors of values into one file
* @param _filename file name * @param _filename file name
@ -149,6 +159,11 @@ public:
throw std::runtime_error(str); throw std::runtime_error(str);
} }
// set the precision of the output
os.precision(precisionOutput);
for (unsigned int j = 0; j < monitorVec.size(); j++)
monitorVec[j]->precision(precisionOutput);
// all vector have the same size // all vector have the same size
unsigned vecSize = monitorVec[0]->size(); unsigned vecSize = monitorVec[0]->size();
@ -176,6 +191,7 @@ public:
throw std::runtime_error(str); throw std::runtime_error(str);
} }
monitorVec[_col]->precision(precisionOutput);
monitorVec[_col]->fileExport(_filename, _openFile); monitorVec[_col]->fileExport(_filename, _openFile);
} }
@ -214,6 +230,9 @@ protected:
std::vector< moVectorMonitor<EOT> *> monitorVec; std::vector< moVectorMonitor<EOT> *> monitorVec;
// precision of the output
unsigned int precisionOutput;
}; };