6#ifndef OperatorOutputMatlab_hh
7#define OperatorOutputMatlab_hh
17 static uint storeDenseMatrixMatlabCounter_ = 0;
18 static uint storeSparseMatrixMatlabCounter_ = 0;
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 =
"") {
67 s <<
"MatDense_" << storeDenseMatrixMatlabCounter_++;
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) {
78 ofs << std::endl << offset;
82 ofs <<
"];" << std::endl;
99 std::string name =
"")
103 s <<
"MatSparse_" << storeSparseMatrixMatlabCounter_++;
106 std::string offset(name.size() + 4,
' ');
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;
const uint nofCols() const
Number of columns.
const uint nofRows() const
Number of rows.
const HashedSparseMatrix< F > * m() const
Returns the sparse matrix itself.
void storeSparseMatrixToOctave(SparseMatrix< F > &matrix, std::ostream &ofs, std::string name="")
Set< F > makeSet(uint n, const F &first,...)
bool storeDenseMatrixToMatlab(F &matrix, const uint nofRows, const uint nofCols, const std::string filename, std::string name="", bool append=false)