KASKADE 7 development version
Loading...
Searching...
No Matches
Kaskade::NumaBCRSMatrix< Entry, Index > Class Template Reference

A NUMA-aware compressed row storage matrix adhering mostly to the Dune ISTL interface (to complete...) More...

#include <threadedMatrix.hh>

Public Types

typedef ScalarType< Entry > Scalar
using field_type = Scalar
using block_type = Entry
using value_type = Entry
using size_type = Index
typedef ThreadedMatrixDetail::NumaBCRSMatrixIterator< Entry, Index > iterator
 iterator type stepping through the rows
typedef ThreadedMatrixDetail::NumaBCRSMatrixConstIterator< Entry, Index > const_iterator
typedef iterator row_type
typedef const_iterator const_row_type
typedef iterator ConstRowIterator
using ColIterator = typename iterator::Iterator
 column iterator stepping through the entries of a row
using ConstColIterator = typename iterator::ConstIterator
 column iterator stepping through the const entries of a row

Public Member Functions

Assignment and simple in-place modifications
Self & operator= (Self const &mat)=default
 Copy assignment.
Self & operator= (Self &&mat)=default
 Move assignment.
template<class EntryA, class IndexA, typename = std::enable_if_t<std::is_convertible_v<EntryA,Entry>>>
Self & operator= (NumaBCRSMatrix< EntryA, IndexA > const &A)
 Copy assignment from another NumaBCRSMatrix, with compatible entry and index types.
Self & operator= (Entry const &a)
 Assigns the given value to each entry.
Self & operator= (typename Entry::field_type const &a)
 Assigns the given scalar value to each entry.
template<class Arguments, class Operation>
Self & operator= (ThreadedMatrixDetail::NumaBCRSMatrixExpression< Arguments, Operation > const &e)
 NOT YET IMPLEMENTED Assigns the given Numa matrix expression.
template<class EntryB, class IndexB>
Self & operator+= (NumaBCRSMatrix< EntryB, IndexB > const &B)
 Adds a sparse matrix to this one.
template<class EntryB, class IndexB>
Self & operator-= (NumaBCRSMatrix< EntryB, IndexB > const &B)
 Subtracts a sparse matrix from this one.
template<class Factor>
Self & operator*= (Factor a)
 Multiplication with a "scalar".
Element access

Matrix entries can be accessed via iterators or by direct access. Iterators allow row-major scanning of existing matrix entries, with an iterator iterating over the rows and for each row an iterator iterating over the entries in that row.

Direct access is provided by the subscript operator [], which returns a row (reference), which in turn provides a subscript operator for selecting the column, e.g.,

A[i][j] = 42;

Note that the second (column) subscript has logarithmic complexity in the number of entries in the row.

iterator begin ()
 returns an iterator to the first row
const_iterator begin () const
iterator end ()
 returns an iterator to the first row
const_iterator end () const
row_type operator[] (Index r)
 Subscript operator allowing random access to rows.
const_row_type operator[] (Index r) const
Submatrix extraction
template<class RowIndices, class ColIndices>
Self operator() (RowIndices const &ri, ColIndices const &ci) const
General matrix information.
Index N () const
 The number of rows.
Index M () const
 The number of columns.
size_t nonzeroes () const
 Returns the number of structurally nonzero elements.
std::shared_ptr< NumaCRSPattern< Index > > getPattern () const
 Returns a pointer to the sparsity pattern.
Chunk & chunk (int i)
 Obtains a reference to the given chunk.
Chunk const & chunk (int i) const
bool exists (Index r, Index c) const
 returns true if (r,c) is structurally nonzero
field_type frobenius_norm () const
 Computes the Frobenius norm \( \|A\|_F = \sqrt{\mathrm{tr}(A^TA)} \).
field_type frobenius_norm2 () const
 Computes the square of the Frobenius norm \( \|A\|_F^2 = \mathrm{tr}(A^TA) \).
Matrix-vector operations
template<class X, class Y>
field_type mv (X const &x, Y &y) const
 Matrix-vector multiplication \( y \leftarrow Ax \) with computation of \( y^T x \) if A is square.
template<class X, class Y>
void mtv (X const &x, Y &y) const
 Matrix-vector multiplication \( y \leftarrow A^Tx \).
template<class X, class Y>
void mmv (X const &x, Y &y) const
 Matrix-vector multiplication \( y \leftarrow -Ax \).
template<class X, class Y>
field_type smv (field_type const &a, X const &x, Y &y) const
 Matrix-vector multiplication \( y \leftarrow aAx \).
template<class X, class Y>
void smtv (field_type const &a, X const &x, Y &y) const
 Matrix-vector multiplication \( y \leftarrow aA^Tx \).
template<class X, class Y>
field_type umv (X const &x, Y &y) const
 Matrix-vector multiplication \( y \leftarrow y + Ax \) and subsequent computation of \( y^T x \) if A is square.
