getfem-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Getfem-commits] (no subject)


From: Tetsuo Koyama
Subject: [Getfem-commits] (no subject)
Date: Tue, 13 Nov 2018 08:14:52 -0500 (EST)

branch: devel-tetsuo-add-format-to-vecsave
commit aa91194ad268390a45331e7a67779d1f3027f3e7
Author: Tetsuo Koyama <address@hidden>
Date:   Tue Nov 13 22:13:31 2018 +0900

    Add format option to GMM's vecsave
---
 src/gmm/gmm_inoutput.h | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/src/gmm/gmm_inoutput.h b/src/gmm/gmm_inoutput.h
index 0e27b17..9c22e7a 100644
--- a/src/gmm/gmm_inoutput.h
+++ b/src/gmm/gmm_inoutput.h
@@ -41,6 +41,7 @@
 #define GMM_INOUTPUT_H
 
 #include <stdio.h>
+#include <boost/format.hpp>
 #include "gmm_kernel.h"
 namespace gmm {
 
@@ -1145,15 +1146,21 @@ namespace gmm {
   }
 
   template<typename VEC> static void vecsave(std::string fname, const VEC& V,
-                                             bool binary=false) {
+                                             bool binary=false, std::string 
Vformat="") {
     if (binary) {
       std::ofstream f(fname.c_str(), std::ofstream::binary);
       for (size_type i=0; i < gmm::vect_size(V); ++i)
         f.write(reinterpret_cast<const char*>(&V[i]), sizeof(V[i]));
     }
     else {
-      std::ofstream f(fname.c_str()); f.precision(16); 
f.imbue(std::locale("C"));
-      for (size_type i=0; i < gmm::vect_size(V); ++i) f << V[i] << "\n";
+      std::ofstream f(fname.c_str()); f.imbue(std::locale("C"));
+      if (Vformat.empty()){
+        f.precision(16);
+        for (size_type i=0; i < gmm::vect_size(V); ++i) f << V[i] << "\n";
+      }
+      else {
+        for (size_type i=0; i < gmm::vect_size(V); ++i) f << 
boost::format(Vformat) % V[i];
+      }
     }
   } 
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]