strumpack::HODLR::ButterflyMatrix< scalar_t > Class Template Reference

Butterfly matrix representation, this includes low-rank matrix representation as a special case. More...

#include <ButterflyMatrix.hpp>

Inheritance diagram for strumpack::HODLR::ButterflyMatrix< scalar_t >:
Collaboration diagram for strumpack::HODLR::ButterflyMatrix< scalar_t >:

Public Types

using mult_t = typename std::function< void(Trans, scalar_t, const DenseM_t &, scalar_t, DenseM_t &)>
 
using delem_blocks_t = typename HODLRMatrix< scalar_t >::delem_blocks_t
 
using elem_blocks_t = typename HODLRMatrix< scalar_t >::elem_blocks_t
 

Public Member Functions

 ButterflyMatrix (const MPIComm &comm, const structured::ClusterTree &row_tree, const structured::ClusterTree &col_tree, const opts_t &opts)
 
 ButterflyMatrix (const HODLRMatrix< scalar_t > &A, const HODLRMatrix< scalar_t > &B)
 
 ButterflyMatrix (const HODLRMatrix< scalar_t > &A, const HODLRMatrix< scalar_t > &B, DenseMatrix< int > &neighbors_rows, DenseMatrix< int > &neighbors_cols, const opts_t &opts)
 
 ButterflyMatrix (const ButterflyMatrix< scalar_t > &h)=delete
 
 ButterflyMatrix (ButterflyMatrix< scalar_t > &&h)
 
ButterflyMatrix< scalar_t > & operator= (const ButterflyMatrix< scalar_t > &h)=delete
 
ButterflyMatrix< scalar_t > & operator= (ButterflyMatrix< scalar_t > &&h)
 
std::size_t rows () const override
 
std::size_t cols () const override
 
std::size_t lrows () const
 
std::size_t local_rows () const override
 
std::size_t lcols () const
 
std::size_t begin_row () const override
 
std::size_t end_row () const override
 
const std::vector< int > & rdist () const override
 
std::size_t begin_col () const
 
std::size_t end_col () const
 
const std::vector< int > & cdist () const override
 
const MPICommComm () const
 
std::size_t memory () const override
 
std::size_t nonzeros () const override
 
std::size_t rank () const override
 
void compress (const mult_t &Amult)
 
void compress (const mult_t &Amult, int rank_guess)
 
void compress (const delem_blocks_t &Aelem)
 
void compress (const elem_blocks_t &Aelem)
 
void mult (Trans op, const DenseM_t &X, DenseM_t &Y) const override
 
void mult (Trans op, const DistM_t &X, DistM_t &Y) const override
 
void extract_add_elements (const VecVec_t &I, const VecVec_t &J, std::vector< DenseMW_t > &B)
 
void extract_add_elements (ExtractionMeta &e, std::vector< DistMW_t > &B)
 
void extract_add_elements (ExtractionMeta &e, std::vector< DenseMW_t > &B)
 
double get_stat (const std::string &name) const
 
void print_stats ()
 
void set_sampling_parameter (double sample_param)
 
void set_BACA_block (int bsize)
 
DistM_t dense (const BLACSGrid *g) const
 
DenseM_t redistribute_2D_to_1D (const DistM_t &R2D, const std::vector< int > &dist) const
 
void redistribute_2D_to_1D (scalar_t a, const DistM_t &R2D, scalar_t b, DenseM_t &R1D, const std::vector< int > &dist) const
 
void redistribute_1D_to_2D (const DenseM_t &S1D, DistM_t &S2D, const std::vector< int > &dist) const
 
- Public Member Functions inherited from strumpack::structured::StructuredMatrix< scalar_t >
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::HODLR::ButterflyMatrix< scalar_t >

Butterfly matrix representation, this includes low-rank matrix representation as a special case.

This requires MPI support.

There are 2 different ways to create a ButterflyMatrix

  • By specifying a matrix-(multiple)vector multiplication routine.
  • By specifying an element extraction routine.
Template Parameters
scalar_tCan be double, or std::complex<double>.
See also
HSS::HSSMatrix, HODLR::HODLRMatrix

Constructor & Destructor Documentation

◆ ButterflyMatrix()

