21template <SquareMatrix Mat>
33 static_assert(
N > 1,
"LDL^T requires at least a 2x2 matrix");
77 const auto y = forward_solve(
L_mat,
b);
78 const auto [z,
event] = diag_solve(y);
92 std::for_each(D_vec.begin(), D_vec.end(), [&](
const auto&
d) { res *= d; });
104 template <linalg::MatrixContainer MatIn>
105 requires(std::same_as<linalg::matrix_scalar_t<MatIn>,
T>)
109 static_assert(
YRows ==
N,
"Codom of Y must match expected dom of A");
112 for (std::size_t
i = 0;
i <
YCols; ++
i) {
127 constexpr void factor(Mat
A) {
128 const auto& tol =
config.tol;
129 auto ldl_t = [&]<std::size_t
j = 0>(
this auto&&
self) ->
bool {
134 constexpr std::size_t
next =
j + 1;
135 if constexpr (
j == 0) {
145 for (std::size_t
k = 0;
k <
j; ++
k) v(
k) =
A(
j,
k) *
A(
k,
k);
188 for (std::size_t
i = 0;
i <
N; ++
i) {
202 constexpr auto diag_solve(
const Vector<T, N>& y)
const {
206 "LDL::diag_solve requires a valid factorization (non-singular)");
210 for (std::size_t
i = 0;
i <
N; ++
i) z(
i) = y(
i) / D_vec(
i);
224 for (
int i =
static_cast<int>(
N) - 1;
i >= 0; --
i) {
constexpr auto get_diag(const Mat &A)
get the diagonal of a matrix A
constexpr auto get_lower_triangle(const Mat &A)
get lower triangle
constexpr auto make_diag(const Vector< T, N > &X)
make a diagonal matrix from a vector
Vector(T, Ts...) -> Vector< std::common_type_t< T, Ts... >, 1+sizeof...(Ts)>
Deduce coordinate type and dimension from constructor arguments.
constexpr auto transpose(const Vec &x)
tranpose of a vector
constexpr T constexpr_abs(T x)
Compute real absolute value or complex magnitude.
constexpr std::size_t mat_rows_v
Registered compile-time row count after cv/ref normalization.
constexpr bool is_fatal_event(NumericalEvent event)
is_fatal_event
constexpr auto get_col(const Mat &A, std::size_t idx)
get the column of matrix A based on given index
constexpr auto as_col_vector(const Vec &X)
express the vector X as a column vector (N x 1)
Configuration for generic numerical factorizations.
std::complex< ScalarT > ComplexT
matrix_scalar_t< Mat > T
alias helpers for types
static constexpr std::size_t N
helper to extract N
Factors a real symmetric matrix as A = L D L^T without pivoting.
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 auto D() const
Reconstruct the diagonal factor.
constexpr T det() const
Compute the determinant from the diagonal pivots.
constexpr auto apply(const MatIn &Y) const
Solve A X = Y one column at a time.
constexpr LDL(const Mat &A, const config::FactorConfig< T > &config_in)
Factor a symmetric matrix with explicit pivot tolerance.
constexpr LDL(const Mat &A)
Factor a symmetric matrix as A = L D L^T.
Owning, fixed-size, row-major matrix container over a scalar field.
forward declaration for symmetric operator
static constexpr std::size_t DIM
helpers to get DIM from mat
SymmetricOperatorType type
member variables
constexpr void compute_definiteness(const Vector< DiagT, N > &diag, const ScalarT &tol)
compute definiteness
constexpr const LDL< Mat > & self() const
self
constexpr bool is_valid() const
is valid
Owning, fixed-size vector container.