Extension: Matrix functions
#include "dg/matrix/matrix.h"
dg::mat::MatrixSqrt< ContainerType > Struct Template Reference

Fast computation of \( \vec x = A^{\pm 1/2}\vec b\) for self-adjoint positive definite \(A\). More...

Public Types

using container_type = ContainerType
 
using value_type = dg::get_value_type< ContainerType >
 

Public Member Functions

 MatrixSqrt ()=default
 Construct empty. More...
 
template<class MatrixType >
 MatrixSqrt (MatrixType &A, int exp, const ContainerType &weights, value_type eps_rel, value_type nrmb_correction=1., unsigned max_iter=500, unsigned cauchy_steps=40)
 Construct from matrix. More...
 
template<class ... Params>
void construct (Params &&...ps)
 Perfect forward parameters to one of the constructors. More...
 
unsigned get_iter () const
 Get the number of Lanczos iterations in latest call to operator() More...
 
void set_benchmark (bool benchmark, std::string message="SQRT")
 Set or unset performance timings during iterations. More...
 
template<class ContainerType0 , class ContainerType1 >
void operator() (const ContainerType0 b, ContainerType1 &x)
 Apply matrix sqrt. More...
 

Detailed Description

template<class ContainerType>
struct dg::mat::MatrixSqrt< ContainerType >

Fast computation of \( \vec x = A^{\pm 1/2}\vec b\) for self-adjoint positive definite \(A\).

Convenience wrapper that uses dg::mat::UniversalLanczos combined with dg::mat::make_SqrtCauchyEigen_Te1 in its "universal" stopping criterion

Note
This is the fastest method to compute matrix square roots vector multiplications that we found to date
Attention
Just as in the Lanczos or PCG methods the matrix \( A\) needs to be positive-definite (i.e. it won't work for negative definite)

Member Typedef Documentation

◆ container_type

template<class ContainerType >
using dg::mat::MatrixSqrt< ContainerType >::container_type = ContainerType

◆ value_type

template<class ContainerType >
using dg::mat::MatrixSqrt< ContainerType >::value_type = dg::get_value_type<ContainerType>

Constructor & Destructor Documentation

◆ MatrixSqrt() [1/2]

template<class ContainerType >
dg::mat::MatrixSqrt< ContainerType >::MatrixSqrt ( )
default

Construct empty.

◆ MatrixSqrt() [2/2]

template<class ContainerType >
template<class MatrixType >
dg::mat::MatrixSqrt< ContainerType >::MatrixSqrt ( MatrixType &  A,
int  exp,
const ContainerType &  weights,
value_type  eps_rel,
value_type  nrmb_correction = 1.,
unsigned  max_iter = 500,
unsigned  cauchy_steps = 40 
)
inline

Construct from matrix.

Template Parameters
MatrixType
Parameters
Aself-adjoint matrix; is stored by reference
expexponent, if < 0 then 1/sqrt(A) is computed, else sqrt(A)
weightsthe weights in which A is self-adjoint
eps_relrelative accuracy of solution
nrmb_correctionabsolute accuracy in units of eps_rel
max_iterMaximum number of iterations in Lanczos tridiagonalization
cauchy_stepsnumber of cells in the Cauchy integral

Member Function Documentation

◆ construct()

template<class ContainerType >
template<class ... Params>
void dg::mat::MatrixSqrt< ContainerType >::construct ( Params &&...  ps)
inline

Perfect forward parameters to one of the constructors.

Template Parameters
Paramsdeduced by the compiler
Parameters
psparameters forwarded to constructors

◆ get_iter()

template<class ContainerType >
unsigned dg::mat::MatrixSqrt< ContainerType >::get_iter ( ) const
inline

Get the number of Lanczos iterations in latest call to operator()

◆ operator()()

template<class ContainerType >
template<class ContainerType0 , class ContainerType1 >
void dg::mat::MatrixSqrt< ContainerType >::operator() ( const ContainerType0  b,
ContainerType1 &  x 
)
inline

Apply matrix sqrt.

Parameters
binput vector
xoutput vector, contains \( x = A^{\pm 1/2} \vec b\)

◆ set_benchmark()

template<class ContainerType >
void dg::mat::MatrixSqrt< ContainerType >::set_benchmark ( bool  benchmark,
std::string  message = "SQRT" 
)
inline

Set or unset performance timings during iterations.

Parameters
benchmarkIf true, additional output will be written to std::cout during solution
messageAn optional identifier that is printed together with the benchmark (intended use is to distinguish different messages in the output)

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