print(Matrix) now formats to allow pasting into C++ code, by including commas and formatting zeros as '0.0'

release/4.3a0
Richard Roberts 2011-02-04 00:49:20 +00:00
parent 3dc36369d9
commit 7cdb9b3564
1 changed files with 4 additions and 1 deletions

View File

@ -379,7 +379,10 @@ void print(const Matrix& A, const string &s, ostream& stream) {
for( size_t i = 0 ; i < m ; i++) {
for( size_t j = 0 ; j < n ; j++) {
double aij = A(i,j);
stream << setw(9) << (fabs(aij)<1e-12 ? 0 : aij) << "\t";
if(aij != 0.0)
stream << setw(12) << setprecision(9) << aij << ",\t";
else
stream << " 0.0,\t";
}
stream << endl;
}