Skip to content
Snippets Groups Projects
Commit aa627012 authored by Lukas Cejka's avatar Lukas Cejka Committed by Tomáš Oberhuber
Browse files

Improved implementation of getNumberOfNonzeroMatrixElements().

parent efef3872
No related branches found
No related tags found
1 merge request!45Matrices revision
......@@ -75,13 +75,12 @@ template< typename Real,
typename Index >
Index Matrix< Real, Device, Index >::getNumberOfNonzeroMatrixElements() const
{
IndexType elements( 0 );
for( IndexType row = 0; row < this->getRows(); row++ )
for( IndexType column = 0; column < this->getColumns(); column++ )
if( this->getElement( row, column ) != 0 )
elements++;
IndexType nonZeroElements( 0 );
for( IndexType i = 0; this->values.getSize(); i++ )
if( this->values.getElement( i ) != 0.0 )
nonZeroElements++;
return elements;
return nonZeroElements;
}
template< typename Real,
......
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