template<class X, class Y>
void umtv (X const &x, Y &y) const
 Matrix-vector multiplication \( y \leftarrow y + A^Tx \).
template<class X, class Y>
field_type usmv (field_type const &a, X const &x, Y &y) const
 Matrix-vector multiplication \( y \leftarrow y + aAx \) and subsequent computation of \( y^T x \) if A is square.
template<class X, class Y>
void usmtv (field_type const &a, X const &x, Y &y) const
 Matrix-vector multiplication \( y \leftarrow y + aA^Tx \).

(Note that these are not member symbols.)

template<class IndexP, class EntryP, class IndexA, class EntryA>
auto conjugation (NumaBCRSMatrix< EntryP, IndexP > const &P, NumaBCRSMatrix< EntryA, IndexA > const &A, bool onlyLowerTriangle=false, bool createDiagonal=false)
 Creates the conjugation product \( P^T A P\).
template<class Target, class Source, class RowIndices, class ColIndices>
Target submatrix (Source const &A, RowIndices const &ri, ColIndices const &ci)
 extracts a sparse or dense submatrix of \( A \)
template<class EntryA, class EntryB, class IndexA, class IndexB>
auto operator* (NumaBCRSMatrix< EntryA, IndexA > const &A, NumaBCRSMatrix< EntryB, IndexB > const &B)
 Computes the matrix-matrix product \( (A,B) \mapsto AB \).
template<class Entry, class Index>
std::ostream & operator<< (std::ostream &out, NumaBCRSMatrix< Entry, Index > const &A)
 Writes a NumaBCRSMatrix to an output stream.
template<class SparseMatrix>
DynamicMatrix< typename SparseMatrix::block_type > full (SparseMatrix const &A)
 Converts a sparse NumaBCRSMatrix to a dense matrix.
template<class SparseMatrix, class RowRange, class ColRange>
DynamicMatrix< typename SparseMatrix::block_type > full (SparseMatrix const &A, RowRange const &rows, ColRange const &cols)
 Converts a subrange of a sparse matrix to a dense matrix.
template<class Entry, class Index, class Index2>
NumaBCRSMatrix< Entry, Index > operator+ (NumaBCRSMatrix< Entry, Index > const &A, NumaBCRSMatrix< Entry, Index2 > const &B)
 Matrix addition \( (A,B) \mapsto A+B \). The sparsity patterns of both matrices can be different. The size of the matrices have to be the same. Both must not have symmetric storage.
template<class Entry, class Index>
auto transpose (NumaBCRSMatrix< Entry, Index > const &A)
 Creates the transposed sparse matrix \( A^T \).
template<class Target, class Source, class RowIndices, class ColIndices>
Target eraseRowsNCols (Source const &A, RowIndices const &ri, ColIndices const &ci)
 "deletes" rows/columns by extracting a copy of the matrix keeping the non-deleted rows/columns.
template<class Target, class Source, class RowIndices>
Target eraseRows (Source const &A, RowIndices const &ri)
 "deletes" rows by extracting a copy of the matrix keeping only the non-deleted rows.
template<class Target, class Source, class ColIndices>
Target eraseCols (Source const &A, ColIndices const &ci)
 "deletes" columns by extracting a copy of the matrix keeping only the non-deleted columns.
template<class Source>
std::vector< size_t > nonZeroColumns (Source const &A)
 returns all indices of nonzero columns.
template<int row2, int col2, int row1, int col1, class Scalar, class Index>
NumaBCRSMatrix< Dune::FieldMatrix< Scalar, row2, col2 >, Index > reshapeBlocks (NumaBCRSMatrix< Dune::FieldMatrix< Scalar, row1, col1 >, Index > const &A)
 reshapes NumaBRCSMAtrix entry block structure
template<int blockrows, int blockcols, class Scalar, class Index>
NumaBCRSMatrix< Dune::FieldMatrix< Scalar, blockrows, blockcols >, Index > horzcat (NumaBCRSMatrix< Dune::FieldMatrix< Scalar, blockrows, blockcols >, Index > const &A, NumaBCRSMatrix< Dune::FieldMatrix< Scalar, blockrows, blockcols >, Index > const &B)
 concatenate two matrices horizontally
template<int blockrows, int blockcols, class Scalar, class Index>
NumaBCRSMatrix< Dune::FieldMatrix< Scalar, blockrows, blockcols >, Index > vertcat (NumaBCRSMatrix< Dune::FieldMatrix< Scalar, blockrows, blockcols >, Index > const &A, NumaBCRSMatrix< Dune::FieldMatrix< Scalar, blockrows, blockcols >, Index > const &B)
 concatenate two matrices vertically
