Skip to content
Snippets Groups Projects
Commit aeb20354 authored by Markus Blatt's avatar Markus Blatt
Browse files

remember fmtflags and reset them at the end of print functions.

[[Imported from SVN: r717]]
parent a76a33fa
Branches
Tags
No related merge requests found
......@@ -5,7 +5,7 @@
#include <math.h>
#include <complex>
#include <iostream>
#include <ios>
#include <iomanip>
#include <fstream>
#include <string>
......@@ -71,6 +71,9 @@ namespace Dune {
// count the numbers printed to make columns
int counter=0;
// remember old flags
std::ios_base::fmtflags oldflags = s.flags();
// set the output format
s.setf(std::ios_base::scientific, std::ios_base::floatfield);
int oldprec = s.precision();
......@@ -87,8 +90,7 @@ namespace Dune {
s << std::endl;
// reset the output format
s.precision(oldprec);
s.setf(std::ios_base::fixed, std::ios_base::floatfield);
s.flags(oldflags);
}
......@@ -176,6 +178,10 @@ namespace Dune {
void printmatrix (std::ostream& s, const M& A, std::string title, std::string rowtext,
int width=10, int precision=2)
{
// remember old flags
std::ios_base::fmtflags oldflags = s.flags();
// set the output format
s.setf(std::ios_base::scientific, std::ios_base::floatfield);
int oldprec = s.precision();
......@@ -201,8 +207,7 @@ namespace Dune {
}
// reset the output format
s.precision(oldprec);
s.setf(std::ios_base::fixed, std::ios_base::floatfield);
s.flags(oldflags);
}
/**
......@@ -228,6 +233,8 @@ namespace Dune {
std::string title, std::string rowtext,
int width=3, int precision=2)
{
// remember old flags
std::ios_base::fmtflags oldflags = s.flags();
// set the output format
s.setf(std::ios_base::scientific, std::ios_base::floatfield);
int oldprec = s.precision();
......@@ -292,8 +299,7 @@ namespace Dune {
}
// reset the output format
s.precision(oldprec);
s.setf(std::ios_base::fixed, std::ios_base::floatfield);
s.flags(oldflags);
}
/** \brief Helper method for the writeMatrixToMatlab routine.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment