diff --git a/src/Python/pytnl/tnl/SparseMatrix.h b/src/Python/pytnl/tnl/SparseMatrix.h
index 03ec5814c4852542448a9bbe87859ef477c357b0..b4cc0fc1a5c2f346ea38bd49d40dd5d1f8dcdc51 100644
--- a/src/Python/pytnl/tnl/SparseMatrix.h
+++ b/src/Python/pytnl/tnl/SparseMatrix.h
@@ -72,7 +72,7 @@ void export_Matrix( py::module & m, const char* name )
         .def("getCompressedRowLengths", _getCompressedRowLengths)
         // TODO: export for more types
         .def("setLike",                 &Matrix::template setLike< typename Matrix::RealType, typename Matrix::DeviceType, typename Matrix::IndexType >)
-        .def("getNumberOfMatrixElements", &Matrix::getNumberOfMatrixElements)
+        .def("getAllocatedElementsCount", &Matrix::getAllocatedElementsCount)
         .def("getNumberOfNonzeroMatrixElements", &Matrix::getNumberOfNonzeroMatrixElements)
         .def("reset",                   &Matrix::reset)
         .def("getRows",                 &Matrix::getRows)
diff --git a/src/TNL/Matrices/Legacy/Sparse_impl.h b/src/TNL/Matrices/Legacy/Sparse_impl.h
index 889d92e627a9c6f456473eeaaaa3cb9d5158f93e..3e479441229197750dc384e210b0efefb044e1a3 100644
--- a/src/TNL/Matrices/Legacy/Sparse_impl.h
+++ b/src/TNL/Matrices/Legacy/Sparse_impl.h
@@ -33,7 +33,7 @@ template< typename Real,
 void Sparse< Real, Device, Index >::setLike( const Sparse< Real2, Device2, Index2 >& matrix )
 {
    Matrix< Real, Device, Index >::setLike( matrix );
-   this->allocateMatrixElements( matrix.getNumberOfMatrixElements() );
+   this->allocateMatrixElements( matrix.getAllocatedElementsCount() );
 }
 
 
diff --git a/src/TNL/Matrices/MatrixReader_impl.h b/src/TNL/Matrices/MatrixReader_impl.h
index 476a7327eb4a76a08a66e52624ffca6fc32340d4..a80d0028378e6cab0a9e4bdb466c2bacce6a278b 100644
--- a/src/TNL/Matrices/MatrixReader_impl.h
+++ b/src/TNL/Matrices/MatrixReader_impl.h
@@ -340,7 +340,7 @@ void MatrixReader< Matrix >::readMatrixElementsFromMtxFile( std::istream& file,
    long int fileSize = file.tellg();
    timer.stop();
    if( verbose )
-     std::cout << " Reading the matrix elements ... " << processedElements << " / " << matrix.getNumberOfMatrixElements()
+     std::cout << " Reading the matrix elements ... " << processedElements << " / " << matrix.getAllocatedElementsCount()
               << " -> " << timer.getRealTime()
               << " sec. i.e. " << fileSize / ( timer.getRealTime() * ( 1 << 20 ))  << "MB/s." << std::endl;
 }
diff --git a/src/TNL/Matrices/SparseMatrix.hpp b/src/TNL/Matrices/SparseMatrix.hpp
index 6189d43d370962d7f2712d6e404df2529271c4dc..3f5636bb6a666a817ac5635187bf09f7d759fd40 100644
--- a/src/TNL/Matrices/SparseMatrix.hpp
+++ b/src/TNL/Matrices/SparseMatrix.hpp
@@ -412,6 +412,9 @@ vectorProduct( const InVector& inVector,
                const RealType& matrixMultiplicator,
                const RealType& inVectorAddition ) const
 {
+   TNL_ASSERT_EQ( this->getColumns(), inVector.getSize(), "Matrix columns do not fit with input vector." );
+   TNL_ASSERT_EQ( this->getRows(), outVector.getSize(), "Matrix rows do not fit with output vector." );
+
    const auto inVectorView = inVector.getConstView();
    auto outVectorView = outVector.getView();
    const auto valuesView = this->values.getConstView();