template<int blockrows, int blockcols, class Index = size_t>
NumaBCRSMatrix< Dune::FieldMatrix< double, blockrows, blockcols >, Index > diagcat (NumaBCRSMatrix< Dune::FieldMatrix< double, blockrows, blockcols >, Index > const &A, NumaBCRSMatrix< Dune::FieldMatrix< double, blockrows, blockcols >, Index > const &B)
 concatenate two matrices diagonally, resulting matrix is zero on the off block-diagonal

Constructors

 NumaBCRSMatrix ()
 Constructs an empty 0x0 matrix.
 NumaBCRSMatrix (Self const &A)=default
 Copy constructor.
 NumaBCRSMatrix (Self &&A)=default
 Move constructor.
 NumaBCRSMatrix (NumaCRSPatternCreator< Index > const &creator, Entry const &init=Entry(0))
 Constructor creating a matrix from a given sparsity pattern creator.
 NumaBCRSMatrix (std::shared_ptr< NumaCRSPattern< Index > > const &pattern_, Entry const &init=Entry(0))
 Constructor creating a matrix from a given sparsity pattern.
template<class Expanded, class Condensed, class Matrix>
 NumaBCRSMatrix (Expanded const &eIndices, Condensed const &cIndices, Matrix const &mat)
 Deprecated. Use simpler version without cIndices instead.
template<class Expanded, class Matrix>
 NumaBCRSMatrix (Expanded const &eIndices, Matrix const &mat)
 Indexed submatrix constructor.
template<class Matrix>
 NumaBCRSMatrix (std::shared_ptr< NumaCRSPattern< Index > > const &pattern_, Matrix const &matrix, bool isSymmetric, bool isTransposed)
 Constructor copying a given matrix.
template<class OtherEntry>
 NumaBCRSMatrix (NumaBCRSMatrix< OtherEntry, Index > const &matrix)
 Constructor copying a given matrix.
template<class Matrix>
 NumaBCRSMatrix (Matrix const &matrix, bool isSymmetric, bool isTransposed=false, bool symmetric=false)
 Constructor.
 NumaBCRSMatrix (NumaBCRSMatrix< Entry, Index > const &matrix, bool isSymmetric, bool isTransposed=false, bool symmetric=false)
 Constructor.
template<class TripletIndex, class TripletScalar>
 NumaBCRSMatrix (std::vector< TripletIndex > const &ridx, std::vector< TripletIndex > const &cidx, TripletIndex nRows, TripletIndex nCols, std::vector< TripletScalar > const &entries)
 Constructor.

Entering data

template<class LMIterator>
void scatter (LMIterator first, LMIterator last)
 Scatters given sub-matrices into the matrix by adding up their entries.
template<class RowIndices, class ColIndices, class BinaryOp = std::plus<Entry>>
void scatter (DynamicMatrix< Entry > const &B, RowIndices const &rows, ColIndices const &cols, BinaryOp const &op=BinaryOp())
 Scatters given submarix into the matrix.

Detailed Description

template<class Entry, class Index = size_t>
class Kaskade::NumaBCRSMatrix< Entry, Index >

A NUMA-aware compressed row storage matrix adhering mostly to the Dune ISTL interface (to complete...)

This class distributes the matrix rows block-wise across available NUMA nodes to exploit the higher memory bandwidth in parallelized matrix-vector products and similar operations.

As the distribution of matrix entries to the NUMA nodes is optimized for equidistribution of storage size and computational effort in matrix vector products, transpose times vector multiplications are much slower than plain matrix-vector multiplications (roughly factor 6).

If the matrix is a priori specified as being symmetric, only the lower triangular elements are stored and can be accessed. Nevertheless, all linear algebra operations (i.e., matrix vector products) act on the complete symmetric matrix. Note that symmetric storage incurs a significant performance penalty for matrix-vector products (roughly factor 3), and should only be used if those operations are rare. In contrast, transpose times vector multiplications do not suffer.

For creating a NumaBCRSMatrix, a sparsity pattern (NumaCRSPattern) has to be provided. This in turn is created using a creator object (NumaCRSPatternCreator). This multi-stage creation allows efficient creation while avoiding stateful interfaces (incompletely created objects). The matrix creation can be done as follows:

// define the pattern creator for a 9x9 matrix
// add a diagonal entry
creator.addElement(2,2);
// create the matrix
// fill the entry
matrix[2][2] = 1.0;
NumaBCRSMatrix()
Constructs an empty 0x0 matrix.
A NUMA-aware creator for matrix sparsity patterns.

Concurrent calls to one NumaBCRSMatrix object are not safe.

Template Parameters
Entrythe type of matrix elements (in general Dune::FieldMatrix<double,n,m>)
Indexintegral type for row/column indices (usually int, long, or size_t), defaults to size_t

Definition at line 920 of file threadedMatrix.hh.

Member Typedef Documentation

◆ block_type

template<class Entry, class Index = size_t>
using Kaskade::NumaBCRSMatrix< Entry, Index >::block_type = Entry

Definition at line 928 of file threadedMatrix.hh.

◆ ColIterator

