Loading src/TNL/Matrices/DenseMatrix.h +13 −2 Original line number Diff line number Diff line Loading @@ -524,6 +524,10 @@ class DenseMatrix : public Matrix< Real, Device, Index > /** * \brief Computes product of matrix and vector. * * More precisely, it computes: * * outVector = matrixMultiplicator * ( *this ) * inVector + outVectorMultiplicator * outVector. * * \tparam InVector is type of input vector. It can be \ref Vector, * \ref VectorView, \ref Array, \ref ArraView or similar container. * \tparam OutVector is type of output vector. It can be \ref Vector, Loading @@ -531,14 +535,21 @@ class DenseMatrix : public Matrix< Real, Device, Index > * * \param inVector is input vector. * \param outVector is output vector. * \param matrixMultiplicator is a factor by which the matrix is multiplied. It is one by default. * \param outVectorMultiplicator is a factor by which the outVector is multiplied before added * to the result of matrix-vector product. It is zero by default. * \param begin is the beginning of the rows range for which the vector product * is computed. It is zero by default. * \param end is the end of the rows range for which the vector product * is computed. It is number if the matrix rows by default. */ template< typename InVector, typename OutVector > void vectorProduct( const InVector& inVector, OutVector& outVector, const RealType& matrixMultiplicator = 1.0, const RealType& outVectorMultiplicator = 0.0, const IndexType firstRow = 0, const IndexType lastRow = 0 ) const; const IndexType begin = 0, const IndexType end = 0 ) const; template< typename Matrix > void addMatrix( const Matrix& matrix, Loading src/TNL/Matrices/DenseMatrix.hpp +3 −3 Original line number Diff line number Diff line Loading @@ -429,10 +429,10 @@ vectorProduct( const InVector& inVector, OutVector& outVector, const RealType& matrixMultiplicator, const RealType& outVectorMultiplicator, const IndexType firstRow, const IndexType lastRow ) const const IndexType begin, const IndexType end ) const { this->view.vectorProduct( inVector, outVector, matrixMultiplicator, outVectorMultiplicator, firstRow, lastRow ); this->view.vectorProduct( inVector, outVector, matrixMultiplicator, outVectorMultiplicator, begin, end ); } template< typename Real, Loading src/TNL/Matrices/DenseMatrixView.h +2 −2 Original line number Diff line number Diff line Loading @@ -146,8 +146,8 @@ class DenseMatrixView : public MatrixView< Real, Device, Index > OutVector& outVector, const RealType& matrixMultiplicator = 1.0, const RealType& outVectorMultiplicator = 0.0, const IndexType firstRow = 0, IndexType lastRow = 0 ) const; const IndexType begin = 0, IndexType end = 0 ) const; template< typename Matrix > void addMatrix( const Matrix& matrix, Loading src/TNL/Matrices/DenseMatrixView.hpp +5 −5 Original line number Diff line number Diff line Loading @@ -379,8 +379,8 @@ vectorProduct( const InVector& inVector, OutVector& outVector, const RealType& matrixMultiplicator, const RealType& outVectorMultiplicator, const IndexType firstRow, IndexType lastRow ) const const IndexType begin, IndexType end ) const { TNL_ASSERT_EQ( this->getColumns(), inVector.getSize(), "Matrix columns count differs with input vector size." ); TNL_ASSERT_EQ( this->getRows(), outVector.getSize(), "Matrix rows count differs with output vector size." ); Loading @@ -388,15 +388,15 @@ vectorProduct( const InVector& inVector, const auto inVectorView = inVector.getConstView(); auto outVectorView = outVector.getView(); const auto valuesView = this->values.getConstView(); if( lastRow == 0 ) lastRow = this->getRows(); if( end == 0 ) end = this->getRows(); auto fetch = [=] __cuda_callable__ ( IndexType row, IndexType column, IndexType offset, bool& compute ) -> RealType { return valuesView[ offset ] * inVectorView[ column ]; }; auto keeper = [=] __cuda_callable__ ( IndexType row, const RealType& value ) mutable { outVectorView[ row ] = matrixMultiplicator * value + outVectorMultiplicator * outVectorView[ row ]; }; this->segments.segmentsReduction( firstRow, lastRow, fetch, std::plus<>{}, keeper, ( RealType ) 0.0 ); this->segments.segmentsReduction( begin, end, fetch, std::plus<>{}, keeper, ( RealType ) 0.0 ); } template< typename Real, Loading Loading
src/TNL/Matrices/DenseMatrix.h +13 −2 Original line number Diff line number Diff line Loading @@ -524,6 +524,10 @@ class DenseMatrix : public Matrix< Real, Device, Index > /** * \brief Computes product of matrix and vector. * * More precisely, it computes: * * outVector = matrixMultiplicator * ( *this ) * inVector + outVectorMultiplicator * outVector. * * \tparam InVector is type of input vector. It can be \ref Vector, * \ref VectorView, \ref Array, \ref ArraView or similar container. * \tparam OutVector is type of output vector. It can be \ref Vector, Loading @@ -531,14 +535,21 @@ class DenseMatrix : public Matrix< Real, Device, Index > * * \param inVector is input vector. * \param outVector is output vector. * \param matrixMultiplicator is a factor by which the matrix is multiplied. It is one by default. * \param outVectorMultiplicator is a factor by which the outVector is multiplied before added * to the result of matrix-vector product. It is zero by default. * \param begin is the beginning of the rows range for which the vector product * is computed. It is zero by default. * \param end is the end of the rows range for which the vector product * is computed. It is number if the matrix rows by default. */ template< typename InVector, typename OutVector > void vectorProduct( const InVector& inVector, OutVector& outVector, const RealType& matrixMultiplicator = 1.0, const RealType& outVectorMultiplicator = 0.0, const IndexType firstRow = 0, const IndexType lastRow = 0 ) const; const IndexType begin = 0, const IndexType end = 0 ) const; template< typename Matrix > void addMatrix( const Matrix& matrix, Loading
src/TNL/Matrices/DenseMatrix.hpp +3 −3 Original line number Diff line number Diff line Loading @@ -429,10 +429,10 @@ vectorProduct( const InVector& inVector, OutVector& outVector, const RealType& matrixMultiplicator, const RealType& outVectorMultiplicator, const IndexType firstRow, const IndexType lastRow ) const const IndexType begin, const IndexType end ) const { this->view.vectorProduct( inVector, outVector, matrixMultiplicator, outVectorMultiplicator, firstRow, lastRow ); this->view.vectorProduct( inVector, outVector, matrixMultiplicator, outVectorMultiplicator, begin, end ); } template< typename Real, Loading
src/TNL/Matrices/DenseMatrixView.h +2 −2 Original line number Diff line number Diff line Loading @@ -146,8 +146,8 @@ class DenseMatrixView : public MatrixView< Real, Device, Index > OutVector& outVector, const RealType& matrixMultiplicator = 1.0, const RealType& outVectorMultiplicator = 0.0, const IndexType firstRow = 0, IndexType lastRow = 0 ) const; const IndexType begin = 0, IndexType end = 0 ) const; template< typename Matrix > void addMatrix( const Matrix& matrix, Loading
src/TNL/Matrices/DenseMatrixView.hpp +5 −5 Original line number Diff line number Diff line Loading @@ -379,8 +379,8 @@ vectorProduct( const InVector& inVector, OutVector& outVector, const RealType& matrixMultiplicator, const RealType& outVectorMultiplicator, const IndexType firstRow, IndexType lastRow ) const const IndexType begin, IndexType end ) const { TNL_ASSERT_EQ( this->getColumns(), inVector.getSize(), "Matrix columns count differs with input vector size." ); TNL_ASSERT_EQ( this->getRows(), outVector.getSize(), "Matrix rows count differs with output vector size." ); Loading @@ -388,15 +388,15 @@ vectorProduct( const InVector& inVector, const auto inVectorView = inVector.getConstView(); auto outVectorView = outVector.getView(); const auto valuesView = this->values.getConstView(); if( lastRow == 0 ) lastRow = this->getRows(); if( end == 0 ) end = this->getRows(); auto fetch = [=] __cuda_callable__ ( IndexType row, IndexType column, IndexType offset, bool& compute ) -> RealType { return valuesView[ offset ] * inVectorView[ column ]; }; auto keeper = [=] __cuda_callable__ ( IndexType row, const RealType& value ) mutable { outVectorView[ row ] = matrixMultiplicator * value + outVectorMultiplicator * outVectorView[ row ]; }; this->segments.segmentsReduction( firstRow, lastRow, fetch, std::plus<>{}, keeper, ( RealType ) 0.0 ); this->segments.segmentsReduction( begin, end, fetch, std::plus<>{}, keeper, ( RealType ) 0.0 ); } template< typename Real, Loading