Skip to content
Snippets Groups Projects
Commit 8bf2a0ae authored by Tomáš Oberhuber's avatar Tomáš Oberhuber
Browse files

Fixed matrix reader to work with empty lines in MTX files.

parent 09af2ea2
No related branches found
No related tags found
No related merge requests found
......@@ -17,7 +17,7 @@
#include <TNL/Matrices/MatrixReader.h>
namespace TNL {
namespace Matrices {
namespace Matrices {
template< typename Matrix >
bool MatrixReader< Matrix >::readMtxFile( const String& fileName,
......@@ -68,7 +68,7 @@ bool MatrixReader< Matrix >::readMtxFileHostMatrix( std::istream& file,
if( ! computeCompressedRowLengthsFromMtxFile( file, rowLengths, columns, rows, symmetricMatrix, verbose ) )
return false;
matrix.setCompressedRowLengths( rowLengths );
if( ! readMatrixElementsFromMtxFile( file, matrix, symmetricMatrix, verbose, symReader ) )
......@@ -271,7 +271,7 @@ bool MatrixReader< Matrix >::computeCompressedRowLengthsFromMtxFile( std::istrea
timer.start();
while( std::getline( file, line ) )
{
if( line[ 0 ] == '%' ) continue;
if( ! line.getSize() || line[ 0 ] == '%' ) continue;
if( ! dimensionsLine )
{
dimensionsLine = true;
......@@ -340,10 +340,10 @@ bool MatrixReader< Matrix >::readMatrixElementsFromMtxFile( std::istream& file,
IndexType processedElements( 0 );
Timer timer;
timer.start();
while( std::getline( file, line ) )
{
if( line[ 0 ] == '%' ) continue;
if( ! line.getSize() || line[ 0 ] == '%' ) continue;
if( ! dimensionsLine )
{
dimensionsLine = true;
......@@ -371,7 +371,7 @@ bool MatrixReader< Matrix >::readMatrixElementsFromMtxFile( std::istream& file,
processedElements++;
}
}
file.clear();
long int fileSize = file.tellg();
timer.stop();
......@@ -379,7 +379,7 @@ bool MatrixReader< Matrix >::readMatrixElementsFromMtxFile( std::istream& file,
std::cout << " Reading the matrix elements ... " << processedElements << " / " << matrix.getNumberOfMatrixElements()
<< " -> " << timer.getRealTime()
<< " sec. i.e. " << fileSize / ( timer.getRealTime() * ( 1 << 20 )) << "MB/s." << std::endl;
return true;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment