Go to the documentation of this file.
6 #ifndef OperatorOutputMatlab_hh
7 #define OperatorOutputMatlab_hh
33 const uint nofCols,
const std::string filename,
34 std::string name =
"",
bool append =
false) {
37 std::ios_base::openmode mode = std::ofstream::out;
38 if (append) mode = mode | std::ofstream::app;
40 std::ofstream ofs(filename.c_str(), mode);
42 std::cerr <<
"Could not open file '" << filename <<
"'" << std::endl;
63 const uint nofCols, std::ostream& ofs,
64 std::string name =
"") {
70 std::string offset(name.size() + 4,
' ');
71 ofs << name <<
" = [" << std::setprecision(16);
73 for (uint i = 0; i < nofRows; ++i) {
74 for (uint j = 0; j < nofCols; ++j) {
75 ofs << OutputMatlab<typename F::value_type>(matrix(i,j));
78 ofs << std::endl << offset;
82 ofs <<
"];" << std::endl;
99 std::string name =
"")
106 std::string offset(name.size() + 4,
' ');
107 ofs << name <<
" = zeros(" << matrix.nofRows() <<
", " << matrix.nofCols()
108 <<
");" << std::endl;
109 ofs <<
"zzz = [" << std::endl << std::setprecision(16);
110 matrix.
m()->outputMatlab(ofs);
111 ofs <<
"];" << std::endl;
112 ofs <<
"for i__=1:size(zzz,1)" << std::endl
113 <<
" " << name <<
"(zzz(i__,1), zzz(i__,2)) = zzz(i__,3);"<< std::endl
114 <<
"end" << std::endl
115 <<
"clear zzz" << std::endl;
120 #endif // OperatorOutputMatlab_hh
bool storeDenseMatrixToMatlab(F &matrix, const uint nofRows, const uint nofCols, const std::string filename, std::string name="", bool append=false)
Stores a matrix to the matlab file filename as dense matrix name.
const HashedSparseMatrix< F > * m() const
Returns the sparse matrix itself.
static uint storeSparseMatrixMatlabCounter_
static uint storeDenseMatrixMatlabCounter_
Counts number of Matlab outputs (used to uniquely name the matrices)
void storeSparseMatrixToOctave(SparseMatrix< F > &matrix, std::ostream &ofs, std::string name="")
Writes a matrix to the stream ofs as dense matrix name in Octave format (older version don't have spa...
Basic namespace for Concepts-2.