strumpack::structured::StructuredMatrix< scalar_t > Class Template Referenceabstract

Class to represent a structured matrix. This is the abstract base class for several types of structured matrices. More...

#include <StructuredMatrix.hpp>

Inheritance diagram for strumpack::structured::StructuredMatrix< scalar_t >:

Public Member Functions

virtual ~StructuredMatrix ()=default
 
virtual std::size_t rows () const =0
 
virtual std::size_t cols () const =0
 
virtual std::size_t memory () const =0
 
virtual std::size_t nonzeros () const =0
 
virtual std::size_t rank () const =0
 
virtual std::size_t local_rows () const
 
virtual std::size_t begin_row () const
 
virtual std::size_t end_row () const
 
virtual const std::vector< int > & dist () const
 
virtual const std::vector< int > & rdist () const
 
virtual const std::vector< int > & cdist () const
 
virtual void mult (Trans op, const DenseMatrix< scalar_t > &x, DenseMatrix< scalar_t > &y) const
 
void mult (Trans op, int m, const scalar_t *x, int ldx, scalar_t *y, int ldy) const
 
virtual void mult (Trans op, const DistributedMatrix< scalar_t > &x, DistributedMatrix< scalar_t > &y) const
 
virtual void factor ()
 
virtual void solve (DenseMatrix< scalar_t > &b) const
 
virtual void solve (int nrhs, scalar_t *b, int ldb) const
 
virtual void solve (DistributedMatrix< scalar_t > &b) const
 
virtual void shift (scalar_t s)
 

Detailed Description

template<typename scalar_t>
class strumpack::structured::StructuredMatrix< scalar_t >

Class to represent a structured matrix. This is the abstract base class for several types of structured matrices.

Template Parameters
scalar_tCan be float, double, std::complex<float> or std::complex<double>. Some formats do not support all precisions, see the table below.

For construction, use one of:

However, not all formats support all construction methods, matrix operations, or precisions (s: float, d: double, c: std::complex<float>, z: std::complex<double>):

parallel? construct from .. operation precision
seq MPI DENSE ELEM MF PMF NN mult factor solve shift s d c z
BLR X X X X X X X ? X X X X
HSS X X X X X X X X X X X X X
HODLR X X X X X X X X ? X X
HODBF X X X X X X X X ? X X
BUTTERFLY X X X X X X X X
LR X X X X X X X X
LOSSY X X X X X X
LOSSLESS X X X X X X
See also
HSS::HSSMatrix, BLR::BLRMatrix, HODLR::HODLRMatrix, HODLR::ButterflyMatrix, ...

Constructor & Destructor Documentation

◆ ~StructuredMatrix()

template<typename scalar_t >
virtual strumpack::structured::StructuredMatrix< scalar_t >::~StructuredMatrix ( )
virtualdefault

Virtual destructor.

Member Function Documentation

◆ begin_row()

template<typename scalar_t >
virtual std::size_t strumpack::structured::StructuredMatrix< scalar_t >::begin_row ( ) const
inlinevirtual

For a distributed matrix, which uses a block row distribution, this gives the first rows stored on this process.

Returns
first rows, should be dist()[p] for rank p

Reimplemented in strumpack::HODLR::HODLRMatrix< scalar_t >, and strumpack::HODLR::ButterflyMatrix< scalar_t >.

◆ cdist()

template<typename scalar_t >
virtual const std::vector<int>& strumpack::structured::StructuredMatrix< scalar_t >::cdist ( ) const
inlinevirtual

For a distributed rectangular matrix, return the 1D block columns distribution.

Returns
vector with P+1 elements, process with rank p will own columns [cdist()[p],cdist()[p+1])

Reimplemented in strumpack::HODLR::ButterflyMatrix< scalar_t >.

◆ cols()

◆ dist()

template<typename scalar_t >
virtual const std::vector<int>& strumpack::structured::StructuredMatrix< scalar_t >::dist ( ) const
inlinevirtual

For a distributed matrix, return the 1D block row distribution over processes. This is for square matrices, for rectagular use rdist for the rows and cdist for the columns.

Returns
vector with P+1 elements, process with rank p will own rows [dist()[p],dist()[p+1])

Reimplemented in strumpack::HODLR::HODLRMatrix< scalar_t >.

◆ end_row()

template<typename scalar_t >
virtual std::size_t strumpack::structured::StructuredMatrix< scalar_t >::end_row ( ) const
inlinevirtual

For a distributed matrix, which uses a block row distribution, this gives the final row (+1) stored on this process.

Returns
last row + 1, should be dist()[p+1] for rank p

Reimplemented in strumpack::HODLR::HODLRMatrix< scalar_t >, and strumpack::HODLR::ButterflyMatrix< scalar_t >.

◆ factor()

template<typename scalar_t >
virtual void strumpack::structured::StructuredMatrix< scalar_t >::factor ( )
virtual

Compute a factorization (or the inverse) of this matrix, to be used later for solving linear systems. The actual type of factorization depends on the StructuredMatrix::Type of this matrix.

Reimplemented in strumpack::HSS::HSSMatrixMPI< scalar_t >, strumpack::HSS::HSSMatrix< scalar_t >, and strumpack::HODLR::HODLRMatrix< scalar_t >.

◆ local_rows()

template<typename scalar_t >
virtual std::size_t strumpack::structured::StructuredMatrix< scalar_t >::local_rows ( ) const
inlinevirtual

For a distributed matrix, which uses a block row distribution, this gives the number of rows stored on this process.