template<class Entry, class Index = size_t>
using Kaskade::NumaBCRSMatrix< Entry, Index >::ColIterator = typename iterator::Iterator

column iterator stepping through the entries of a row

Definition at line 943 of file threadedMatrix.hh.

◆ const_iterator

template<class Entry, class Index = size_t>
typedef ThreadedMatrixDetail::NumaBCRSMatrixConstIterator<Entry,Index> Kaskade::NumaBCRSMatrix< Entry, Index >::const_iterator

Definition at line 936 of file threadedMatrix.hh.

◆ const_row_type

template<class Entry, class Index = size_t>
typedef const_iterator Kaskade::NumaBCRSMatrix< Entry, Index >::const_row_type

Definition at line 938 of file threadedMatrix.hh.

◆ ConstColIterator

template<class Entry, class Index = size_t>
using Kaskade::NumaBCRSMatrix< Entry, Index >::ConstColIterator = typename iterator::ConstIterator

column iterator stepping through the const entries of a row

Definition at line 946 of file threadedMatrix.hh.

◆ ConstRowIterator

template<class Entry, class Index = size_t>
typedef iterator Kaskade::NumaBCRSMatrix< Entry, Index >::ConstRowIterator

Definition at line 940 of file threadedMatrix.hh.

◆ field_type

template<class Entry, class Index = size_t>
using Kaskade::NumaBCRSMatrix< Entry, Index >::field_type = Scalar

Definition at line 927 of file threadedMatrix.hh.

◆ iterator

template<class Entry, class Index = size_t>
typedef ThreadedMatrixDetail::NumaBCRSMatrixIterator<Entry,Index> Kaskade::NumaBCRSMatrix< Entry, Index >::iterator

iterator type stepping through the rows

Definition at line 935 of file threadedMatrix.hh.

◆ row_type

template<class Entry, class Index = size_t>
typedef iterator Kaskade::NumaBCRSMatrix< Entry, Index >::row_type

Definition at line 937 of file threadedMatrix.hh.

◆ Scalar

template<class Entry, class Index = size_t>
typedef ScalarType<Entry> Kaskade::NumaBCRSMatrix< Entry, Index >::Scalar

Definition at line 926 of file threadedMatrix.hh.

◆ size_type

template<class Entry, class Index = size_t>
using Kaskade::NumaBCRSMatrix< Entry, Index >::size_type = Index

Definition at line 930 of file threadedMatrix.hh.

◆ value_type

template<class Entry, class Index = size_t>
using Kaskade::NumaBCRSMatrix< Entry, Index >::value_type = Entry

Definition at line 929 of file threadedMatrix.hh.

Constructor & Destructor Documentation

◆ NumaBCRSMatrix() [1/12]

template<class Entry, class Index = size_t>
Kaskade::NumaBCRSMatrix< Entry, Index >::NumaBCRSMatrix ( )
inline

Constructs an empty 0x0 matrix.

Definition at line 957 of file threadedMatrix.hh.

◆ NumaBCRSMatrix() [2/12]

template<class Entry, class Index = size_t>
Kaskade::NumaBCRSMatrix< Entry, Index >::NumaBCRSMatrix ( Self const & A)
default

Copy constructor.

◆ NumaBCRSMatrix() [3/12]

template<class Entry, class Index = size_t>
Kaskade::NumaBCRSMatrix< Entry, Index >::NumaBCRSMatrix ( Self && A)
default

Move constructor.

◆ NumaBCRSMatrix() [4/12]

template<class Entry, class Index = size_t>
Kaskade::NumaBCRSMatrix< Entry, Index >::NumaBCRSMatrix ( NumaCRSPatternCreator< Index > const & creator,
Entry const & init = Entry(0) )
inline

Constructor creating a matrix from a given sparsity pattern creator.

This is a convenience constructor that creates a new pattern under the hood.

Parameters
creatorthe sparsity pattern creatorof the matrix to be constructed
initinitialization value for the entries

Definition at line 979 of file threadedMatrix.hh.

◆ NumaBCRSMatrix() [5/12]

template<class Entry, class Index = size_t>
Kaskade::NumaBCRSMatrix< Entry, Index >::NumaBCRSMatrix ( std::shared_ptr< NumaCRSPattern< Index > > const & pattern_,
Entry const & init = Entry(0) )
inline

Constructor creating a matrix from a given sparsity pattern.

Parameters
patternthe sparsity pattern of the matrix to be constructed
initinitialization value for the entries

Definition at line 989 of file threadedMatrix.hh.

◆ NumaBCRSMatrix() [6/12]

template<class Entry, class Index = size_t>
template<class Expanded, class Condensed, class Matrix>
Kaskade::NumaBCRSMatrix< Entry, Index >::NumaBCRSMatrix ( Expanded const & eIndices,
Condensed const & cIndices,
Matrix const & mat )
inline

