diff --git a/src/TNL/Matrices/MatrixWriter.h b/src/TNL/Matrices/MatrixWriter.h index 5d2be313a4b900272acc3382b54fd35f2ad24572..634a3437b9e6da626a1e1ae47930126c21e2cf0a 100644 --- a/src/TNL/Matrices/MatrixWriter.h +++ b/src/TNL/Matrices/MatrixWriter.h @@ -11,6 +11,7 @@ #pragma once #include <ostream> +#include <iostream> namespace TNL { namespace Matrices { @@ -23,26 +24,27 @@ class MatrixWriter typedef typename Matrix::IndexType IndexType; typedef typename Matrix::RealType RealType; - static bool writeToGnuplot( std::ostream str, + static bool writeToGnuplot( std::ostream& str, const Matrix& matrix, bool verbose = false ); - static bool writeToEps( std::ostream str, + static bool writeToEps( std::ostream& str, const Matrix& matrix, bool verbose = false ); protected: - static bool writeEpsHeader( std::ostream str, + static bool writeEpsHeader( std::ostream& str, const Matrix& matrix, const int elementSize ); - static bool writeEpsBody( std::ostream str, + static bool writeEpsBody( std::ostream& str, const Matrix& matrix, - const int elementSize ); - - + const int elementSize, + bool verbose ); }; } // namespace Matrices } // namespace TNL + +#include <TNL/Matrices/MatrixWriter_impl.h> diff --git a/src/TNL/Matrices/MatrixWriter_impl.h b/src/TNL/Matrices/MatrixWriter_impl.h index 9f36993251f073ad99ecb1e8dc2166cd811ea276..1db1a9df9e63435e9052aa65f4d35527038278bc 100644 --- a/src/TNL/Matrices/MatrixWriter_impl.h +++ b/src/TNL/Matrices/MatrixWriter_impl.h @@ -10,21 +10,23 @@ #pragma once +#include <TNL/Matrices/MatrixWriter.h> + namespace TNL { namespace Matrices { template< typename Matrix > -bool MatrixWriter< Matrix >::writeToGnuplot( std::ostream str, - const Matrix& matrix, - bool verbose ) +bool MatrixWriter< Matrix >::writeToGnuplot( std::ostream& str, + const Matrix& matrix, + bool verbose ) { for( IndexType row = 0; row < matrix.getRows(); row ++ ) { for( IndexType column = 0; column < matrix.getColumns(); column ++ ) { - RealType elementValue = maytrix.getElement( row, column ); + RealType elementValue = matrix.getElement( row, column ); if( elementValue != ( RealType ) 0.0 ) - str << column << " " << getSize() - row << " " << elementValue << std::endl; + str << column << " " << row << " " << elementValue << std::endl; } if( verbose ) std::cout << "Drawing the row " << row << " \r" << std::flush; @@ -35,9 +37,9 @@ bool MatrixWriter< Matrix >::writeToGnuplot( std::ostream str, } template< typename Matrix > -bool MatrixWriter< Matrix >::writeToEps( std::ostream str, - const Matrix& matrix, - bool verbose ) +bool MatrixWriter< Matrix >::writeToEps( std::ostream& str, + const Matrix& matrix, + bool verbose ) { const int elementSize = 10; if( ! writeEpsHeader( str, matrix, elementSize ) ) @@ -54,9 +56,9 @@ bool MatrixWriter< Matrix >::writeToEps( std::ostream str, } template< typename Matrix > -bool MatrixWriter< Matrix >::writeEpsHeader( std::ostream str, - const Marix& matrix, - const int elementSize ) +bool MatrixWriter< Matrix >::writeEpsHeader( std::ostream& str, + const Matrix& matrix, + const int elementSize ) { const double scale = elementSize * max( matrix.getRows(), matrix.getColumns() ); str << "%!PS-Adobe-2.0 EPSF-2.0" << std::endl; @@ -69,14 +71,15 @@ bool MatrixWriter< Matrix >::writeEpsHeader( std::ostream str, } template< typename Matrix > -bool MatrixWriter< Matrix >::writeEpsBody( std::ostream str, - const Marix& matrix, - const int elementSize ) +bool MatrixWriter< Matrix >::writeEpsBody( std::ostream& str, + const Matrix& matrix, + const int elementSize, + bool verbose ) { IndexType lastRow( 0 ), lastColumn( 0 ); - for( IndexType row = 0; row < getSize(); row ++ ) + for( IndexType row = 0; row < matrix.getRows(); row ++ ) { - for( IndexType column = 0; column < getSize(); column ++ ) + for( IndexType column = 0; column < matrix.getColumns(); column ++ ) { RealType elementValue = getElement( row, column ); if( elementValue != ( RealType ) 0.0 )