Loading src/TNL/Matrices/DenseMatrix.h +52 −0 Original line number Diff line number Diff line Loading @@ -440,6 +440,33 @@ class DenseMatrix : public Matrix< Real, Device, Index, RealAllocator > * \include DenseMatrixExample_rowsReduction.out */ template< typename Fetch, typename Reduce, typename Keep, typename FetchValue > void rowsReduction( IndexType begin, IndexType end, Fetch& fetch, const Reduce& reduce, Keep& keep, const FetchValue& zero ); /** * \brief Method for performing general reduction on matrix rows for constant instances. * * \tparam Fetch is a type of lambda function for data fetch declared as * `fetch( IndexType rowIdx, IndexType columnIdx, RealType elementValue ) -> FetchValue`. * The return type of this lambda can be any non void. * \tparam Reduce is a type of lambda function for reduction declared as * `reduce( const FetchValue& v1, const FetchValue& v2 ) -> FetchValue`. * \tparam Keep is a type of lambda function for storing results of reduction in each row. * It is declared as `keep( const IndexType rowIdx, const double& value )`. * \tparam FetchValue is type returned by the Fetch lambda function. * * \param begin defines beginning of the range [begin,end) of rows to be processed. * \param end defines ending of the range [begin,end) of rows to be processed. * \param fetch is an instance of lambda function for data fetch. * \param reduce is an instance of lambda function for reduction. * \param keep in an instance of lambda function for storing results. * \param zero is zero of given reduction operation also known as idempotent element. * * \par Example * \include Matrices/DenseMatrix/DenseMatrixExample_rowsReduction.cpp * \par Output * \include DenseMatrixExample_rowsReduction.out */ template< typename Fetch, typename Reduce, typename Keep, typename FetchValue > void rowsReduction( IndexType begin, IndexType end, Fetch& fetch, const Reduce& reduce, Keep& keep, const FetchValue& zero ) const; /** Loading @@ -465,6 +492,31 @@ class DenseMatrix : public Matrix< Real, Device, Index, RealAllocator > * \include DenseMatrixExample_allRowsReduction.out */ template< typename Fetch, typename Reduce, typename Keep, typename FetchReal > void allRowsReduction( Fetch& fetch, const Reduce& reduce, Keep& keep, const FetchReal& zero ); /** * \brief Method for performing general reduction on ALL matrix rows for constant instances. * * \tparam Fetch is a type of lambda function for data fetch declared as * `fetch( IndexType rowIdx, IndexType columnIdx, RealType elementValue ) -> FetchValue`. * The return type of this lambda can be any non void. * \tparam Reduce is a type of lambda function for reduction declared as * `reduce( const FetchValue& v1, const FetchValue& v2 ) -> FetchValue`. * \tparam Keep is a type of lambda function for storing results of reduction in each row. * It is declared as `keep( const IndexType rowIdx, const double& value )`. * \tparam FetchValue is type returned by the Fetch lambda function. * * \param fetch is an instance of lambda function for data fetch. * \param reduce is an instance of lambda function for reduction. * \param keep in an instance of lambda function for storing results. * \param zero is zero of given reduction operation also known as idempotent element. * * \par Example * \include Matrices/DenseMatrix/DenseMatrixExample_allRowsReduction.cpp * \par Output * \include DenseMatrixExample_allRowsReduction.out */ template< typename Fetch, typename Reduce, typename Keep, typename FetchReal > void allRowsReduction( Fetch& fetch, const Reduce& reduce, Keep& keep, const FetchReal& zero ) const; /** Loading src/TNL/Matrices/DenseMatrix.hpp +26 −0 Original line number Diff line number Diff line Loading @@ -332,6 +332,19 @@ getElement( const IndexType row, return this->view.getElement( row, column ); } template< typename Real, typename Device, typename Index, ElementsOrganization Organization, typename RealAllocator > template< typename Fetch, typename Reduce, typename Keep, typename FetchValue > void DenseMatrix< Real, Device, Index, Organization, RealAllocator >:: rowsReduction( IndexType begin, IndexType end, Fetch& fetch, const Reduce& reduce, Keep& keep, const FetchValue& zero ) { this->view.rowsReduction( begin, end, fetch, reduce, keep, zero ); } template< typename Real, typename Device, typename Index, Loading @@ -345,6 +358,19 @@ rowsReduction( IndexType begin, IndexType end, Fetch& fetch, const Reduce& reduc this->view.rowsReduction( begin, end, fetch, reduce, keep, zero ); } template< typename Real, typename Device, typename Index, ElementsOrganization Organization, typename RealAllocator > template< typename Fetch, typename Reduce, typename Keep, typename FetchReal > void DenseMatrix< Real, Device, Index, Organization, RealAllocator >:: allRowsReduction( Fetch& fetch, const Reduce& reduce, Keep& keep, const FetchReal& zero ) { this->rowsReduction( 0, this->getRows(), fetch, reduce, keep, zero ); } template< typename Real, typename Device, typename Index, Loading src/TNL/Matrices/DenseMatrixView.h +52 −0 Original line number Diff line number Diff line Loading @@ -388,6 +388,33 @@ class DenseMatrixView : public MatrixView< Real, Device, Index > * \include DenseMatrixViewExample_rowsReduction.out */ template< typename Fetch, typename Reduce, typename Keep, typename FetchReal > void rowsReduction( IndexType begin, IndexType end, Fetch& fetch, const Reduce& reduce, Keep& keep, const FetchReal& zero ); /** * \brief Method for performing general reduction on matrix rows for constant instances. * * \tparam Fetch is a type of lambda function for data fetch declared as * `fetch( IndexType rowIdx, IndexType columnIdx, RealType elementValue ) -> FetchValue`. * The return type of this lambda can be any non void. * \tparam Reduce is a type of lambda function for reduction declared as * `reduce( const FetchValue& v1, const FetchValue& v2 ) -> FetchValue`. * \tparam Keep is a type of lambda function for storing results of reduction in each row. * It is declared as `keep( const IndexType rowIdx, const double& value )`. * \tparam FetchValue is type returned by the Fetch lambda function. * * \param begin defines beginning of the range [begin,end) of rows to be processed. * \param end defines ending of the range [begin,end) of rows to be processed. * \param fetch is an instance of lambda function for data fetch. * \param reduce is an instance of lambda function for reduction. * \param keep in an instance of lambda function for storing results. * \param zero is zero of given reduction operation also known as idempotent element. * * \par Example * \include Matrices/DenseMatrix/DenseMatrixViewExample_rowsReduction.cpp * \par Output * \include DenseMatrixViewExample_rowsReduction.out */ template< typename Fetch, typename Reduce, typename Keep, typename FetchReal > void rowsReduction( IndexType begin, IndexType end, Fetch& fetch, const Reduce& reduce, Keep& keep, const FetchReal& zero ) const; /** Loading @@ -413,6 +440,31 @@ class DenseMatrixView : public MatrixView< Real, Device, Index > * \include DenseMatrixViewExample_allRowsReduction.out */ template< typename Fetch, typename Reduce, typename Keep, typename FetchReal > void allRowsReduction( Fetch& fetch, const Reduce& reduce, Keep& keep, const FetchReal& zero ); /** * \brief Method for performing general reduction on ALL matrix rows for constant instances. * * \tparam Fetch is a type of lambda function for data fetch declared as * `fetch( IndexType rowIdx, IndexType columnIdx, RealType elementValue ) -> FetchValue`. * The return type of this lambda can be any non void. * \tparam Reduce is a type of lambda function for reduction declared as * `reduce( const FetchValue& v1, const FetchValue& v2 ) -> FetchValue`. * \tparam Keep is a type of lambda function for storing results of reduction in each row. * It is declared as `keep( const IndexType rowIdx, const double& value )`. * \tparam FetchValue is type returned by the Fetch lambda function. * * \param fetch is an instance of lambda function for data fetch. * \param reduce is an instance of lambda function for reduction. * \param keep in an instance of lambda function for storing results. * \param zero is zero of given reduction operation also known as idempotent element. * * \par Example * \include Matrices/DenseMatrix/DenseMatrixViewExample_allRowsReduction.cpp * \par Output * \include DenseMatrixViewExample_allRowsReduction.out */ template< typename Fetch, typename Reduce, typename Keep, typename FetchReal > void allRowsReduction( Fetch& fetch, const Reduce& reduce, Keep& keep, const FetchReal& zero ) const; /** Loading src/TNL/Matrices/DenseMatrixView.hpp +29 −0 Original line number Diff line number Diff line Loading @@ -264,6 +264,23 @@ getElement( const IndexType row, return this->values.getElement( this->getElementIndex( row, column ) ); } template< typename Real, typename Device, typename Index, ElementsOrganization Organization > template< typename Fetch, typename Reduce, typename Keep, typename FetchValue > void DenseMatrixView< Real, Device, Index, Organization >:: rowsReduction( IndexType begin, IndexType end, Fetch& fetch, const Reduce& reduce, Keep& keep, const FetchValue& zero ) { auto values_view = this->values.getView(); auto fetch_ = [=] __cuda_callable__ ( IndexType rowIdx, IndexType columnIdx, IndexType globalIdx, bool& compute ) mutable -> decltype( fetch( IndexType(), IndexType(), RealType() ) ) { return fetch( rowIdx, columnIdx, values_view[ globalIdx ] ); return zero; }; this->segments.segmentsReduction( begin, end, fetch_, reduce, keep, zero ); } template< typename Real, typename Device, typename Index, Loading @@ -281,6 +298,18 @@ rowsReduction( IndexType begin, IndexType end, Fetch& fetch, const Reduce& reduc this->segments.segmentsReduction( begin, end, fetch_, reduce, keep, zero ); } template< typename Real, typename Device, typename Index, ElementsOrganization Organization > template< typename Fetch, typename Reduce, typename Keep, typename FetchReal > void DenseMatrixView< Real, Device, Index, Organization >:: allRowsReduction( Fetch& fetch, const Reduce& reduce, Keep& keep, const FetchReal& zero ) { this->rowsReduction( 0, this->getRows(), fetch, reduce, keep, zero ); } template< typename Real, typename Device, typename Index, Loading src/TNL/Matrices/SparseMatrix.h +53 −1 Original line number Diff line number Diff line Loading @@ -570,7 +570,34 @@ class SparseMatrix : public Matrix< Real, Device, Index, RealAllocator > * \brief Method for performing general reduction on matrix rows. * * \tparam Fetch is a type of lambda function for data fetch declared as * `fetch( IndexType rowIdx, IndexType columnIdx, RealType elementValue ) -> FetchValue`. * `fetch( IndexType rowIdx, IndexType& columnIdx, RealType& elementValue ) -> FetchValue`. * The return type of this lambda can be any non void. * \tparam Reduce is a type of lambda function for reduction declared as * `reduce( const FetchValue& v1, const FetchValue& v2 ) -> FetchValue`. * \tparam Keep is a type of lambda function for storing results of reduction in each row. * It is declared as `keep( const IndexType rowIdx, const double& value )`. * \tparam FetchValue is type returned by the Fetch lambda function. * * \param begin defines beginning of the range [begin,end) of rows to be processed. * \param end defines ending of the range [begin,end) of rows to be processed. * \param fetch is an instance of lambda function for data fetch. * \param reduce is an instance of lambda function for reduction. * \param keep in an instance of lambda function for storing results. * \param zero is zero of given reduction operation also known as idempotent element. * * \par Example * \include Matrices/SparseMatrix/SparseMatrixExample_rowsReduction.cpp * \par Output * \include SparseMatrixExample_rowsReduction.out */ template< typename Fetch, typename Reduce, typename Keep, typename FetchReal > void rowsReduction( IndexType begin, IndexType end, Fetch& fetch, const Reduce& reduce, Keep& keep, const FetchReal& zero ); /** * \brief Method for performing general reduction on matrix rows for constant instances. * * \tparam Fetch is a type of lambda function for data fetch declared as * `fetch( IndexType rowIdx, IndexType& columnIdx, RealType& elementValue ) -> FetchValue`. * The return type of this lambda can be any non void. * \tparam Reduce is a type of lambda function for reduction declared as * `reduce( const FetchValue& v1, const FetchValue& v2 ) -> FetchValue`. Loading Loading @@ -616,6 +643,31 @@ class SparseMatrix : public Matrix< Real, Device, Index, RealAllocator > * \include SparseMatrixExample_allRowsReduction.out */ template< typename Fetch, typename Reduce, typename Keep, typename FetchReal > void allRowsReduction( Fetch& fetch, const Reduce& reduce, Keep& keep, const FetchReal& zero ); /** * \brief Method for performing general reduction on all matrix rows for constant instances. * * \tparam Fetch is a type of lambda function for data fetch declared as * `fetch( IndexType rowIdx, IndexType& columnIdx, RealType& elementValue ) -> FetchValue`. * The return type of this lambda can be any non void. * \tparam Reduce is a type of lambda function for reduction declared as * `reduce( const FetchValue& v1, const FetchValue& v2 ) -> FetchValue`. * \tparam Keep is a type of lambda function for storing results of reduction in each row. * It is declared as `keep( const IndexType rowIdx, const double& value )`. * \tparam FetchValue is type returned by the Fetch lambda function. * * \param fetch is an instance of lambda function for data fetch. * \param reduce is an instance of lambda function for reduction. * \param keep in an instance of lambda function for storing results. * \param zero is zero of given reduction operation also known as idempotent element. * * \par Example * \include Matrices/SparseMatrix/SparseMatrixExample_allRowsReduction.cpp * \par Output * \include SparseMatrixExample_allRowsReduction.out */ template< typename Fetch, typename Reduce, typename Keep, typename FetchReal > void allRowsReduction( Fetch& fetch, const Reduce& reduce, Keep& keep, const FetchReal& zero ) const; /** Loading Loading
src/TNL/Matrices/DenseMatrix.h +52 −0 Original line number Diff line number Diff line Loading @@ -440,6 +440,33 @@ class DenseMatrix : public Matrix< Real, Device, Index, RealAllocator > * \include DenseMatrixExample_rowsReduction.out */ template< typename Fetch, typename Reduce, typename Keep, typename FetchValue > void rowsReduction( IndexType begin, IndexType end, Fetch& fetch, const Reduce& reduce, Keep& keep, const FetchValue& zero ); /** * \brief Method for performing general reduction on matrix rows for constant instances. * * \tparam Fetch is a type of lambda function for data fetch declared as * `fetch( IndexType rowIdx, IndexType columnIdx, RealType elementValue ) -> FetchValue`. * The return type of this lambda can be any non void. * \tparam Reduce is a type of lambda function for reduction declared as * `reduce( const FetchValue& v1, const FetchValue& v2 ) -> FetchValue`. * \tparam Keep is a type of lambda function for storing results of reduction in each row. * It is declared as `keep( const IndexType rowIdx, const double& value )`. * \tparam FetchValue is type returned by the Fetch lambda function. * * \param begin defines beginning of the range [begin,end) of rows to be processed. * \param end defines ending of the range [begin,end) of rows to be processed. * \param fetch is an instance of lambda function for data fetch. * \param reduce is an instance of lambda function for reduction. * \param keep in an instance of lambda function for storing results. * \param zero is zero of given reduction operation also known as idempotent element. * * \par Example * \include Matrices/DenseMatrix/DenseMatrixExample_rowsReduction.cpp * \par Output * \include DenseMatrixExample_rowsReduction.out */ template< typename Fetch, typename Reduce, typename Keep, typename FetchValue > void rowsReduction( IndexType begin, IndexType end, Fetch& fetch, const Reduce& reduce, Keep& keep, const FetchValue& zero ) const; /** Loading @@ -465,6 +492,31 @@ class DenseMatrix : public Matrix< Real, Device, Index, RealAllocator > * \include DenseMatrixExample_allRowsReduction.out */ template< typename Fetch, typename Reduce, typename Keep, typename FetchReal > void allRowsReduction( Fetch& fetch, const Reduce& reduce, Keep& keep, const FetchReal& zero ); /** * \brief Method for performing general reduction on ALL matrix rows for constant instances. * * \tparam Fetch is a type of lambda function for data fetch declared as * `fetch( IndexType rowIdx, IndexType columnIdx, RealType elementValue ) -> FetchValue`. * The return type of this lambda can be any non void. * \tparam Reduce is a type of lambda function for reduction declared as * `reduce( const FetchValue& v1, const FetchValue& v2 ) -> FetchValue`. * \tparam Keep is a type of lambda function for storing results of reduction in each row. * It is declared as `keep( const IndexType rowIdx, const double& value )`. * \tparam FetchValue is type returned by the Fetch lambda function. * * \param fetch is an instance of lambda function for data fetch. * \param reduce is an instance of lambda function for reduction. * \param keep in an instance of lambda function for storing results. * \param zero is zero of given reduction operation also known as idempotent element. * * \par Example * \include Matrices/DenseMatrix/DenseMatrixExample_allRowsReduction.cpp * \par Output * \include DenseMatrixExample_allRowsReduction.out */ template< typename Fetch, typename Reduce, typename Keep, typename FetchReal > void allRowsReduction( Fetch& fetch, const Reduce& reduce, Keep& keep, const FetchReal& zero ) const; /** Loading
src/TNL/Matrices/DenseMatrix.hpp +26 −0 Original line number Diff line number Diff line Loading @@ -332,6 +332,19 @@ getElement( const IndexType row, return this->view.getElement( row, column ); } template< typename Real, typename Device, typename Index, ElementsOrganization Organization, typename RealAllocator > template< typename Fetch, typename Reduce, typename Keep, typename FetchValue > void DenseMatrix< Real, Device, Index, Organization, RealAllocator >:: rowsReduction( IndexType begin, IndexType end, Fetch& fetch, const Reduce& reduce, Keep& keep, const FetchValue& zero ) { this->view.rowsReduction( begin, end, fetch, reduce, keep, zero ); } template< typename Real, typename Device, typename Index, Loading @@ -345,6 +358,19 @@ rowsReduction( IndexType begin, IndexType end, Fetch& fetch, const Reduce& reduc this->view.rowsReduction( begin, end, fetch, reduce, keep, zero ); } template< typename Real, typename Device, typename Index, ElementsOrganization Organization, typename RealAllocator > template< typename Fetch, typename Reduce, typename Keep, typename FetchReal > void DenseMatrix< Real, Device, Index, Organization, RealAllocator >:: allRowsReduction( Fetch& fetch, const Reduce& reduce, Keep& keep, const FetchReal& zero ) { this->rowsReduction( 0, this->getRows(), fetch, reduce, keep, zero ); } template< typename Real, typename Device, typename Index, Loading
src/TNL/Matrices/DenseMatrixView.h +52 −0 Original line number Diff line number Diff line Loading @@ -388,6 +388,33 @@ class DenseMatrixView : public MatrixView< Real, Device, Index > * \include DenseMatrixViewExample_rowsReduction.out */ template< typename Fetch, typename Reduce, typename Keep, typename FetchReal > void rowsReduction( IndexType begin, IndexType end, Fetch& fetch, const Reduce& reduce, Keep& keep, const FetchReal& zero ); /** * \brief Method for performing general reduction on matrix rows for constant instances. * * \tparam Fetch is a type of lambda function for data fetch declared as * `fetch( IndexType rowIdx, IndexType columnIdx, RealType elementValue ) -> FetchValue`. * The return type of this lambda can be any non void. * \tparam Reduce is a type of lambda function for reduction declared as * `reduce( const FetchValue& v1, const FetchValue& v2 ) -> FetchValue`. * \tparam Keep is a type of lambda function for storing results of reduction in each row. * It is declared as `keep( const IndexType rowIdx, const double& value )`. * \tparam FetchValue is type returned by the Fetch lambda function. * * \param begin defines beginning of the range [begin,end) of rows to be processed. * \param end defines ending of the range [begin,end) of rows to be processed. * \param fetch is an instance of lambda function for data fetch. * \param reduce is an instance of lambda function for reduction. * \param keep in an instance of lambda function for storing results. * \param zero is zero of given reduction operation also known as idempotent element. * * \par Example * \include Matrices/DenseMatrix/DenseMatrixViewExample_rowsReduction.cpp * \par Output * \include DenseMatrixViewExample_rowsReduction.out */ template< typename Fetch, typename Reduce, typename Keep, typename FetchReal > void rowsReduction( IndexType begin, IndexType end, Fetch& fetch, const Reduce& reduce, Keep& keep, const FetchReal& zero ) const; /** Loading @@ -413,6 +440,31 @@ class DenseMatrixView : public MatrixView< Real, Device, Index > * \include DenseMatrixViewExample_allRowsReduction.out */ template< typename Fetch, typename Reduce, typename Keep, typename FetchReal > void allRowsReduction( Fetch& fetch, const Reduce& reduce, Keep& keep, const FetchReal& zero ); /** * \brief Method for performing general reduction on ALL matrix rows for constant instances. * * \tparam Fetch is a type of lambda function for data fetch declared as * `fetch( IndexType rowIdx, IndexType columnIdx, RealType elementValue ) -> FetchValue`. * The return type of this lambda can be any non void. * \tparam Reduce is a type of lambda function for reduction declared as * `reduce( const FetchValue& v1, const FetchValue& v2 ) -> FetchValue`. * \tparam Keep is a type of lambda function for storing results of reduction in each row. * It is declared as `keep( const IndexType rowIdx, const double& value )`. * \tparam FetchValue is type returned by the Fetch lambda function. * * \param fetch is an instance of lambda function for data fetch. * \param reduce is an instance of lambda function for reduction. * \param keep in an instance of lambda function for storing results. * \param zero is zero of given reduction operation also known as idempotent element. * * \par Example * \include Matrices/DenseMatrix/DenseMatrixViewExample_allRowsReduction.cpp * \par Output * \include DenseMatrixViewExample_allRowsReduction.out */ template< typename Fetch, typename Reduce, typename Keep, typename FetchReal > void allRowsReduction( Fetch& fetch, const Reduce& reduce, Keep& keep, const FetchReal& zero ) const; /** Loading
src/TNL/Matrices/DenseMatrixView.hpp +29 −0 Original line number Diff line number Diff line Loading @@ -264,6 +264,23 @@ getElement( const IndexType row, return this->values.getElement( this->getElementIndex( row, column ) ); } template< typename Real, typename Device, typename Index, ElementsOrganization Organization > template< typename Fetch, typename Reduce, typename Keep, typename FetchValue > void DenseMatrixView< Real, Device, Index, Organization >:: rowsReduction( IndexType begin, IndexType end, Fetch& fetch, const Reduce& reduce, Keep& keep, const FetchValue& zero ) { auto values_view = this->values.getView(); auto fetch_ = [=] __cuda_callable__ ( IndexType rowIdx, IndexType columnIdx, IndexType globalIdx, bool& compute ) mutable -> decltype( fetch( IndexType(), IndexType(), RealType() ) ) { return fetch( rowIdx, columnIdx, values_view[ globalIdx ] ); return zero; }; this->segments.segmentsReduction( begin, end, fetch_, reduce, keep, zero ); } template< typename Real, typename Device, typename Index, Loading @@ -281,6 +298,18 @@ rowsReduction( IndexType begin, IndexType end, Fetch& fetch, const Reduce& reduc this->segments.segmentsReduction( begin, end, fetch_, reduce, keep, zero ); } template< typename Real, typename Device, typename Index, ElementsOrganization Organization > template< typename Fetch, typename Reduce, typename Keep, typename FetchReal > void DenseMatrixView< Real, Device, Index, Organization >:: allRowsReduction( Fetch& fetch, const Reduce& reduce, Keep& keep, const FetchReal& zero ) { this->rowsReduction( 0, this->getRows(), fetch, reduce, keep, zero ); } template< typename Real, typename Device, typename Index, Loading
src/TNL/Matrices/SparseMatrix.h +53 −1 Original line number Diff line number Diff line Loading @@ -570,7 +570,34 @@ class SparseMatrix : public Matrix< Real, Device, Index, RealAllocator > * \brief Method for performing general reduction on matrix rows. * * \tparam Fetch is a type of lambda function for data fetch declared as * `fetch( IndexType rowIdx, IndexType columnIdx, RealType elementValue ) -> FetchValue`. * `fetch( IndexType rowIdx, IndexType& columnIdx, RealType& elementValue ) -> FetchValue`. * The return type of this lambda can be any non void. * \tparam Reduce is a type of lambda function for reduction declared as * `reduce( const FetchValue& v1, const FetchValue& v2 ) -> FetchValue`. * \tparam Keep is a type of lambda function for storing results of reduction in each row. * It is declared as `keep( const IndexType rowIdx, const double& value )`. * \tparam FetchValue is type returned by the Fetch lambda function. * * \param begin defines beginning of the range [begin,end) of rows to be processed. * \param end defines ending of the range [begin,end) of rows to be processed. * \param fetch is an instance of lambda function for data fetch. * \param reduce is an instance of lambda function for reduction. * \param keep in an instance of lambda function for storing results. * \param zero is zero of given reduction operation also known as idempotent element. * * \par Example * \include Matrices/SparseMatrix/SparseMatrixExample_rowsReduction.cpp * \par Output * \include SparseMatrixExample_rowsReduction.out */ template< typename Fetch, typename Reduce, typename Keep, typename FetchReal > void rowsReduction( IndexType begin, IndexType end, Fetch& fetch, const Reduce& reduce, Keep& keep, const FetchReal& zero ); /** * \brief Method for performing general reduction on matrix rows for constant instances. * * \tparam Fetch is a type of lambda function for data fetch declared as * `fetch( IndexType rowIdx, IndexType& columnIdx, RealType& elementValue ) -> FetchValue`. * The return type of this lambda can be any non void. * \tparam Reduce is a type of lambda function for reduction declared as * `reduce( const FetchValue& v1, const FetchValue& v2 ) -> FetchValue`. Loading Loading @@ -616,6 +643,31 @@ class SparseMatrix : public Matrix< Real, Device, Index, RealAllocator > * \include SparseMatrixExample_allRowsReduction.out */ template< typename Fetch, typename Reduce, typename Keep, typename FetchReal > void allRowsReduction( Fetch& fetch, const Reduce& reduce, Keep& keep, const FetchReal& zero ); /** * \brief Method for performing general reduction on all matrix rows for constant instances. * * \tparam Fetch is a type of lambda function for data fetch declared as * `fetch( IndexType rowIdx, IndexType& columnIdx, RealType& elementValue ) -> FetchValue`. * The return type of this lambda can be any non void. * \tparam Reduce is a type of lambda function for reduction declared as * `reduce( const FetchValue& v1, const FetchValue& v2 ) -> FetchValue`. * \tparam Keep is a type of lambda function for storing results of reduction in each row. * It is declared as `keep( const IndexType rowIdx, const double& value )`. * \tparam FetchValue is type returned by the Fetch lambda function. * * \param fetch is an instance of lambda function for data fetch. * \param reduce is an instance of lambda function for reduction. * \param keep in an instance of lambda function for storing results. * \param zero is zero of given reduction operation also known as idempotent element. * * \par Example * \include Matrices/SparseMatrix/SparseMatrixExample_allRowsReduction.cpp * \par Output * \include SparseMatrixExample_allRowsReduction.out */ template< typename Fetch, typename Reduce, typename Keep, typename FetchReal > void allRowsReduction( Fetch& fetch, const Reduce& reduce, Keep& keep, const FetchReal& zero ) const; /** Loading