Deprecated. Use simpler version without cIndices instead.

This constructor will be made private after 2022-12.

Definition at line 1009 of file threadedMatrix.hh.

◆ NumaBCRSMatrix() [7/12]

template<class Entry, class Index = size_t>
template<class Expanded, class Matrix>
Kaskade::NumaBCRSMatrix< Entry, Index >::NumaBCRSMatrix ( Expanded const & eIndices,
Matrix const & mat )
inline

Indexed submatrix constructor.

This works like Matlab A(idx,idx), where idx is given by eIndices. It creates a \( n \times n \) matrix \( a \) from the \( N \times N\) matrix \( A \), where \( a_{ij} = A_{e_ie_j} \). Of course, \( n \le N \) has to hold.

Template Parameters
Expandedan array type with value type convertible to Index
Parameters
eIndicessorted global array of size \( n \) of expanded indices
mata square matrix with BCRSMatrix interface

Definition at line 1048 of file threadedMatrix.hh.

◆ NumaBCRSMatrix() [8/12]

template<class Entry, class Index = size_t>
template<class Matrix>
Kaskade::NumaBCRSMatrix< Entry, Index >::NumaBCRSMatrix ( std::shared_ptr< NumaCRSPattern< Index > > const & pattern_,
Matrix const & matrix,
bool isSymmetric,
bool isTransposed )
inline

Constructor copying a given matrix.

Template Parameters
Matrixthe type of the supplied matrix to copy (usually a Dune::BCRSMatrix or a NumaBCRSMatrix with different scalar type).
Parameters
patternthe sparsity pattern to use
matrixthe matrix to be copied (shall have the given sparsity pattern)
isSymmetricwhether the supplied matrix is symmetric (then only its lower triangular part is accessed)
isTransposedwhether the supplied matrix is transposed

Definition at line 1065 of file threadedMatrix.hh.

◆ NumaBCRSMatrix() [9/12]

template<class Entry, class Index = size_t>
template<class OtherEntry>
Kaskade::NumaBCRSMatrix< Entry, Index >::NumaBCRSMatrix ( NumaBCRSMatrix< OtherEntry, Index > const & matrix)
inline

Constructor copying a given matrix.

Template Parameters
OtherEntryThe entry type of the matrix to be copied. The entries shall have the same dimension (but possibly different scalar type).
Parameters
matrixthe matrix to be copied (shall conform to the Dune::BCRSMatrix interface)

Use this for switching between different entry types (e.g. float vs double). The sparsity pattern is shared between both matrices.

The number of chunks created is the number of NUMA nodes as reported by NumaThreadPool.

Definition at line 1088 of file threadedMatrix.hh.

◆ NumaBCRSMatrix() [10/12]

template<class Entry, class Index = size_t>
template<class Matrix>
Kaskade::NumaBCRSMatrix< Entry, Index >::NumaBCRSMatrix ( Matrix const & matrix,
bool isSymmetric,
bool isTransposed = false,
bool symmetric = false )
inline

Constructor.

Template Parameters
Matrixthe type of the supplied matrix to copy (shall conform to the Dune::BCRSMatrix interface)
Parameters
matrixthe matrix to be copied
isSymmetricwhether the supplied matrix is symmetric (then only its lower triangular part is accessed, requires square matrix and entries)
isTransposedwhether the supplied matrix is transposed
symmetricwhether only the lower triangular part should be stored (requires a square matrix and entries)

This is a convenience constructor that creates a new sparsity pattern from scratch. The number of chunks created is the number of NUMA nodes as reported by NumaThreadPool.

Note that !isSymmetric && symmetric is highly questionable and hence not allowed.

Definition at line 1110 of file threadedMatrix.hh.

◆ NumaBCRSMatrix() [11/12]

template<class Entry, class Index = size_t>
Kaskade::NumaBCRSMatrix< Entry, Index >::NumaBCRSMatrix ( NumaBCRSMatrix< Entry, Index > const & matrix,
bool isSymmetric,
bool isTransposed = false,
bool symmetric = false )
inline

Constructor.

Parameters
matrixthe matrix to be copied (shall conform to the Dune::BCRSMatrix interface)
isSymmetricwhether the supplied matrix is symmetric (then only its lower triangular part is accessed, requires square matrix and entries)
isTransposedwhether the supplied matrix is transposed
symmetricwhether only the lower triangular part should be stored (requires a square matrix and entries)

This is a convenience constructor that creates a new sparsity pattern from scratch. Use it for switching between symmetric/normal storage patterns and for creating transposed matrices.

The number of chunks created is the number of NUMA nodes as reported by NumaThreadPool.

Note that !isSymmetric && symmetric is highly questionable and hence not allowed.

Definition at line 1141 of file threadedMatrix.hh.

◆ NumaBCRSMatrix() [12/12]