Returns
local rows, should be dist()[p+1]-dist()[p] for rank p

Reimplemented in strumpack::HODLR::HODLRMatrix< scalar_t >, and strumpack::HODLR::ButterflyMatrix< scalar_t >.

◆ memory()

template<typename scalar_t >
virtual std::size_t strumpack::structured::StructuredMatrix< scalar_t >::memory ( ) const
pure virtual

◆ mult() [1/3]

template<typename scalar_t >
virtual void strumpack::structured::StructuredMatrix< scalar_t >::mult ( Trans  op,
const DenseMatrix< scalar_t > &  x,
DenseMatrix< scalar_t > &  y 
) const
virtual

Multiply the StructuredMatrix (A) with a dense matrix: y = op(A)*x.

Parameters
optake transpose/conjugate or not
xmatrix, x.rows() == op(A).cols()
ymatrix, y.cols() == x.cols(), y.rows() == A.rows()

Reimplemented in strumpack::HSS::HSSMatrix< scalar_t >, strumpack::HODLR::HODLRMatrix< scalar_t >, strumpack::HODLR::ButterflyMatrix< scalar_t >, and strumpack::BLR::BLRMatrix< scalar_t >.

◆ mult() [2/3]

template<typename scalar_t >
virtual void strumpack::structured::StructuredMatrix< scalar_t >::mult ( Trans  op,
const DistributedMatrix< scalar_t > &  x,
DistributedMatrix< scalar_t > &  y 
) const
virtual

Multiply the StructuredMatrix (A) with a dense matrix: y = op(A)*x. x and y are 2d block cyclic.

Parameters
optake transpose/conjugate or not
xmatrix, x.rows() == op(A).cols()
ymatrix, y.cols() == x.cols(), y.rows() == A.rows()

Reimplemented in strumpack::HSS::HSSMatrixMPI< scalar_t >, strumpack::HODLR::HODLRMatrix< scalar_t >, and strumpack::HODLR::ButterflyMatrix< scalar_t >.

◆ mult() [3/3]

template<typename scalar_t >
void strumpack::structured::StructuredMatrix< scalar_t >::mult ( Trans  op,
int  m,
const scalar_t *  x,
int  ldx,
scalar_t *  y,
int  ldy 
) const

Multiply the StructuredMatrix (A) with a dense matrix: y = op(A)*x.

Parameters
optake transpose/conjugate or not
mcolumns in x and y
xmatrix, x should have rows == op(A).cols()
ldxleading dimension of x
ymatrix, y should have cols == x.cols(), and rows == A.rows()
ldyleading dimension of y

◆ nonzeros()

template<typename scalar_t >
virtual std::size_t strumpack::structured::StructuredMatrix< scalar_t >::nonzeros ( ) const
pure virtual

◆ rank()

template<typename scalar_t >
virtual std::size_t strumpack::structured::StructuredMatrix< scalar_t >::rank ( ) const
pure virtual

◆ rdist()

template<typename scalar_t >
virtual const std::vector<int>& strumpack::structured::StructuredMatrix< scalar_t >::rdist ( ) const
inlinevirtual

For a distributed rectangular matrix, return the 1D block row distribution.

Returns
vector with P+1 elements, process with rank p will own rows [cdist()[p],cdist()[p+1])

Reimplemented in strumpack::HODLR::ButterflyMatrix< scalar_t >.

◆ rows()

◆ shift()

template<typename scalar_t >
virtual void strumpack::structured::StructuredMatrix< scalar_t >::shift ( scalar_t  s)
virtual

Apply a shift to the diagonal of this matrix. Ie, this += s*I, with I the identity matrix. If this is called after calling factor, then the factors are not updated. To solve a linear system with the shifted matrix, you need to call factor again.

Parameters
sShift to be applied to the diagonal.

Reimplemented in strumpack::HSS::HSSMatrixBase< scalar_t >, strumpack::HSS::HSSMatrixMPI< scalar_t >, and strumpack::HSS::HSSMatrix< scalar_t >.

◆ solve() [1/3]

template<typename scalar_t >
virtual void strumpack::structured::StructuredMatrix< scalar_t >::solve ( DenseMatrix< scalar_t > &  b) const
virtual

Solve a linear system A*x=b, with this StructuredMatrix (A). This solve is done in-place.

Parameters
bright-hand side, b.rows() == A.cols(), will be overwritten with the solution x.

Reimplemented in strumpack::HSS::HSSMatrix< scalar_t >, and strumpack::HODLR::HODLRMatrix< scalar_t >.

◆ solve() [2/3]

template<typename scalar_t >
virtual void strumpack::structured::StructuredMatrix< scalar_t >::solve ( DistributedMatrix< scalar_t > &  b) const
virtual

Solve a linear system A*x=b, with this StructuredMatrix (A). This solve is done in-place.

Parameters
bright-hand side, b.rows() == A.cols(), will be overwritten with the solution x.

Reimplemented in strumpack::HSS::HSSMatrixMPI< scalar_t >, and strumpack::HODLR::HODLRMatrix< scalar_t >.

◆ solve() [3/3]

template<typename scalar_t >
virtual void strumpack::structured::StructuredMatrix< scalar_t >::solve ( int  nrhs,
scalar_t *  b,
int  ldb 
) const
inlinevirtual

Solve a linear system A*x=b, with this StructuredMatrix (A). This solve is done in-place.

Parameters
nrhsnumber of right-hand sides
bright-hand side, should have this->cols() rows, will be overwritten with the solution x.
ldbleading dimension of b

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