template<typename scalar_t >
strumpack::HODLR::ButterflyMatrix< scalar_t >::ButterflyMatrix ( const HODLRMatrix< scalar_t > &  A,
const HODLRMatrix< scalar_t > &  B 
)

Construct the block X, subblock of the matrix [A X; Y B] A and B should be defined on the same MPI communicator.

Member Function Documentation

◆ begin_row()

template<typename scalar_t >
std::size_t strumpack::HODLR::ButterflyMatrix< scalar_t >::begin_row ( ) const
inlineoverridevirtual

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 from strumpack::structured::StructuredMatrix< scalar_t >.

◆ cdist()

template<typename scalar_t >
const std::vector< int > & strumpack::HODLR::ButterflyMatrix< scalar_t >::cdist ( ) const
inlineoverridevirtual

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 from strumpack::structured::StructuredMatrix< scalar_t >.

◆ cols()

template<typename scalar_t >
std::size_t strumpack::HODLR::ButterflyMatrix< scalar_t >::cols ( ) const
inlineoverridevirtual

Get number of columns in this matrix

Implements strumpack::structured::StructuredMatrix< scalar_t >.

◆ end_row()

template<typename scalar_t >
std::size_t strumpack::HODLR::ButterflyMatrix< scalar_t >::end_row ( ) const
inlineoverridevirtual

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 from strumpack::structured::StructuredMatrix< scalar_t >.

◆ local_rows()

template<typename scalar_t >
std::size_t strumpack::HODLR::ButterflyMatrix< scalar_t >::local_rows ( ) const
inlineoverridevirtual

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 from strumpack::structured::StructuredMatrix< scalar_t >.

◆ memory()

template<typename scalar_t >
std::size_t strumpack::HODLR::ButterflyMatrix< scalar_t >::memory ( ) const
inlineoverridevirtual

Return the total amount of memory used by this matrix, in bytes.

Returns
Memory usage in bytes.
See also
nonzeros

Implements strumpack::structured::StructuredMatrix< scalar_t >.

◆ mult() [1/2]

template<typename scalar_t >
void strumpack::HODLR::ButterflyMatrix< scalar_t >::mult ( Trans  op,
const DenseM_t x,
DenseM_t y 
) const
overridevirtual

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 from strumpack::structured::StructuredMatrix< scalar_t >.

◆ mult() [2/2]

template<typename scalar_t >
void strumpack::HODLR::ButterflyMatrix< scalar_t >::mult ( Trans  op,
const DistM_t X,
DistM_t Y 
) const
overridevirtual

Multiply this low-rank (or butterfly) matrix with a dense matrix: Y = op(A) * X, where op can be none, transpose or complex conjugate. X and Y are in 2D block cyclic distribution.

Parameters
opTranspose, conjugate, or none.
XRight-hand side matrix. Should be X.rows() == this.rows().
YResult, should be Y.cols() == X.cols(), Y.rows() == this.rows()
See also
mult

Reimplemented from strumpack::structured::StructuredMatrix< scalar_t >.

◆ nonzeros()

template<typename scalar_t >
std::size_t strumpack::HODLR::ButterflyMatrix< scalar_t >::nonzeros ( ) const
inlineoverridevirtual

Return the total number of nonzeros stored by this matrix.

Returns
Nonzeros in the matrix representation.
See also
memory

Implements strumpack::structured::StructuredMatrix< scalar_t >.

◆ rank()

template<typename scalar_t >
std::size_t strumpack::HODLR::ButterflyMatrix< scalar_t >::rank ( ) const
inlineoverridevirtual

Return the maximum rank of this matrix over all low-rank compressed blocks.

Returns
Maximum rank.

Implements strumpack::structured::StructuredMatrix< scalar_t >.

◆ rdist()

template<typename scalar_t >
const std::vector< int > & strumpack::HODLR::ButterflyMatrix< scalar_t >::rdist ( ) const
inlineoverridevirtual

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 from strumpack::structured::StructuredMatrix< scalar_t >.

◆ rows()

template<typename scalar_t >
std::size_t strumpack::HODLR::ButterflyMatrix< scalar_t >::rows ( ) const
inlineoverridevirtual

Get number of rows in this matrix

Implements strumpack::structured::StructuredMatrix< scalar_t >.


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