template<class Entry, class Index = size_t>
template<class TripletIndex, class TripletScalar>
Kaskade::NumaBCRSMatrix< Entry, Index >::NumaBCRSMatrix ( std::vector< TripletIndex > const & ridx,
std::vector< TripletIndex > const & cidx,
TripletIndex nRows,
TripletIndex nCols,
std::vector< TripletScalar > const & entries )
inline

Constructor.

Creates a NumaBCRSMatrix from explicitly given row and column indices and scalar entries. If we create a matrix with non-scalar entries, the provided scalar entries are assembled into the sub-entries of the block-entries.

Parameters
ridxrow indices
cidxcolumn indices
nRowsnumber of (block) rows of the constructed matrix
nColsnumber of (block) columns of the constructed matrix
entriesscalar matrix entries

Definition at line 1167 of file threadedMatrix.hh.

Member Function Documentation

◆ begin() [1/2]

◆ begin() [2/2]

template<class Entry, class Index = size_t>
const_iterator Kaskade::NumaBCRSMatrix< Entry, Index >::begin ( ) const
inline

Definition at line 1343 of file threadedMatrix.hh.

◆ chunk() [1/2]

template<class Entry, class Index = size_t>
Chunk & Kaskade::NumaBCRSMatrix< Entry, Index >::chunk ( int i)
inline

◆ chunk() [2/2]

template<class Entry, class Index = size_t>
Chunk const & Kaskade::NumaBCRSMatrix< Entry, Index >::chunk ( int i) const
inline

Definition at line 1417 of file threadedMatrix.hh.

◆ end() [1/2]

◆ end() [2/2]

template<class Entry, class Index = size_t>
const_iterator Kaskade::NumaBCRSMatrix< Entry, Index >::end ( ) const
inline

Definition at line 1349 of file threadedMatrix.hh.

◆ exists()

template<class Entry, class Index = size_t>
bool Kaskade::NumaBCRSMatrix< Entry, Index >::exists ( Index r,
Index c ) const
inline

returns true if (r,c) is structurally nonzero

Definition at line 1425 of file threadedMatrix.hh.

◆ frobenius_norm()

template<class Entry, class Index = size_t>
field_type Kaskade::NumaBCRSMatrix< Entry, Index >::frobenius_norm ( ) const
inline

Computes the Frobenius norm \( \|A\|_F = \sqrt{\mathrm{tr}(A^TA)} \).

Todo
parallelize

Definition at line 1434 of file threadedMatrix.hh.

◆ frobenius_norm2()

template<class Entry, class Index = size_t>
field_type Kaskade::NumaBCRSMatrix< Entry, Index >::frobenius_norm2 ( ) const
inline

Computes the square of the Frobenius norm \( \|A\|_F^2 = \mathrm{tr}(A^TA) \).

Todo
parallelize

Definition at line 1443 of file threadedMatrix.hh.

Referenced by Kaskade::NumaBCRSMatrix< Dune::FieldMatrix< Scalar, 1, 1 >, Index >::frobenius_norm().

◆ getPattern()

template<class Entry, class Index = size_t>
std::shared_ptr< NumaCRSPattern< Index > > Kaskade::NumaBCRSMatrix< Entry, Index >::getPattern ( ) const
inline

◆ M()

◆ mmv()

template<class Entry, class Index = size_t>
template<class X, class Y>
void Kaskade::NumaBCRSMatrix< Entry, Index >::mmv ( X const & x,
Y & y ) const
inline

Matrix-vector multiplication \( y \leftarrow -Ax \).

Definition at line 1482 of file threadedMatrix.hh.

◆ mtv()

template<class Entry, class Index = size_t>
template<class X, class Y>
void Kaskade::NumaBCRSMatrix< Entry, Index >::mtv ( X const & x,
Y & y ) const
inline

Matrix-vector multiplication \( y \leftarrow A^Tx \).

Parameters
xa vector of size M()
ya vector of size N()

Note that transpose times vector operations are quite expensive (a factor of 6 slower than matrix-vector operations) and should be avoided. If you need transpose times vector products, consider storing a transposed matrix directly.

Definition at line 1476 of file threadedMatrix.hh.

◆ mv()

template<class Entry, class Index = size_t>
template<class X, class Y>
field_type Kaskade::NumaBCRSMatrix< Entry, Index >::mv ( X const & x,
Y & y ) const
inline

Matrix-vector multiplication \( y \leftarrow Ax \) with computation of \( y^T x \) if A is square.

Parameters
xa vector of size M()
ya vector of size N()

Definition at line 1465 of file threadedMatrix.hh.

◆ N()

◆ nonzeroes()

template<class Entry, class Index = size_t>
size_t Kaskade::NumaBCRSMatrix< Entry, Index >::nonzeroes ( ) const
inline

Returns the number of structurally nonzero elements.

In symmetric storage, the number of actually stored entries is smaller, usually by a factor of almost two.

Definition at line 1396 of file threadedMatrix.hh.

