akreon-linalg
Fixed-size linear algebra and numerical methods in C++26.
Loading...
Searching...
No Matches
linalg::LDL< Mat > Struct Template Reference

Factors a real symmetric matrix as A = L D L^T without pivoting. More...

#include <ldl.hpp>

Inheritance diagram for linalg::LDL< Mat >:
[legend]

Public Types

using SymmetricBase = SymmetricOperator< Mat, LDL< Mat > >
 alias for symmetric matrix
 
- Public Types inherited from linalg::SymmetricOperator< Mat, LDL< Mat > >
using OperatorBase = Endomorphism< Mat, SymmetricOperator< Mat, LDL< Mat > > >
 alias to extract base types
 
- Public Types inherited from linalg::Endomorphism< Mat, Derived >
using T = matrix_scalar_t< Mat >
 alias helpers for types
 
using ScalarT = real_type_t< T >
 
using ComplexT = std::complex< ScalarT >
 

Public Member Functions

constexpr LDL (const Mat &A)
 Factor a symmetric matrix as A = L D L^T.
 
constexpr LDL (const Mat &A, const config::FactorConfig< T > &config_in)
 Factor a symmetric matrix with explicit pivot tolerance.
 
constexpr auto D () const
 Reconstruct the diagonal factor.
 
constexpr auto L () const
 Reconstruct the unit lower-triangular factor.
 
constexpr auto solve (const Vector< T, N > &b) const
 Solve A x = b using the stored LDL^T factors.
 
constexpr T det () const
 Compute the determinant from the diagonal pivots.
 
template<linalg::MatrixContainer MatIn>
requires (std::same_as<linalg::matrix_scalar_t<MatIn>, T>)
constexpr auto apply (const MatIn &Y) const
 Solve A X = Y one column at a time.
 
- Public Member Functions inherited from linalg::SymmetricOperator< Mat, LDL< Mat > >
constexpr SymmetricOperator (const Mat &A)
 CTOR.
 
constexpr auto operator() (std::size_t i, std::size_t j) const
 get element at (i,j) index
 
constexpr std::size_t index (std::size_t i, std::size_t j) const
 index from (row, col)
 
constexpr bool is_pd () const
 is pd check
 
constexpr bool is_nd () const
 is nd check
 
constexpr bool is_psd () const
 is psd check
 
constexpr bool is_nsd () const
 is nsd check
 
constexpr bool is_ind () const
 is indefinite
 
constexpr bool is_valid () const
 is valid
 
constexpr void compute_definiteness (const Vector< DiagT, N > &diag, const ScalarT &tol)
 compute definiteness
 
constexpr const LDL< Mat > & self () const
 self
 
- Public Member Functions inherited from linalg::Endomorphism< Mat, Derived >
constexpr const T & operator() (std::size_t i, std::size_t j) const
 get element at (i,j) index
 
constexpr T & operator() (std::size_t i, std::size_t j)
 get element at (i,j) index
 
constexpr Derived & self ()
 self
 
constexpr const Derived & self () const
 self
 

Additional Inherited Members

- Public Attributes inherited from linalg::SymmetricOperator< Mat, LDL< Mat > >
SymmetricOperatorType type
 member variables
 
Vector< T, DIM > svec
 
- Static Public Attributes inherited from linalg::SymmetricOperator< Mat, LDL< Mat > >
static constexpr std::size_t DIM
 helpers to get DIM from mat
 
- Static Public Attributes inherited from linalg::Endomorphism< Mat, Derived >
static constexpr std::size_t N = mat_rows_v<Mat>
 helper to extract N
 

Detailed Description

template<SquareMatrix Mat>
struct linalg::LDL< Mat >

Factors a real symmetric matrix as A = L D L^T without pivoting.

forward declaration of LDL^T operator

Template Parameters
MatSquare symmetric matrix type.

Definition at line 22 of file ldl.hpp.

Member Typedef Documentation

◆ SymmetricBase

template<SquareMatrix Mat>
using linalg::LDL< Mat >::SymmetricBase = SymmetricOperator<Mat, LDL<Mat> >

alias for symmetric matrix

Definition at line 24 of file ldl.hpp.

Constructor & Destructor Documentation

◆ LDL() [1/2]

template<SquareMatrix Mat>
constexpr linalg::LDL< Mat >::LDL ( const Mat &  A)
inlineexplicitconstexpr

Factor a symmetric matrix as A = L D L^T.

Parameters
[in]ASquare symmetric input matrix.

Definition at line 40 of file ldl.hpp.

References linalg::mat_rows_v.

◆ LDL() [2/2]

template<SquareMatrix Mat>
constexpr linalg::LDL< Mat >::LDL ( const Mat &  A,
const config::FactorConfig< T > &  config_in 
)
inlineexplicitconstexpr

Factor a symmetric matrix with explicit pivot tolerance.

Parameters
[in]ASquare symmetric input matrix.
[in]config_inFactorization settings, including pivot tolerance.

Definition at line 48 of file ldl.hpp.

References linalg::mat_rows_v.

Member Function Documentation

◆ apply()

template<SquareMatrix Mat>
template<linalg::MatrixContainer MatIn>
requires (std::same_as<linalg::matrix_scalar_t<MatIn>, T>)
constexpr auto linalg::LDL< Mat >::apply ( const MatIn &  Y) const
inlineconstexpr

Solve A X = Y one column at a time.

Template Parameters
MatInMatrix type sharing the factorization scalar type.
Parameters
[in]YRight-hand-side matrix with N rows.
Returns
Tuple (solution matrix X, NumericalEvent event); X = A^-1 Y on success.

Definition at line 106 of file ldl.hpp.

References linalg::get_col(), linalg::is_fatal_event(), linalg::mat_rows_v, linalg::Endomorphism< Mat, Derived >::N, linalg::NONE, and linalg::LDL< Mat >::solve().

◆ D()

template<SquareMatrix Mat>
constexpr auto linalg::LDL< Mat >::D ( ) const
inlineconstexpr

Reconstruct the diagonal factor.

Returns
Matrix<T, N, N> containing D.

Definition at line 58 of file ldl.hpp.

References linalg::make_diag().

◆ det()

template<SquareMatrix Mat>
constexpr T linalg::LDL< Mat >::det ( ) const
inlineconstexpr

Compute the determinant from the diagonal pivots.

Returns
Scalar T equal to the product of the entries of D.

Definition at line 90 of file ldl.hpp.

References linalg::mat_rows_v.

◆ L()

template<SquareMatrix Mat>
constexpr auto linalg::LDL< Mat >::L ( ) const
inlineconstexpr

Reconstruct the unit lower-triangular factor.

Returns
Matrix<T, N, N> containing L.

Definition at line 65 of file ldl.hpp.

References linalg::mat_rows_v.

Referenced by linalg::LDL< Mat >::solve().

◆ solve()

template<SquareMatrix Mat>
constexpr auto linalg::LDL< Mat >::solve ( const Vector< T, N > &  b) const
inlineconstexpr

Solve A x = b using the stored LDL^T factors.

Solve L y = b, D z = y, then L^T x = z.

Parameters
[in]bRight-hand side with N entries.
Returns
Tuple (Vector<T, N> x, NumericalEvent event).

Definition at line 75 of file ldl.hpp.

References linalg::is_fatal_event(), linalg::LDL< Mat >::L(), linalg::mat_rows_v, linalg::NONE, and linalg::transpose().

Referenced by linalg::LDL< Mat >::apply().


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