Template Numerical Library version\ main:94209208
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Protected Attributes | List of all members
TNL::Matrices::MultidiagonalMatrixRowView< ValuesView, Indexer, DiagonalsOffsetsView_ > Class Template Reference

RowView is a simple structure for accessing rows of multidiagonal matrix. More...

#include <TNL/Matrices/MultidiagonalMatrixRowView.h>

Public Types

using ConstDiagonalsOffsetsView = typename DiagonalsOffsetsView::ConstViewType
 Type of constant container view used for storing the column indexes of the matrix elements.
 
using ConstIteratorType = MatrixRowViewIterator< ConstRowView >
 Type of constant iterator for the matrix row.
 
using ConstRowView = MultidiagonalMatrixRowView< ConstValuesViewType, IndexerType, ConstDiagonalsOffsetsView >
 Type of constant sparse matrix row view.
 
using ConstValuesViewType = typename ValuesViewType::ConstViewType
 Type of constant container view used for storing the matrix elements values.
 
using DiagonalsOffsetsView = DiagonalsOffsetsView_
 Type of a container view holding offsets of diagonals of multidiagonal matrix.
 
using IndexerType = Indexer
 Type of object responsible for indexing and organization of matrix elements.
 
using IndexType = typename ValuesView::IndexType
 The type used for matrix elements indexing.
 
using IteratorType = MatrixRowViewIterator< RowView >
 Type of iterator for the matrix row.
 
using MatrixElementType = MultidiagonalMatrixElement< RealType, IndexType >
 The type of related matrix element.
 
using RealType = typename ValuesView::RealType
 The type of matrix elements.
 
using RowView = MultidiagonalMatrixRowView< ValuesViewType, IndexerType, DiagonalsOffsetsView >
 Type of constant sparse matrix row view.
 
using ValuesViewType = ValuesView
 Type of container view used for storing the matrix elements values.
 

Public Member Functions

__cuda_callable__ MultidiagonalMatrixRowView (IndexType rowIdx, const DiagonalsOffsetsView &diagonalsOffsets, const ValuesViewType &values, const IndexerType &indexer)
 Constructor with all necessary data.
 
__cuda_callable__ IteratorType begin ()
 Returns iterator pointing at the beginning of the matrix row.
 
__cuda_callable__ ConstIteratorType cbegin () const
 Returns constant iterator pointing at the beginning of the matrix row.
 
__cuda_callable__ ConstIteratorType cend () const
 Returns constant iterator pointing at the end of the matrix row.
 
__cuda_callable__ IteratorType end ()
 Returns iterator pointing at the end of the matrix row.
 
__cuda_callable__ IndexType getColumnIndex (IndexType localIdx) const
 Computes column index of matrix element on given subdiagonal.
 
__cuda_callable__ IndexType getRowIndex () const
 Returns the matrix row index.
 
__cuda_callable__ IndexType getSize () const
 Returns number of diagonals of the multidiagonal matrix.
 
__cuda_callable__ RealTypegetValue (IndexType localIdx)
 Returns value of matrix element on given subdiagonal.
 
__cuda_callable__ const RealTypegetValue (IndexType localIdx) const
 Returns value of matrix element on given subdiagonal.
 
__cuda_callable__ void setElement (IndexType localIdx, const RealType &value)
 Changes value of matrix element on given subdiagonal.
 

Protected Attributes

DiagonalsOffsetsView diagonalsOffsets
 
Indexer indexer
 
IndexType rowIdx
 
ValuesViewType values
 

Detailed Description

template<typename ValuesView, typename Indexer, typename DiagonalsOffsetsView_>
class TNL::Matrices::MultidiagonalMatrixRowView< ValuesView, Indexer, DiagonalsOffsetsView_ >

RowView is a simple structure for accessing rows of multidiagonal matrix.

Template Parameters
ValuesViewis a vector view storing the matrix elements values.
Indexeris type of object responsible for indexing and organization of matrix elements.
DiagonalsOffsetsView_is a container view holding offsets of diagonals of multidiagonal matrix.

See MultidiagonalMatrix and MultidiagonalMatrixView.

Example
#include <iostream>
#include <TNL/Algorithms/parallelFor.h>
#include <TNL/Matrices/MultidiagonalMatrix.h>
#include <TNL/Devices/Host.h>
#include <TNL/Devices/Cuda.h>
template< typename Device >
void
getRowExample()
{
const int matrixSize( 5 );
MatrixType matrix( matrixSize, // number of matrix rows
matrixSize, // number of matrix columns
{ -1, 0, 1 } );
auto view = matrix.getView();
auto f = [ = ] __cuda_callable__( int rowIdx ) mutable
{
auto row = view.getRow( rowIdx );
if( rowIdx > 0 )
row.setElement( 0, -1.0 ); // elements below the diagonal
row.setElement( 1, 2.0 ); // elements on the diagonal
if( rowIdx < matrixSize - 1 ) // elements above the diagonal
row.setElement( 2, -1.0 );
};
/***
* Set the matrix elements.
*/
TNL::Algorithms::parallelFor< Device >( 0, matrix.getRows(), f );
std::cout << std::endl << matrix << std::endl;
}
int
main( int argc, char* argv[] )
{
std::cout << "Getting matrix rows on host: " << std::endl;
getRowExample< TNL::Devices::Host >();
#ifdef __CUDACC__
std::cout << "Getting matrix rows on CUDA device: " << std::endl;
getRowExample< TNL::Devices::Cuda >();
#endif
}
#define __cuda_callable__
Definition Macros.h:49
Implementation of sparse multidiagonal matrix.
Definition MultidiagonalMatrix.h:64
T endl(T... args)
Structure for specifying type of sparse matrix.
Definition MatrixType.h:17
Output
Getting matrix rows on host:
Row: 0 -> 0:2 1:-1
Row: 1 -> 0:-1 1:2 2:-1
Row: 2 -> 1:-1 2:2 3:-1
Row: 3 -> 2:-1 3:2 4:-1
Row: 4 -> 3:-1 4:2
Getting matrix rows on CUDA device:
Row: 0 -> 0:2 1:-1
Row: 1 -> 0:-1 1:2 2:-1
Row: 2 -> 1:-1 2:2 3:-1
Row: 3 -> 2:-1 3:2 4:-1
Row: 4 -> 3:-1 4:2