◆ operator()()

template<class Entry, class Index = size_t>
template<class RowIndices, class ColIndices>
Self Kaskade::NumaBCRSMatrix< Entry, Index >::operator() ( RowIndices const & ri,
ColIndices const & ci ) const
inline

Definition at line 1366 of file threadedMatrix.hh.

◆ operator*=()

template<class Entry, class Index = size_t>
template<class Factor>
Self & Kaskade::NumaBCRSMatrix< Entry, Index >::operator*= ( Factor a)
inline

Multiplication with a "scalar".

The factor a can be a scalar or a quadratic matrix of compatible static size.

Definition at line 1309 of file threadedMatrix.hh.

◆ operator+=()

template<class Entry, class Index = size_t>
template<class EntryB, class IndexB>
Self & Kaskade::NumaBCRSMatrix< Entry, Index >::operator+= ( NumaBCRSMatrix< EntryB, IndexB > const & B)
inline

Adds a sparse matrix to this one.

The sparsity pattern of B must be a subset of our sparsity pattern.

Definition at line 1285 of file threadedMatrix.hh.

◆ operator-=()

template<class Entry, class Index = size_t>
template<class EntryB, class IndexB>
Self & Kaskade::NumaBCRSMatrix< Entry, Index >::operator-= ( NumaBCRSMatrix< EntryB, IndexB > const & B)
inline

Subtracts a sparse matrix from this one.

The sparsity pattern of B must be a subset of our sparsity pattern.

Definition at line 1297 of file threadedMatrix.hh.

◆ operator=() [1/6]

template<class Entry, class Index = size_t>
Self & Kaskade::NumaBCRSMatrix< Entry, Index >::operator= ( Entry const & a)
inline

Assigns the given value to each entry.

Definition at line 1245 of file threadedMatrix.hh.

◆ operator=() [2/6]

template<class Entry, class Index = size_t>
template<class EntryA, class IndexA, typename = std::enable_if_t<std::is_convertible_v<EntryA,Entry>>>
Self & Kaskade::NumaBCRSMatrix< Entry, Index >::operator= ( NumaBCRSMatrix< EntryA, IndexA > const & A)
inline

Copy assignment from another NumaBCRSMatrix, with compatible entry and index types.

The matrix becomes a copy of the given one, no matter what its previous structure or size was. The sparsity pattern is shared between both matrices if both index types agree.

Definition at line 1224 of file threadedMatrix.hh.

◆ operator=() [3/6]

template<class Entry, class Index = size_t>
Self & Kaskade::NumaBCRSMatrix< Entry, Index >::operator= ( Self && mat)
default

Move assignment.

The matrices need not be of same size or sparsity pattern.

◆ operator=() [4/6]

template<class Entry, class Index = size_t>
Self & Kaskade::NumaBCRSMatrix< Entry, Index >::operator= ( Self const & mat)
default

Copy assignment.

The matrix becomes a copy of the given one, no matter what its previous structure or size was. The sparsity pattern is shared between both matrices.

◆ operator=() [5/6]

template<class Entry, class Index = size_t>
template<class Arguments, class Operation>
Self & Kaskade::NumaBCRSMatrix< Entry, Index >::operator= ( ThreadedMatrixDetail::NumaBCRSMatrixExpression< Arguments, Operation > const & e)
inline

NOT YET IMPLEMENTED Assigns the given Numa matrix expression.

Definition at line 1268 of file threadedMatrix.hh.

◆ operator=() [6/6]

template<class Entry, class Index = size_t>
Self & Kaskade::NumaBCRSMatrix< Entry, Index >::operator= ( typename Entry::field_type const & a)
inline

Assigns the given scalar value to each entry.

Definition at line 1259 of file threadedMatrix.hh.

◆ operator[]() [1/2]

template<class Entry, class Index = size_t>
row_type Kaskade::NumaBCRSMatrix< Entry, Index >::operator[] ( Index r)
inline

Subscript operator allowing random access to rows.

This has constant complexity.

Definition at line 1356 of file threadedMatrix.hh.

◆ operator[]() [2/2]

template<class Entry, class Index = size_t>
const_row_type Kaskade::NumaBCRSMatrix< Entry, Index >::operator[] ( Index r) const
inline

Definition at line 1357 of file threadedMatrix.hh.

◆ scatter()

template<class Entry, class Index = size_t>
template<class LMIterator>
void Kaskade::NumaBCRSMatrix< Entry, Index >::scatter ( LMIterator first,
LMIterator last )
inline

Scatters given sub-matrices into the matrix by adding up their entries.

Template Parameters
LMIteratora forward iterator with value type of LocalMatrix (requirements see below).

