From a22f1e58d75bfc07f8d13532b181b53d7f99877f Mon Sep 17 00:00:00 2001 From: verel Date: Wed, 29 Dec 2010 10:49:17 +0000 Subject: [PATCH] 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 --- trunk/paradiseo-mo/src/sampling/moSampling.h | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/trunk/paradiseo-mo/src/sampling/moSampling.h b/trunk/paradiseo-mo/src/sampling/moSampling.h index 765652ee4..b118b9d48 100644 --- a/trunk/paradiseo-mo/src/sampling/moSampling.h +++ b/trunk/paradiseo-mo/src/sampling/moSampling.h @@ -74,6 +74,8 @@ public: { checkpoint = new moCheckpoint(*continuator); add(_stat, _monitoring); + // precision of the output by default + precisionOutput = std::cout.precision(); } /** @@ -128,6 +130,14 @@ public: 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 * @param _filename file name @@ -149,6 +159,11 @@ public: 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 unsigned vecSize = monitorVec[0]->size(); @@ -176,6 +191,7 @@ public: throw std::runtime_error(str); } + monitorVec[_col]->precision(precisionOutput); monitorVec[_col]->fileExport(_filename, _openFile); } @@ -214,6 +230,9 @@ protected: std::vector< moVectorMonitor *> monitorVec; + // precision of the output + unsigned int precisionOutput; + };