diff --git a/src/TNL/Matrices/Dense.h b/src/TNL/Matrices/Dense.h index 778fd0bd4af9568c0abae2de891fd49379251144..485c94701032dba62535f86bd6ab6da682615be4 100644 --- a/src/TNL/Matrices/Dense.h +++ b/src/TNL/Matrices/Dense.h @@ -107,11 +107,11 @@ class Dense : public Matrix< Real, Device, Index > const Real& operator()( const IndexType row, const IndexType column ) const; - bool setElement( const IndexType row, + void setElement( const IndexType row, const IndexType column, const RealType& value ); - bool addElement( const IndexType row, + void addElement( const IndexType row, const IndexType column, const RealType& value, const RealType& thisElementMultiplicator = 1.0 ); diff --git a/src/TNL/Matrices/Dense.hpp b/src/TNL/Matrices/Dense.hpp index c4deeb6fa4834ab6192887d125d1dc7be7f3618f..7e6f37948647df528397e4895072d847df20f7bf 100644 --- a/src/TNL/Matrices/Dense.hpp +++ b/src/TNL/Matrices/Dense.hpp @@ -289,12 +289,13 @@ template< typename Real, typename Index, bool RowMajorOrder, typename RealAllocator > -bool Dense< Real, Device, Index, RowMajorOrder, RealAllocator >::setElement( const IndexType row, - const IndexType column, - const RealType& value ) +void +Dense< Real, Device, Index, RowMajorOrder, RealAllocator >:: +setElement( const IndexType row, + const IndexType column, + const RealType& value ) { this->values.setElement( this->getElementIndex( row, column ), value ); - return true; } template< typename Real, @@ -302,10 +303,12 @@ template< typename Real, typename Index, bool RowMajorOrder, typename RealAllocator > -bool Dense< Real, Device, Index, RowMajorOrder, RealAllocator >::addElement( const IndexType row, - const IndexType column, - const RealType& value, - const RealType& thisElementMultiplicator ) +void +Dense< Real, Device, Index, RowMajorOrder, RealAllocator >:: +addElement( const IndexType row, + const IndexType column, + const RealType& value, + const RealType& thisElementMultiplicator ) { const IndexType elementIndex = this->getElementIndex( row, column ); if( thisElementMultiplicator == 1.0 ) @@ -314,7 +317,6 @@ bool Dense< Real, Device, Index, RowMajorOrder, RealAllocator >::addElement( con else this->values.setElement( elementIndex, thisElementMultiplicator * this->values.getElement( elementIndex ) + value ); - return true; } template< typename Real, diff --git a/src/TNL/Matrices/DenseMatrixView.h b/src/TNL/Matrices/DenseMatrixView.h index 23f5d7317809f64c350fb15219337b4f3d3260e5..9bad424b2a8cd4e7f8f566a347e90e8318be6d6b 100644 --- a/src/TNL/Matrices/DenseMatrixView.h +++ b/src/TNL/Matrices/DenseMatrixView.h @@ -111,11 +111,11 @@ class DenseMatrixView : public MatrixView< Real, Device, Index > const Real& operator()( const IndexType row, const IndexType column ) const; - bool setElement( const IndexType row, + void setElement( const IndexType row, const IndexType column, const RealType& value ); - bool addElement( const IndexType row, + void addElement( const IndexType row, const IndexType column, const RealType& value, const RealType& thisElementMultiplicator = 1.0 ); diff --git a/src/TNL/Matrices/DenseMatrixView.hpp b/src/TNL/Matrices/DenseMatrixView.hpp index 48c0ccdc3278f8c4d35d07b11ebe70a41b50d17f..21f6d79ef5a76de759d63535e93daee385b58558 100644 --- a/src/TNL/Matrices/DenseMatrixView.hpp +++ b/src/TNL/Matrices/DenseMatrixView.hpp @@ -240,22 +240,25 @@ template< typename Real, typename Device, typename Index, bool RowMajorOrder > -bool DenseMatrixView< Real, Device, Index, RowMajorOrder >::setElement( const IndexType row, - const IndexType column, - const RealType& value ) +void +DenseMatrixView< Real, Device, Index, RowMajorOrder >:: +setElement( const IndexType row, + const IndexType column, + const RealType& value ) { this->values.setElement( this->getElementIndex( row, column ), value ); - return true; } template< typename Real, typename Device, typename Index, bool RowMajorOrder > -bool DenseMatrixView< Real, Device, Index, RowMajorOrder >::addElement( const IndexType row, - const IndexType column, - const RealType& value, - const RealType& thisElementMultiplicator ) +void +DenseMatrixView< Real, Device, Index, RowMajorOrder >:: +addElement( const IndexType row, + const IndexType column, + const RealType& value, + const RealType& thisElementMultiplicator ) { const IndexType elementIndex = this->getElementIndex( row, column ); if( thisElementMultiplicator == 1.0 ) @@ -264,7 +267,6 @@ bool DenseMatrixView< Real, Device, Index, RowMajorOrder >::addElement( const In else this->values.setElement( elementIndex, thisElementMultiplicator * this->values.getElement( elementIndex ) + value ); - return true; } template< typename Real, diff --git a/src/TNL/Matrices/Matrix.hpp b/src/TNL/Matrices/Matrix.hpp index 0710ca829dfe2a6082ef1a456f6304613aaf2d7c..2d5906d236de8a013e2a4dfbec5eef8240e6d462 100644 --- a/src/TNL/Matrices/Matrix.hpp +++ b/src/TNL/Matrices/Matrix.hpp @@ -139,12 +139,12 @@ getValues() const { return this->values; } - + template< typename Real, typename Device, typename Index, typename RealAllocator > -typename Matrix< Real, Device, Index, RealAllocator >::ValuesVector& +typename Matrix< Real, Device, Index, RealAllocator >::ValuesVector& Matrix< Real, Device, Index, RealAllocator >:: getValues() { @@ -237,7 +237,7 @@ template< typename Real, typename Device, typename Index, typename RealAllocator > -void +void Matrix< Real, Device, Index, RealAllocator >:: computeColorsVector(Containers::Vector<Index, Device, Index> &colorsVector) { diff --git a/src/TNL/Matrices/SparseMatrixView.h b/src/TNL/Matrices/SparseMatrixView.h index 1f587acf33b5490cf20d700f6bd7c0d769bba495..aba3b46423f887af25dedfdecf57f5e5edd3adda 100644 --- a/src/TNL/Matrices/SparseMatrixView.h +++ b/src/TNL/Matrices/SparseMatrixView.h @@ -92,11 +92,11 @@ class SparseMatrixView : public MatrixView< Real, Device, Index > __cuda_callable__ RowView getRow( const IndexType& rowIdx ); - bool setElement( const IndexType row, + void setElement( const IndexType row, const IndexType column, const RealType& value ); - bool addElement( const IndexType row, + void addElement( const IndexType row, const IndexType column, const RealType& value, const RealType& thisElementMultiplicator = 1.0 ); diff --git a/src/TNL/Matrices/SparseMatrixView.hpp b/src/TNL/Matrices/SparseMatrixView.hpp index d836fe5e978dfbab1152d18a423fedab964d7393..3b192b4e95203af305c69d97b9d9968dd4830963 100644 --- a/src/TNL/Matrices/SparseMatrixView.hpp +++ b/src/TNL/Matrices/SparseMatrixView.hpp @@ -54,7 +54,7 @@ auto SparseMatrixView< Real, Device, Index, MatrixType, SegmentsView >:: getView() -> ViewType { - return ViewType( this->getRows(), + return ViewType( this->getRows(), this->getColumns(), this->getValues().getView(), this->columnIndexes.getView(), @@ -204,13 +204,13 @@ template< typename Real, typename Index, typename MatrixType, template< typename, typename > class SegmentsView > -bool +void SparseMatrixView< Real, Device, Index, MatrixType, SegmentsView >:: setElement( const IndexType row, const IndexType column, const RealType& value ) { - return this->addElement( row, column, value, 0.0 ); + this->addElement( row, column, value, 0.0 ); } template< typename Real, @@ -218,7 +218,7 @@ template< typename Real, typename Index, typename MatrixType, template< typename, typename > class SegmentsView > -bool +void SparseMatrixView< Real, Device, Index, MatrixType, SegmentsView >:: addElement( const IndexType row, const IndexType column, @@ -244,18 +244,22 @@ addElement( const IndexType row, if( col == column ) { this->values.setElement( globalIdx, thisElementMultiplicator * this->values.getElement( globalIdx ) + value ); - return true; + return; } if( col == this->getPaddingIndex() || col > column ) break; } if( i == rowSize ) - return false; + { + std::stringstream msg; + msg << "The capacity of the sparse matrix row number " << row << " was exceeded."; + throw std::logic_error( msg.str() ); + } if( col == this->getPaddingIndex() ) { this->columnIndexes.setElement( globalIdx, column ); this->values.setElement( globalIdx, value ); - return true; + return; } else { @@ -273,7 +277,7 @@ addElement( const IndexType row, this->columnIndexes.setElement( globalIdx, column ); this->values.setElement( globalIdx, value ); - return true; + return; } } diff --git a/src/TNL/Matrices/Tridiagonal.hpp b/src/TNL/Matrices/Tridiagonal.hpp index 41d722c6a75f3b624075d3db18b3833051b425e6..8f4f4e190b1d59f85e1ab8480c7763a6f68ed5fc 100644 --- a/src/TNL/Matrices/Tridiagonal.hpp +++ b/src/TNL/Matrices/Tridiagonal.hpp @@ -404,7 +404,7 @@ template< typename Real, typename RealAllocator > template< typename Vector > __cuda_callable__ -typename Vector::RealType +typename Vector::RealType Tridiagonal< Real, Device, Index, RowMajorOrder, RealAllocator >:: rowVectorProduct( const IndexType row, const Vector& vector ) const { @@ -418,7 +418,7 @@ template< typename Real, typename RealAllocator > template< typename InVector, typename OutVector > -void +void Tridiagonal< Real, Device, Index, RowMajorOrder, RealAllocator >:: vectorProduct( const InVector& inVector, OutVector& outVector ) const { diff --git a/src/TNL/Matrices/TridiagonalMatrixView.hpp b/src/TNL/Matrices/TridiagonalMatrixView.hpp index e851d2a1f928b97bb96234d13a2aeea882b8e2a2..008becb092e6a895eb347d3d556bba9fab79d127 100644 --- a/src/TNL/Matrices/TridiagonalMatrixView.hpp +++ b/src/TNL/Matrices/TridiagonalMatrixView.hpp @@ -228,7 +228,6 @@ setElement( const IndexType row, const IndexType column, const RealType& value ) throw std::logic_error( msg.str() ); } this->values.setElement( this->getElementIndex( row, column ), value ); - return true; } template< typename Real, @@ -254,7 +253,6 @@ addElement( const IndexType row, } const Index i = this->getElementIndex( row, column ); this->values.setElement( i, thisElementMultiplicator * this->values.getElement( i ) + value ); - return true; } template< typename Real,