Local matrices \( a \) in the range [first,last[ are scattered into the global matrix as follows:

\[ A_{I_k,J_l} \leftarrow A_{I_k,J_l} + a_{i_k,j_l} \quad 0\le k < r, 0\le l < c \]

The possibly different ordering of entries in the local and global matrices is taken into account by the indirect indexing via \( (I_k,J_k) \) for the global indices and \( (i_k,j_l) \) for the local indices.

Objects a of LocalMatrix type have to provide the following access:

  • a(ik,jl) is the value of the local matrix entry \( a_{i_k,j_l} \)
  • ridx() returns a range of \( (I_k,i_k) \) pairs (of type std::pair), sorted ascendingly according to \( I_k \)
  • cidx() returns a range of \( (J_l,j_l) \) pairs (of type std::pair), sorted ascendingly according to \( J_l \)

In case LocalMatrix::lumped is true, then ridx()==cidx() shall hold and only the diagonal of \( a \) is to be scattered.

In contrast to the other methods, this method can (and should) be called concurrently from different threads.

Definition at line 1561 of file threadedMatrix.hh.

◆ smtv()

template<class Entry, class Index = size_t>
template<class X, class Y>
void Kaskade::NumaBCRSMatrix< Entry, Index >::smtv ( field_type const & a,
X const & x,
Y & y ) const
inline

Matrix-vector multiplication \( y \leftarrow aA^Tx \).

Note that transpose times vector operations are quite expensive (a factor of 6 slower than matrix-vector operations) and should be avoided. If you need transpose times vector products, consider storing a transposed matrix directly.

Definition at line 1497 of file threadedMatrix.hh.

◆ smv()

template<class Entry, class Index = size_t>
template<class X, class Y>
field_type Kaskade::NumaBCRSMatrix< Entry, Index >::smv ( field_type const & a,
X const & x,
Y & y ) const
inline

Matrix-vector multiplication \( y \leftarrow aAx \).

Definition at line 1488 of file threadedMatrix.hh.

◆ umtv()

template<class Entry, class Index = size_t>
template<class X, class Y>
void Kaskade::NumaBCRSMatrix< Entry, Index >::umtv ( X const & x,
Y & y ) const
inline

Matrix-vector multiplication \( y \leftarrow y + A^Tx \).

Note that transpose times vector operations are quite expensive (a factor of 6 slower than matrix-vector operations) and should be avoided. If you need transpose times vector products, consider storing a transposed matrix directly.

Definition at line 1512 of file threadedMatrix.hh.

◆ umv()

template<class Entry, class Index = size_t>
template<class X, class Y>
field_type Kaskade::NumaBCRSMatrix< Entry, Index >::umv ( X const & x,
Y & y ) const
inline

Matrix-vector multiplication \( y \leftarrow y + Ax \) and subsequent computation of \( y^T x \) if A is square.

Definition at line 1503 of file threadedMatrix.hh.

◆ usmtv()

template<class Entry, class Index = size_t>
template<class X, class Y>
void Kaskade::NumaBCRSMatrix< Entry, Index >::usmtv ( field_type const & a,
X const & x,
Y & y ) const
inline

Matrix-vector multiplication \( y \leftarrow y + aA^Tx \).

Note that transpose times vector operations are quite expensive (a factor of 6 slower than matrix-vector operations) and should be avoided. If you need transpose times vector products, consider storing a transposed matrix directly.

Definition at line 1527 of file threadedMatrix.hh.

◆ usmv()

template<class Entry, class Index = size_t>
template<class X, class Y>
field_type Kaskade::NumaBCRSMatrix< Entry, Index >::usmv ( field_type const & a,
X const & x,
Y & y ) const
inline

Matrix-vector multiplication \( y \leftarrow y + aAx \) and subsequent computation of \( y^T x \) if A is square.

Definition at line 1518 of file threadedMatrix.hh.

◆ scatter()

template<class Entry, class Index = size_t>
template<class RowIndices, class ColIndices, class BinaryOp = std::plus<Entry>>
void scatter ( DynamicMatrix< Entry > const & B,
RowIndices const & rows,
ColIndices const & cols,
BinaryOp const & op = BinaryOp() )
related

Scatters given submarix into the matrix.

This performs \( A_{r_i c_j} = A_{r_i c_j} \circ B_{ij} \) for \( i,j \) indexing the provided matrix \( B \). Here, \( \circ \) denotes the given binary operation, which defaults to addition (the classical scatter operation).

Template Parameters
RowIndicesan STL sequence type with value_type convertible to Index
ColIndicesan STL sequence type with value_type convertible to Index
BinaryOpa binary callable type with op(Entry const, Entry const) convertible to Entry.
Parameters
Bthe given matrix data
rowsthe target row indices \( r_i \) for ourselves
colsthe target col indices \( c_i \) for ourselves
opan arbitrary binary operation on Entry, defaults to plus

Note that all entries \( A_{r_ic_i} \) must exist in this matrix.

As long as the row or column indices do not overlap, this method can safely be called concurrently.

Definition at line 1592 of file threadedMatrix.hh.


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