Constructor & Destructor Documentation

◆ MultidiagonalMatrixRowView()

template<typename ValuesView , typename Indexer , typename DiagonalsOffsetsView >
__cuda_callable__ TNL::Matrices::MultidiagonalMatrixRowView< ValuesView, Indexer, DiagonalsOffsetsView >::MultidiagonalMatrixRowView ( IndexType rowIdx,
const DiagonalsOffsetsView & diagonalsOffsets,
const ValuesViewType & values,
const IndexerType & indexer )

Constructor with all necessary data.

Parameters
rowIdxis index of the matrix row this RowView refer to.
diagonalsOffsetsis a vector view holding offsets of matrix diagonals,
valuesis a vector view holding values of matrix elements.
indexeris object responsible for indexing and organization of matrix elements

Member Function Documentation

◆ begin()

template<typename ValuesView , typename Indexer , typename DiagonalsOffsetsView >
__cuda_callable__ auto TNL::Matrices::MultidiagonalMatrixRowView< ValuesView, Indexer, DiagonalsOffsetsView >::begin ( )

Returns iterator pointing at the beginning of the matrix row.

Returns
iterator pointing at the beginning.

◆ cbegin()

template<typename ValuesView , typename Indexer , typename DiagonalsOffsetsView >
__cuda_callable__ auto TNL::Matrices::MultidiagonalMatrixRowView< ValuesView, Indexer, DiagonalsOffsetsView >::cbegin ( ) const

Returns constant iterator pointing at the beginning of the matrix row.

Returns
iterator pointing at the beginning.

◆ cend()

template<typename ValuesView , typename Indexer , typename DiagonalsOffsetsView >
__cuda_callable__ auto TNL::Matrices::MultidiagonalMatrixRowView< ValuesView, Indexer, DiagonalsOffsetsView >::cend ( ) const

Returns constant iterator pointing at the end of the matrix row.

Returns
iterator pointing at the end.

◆ end()

template<typename ValuesView , typename Indexer , typename DiagonalsOffsetsView >
__cuda_callable__ auto TNL::Matrices::MultidiagonalMatrixRowView< ValuesView, Indexer, DiagonalsOffsetsView >::end ( )

Returns iterator pointing at the end of the matrix row.

Returns
iterator pointing at the end.

◆ getColumnIndex()

template<typename ValuesView , typename Indexer , typename DiagonalsOffsetsView >
__cuda_callable__ auto TNL::Matrices::MultidiagonalMatrixRowView< ValuesView, Indexer, DiagonalsOffsetsView >::getColumnIndex ( IndexType localIdx) const

Computes column index of matrix element on given subdiagonal.

Parameters
localIdxis an index of the subdiagonal.
Returns
column index of matrix element on given subdiagonal.

◆ getRowIndex()

template<typename ValuesView , typename Indexer , typename DiagonalsOffsetsView >
__cuda_callable__ auto TNL::Matrices::MultidiagonalMatrixRowView< ValuesView, Indexer, DiagonalsOffsetsView >::getRowIndex ( ) const

Returns the matrix row index.

Returns
matrix row index.

◆ getSize()

template<typename ValuesView , typename Indexer , typename DiagonalsOffsetsView >
__cuda_callable__ auto TNL::Matrices::MultidiagonalMatrixRowView< ValuesView, Indexer, DiagonalsOffsetsView >::getSize ( ) const

Returns number of diagonals of the multidiagonal matrix.

Returns
number of diagonals of the multidiagonal matrix.

◆ getValue() [1/2]

template<typename ValuesView , typename Indexer , typename DiagonalsOffsetsView >
__cuda_callable__ auto TNL::Matrices::MultidiagonalMatrixRowView< ValuesView, Indexer, DiagonalsOffsetsView >::getValue ( IndexType localIdx)

Returns value of matrix element on given subdiagonal.

Parameters
localIdxis an index of the subdiagonal.
Returns
non-constant reference to matrix element value.

◆ getValue() [2/2]

template<typename ValuesView , typename Indexer , typename DiagonalsOffsetsView >
__cuda_callable__ auto TNL::Matrices::MultidiagonalMatrixRowView< ValuesView, Indexer, DiagonalsOffsetsView >::getValue ( IndexType localIdx) const

Returns value of matrix element on given subdiagonal.

Parameters
localIdxis an index of the subdiagonal.
Returns
constant reference to matrix element value.

◆ setElement()

template<typename ValuesView , typename Indexer , typename DiagonalsOffsetsView >
__cuda_callable__ void TNL::Matrices::MultidiagonalMatrixRowView< ValuesView, Indexer, DiagonalsOffsetsView >::setElement ( IndexType localIdx,
const RealType & value )

Changes value of matrix element on given subdiagonal.

Parameters
localIdxis an index of the matrix subdiagonal.
valueis the new value of the matrix element.

The documentation for this class was generated from the following files: