Skip to content
Snippets Groups Projects
Commit 9d9f61c2 authored by René Fritze's avatar René Fritze
Browse files

max output print precision

parent af72e5ba
No related branches found
No related tags found
No related merge requests found
...@@ -5,12 +5,14 @@ ...@@ -5,12 +5,14 @@
#include <iostream> #include <iostream>
#include <iomanip> #include <iomanip>
#include <cmath> #include <cmath>
#include <limits>
#include <boost/format.hpp> #include <boost/format.hpp>
#include <dune/stuff/functions.hh> #include <dune/stuff/functions.hh>
#include <dune/stuff/parametercontainer.hh> #include <dune/stuff/parametercontainer.hh>
namespace Stuff { namespace Stuff {
static const unsigned int matlab_output_precision = std::numeric_limits<double>::digits10 + 1;
/** /**
* \brief prints a Dune::FieldVector * \brief prints a Dune::FieldVector
* *
...@@ -89,7 +91,8 @@ void printSparseRowMatrixMatlabStyle(const T& arg, const std::string name, strea ...@@ -89,7 +91,8 @@ void printSparseRowMatrixMatlabStyle(const T& arg, const std::string name, strea
for (int row = 0; row < arg.rows(); row++) { for (int row = 0; row < arg.rows(); row++) {
for (int col = 0; col < arg.cols(); col++) { for (int col = 0; col < arg.cols(); col++) {
if (std::fabs(arg(row, col)) > eps) if (std::fabs(arg(row, col)) > eps)
out << name << "(" << row + 1 << "," << col + 1 << ")=" << std::setprecision(12) << arg(row, col) << ";\n"; out << name << "(" << row + 1 << "," << col + 1 << ")=" << std::setprecision(matlab_output_precision)
<< arg(row, col) << ";\n";
} }
} }
} }
...@@ -104,7 +107,7 @@ void printDiscreteFunctionMatlabStyle(const T& arg, const std::string name, stre ...@@ -104,7 +107,7 @@ void printDiscreteFunctionMatlabStyle(const T& arg, const std::string name, stre
typedef typename T::ConstDofIteratorType ConstDofIteratorType; typedef typename T::ConstDofIteratorType ConstDofIteratorType;
ConstDofIteratorType itEnd = arg.dend(); ConstDofIteratorType itEnd = arg.dend();
for (ConstDofIteratorType it = arg.dbegin(); it != itEnd; ++it) { for (ConstDofIteratorType it = arg.dbegin(); it != itEnd; ++it) {
out << std::setprecision(12) << *it; out << std::setprecision(matlab_output_precision) << *it;
out << ";" << std::endl; out << ";" << std::endl;
} }
out << "];" << std::endl; out << "];" << std::endl;
...@@ -118,7 +121,7 @@ void printDoubleVectorMatlabStyle(const T* arg, const int size, const std::strin ...@@ -118,7 +121,7 @@ void printDoubleVectorMatlabStyle(const T* arg, const int size, const std::strin
{ {
out << "\n" << name << " = [ " << std::endl; out << "\n" << name << " = [ " << std::endl;
for (unsigned int i = 0; i < size; i++) { for (unsigned int i = 0; i < size; i++) {
out << std::setprecision(12) << arg[i]; out << std::setprecision(matlab_output_precision) << arg[i];
out << ";" << std::endl; out << ";" << std::endl;
} }
out << "];" << std::endl; out << "];" << std::endl;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment