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

Implemented getNumberofNonzeroMatrixElements().

parent 3fb1c95e
No related branches found
No related tags found
1 merge request!45Matrices revision
...@@ -70,6 +70,20 @@ void Matrix< Real, Device, Index >::setLike( const Matrix< Real2, Device2, Index ...@@ -70,6 +70,20 @@ void Matrix< Real, Device, Index >::setLike( const Matrix< Real2, Device2, Index
setDimensions( matrix.getRows(), matrix.getColumns() ); setDimensions( matrix.getRows(), matrix.getColumns() );
} }
template< typename Real,
typename Device,
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++;
return elements;
}
template< typename Real, template< typename Real,
typename Device, typename Device,
typename Index > typename Index >
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment