Loading src/TNL/Matrices/MatrixWriter.h +9 −7 Original line number Diff line number Diff line Loading @@ -11,6 +11,7 @@ #pragma once #include <ostream> #include <iostream> namespace TNL { namespace Matrices { Loading @@ -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> src/TNL/Matrices/MatrixWriter_impl.h +19 −16 Original line number Diff line number Diff line Loading @@ -10,11 +10,13 @@ #pragma once #include <TNL/Matrices/MatrixWriter.h> namespace TNL { namespace Matrices { template< typename Matrix > bool MatrixWriter< Matrix >::writeToGnuplot( std::ostream str, bool MatrixWriter< Matrix >::writeToGnuplot( std::ostream& str, const Matrix& matrix, bool verbose ) { Loading @@ -22,9 +24,9 @@ bool MatrixWriter< Matrix >::writeToGnuplot( std::ostream str, { 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; Loading @@ -35,7 +37,7 @@ bool MatrixWriter< Matrix >::writeToGnuplot( std::ostream str, } template< typename Matrix > bool MatrixWriter< Matrix >::writeToEps( std::ostream str, bool MatrixWriter< Matrix >::writeToEps( std::ostream& str, const Matrix& matrix, bool verbose ) { Loading @@ -54,8 +56,8 @@ bool MatrixWriter< Matrix >::writeToEps( std::ostream str, } template< typename Matrix > bool MatrixWriter< Matrix >::writeEpsHeader( std::ostream str, const Marix& matrix, bool MatrixWriter< Matrix >::writeEpsHeader( std::ostream& str, const Matrix& matrix, const int elementSize ) { const double scale = elementSize * max( matrix.getRows(), matrix.getColumns() ); Loading @@ -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 ) Loading Loading
src/TNL/Matrices/MatrixWriter.h +9 −7 Original line number Diff line number Diff line Loading @@ -11,6 +11,7 @@ #pragma once #include <ostream> #include <iostream> namespace TNL { namespace Matrices { Loading @@ -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>
src/TNL/Matrices/MatrixWriter_impl.h +19 −16 Original line number Diff line number Diff line Loading @@ -10,11 +10,13 @@ #pragma once #include <TNL/Matrices/MatrixWriter.h> namespace TNL { namespace Matrices { template< typename Matrix > bool MatrixWriter< Matrix >::writeToGnuplot( std::ostream str, bool MatrixWriter< Matrix >::writeToGnuplot( std::ostream& str, const Matrix& matrix, bool verbose ) { Loading @@ -22,9 +24,9 @@ bool MatrixWriter< Matrix >::writeToGnuplot( std::ostream str, { 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; Loading @@ -35,7 +37,7 @@ bool MatrixWriter< Matrix >::writeToGnuplot( std::ostream str, } template< typename Matrix > bool MatrixWriter< Matrix >::writeToEps( std::ostream str, bool MatrixWriter< Matrix >::writeToEps( std::ostream& str, const Matrix& matrix, bool verbose ) { Loading @@ -54,8 +56,8 @@ bool MatrixWriter< Matrix >::writeToEps( std::ostream str, } template< typename Matrix > bool MatrixWriter< Matrix >::writeEpsHeader( std::ostream str, const Marix& matrix, bool MatrixWriter< Matrix >::writeEpsHeader( std::ostream& str, const Matrix& matrix, const int elementSize ) { const double scale = elementSize * max( matrix.getRows(), matrix.getColumns() ); Loading @@ -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 ) Loading