1#ifndef FUSED_ALGORITHMS_CHOLESKY_SOLVE_H
2#define FUSED_ALGORITHMS_CHOLESKY_SOLVE_H
80 template <
typename T, my_
size_t N>
85 static_assert(is_floating_point_v<T>,
86 "cholesky_solve requires a floating-point scalar type");
91 if (!chol_result.has_value())
96 auto &L = chol_result.value();
103 if (!fwd_result.has_value())
108 auto &y = fwd_result.value();
121 sum -= L(k, i) * x(k);
124 x(i) =
sum / L(i, i);
Cholesky decomposition for symmetric positive-definite matrices.
A discriminated union holding either a success value or an error.
Definition expected.h:86
Definition fused_matrix.h:12
Definition fused_vector.h:9
Global configuration for the tesseract tensor library.
#define my_size_t
Size/index type used throughout the library.
Definition config.h:126
A minimal, STL-free expected/result type for failable operations.
Runtime property descriptors and error codes for matrices.
Expected< MatrixType, MatrixStatus > cholesky(const MatrixType &A, typename MatrixType::value_type tol=typename MatrixType::value_type(PRECISION_TOLERANCE))
Compute the Cholesky decomposition of a symmetric positive-definite matrix.
Definition cholesky.h:87
Expected< FusedVector< T, N >, MatrixStatus > forward_substitute(const FusedMatrix< T, N, N > &L, const FusedVector< T, N > &b)
Solve the lower-triangular system Lx = b by forward substitution.
Definition triangular_solve.h:74
Expected< FusedVector< T, N >, MatrixStatus > cholesky_solve(const FusedMatrix< T, N, N > &A, const FusedVector< T, N > &b)
Solve Ax = b for symmetric positive-definite A via Cholesky decomposition.
Definition cholesky_solve.h:81
MatrixStatus
Error codes for matrix decomposition and solver algorithms.
Definition matrix_traits.h:33
Expr::value_type sum(const BaseExpr< Expr > &expr)
Definition reductions.h:30
constexpr remove_reference_t< T > && move(T &&t) noexcept
Cast to rvalue reference (replacement for std::move).
Definition simple_type_traits.h:178
Tag type for constructing an Expected in the error state.
Definition expected.h:30
E error
The error value.
Definition expected.h:31
Forward/back substitution for triangular systems.