[mlpack-svn] r16136 - mlpack/trunk/src/mlpack/core/util

fastlab-svn at coffeetalk-1.cc.gatech.edu fastlab-svn at coffeetalk-1.cc.gatech.edu
Thu Jan 9 12:16:32 EST 2014


Author: rcurtin
Date: Thu Jan  9 12:16:32 2014
New Revision: 16136

Log:
Increase precision of saves.


Modified:
   mlpack/trunk/src/mlpack/core/util/save_restore_utility.cpp
   mlpack/trunk/src/mlpack/core/util/save_restore_utility_impl.hpp

Modified: mlpack/trunk/src/mlpack/core/util/save_restore_utility.cpp
==============================================================================
--- mlpack/trunk/src/mlpack/core/util/save_restore_utility.cpp	(original)
+++ mlpack/trunk/src/mlpack/core/util/save_restore_utility.cpp	Thu Jan  9 12:16:32 2014
@@ -176,9 +176,9 @@
   {
     for (size_t c = 0; c < columns - 1; ++c)
     {
-      output << mat(r,c) << ",";
+      output << std::setprecision(15) << mat(r, c) << ",";
     }
-    output << mat(r,columns - 1) << std::endl;
+    output << std::setprecision(15) << mat(r, columns - 1) << std::endl;
   }
   parameters[name] = output.str();
 }

Modified: mlpack/trunk/src/mlpack/core/util/save_restore_utility_impl.hpp
==============================================================================
--- mlpack/trunk/src/mlpack/core/util/save_restore_utility_impl.hpp	(original)
+++ mlpack/trunk/src/mlpack/core/util/save_restore_utility_impl.hpp	Thu Jan  9 12:16:32 2014
@@ -66,7 +66,9 @@
 void SaveRestoreUtility::SaveParameter(const T& t, const std::string& name)
 {
   std::ostringstream output;
-  output << t;
+  // Manually increase precision to solve #313 for now, until we have a way to
+  // store this as an actual binary number.
+  output << std::setprecision(15) << t;
   parameters[name] = output.str();
 }
 



More information about the mlpack-svn mailing list