Template Numerical Library version\ main:8b8c8226
|
Implementation of dense matrix view. More...
#include <TNL/Matrices/DenseMatrixView.h>
Public Types | |
using | ConstRowView = typename RowView::ConstRowView |
Type for accessing immutable matrix row. | |
using | ConstValuesViewType = typename ValuesViewType::ConstViewType |
Matrix elements container view type. More... | |
using | ConstViewType = DenseMatrixView< std::add_const_t< Real >, Device, Index, Organization > |
Matrix view type for constant instances. More... | |
using | DeviceType = Device |
The device where the matrix is allocated. | |
using | IndexType = Index |
The type used for matrix elements indexing. | |
using | RealType = Real |
The type of matrix elements. | |
using | RowView = DenseMatrixRowView< SegmentViewType, ValuesViewType > |
Type for accessing matrix row. | |
template<typename _Real = Real, typename _Device = Device, typename _Index = Index> | |
using | Self = DenseMatrixView< _Real, _Device, _Index > |
Helper type for getting self type or its modifications. | |
using | ValuesViewType = typename BaseType::ValuesView |
Matrix elements container view type. More... | |
using | ViewType = DenseMatrixView< Real, Device, Index, Organization > |
Matrix view type. More... | |
![]() | |
using | ConstRowsCapacitiesTypeView = typename RowsCapacitiesTypeView::ConstViewType |
using | ConstValuesView = typename ValuesView::ConstViewType |
Type of constant vector view holding values of matrix elements. | |
using | ConstViewType = MatrixView< typename std::add_const_t< Real >, Device, Index > |
Type of base matrix view for constant instances. More... | |
using | DeviceType = Device |
The device where the matrix is allocated. | |
using | IndexType = Index |
The type used for matrix elements indexing. | |
using | RealType = Real |
The type of matrix elements. | |
using | RowsCapacitiesType = Containers::Vector< Index, Device, Index > |
using | RowsCapacitiesTypeView = Containers::VectorView< Index, Device, Index > |
using | ValuesView = Containers::VectorView< Real, Device, Index > |
Type of vector view holding values of matrix elements. | |
using | ViewType = MatrixView< Real, Device, Index > |
Type of base matrix view. More... | |
Public Member Functions | |
__cuda_callable__ | DenseMatrixView () |
Constructor without parameters. | |
__cuda_callable__ | DenseMatrixView (const DenseMatrixView &matrix)=default |
Copy constructor. More... | |
template<typename Real_ > | |
__cuda_callable__ | DenseMatrixView (IndexType rows, IndexType columns, const Containers::VectorView< Real_, Device, Index > &values) |
Constructor with matrix dimensions and values. More... | |
template<typename Value_ > | |
__cuda_callable__ | DenseMatrixView (IndexType rows, IndexType columns, const Containers::VectorView< Value_, Device, Index > &values) |
__cuda_callable__ | DenseMatrixView (IndexType rows, IndexType columns, const ValuesViewType &values) |
Constructor with matrix dimensions and values. More... | |
__cuda_callable__ void | addElement (IndexType row, IndexType column, const RealType &value, const RealType &thisElementMultiplicator=1.0) |
Add element at given row and column to given value. More... | |
template<typename Matrix > | |
void | addMatrix (const Matrix &matrix, const RealType &matrixMultiplicator=1.0, const RealType &thisMatrixMultiplicator=1.0) |
template<typename Function > | |
void | forAllElements (Function &&function) |
This method calls forElements for all matrix rows. More... | |
template<typename Function > | |
void | forAllElements (Function &&function) const |
This method calls forElements for all matrix rows. More... | |
template<typename Function > | |
void | forAllRows (Function &&function) |
Method for parallel iteration over all matrix rows. More... | |
template<typename Function > | |
void | forAllRows (Function &&function) const |
Method for parallel iteration over all matrix rows for constant instances. More... | |
template<typename Function > | |
void | forElements (IndexType begin, IndexType end, Function &&function) |
Method for iteration over all matrix rows for non-constant instances. More... | |
template<typename Function > | |
void | forElements (IndexType begin, IndexType end, Function &&function) const |
Method for iteration over all matrix rows for constant instances. More... | |
template<typename Function > | |
void | forRows (IndexType begin, IndexType end, Function &&function) |
Method for parallel iteration over matrix rows from interval [ begin, end). More... | |
template<typename Function > | |
void | forRows (IndexType begin, IndexType end, Function &&function) const |
Method for parallel iteration over matrix rows from interval [ begin, end) for constant instances. More... | |
IndexType | getAllocatedElementsCount () const |
Returns number of all matrix elements. More... | |
template<typename Vector > | |
void | getCompressedRowLengths (Vector &rowLengths) const |
Computes number of non-zeros in each row. More... | |
__cuda_callable__ ConstViewType | getConstView () const |
Returns a non-modifiable dense matrix view. More... | |
__cuda_callable__ Real | getElement (IndexType row, IndexType column) const |
Returns value of matrix element at position given by its row and column index. More... | |
IndexType | getNonzeroElementsCount () const override |
Returns number of non-zero matrix elements. More... | |
__cuda_callable__ RowView | getRow (IndexType rowIdx) |
Non-constant getter of simple structure for accessing given matrix row. More... | |
__cuda_callable__ ConstRowView | getRow (IndexType rowIdx) const |
Constant getter of simple structure for accessing given matrix row. More... | |
template<typename Vector > | |
void | getRowCapacities (Vector &rowCapacities) const |
Compute capacities of all rows. More... | |
std::string | getSerializationTypeVirtual () const override |
Returns string with serialization type. More... | |
__cuda_callable__ ViewType | getView () |
Returns a modifiable dense matrix view. More... | |
template<typename Real_ , typename Device_ , typename Index_ > | |
bool | operator!= (const DenseMatrixView< Real_, Device_, Index_, Organization > &matrix) const |
Comparison operator with another dense matrix view. More... | |
template<typename Matrix > | |
bool | operator!= (const Matrix &matrix) const |
Comparison operator with another arbitrary matrix type. More... | |
__cuda_callable__ Real & | operator() (IndexType row, IndexType column) |
Returns non-constant reference to element at row row and column column. More... | |
__cuda_callable__ const Real & | operator() (IndexType row, IndexType column) const |
Returns constant reference to element at row row and column column. More... | |
DenseMatrixView & | operator= (const DenseMatrixView &matrix) |
Assignment operator with DenseMatrix. More... | |
template<typename Real_ , typename Device_ , typename Index_ > | |
bool | operator== (const DenseMatrixView< Real_, Device_, Index_, Organization > &matrix) const |
Comparison operator with another dense matrix view. More... | |
template<typename Matrix > | |
bool | operator== (const Matrix &matrix) const |
Comparison operator with another arbitrary matrix type. More... | |
void | print (std::ostream &str) const override |
Method for printing the matrix to output stream. More... | |
template<typename Fetch , typename Reduce , typename Keep , typename FetchReal > | |
void | reduceAllRows (Fetch &fetch, const Reduce &reduce, Keep &keep, const FetchReal &identity) |
Method for performing general reduction on ALL matrix rows. More... | |
template<typename Fetch , typename Reduce , typename Keep , typename FetchReal > | |
void | reduceAllRows (Fetch &fetch, const Reduce &reduce, Keep &keep, const FetchReal &identity) const |
Method for performing general reduction on ALL matrix rows for constant instances. More... | |
template<typename Fetch , typename Reduce , typename Keep , typename FetchReal > | |
void | reduceRows (IndexType begin, IndexType end, Fetch &fetch, const Reduce &reduce, Keep &keep, const FetchReal &identity) |
Method for performing general reduction on matrix rows. More... | |
template<typename Fetch , typename Reduce , typename Keep , typename FetchReal > | |
void | reduceRows (IndexType begin, IndexType end, Fetch &fetch, const Reduce &reduce, Keep &keep, const FetchReal &identity) const |
Method for performing general reduction on matrix rows for constant instances. More... | |
template<typename Fetch , typename Reduce , typename Keep , typename FetchValue > | |
void | reduceRows (IndexType begin, IndexType end, Fetch &fetch, const Reduce &reduce, Keep &keep, const FetchValue &identity) |
template<typename Fetch , typename Reduce , typename Keep , typename FetchValue > | |
void | reduceRows (IndexType begin, IndexType end, Fetch &fetch, const Reduce &reduce, Keep &keep, const FetchValue &identity) const |
void | save (const String &fileName) const |
Method for saving the matrix view to the file with given filename. More... | |
void | save (File &file) const override |
Method for saving the matrix view to a file. More... | |
template<typename Function > | |
void | sequentialForAllRows (Function &&function) |
This method calls sequentialForRows for all matrix rows. More... | |
template<typename Function > | |
void | sequentialForAllRows (Function &&function) const |
This method calls sequentialForRows for all matrix rows (for constant instances). More... | |
template<typename Function > | |
void | sequentialForRows (IndexType begin, IndexType end, Function &&function) |
Method for sequential iteration over all matrix rows for non-constant instances. More... | |
template<typename Function > | |
void | sequentialForRows (IndexType begin, IndexType end, Function &&function) const |
Method for sequential iteration over all matrix rows for constant instances. More... | |
__cuda_callable__ void | setElement (IndexType row, IndexType column, const RealType &value) |
Sets element at given row and column to given value. More... | |
void | setValue (const RealType &v) |
Sets all matrix elements to value v. More... | |
template<typename InVector , typename OutVector > | |
void | vectorProduct (const InVector &inVector, OutVector &outVector, const RealType &matrixMultiplicator=1.0, const RealType &outVectorMultiplicator=0.0, IndexType begin=0, IndexType end=0) const |
Computes product of matrix and vector. More... | |
![]() | |
__cuda_callable__ | MatrixView () |
Basic constructor with no parameters. | |
__cuda_callable__ | MatrixView (const MatrixView &view)=default |
Shallow copy constructor. More... | |
__cuda_callable__ | MatrixView (IndexType rows, IndexType columns, ValuesView values) |
Constructor with matrix dimensions and matrix elements values. More... | |
__cuda_callable__ | MatrixView (MatrixView &&view) noexcept=default |
Move constructor. More... | |
IndexType | getAllocatedElementsCount () const |
Tells the number of allocated matrix elements. More... | |
__cuda_callable__ IndexType | getColumns () const |
Returns number of matrix columns. More... | |
virtual IndexType | getNonzeroElementsCount () const |
Computes a current number of nonzero matrix elements. More... | |
__cuda_callable__ IndexType | getRows () const |
Returns number of matrix rows. More... | |
virtual std::string | getSerializationTypeVirtual () const =0 |
__cuda_callable__ ValuesView & | getValues () |
Returns a reference to a vector with the matrix elements values. More... | |
__cuda_callable__ const ValuesView & | getValues () const |
Returns a constant reference to a vector with the matrix elements values. More... | |
template<typename Matrix > | |
bool | operator!= (const Matrix &matrix) const |
Comparison operator with another arbitrary matrix view type. More... | |
template<typename MatrixT > | |
bool | operator!= (const MatrixT &matrix) const |
__cuda_callable__ MatrixView & | operator= (const MatrixView &view) |
Shallow copy of the matrix view. More... | |
template<typename Matrix > | |
bool | operator== (const Matrix &matrix) const |
Comparison operator with another arbitrary matrix view type. More... | |
template<typename MatrixT > | |
bool | operator== (const MatrixT &matrix) const |
virtual void | print (std::ostream &str) const |
Method for printing the matrix view to output stream. More... | |
void | save (const String &fileName) const |
Method for saving the matrix view to a file. More... | |
virtual void | save (File &file) const |
Method for saving the matrix view to a file. More... | |
Static Public Member Functions | |
static constexpr ElementsOrganization | getOrganization () |
Matrix elements organization getter. More... | |
static std::string | getSerializationType () |
Returns string with serialization type. More... | |
Protected Types | |
using | BaseType = MatrixView< Real, Device, Index > |
using | SegmentsType = Algorithms::Segments::Ellpack< Device, Index, typename Allocators::Default< Device >::template Allocator< Index >, Organization, 1 > |
using | SegmentsViewType = typename SegmentsType::ViewType |
using | SegmentViewType = typename SegmentsType::SegmentViewType |
Protected Member Functions | |
__cuda_callable__ IndexType | getElementIndex (IndexType row, IndexType column) const |
Protected Attributes | |
SegmentsViewType | segments |
![]() | |
IndexType | columns |
IndexType | rows |
ValuesView | values |
Implementation of dense matrix view.
It serves as an accessor to DenseMatrix for example when passing the matrix to lambda functions. DenseMatrix view can be also created in CUDA kernels.
Real | is a type of matrix elements. |
Device | is a device where the matrix is allocated. |
Index | is a type for indexing of the matrix elements. |
MatrixElementsOrganization | tells the ordering of matrix elements in memory. It is either TNL::Algorithms::Segments::RowMajorOrder or TNL::Algorithms::Segments::ColumnMajorOrder. |
See DenseMatrix.
using TNL::Matrices::DenseMatrixView< Real, Device, Index, Organization >::ConstValuesViewType = typename ValuesViewType::ConstViewType |
Matrix elements container view type.
Use this for embedding of the matrix elements values.
using TNL::Matrices::DenseMatrixView< Real, Device, Index, Organization >::ConstViewType = DenseMatrixView< std::add_const_t< Real >, Device, Index, Organization > |
Matrix view type for constant instances.
See DenseMatrixView.
using TNL::Matrices::DenseMatrixView< Real, Device, Index, Organization >::ValuesViewType = typename BaseType::ValuesView |
Matrix elements container view type.
Use this for embedding of the matrix elements values.
using TNL::Matrices::DenseMatrixView< Real, Device, Index, Organization >::ViewType = DenseMatrixView< Real, Device, Index, Organization > |
Matrix view type.
See DenseMatrixView.
__cuda_callable__ TNL::Matrices::DenseMatrixView< Real, Device, Index, Organization >::DenseMatrixView | ( | IndexType | rows, |
IndexType | columns, | ||
const ValuesViewType & | values | ||
) |
Constructor with matrix dimensions and values.
Organization of matrix elements values in
rows | number of matrix rows. |
columns | number of matrix columns. |
values | is vector view with matrix elements values. |
__cuda_callable__ TNL::Matrices::DenseMatrixView< Real, Device, Index, Organization >::DenseMatrixView | ( | IndexType | rows, |
IndexType | columns, | ||
const Containers::VectorView< Real_, Device, Index > & | values | ||
) |
Constructor with matrix dimensions and values.
Organization of matrix elements values in
rows | number of matrix rows. |
columns | number of matrix columns. |
values | is vector view with matrix elements values. |
|
default |
Copy constructor.
matrix | is the source matrix view. |
__cuda_callable__ void TNL::Matrices::DenseMatrixView< Real, Device, Index, Organization >::addElement | ( | IndexType | row, |
IndexType | column, | ||
const RealType & | value, | ||
const RealType & | thisElementMultiplicator = 1.0 |
||
) |
Add element at given row and column to given value.
This method can be called from the host system (CPU) no matter where the matrix is allocated. If the matrix is allocated on GPU this method can be called even from device kernels. If the matrix is allocated in GPU device this method is called from CPU, it transfers values of each matrix element separately and so the performance is very low. For higher performance see. DenseMatrix::getRow or DenseMatrix::forElements and DenseMatrix::forAllElements.
row | is row index of the element. |
column | is columns index of the element. |
value | is the value the element will be set to. |
thisElementMultiplicator | is multiplicator the original matrix element value is multiplied by before addition of given value. |
void TNL::Matrices::DenseMatrixView< Real, Device, Index, Organization >::forAllElements | ( | Function && | function | ) |
This method calls forElements for all matrix rows.
See DenseMatrix::forAllElements.
Function | is a type of lambda function that will operate on matrix elements. |
function | is an instance of the lambda function to be called in each row. |
void TNL::Matrices::DenseMatrixView< Real, Device, Index, Organization >::forAllElements | ( | Function && | function | ) | const |
This method calls forElements for all matrix rows.
Function | is a type of lambda function that will operate on matrix elements. |
function | is an instance of the lambda function to be called in each row. |
void TNL::Matrices::DenseMatrixView< Real, Device, Index, Organization >::forAllRows | ( | Function && | function | ) |
Method for parallel iteration over all matrix rows.
In each row, given lambda function is performed. Each row is processed by at most one thread unlike the method DenseMatrixView::forAllElements where more than one thread can be mapped to each row.
Function | is type of the lambda function. |
function | is an instance of the lambda function to be called for each row. |
RowView represents matrix row - see TNL::Matrices::DenseMatrixView::RowView.
void TNL::Matrices::DenseMatrixView< Real, Device, Index, Organization >::forAllRows | ( | Function && | function | ) | const |
Method for parallel iteration over all matrix rows for constant instances.
In each row, given lambda function is performed. Each row is processed by at most one thread unlike the method DenseMatrixView::forAllElements where more than one thread can be mapped to each row.
Function | is type of the lambda function. |
function | is an instance of the lambda function to be called for each row. |
RowView represents matrix row - see TNL::Matrices::DenseMatrixView::RowView.
void TNL::Matrices::DenseMatrixView< Real, Device, Index, Organization >::forElements | ( | IndexType | begin, |
IndexType | end, | ||
Function && | function | ||
) |
Method for iteration over all matrix rows for non-constant instances.
Function | is type of lambda function that will operate on matrix elements. It is should have form like |
The column index repeats twice only for compatibility with sparse matrices.
begin | defines beginning of the range [begin,end) of rows to be processed. |
end | defines ending of the range [begin,end) of rows to be processed. |
function | is an instance of the lambda function to be called in each row. |
void TNL::Matrices::DenseMatrixView< Real, Device, Index, Organization >::forElements | ( | IndexType | begin, |
IndexType | end, | ||
Function && | function | ||
) | const |
Method for iteration over all matrix rows for constant instances.
Function | is type of lambda function that will operate on matrix elements. It is should have form like |
The column index repeats twice only for compatibility with sparse matrices.
begin | defines beginning of the range [begin,end) of rows to be processed. |
end | defines ending of the range [begin,end) of rows to be processed. |
function | is an instance of the lambda function to be called in each row. |
void TNL::Matrices::DenseMatrixView< Real, Device, Index, Organization >::forRows | ( | IndexType | begin, |
IndexType | end, | ||
Function && | function | ||
) |
Method for parallel iteration over matrix rows from interval [ begin, end).
In each row, given lambda function is performed. Each row is processed by at most one thread unlike the method DenseMatrix::forElements where more than one thread can be mapped to each row.
Function | is type of the lambda function. |
begin | defines beginning of the range [ begin,end ) of rows to be processed. |
end | defines ending of the range [ begin, end ) of rows to be processed. |
function | is an instance of the lambda function to be called for each row. |
RowView represents matrix row - see TNL::Matrices::DenseMatrix::RowView.
void TNL::Matrices::DenseMatrixView< Real, Device, Index, Organization >::forRows | ( | IndexType | begin, |
IndexType | end, | ||
Function && | function | ||
) | const |
Method for parallel iteration over matrix rows from interval [ begin, end) for constant instances.
In each row, given lambda function is performed. Each row is processed by at most one thread unlike the method DenseMatrixView::forElements where more than one thread can be mapped to each row.
Function | is type of the lambda function. |
begin | defines beginning of the range [ begin,end ) of rows to be processed. |
end | defines ending of the range [ begin, end ) of rows to be processed. |
function | is an instance of the lambda function to be called for each row. |
RowView represents matrix row - see TNL::Matrices::DenseMatrixView::RowView.
Index TNL::Matrices::DenseMatrixView< Real, Device, Index, Organization >::getAllocatedElementsCount |
Returns number of all matrix elements.
This method is here mainly for compatibility with sparse matrices since the number of all matrix elements is just number of rows times number of columns.
void TNL::Matrices::DenseMatrixView< Real, Device, Index, Organization >::getCompressedRowLengths | ( | Vector & | rowLengths | ) | const |
Computes number of non-zeros in each row.
rowLengths | is a vector into which the number of non-zeros in each row will be stored. |
__cuda_callable__ auto TNL::Matrices::DenseMatrixView< Real, Device, Index, Organization >::getConstView |
Returns a non-modifiable dense matrix view.
__cuda_callable__ Real TNL::Matrices::DenseMatrixView< Real, Device, Index, Organization >::getElement | ( | IndexType | row, |
IndexType | column | ||
) | const |
Returns value of matrix element at position given by its row and column index.
This method can be called from the host system (CPU) no matter where the matrix is allocated. If the matrix is allocated on GPU this method can be called even from device kernels. If the matrix is allocated in GPU device this method is called from CPU, it transfers values of each matrix element separately and so the performance is very low. For higher performance see. DenseMatrix::getRow or DenseMatrix::forElements and DenseMatrix::forAllElements.
row | is a row index of the matrix element. |
column | i a column index of the matrix element. |
|
overridevirtual |
Returns number of non-zero matrix elements.
Reimplemented from TNL::Matrices::MatrixView< Real, Device, Index >.
|
inlinestaticconstexpr |
Matrix elements organization getter.
__cuda_callable__ auto TNL::Matrices::DenseMatrixView< Real, Device, Index, Organization >::getRow | ( | IndexType | rowIdx | ) |
Non-constant getter of simple structure for accessing given matrix row.
rowIdx | is matrix row index. |
See DenseMatrixRowView.
__cuda_callable__ auto TNL::Matrices::DenseMatrixView< Real, Device, Index, Organization >::getRow | ( | IndexType | rowIdx | ) | const |
Constant getter of simple structure for accessing given matrix row.
rowIdx | is matrix row index. |
See DenseMatrixRowView.
void TNL::Matrices::DenseMatrixView< Real, Device, Index, Organization >::getRowCapacities | ( | Vector & | rowCapacities | ) | const |
Compute capacities of all rows.
The row capacities are not stored explicitly and must be computed.
rowCapacities | is a vector where the row capacities will be stored. |
|
static |
Returns string with serialization type.
The string has a form `MatricesDenseMatrix< RealType, [any_device], IndexType, [any_allocator], true/false >`.
|
overridevirtual |
Returns string with serialization type.
See DenseMatrixView::getSerializationType.
Implements TNL::Matrices::MatrixView< Real, Device, Index >.
__cuda_callable__ auto TNL::Matrices::DenseMatrixView< Real, Device, Index, Organization >::getView |
Returns a modifiable dense matrix view.
bool TNL::Matrices::DenseMatrixView< Real, Device, Index, Organization >::operator!= | ( | const DenseMatrixView< Real_, Device_, Index_, Organization > & | matrix | ) | const |
Comparison operator with another dense matrix view.
matrix | is the right-hand side matrix. |
bool TNL::Matrices::DenseMatrixView< Real, Device, Index, Organization >::operator!= | ( | const Matrix & | matrix | ) | const |
Comparison operator with another arbitrary matrix type.
matrix | is the right-hand side matrix. |
__cuda_callable__ Real & TNL::Matrices::DenseMatrixView< Real, Device, Index, Organization >::operator() | ( | IndexType | row, |
IndexType | column | ||
) |
Returns non-constant reference to element at row row and column column.
Since this method returns reference to the element, it cannot be called across different address spaces. It means that it can be called only form CPU if the matrix is allocated on CPU or only from GPU kernels if the matrix is allocated on GPU.
row | is a row index of the element. |
column | is a columns index of the element. |
__cuda_callable__ const Real & TNL::Matrices::DenseMatrixView< Real, Device, Index, Organization >::operator() | ( | IndexType | row, |
IndexType | column | ||
) | const |
Returns constant reference to element at row row and column column.
Since this method returns reference to the element, it cannot be called across different address spaces. It means that it can be called only form CPU if the matrix is allocated on CPU or only from GPU kernels if the matrix is allocated on GPU.
row | is a row index of the element. |
column | is a columns index of the element. |
DenseMatrixView< Real, Device, Index, Organization > & TNL::Matrices::DenseMatrixView< Real, Device, Index, Organization >::operator= | ( | const DenseMatrixView< Real, Device, Index, Organization > & | matrix | ) |
Assignment operator with DenseMatrix.
matrix | is the right-hand side matrix. |
bool TNL::Matrices::DenseMatrixView< Real, Device, Index, Organization >::operator== | ( | const DenseMatrixView< Real_, Device_, Index_, Organization > & | matrix | ) | const |
Comparison operator with another dense matrix view.
matrix | is the right-hand side matrix view. |
bool TNL::Matrices::DenseMatrixView< Real, Device, Index, Organization >::operator== | ( | const Matrix & | matrix | ) | const |
Comparison operator with another arbitrary matrix type.
matrix | is the right-hand side matrix. |
|
overridevirtual |
Method for printing the matrix to output stream.
str | is the output stream. |
Reimplemented from TNL::Matrices::MatrixView< Real, Device, Index >.
void TNL::Matrices::DenseMatrixView< Real, Device, Index, Organization >::reduceAllRows | ( | Fetch & | fetch, |
const Reduce & | reduce, | ||
Keep & | keep, | ||
const FetchReal & | identity | ||
) |
Method for performing general reduction on ALL matrix rows.
Fetch | is a type of lambda function for data fetch declared as |
The return type of this lambda can be any non void.
Reduce | is a type of lambda function for reduction declared as |
Keep | is a type of lambda function for storing results of reduction in each row. It is declared as |
FetchValue | is type returned by the Fetch lambda function. |
fetch | is an instance of lambda function for data fetch. |
reduce | is an instance of lambda function for reduction. |
keep | in an instance of lambda function for storing results. |
identity | is the identity element for the reduction operation, i.e. element which does not change the result of the reduction. |
void TNL::Matrices::DenseMatrixView< Real, Device, Index, Organization >::reduceAllRows | ( | Fetch & | fetch, |
const Reduce & | reduce, | ||
Keep & | keep, | ||
const FetchReal & | identity | ||
) | const |
Method for performing general reduction on ALL matrix rows for constant instances.
Fetch | is a type of lambda function for data fetch declared as |
The return type of this lambda can be any non void.
Reduce | is a type of lambda function for reduction declared as |
Keep | is a type of lambda function for storing results of reduction in each row. It is declared as |
FetchValue | is type returned by the Fetch lambda function. |
fetch | is an instance of lambda function for data fetch. |
reduce | is an instance of lambda function for reduction. |
keep | in an instance of lambda function for storing results. |
identity | is the identity element for the reduction operation, i.e. element which does not change the result of the reduction. |
void TNL::Matrices::DenseMatrixView< Real, Device, Index, Organization >::reduceRows | ( | IndexType | begin, |
IndexType | end, | ||
Fetch & | fetch, | ||
const Reduce & | reduce, | ||
Keep & | keep, | ||
const FetchReal & | identity | ||
) |
Method for performing general reduction on matrix rows.
Fetch | is a type of lambda function for data fetch declared as |
The return type of this lambda can be any non void.
Reduce | is a type of lambda function for reduction declared as |
Keep | is a type of lambda function for storing results of reduction in each row. It is declared as |
FetchValue | is type returned by the Fetch lambda function. |
begin | defines beginning of the range [begin,end) of rows to be processed. |
end | defines ending of the range [begin,end) of rows to be processed. |
fetch | is an instance of lambda function for data fetch. |
reduce | is an instance of lambda function for reduction. |
keep | in an instance of lambda function for storing results. |
identity | is the identity element for the reduction operation, i.e. element which does not change the result of the reduction. |
void TNL::Matrices::DenseMatrixView< Real, Device, Index, Organization >::reduceRows | ( | IndexType | begin, |
IndexType | end, | ||
Fetch & | fetch, | ||
const Reduce & | reduce, | ||
Keep & | keep, | ||
const FetchReal & | identity | ||
) | const |
Method for performing general reduction on matrix rows for constant instances.
Fetch | is a type of lambda function for data fetch declared as |
The return type of this lambda can be any non void.
Reduce | is a type of lambda function for reduction declared as |
Keep | is a type of lambda function for storing results of reduction in each row. It is declared as |
FetchValue | is type returned by the Fetch lambda function. |
begin | defines beginning of the range [begin,end) of rows to be processed. |
end | defines ending of the range [begin,end) of rows to be processed. |
fetch | is an instance of lambda function for data fetch. |
reduce | is an instance of lambda function for reduction. |
keep | in an instance of lambda function for storing results. |
identity | is the identity element for the reduction operation, i.e. element which does not change the result of the reduction. |
void TNL::Matrices::DenseMatrixView< Real, Device, Index, Organization >::save | ( | const String & | fileName | ) | const |
Method for saving the matrix view to the file with given filename.
The ouput file can be loaded by DenseMatrix.
fileName | is name of the file. |
|
overridevirtual |
Method for saving the matrix view to a file.
The ouput file can be loaded by DenseMatrix.
file | is the file where the matrix will be saved. |
Reimplemented from TNL::Matrices::MatrixView< Real, Device, Index >.
void TNL::Matrices::DenseMatrixView< Real, Device, Index, Organization >::sequentialForAllRows | ( | Function && | function | ) |
This method calls sequentialForRows for all matrix rows.
See DenseMatrixView::sequentialForAllRows.
Function | is a type of lambda function that will operate on matrix elements. |
function | is an instance of the lambda function to be called in each row. |
void TNL::Matrices::DenseMatrixView< Real, Device, Index, Organization >::sequentialForAllRows | ( | Function && | function | ) | const |
This method calls sequentialForRows for all matrix rows (for constant instances).
See DenseMatrixView::sequentialForRows.
Function | is a type of lambda function that will operate on matrix elements. |
function | is an instance of the lambda function to be called in each row. |
void TNL::Matrices::DenseMatrixView< Real, Device, Index, Organization >::sequentialForRows | ( | IndexType | begin, |
IndexType | end, | ||
Function && | function | ||
) |
Method for sequential iteration over all matrix rows for non-constant instances.
Function | is type of lambda function that will operate on matrix elements. It is should have form like |
RowView represents matrix row - see TNL::Matrices::DenseMatrixView::RowView.
begin | defines beginning of the range [begin,end) of rows to be processed. |
end | defines ending of the range [begin,end) of rows to be processed. |
function | is an instance of the lambda function to be called in each row. |
void TNL::Matrices::DenseMatrixView< Real, Device, Index, Organization >::sequentialForRows | ( | IndexType | begin, |
IndexType | end, | ||
Function && | function | ||
) | const |
Method for sequential iteration over all matrix rows for constant instances.
Function | is type of lambda function that will operate on matrix elements. It is should have form like |
RowView represents matrix row - see TNL::Matrices::DenseMatrixView::RowView.
begin | defines beginning of the range [begin,end) of rows to be processed. |
end | defines ending of the range [begin,end) of rows to be processed. |
function | is an instance of the lambda function to be called in each row. |
__cuda_callable__ void TNL::Matrices::DenseMatrixView< Real, Device, Index, Organization >::setElement | ( | IndexType | row, |
IndexType | column, | ||
const RealType & | value | ||
) |
Sets element at given row and column to given value.
This method can be called from the host system (CPU) no matter where the matrix is allocated. If the matrix is allocated on GPU this method can be called even from device kernels. If the matrix is allocated in GPU device this method is called from CPU, it transfers values of each matrix element separately and so the performance is very low. For higher performance see. DenseMatrix::getRow or DenseMatrix::forElements and DenseMatrix::forAllElements.
row | is row index of the element. |
column | is columns index of the element. |
value | is the value the element will be set to. |
void TNL::Matrices::DenseMatrixView< Real, Device, Index, Organization >::setValue | ( | const RealType & | v | ) |
Sets all matrix elements to value v.
v | is value all matrix elements will be set to. |
void TNL::Matrices::DenseMatrixView< Real, Device, Index, Organization >::vectorProduct | ( | const InVector & | inVector, |
OutVector & | outVector, | ||
const RealType & | matrixMultiplicator = 1.0 , |
||
const RealType & | outVectorMultiplicator = 0.0 , |
||
IndexType | begin = 0 , |
||
IndexType | end = 0 |
||
) | const |
Computes product of matrix and vector.
More precisely, it computes:
InVector | is type of input vector. It can be TNL::Containers::Vector, TNL::Containers::VectorView, TNL::Containers::Array, TNL::Containers::ArrayView, or similar container. |
OutVector | is type of output vector. It can be TNL::Containers::Vector, TNL::Containers::VectorView, TNL::Containers::Array, TNL::Containers::ArrayView, or similar container. |
inVector | is input vector. |
outVector | is output vector. |
matrixMultiplicator | is a factor by which the matrix is multiplied. It is one by default. |
outVectorMultiplicator | is a factor by which the outVector is multiplied before added to the result of matrix-vector product. It is zero by default. |
begin | is the beginning of the rows range for which the vector product is computed. It is zero by default. |
end | is the end of the rows range for which the vector product is computed. It is number if the matrix rows by default. |
Note that the ouput vector dimension must be the same as the number of matrix rows no matter how we set begin
and end
parameters. These parameters just say that some matrix rows and the output vector elements are omitted.