MTL5 -- Matrix Template Library C++ API
mtl:: -- C++20 header-only linear algebra for mixed-precision algorithm design
Loading...
Searching...
No Matches
mtl::sparse::factorization Namespace Reference

Namespaces

namespace  detail
 Numeric KLU factorization: BTF permutation, the permuted matrix B = P*A*Q (block upper triangular), the per-new-index block id, and a left-looking LU factorization of each diagonal block.

Classes

struct  lower_solve_schedule
 Reusable schedule for a level-scheduled lower-triangular forward solve. More...
struct  lower_transpose_solve_schedule
 Reusable schedule for a level-scheduled lower-triangular TRANSPOSE solve. More...
struct  upper_solve_schedule
 Reusable schedule for a level-scheduled UPPER-triangular solve U x = b. More...
struct  unit_lower_solve_schedule
 Schedule for a level-scheduled UNIT lower forward solve L x = b. More...
struct  unit_lower_transpose_solve_schedule
 Schedule for a level-scheduled UNIT lower TRANSPOSE solve L^T x = b (gathers within CSC columns over the below-diagonal entries; no division). More...
struct  klu_numeric
struct  klu_refactor_options
 Options of native_klu_refactor's checked form (issue 946). More...
struct  klu_growth_error
 Thrown by native_klu_refactor when the refactorization's rgrowth() is below klu_refactor_options::min_rgrowth. More...
struct  cholesky_symbolic
 Result of symbolic Cholesky analysis. More...
struct  cholesky_numeric
 Result of numeric Cholesky factorization. More...
struct  ldlt_numeric
 Result of numeric LDL^T factorization. More...
struct  lu_symbolic
 Result of symbolic LU analysis. More...
struct  lu_numeric
 Result of numeric LU factorization. More...
struct  accumulator_traits
 Accumulator policy for the numeric workspace of the left-looking solve. More...
struct  qr_symbolic
 Result of symbolic QR analysis. More...
struct  qr_numeric
 Result of numeric QR factorization. More...
struct  supernodal_symbolic
 Symbolic analysis for supernodal LDL^T. More...
struct  supernodal_ldlt_factor
 Result of numeric supernodal LDL^T factorization. More...
struct  supernodal_lu_symbolic
 Symbolic analysis for supernodal LU: a fill-reducing column order fused with the column-etree postorder (so supernode columns are contiguous), plus the relaxed-supernode boundaries that cap dynamic supernode growth. More...
struct  supernodal_lu_factor
 Result of numeric supernodal LU factorization (same factor layout as lu_numeric, plus the dynamic L-supernode boundaries). More...

Typedefs

using ldlt_symbolic = cholesky_symbolic
 Symbolic analysis result - identical to Cholesky since sparsity of L is the same for LDL^T and LL^T.

Enumerations

enum class  diagonal_check { every_solve , done_by_caller }
 Level-scheduled lower-triangular forward solve: solve L x = b with x holding b on entry and the solution on exit. More...

Functions

template<typename Value, typename SizeType>
lower_solve_schedule build_lower_solve_schedule (const util::csc_matrix< Value, SizeType > &L)
 Build the forward-solve schedule from a lower-triangular L (CSC).
template<typename Accumulator = void, typename Value, typename SizeType>
void level_scheduled_lower_solve (const util::csc_matrix< Value, SizeType > &L, const lower_solve_schedule &s, std::vector< Value > &x, diagonal_check check=diagonal_check::every_solve)
template<typename Value, typename SizeType>
lower_transpose_solve_schedule build_lower_transpose_solve_schedule (const util::csc_matrix< Value, SizeType > &L)
 Build the transpose-solve schedule from a lower-triangular L (CSC).
template<typename Accumulator = void, typename Value, typename SizeType>
void level_scheduled_lower_transpose_solve (const util::csc_matrix< Value, SizeType > &L, const lower_transpose_solve_schedule &s, std::vector< Value > &x, diagonal_check check=diagonal_check::every_solve)
 Level-scheduled transpose solve: solve L^T x = b with x holding b on entry and the solution on exit.
template<typename Value, typename SizeType>
upper_solve_schedule build_upper_solve_schedule (const util::csc_matrix< Value, SizeType > &U)
 Build the upper-solve schedule from an upper-triangular U (CSC, diagonal last).
template<typename Accumulator = void, typename Value, typename SizeType>
void level_scheduled_upper_solve (const util::csc_matrix< Value, SizeType > &U, const upper_solve_schedule &s, std::vector< Value > &x, diagonal_check check=diagonal_check::every_solve)
 Level-scheduled upper-triangular solve: solve U x = b with x holding b on entry and the solution on exit.
template<typename Value, typename SizeType>
unit_lower_solve_schedule build_unit_lower_solve_schedule (const util::csc_matrix< Value, SizeType > &L)
template<typename Accumulator = void, typename Value, typename SizeType>
void level_scheduled_unit_lower_solve (const util::csc_matrix< Value, SizeType > &L, const unit_lower_solve_schedule &s, std::vector< Value > &x)
 Level-scheduled UNIT lower forward solve.
template<typename Value, typename SizeType>
unit_lower_transpose_solve_schedule build_unit_lower_transpose_solve_schedule (const util::csc_matrix< Value, SizeType > &L)
template<typename Accumulator = void, typename Value, typename SizeType>
void level_scheduled_unit_lower_transpose_solve (const util::csc_matrix< Value, SizeType > &L, const unit_lower_transpose_solve_schedule &s, std::vector< Value > &x)
 Level-scheduled UNIT lower transpose solve.
template<typename Accumulator = void, typename Value, typename Parameters>
requires OrderedField<Value>
klu_numeric< Value > native_klu_factor (const mat::compressed2D< Value, Parameters > &A, Value threshold=Value{1}, bool scale=true, Value pivot_perturb=Value{0})
 Factor A using native KLU: BTF, then a left-looking LU of each diagonal block with threshold partial pivoting.
template<typename Value, typename Parameters>
requires OrderedField<Value>
klu_numeric< Value > native_klu_refactor (const mat::compressed2D< Value, Parameters > &A, const klu_numeric< Value > &prev)
 Refactorize a matrix with the SAME sparsity pattern as a prior native KLU factorization, reusing its BTF permutation, per-block orderings, and per-block pivot sequences – recomputing only the numeric values.
template<typename Value, typename Parameters>
requires OrderedField<Value>
klu_numeric< Value > native_klu_refactor (const mat::compressed2D< Value, Parameters > &A, const klu_numeric< Value > &prev, const std::type_identity_t< klu_refactor_options< Value > > &opt)
 native_klu_refactor, then the check opt asks for: with opt.min_rgrowth
template<typename Value, typename Parameters, typename VecX, typename VecB>
requires OrderedField<Value>
void native_klu_solve (const mat::compressed2D< Value, Parameters > &A, VecX &x, const VecB &b, Value threshold=Value{1})
 One-shot native KLU solve: factor and solve A*x = b.
template<typename Value, typename Parameters, typename Ordering>
cholesky_symbolic sparse_cholesky_symbolic (const mat::compressed2D< Value, Parameters > &A, const Ordering &ordering)
 Perform symbolic Cholesky analysis on a symmetric sparse matrix.
template<typename Value, typename Parameters>
cholesky_symbolic sparse_cholesky_symbolic (const mat::compressed2D< Value, Parameters > &A)
 Overload without ordering: uses identity permutation (natural ordering).
template<typename Accumulator = void, typename Value, typename Parameters>
cholesky_numeric< Value > sparse_cholesky_numeric (const mat::compressed2D< Value, Parameters > &A, const cholesky_symbolic &sym)
 Perform numeric Cholesky factorization using pre-computed symbolic analysis.
template<typename Accumulator = void, typename Value, typename Parameters, typename VecX, typename VecB, typename Ordering>
void sparse_cholesky_solve (const mat::compressed2D< Value, Parameters > &A, VecX &x, const VecB &b, const Ordering &ordering)
 One-shot sparse Cholesky solve: factor and solve A*x = b.
template<typename Accumulator = void, typename Value, typename Parameters, typename VecX, typename VecB>
void sparse_cholesky_solve (const mat::compressed2D< Value, Parameters > &A, VecX &x, const VecB &b)
 One-shot sparse Cholesky solve without ordering (natural ordering).
template<typename Value, typename Parameters, typename Ordering>
ldlt_symbolic sparse_ldlt_symbolic (const mat::compressed2D< Value, Parameters > &A, const Ordering &ordering)
 Perform symbolic LDL^T analysis on a symmetric sparse matrix.
template<typename Value, typename Parameters>
ldlt_symbolic sparse_ldlt_symbolic (const mat::compressed2D< Value, Parameters > &A)
 Overload without ordering: uses identity permutation (natural ordering).
template<typename Accumulator = void, typename Value, typename Parameters>
ldlt_numeric< Value > sparse_ldlt_numeric (const mat::compressed2D< Value, Parameters > &A, const ldlt_symbolic &sym)
 Perform numeric LDL^T factorization using pre-computed symbolic analysis.
template<typename Accumulator = void, typename Value, typename Parameters, typename VecX, typename VecB, typename Ordering>
void sparse_ldlt_solve (const mat::compressed2D< Value, Parameters > &A, VecX &x, const VecB &b, const Ordering &ordering)
 One-shot sparse LDL^T solve: factor and solve A*x = b.
template<typename Accumulator = void, typename Value, typename Parameters, typename VecX, typename VecB>
void sparse_ldlt_solve (const mat::compressed2D< Value, Parameters > &A, VecX &x, const VecB &b)
 One-shot sparse LDL^T solve without ordering (natural ordering).
template<typename Value, typename Parameters, typename Ordering>
lu_symbolic sparse_lu_symbolic (const mat::compressed2D< Value, Parameters > &A, const Ordering &ordering)
 Perform symbolic LU analysis on a square sparse matrix.
template<typename Value, typename Parameters>
lu_symbolic sparse_lu_symbolic (const mat::compressed2D< Value, Parameters > &A)
 Overload without ordering: uses identity permutation (natural ordering).
template<typename Accumulator = void, typename Value, typename Parameters>
requires OrderedField<Value>
lu_numeric< Value > sparse_lu_numeric (const mat::compressed2D< Value, Parameters > &A, const lu_symbolic &sym, Value threshold=Value{1}, Value pivot_perturb=Value{0})
 Perform numeric LU factorization with threshold partial pivoting.
template<typename Value, typename Parameters>
requires OrderedField<Value>
void sparse_lu_refactor_in_place (const mat::compressed2D< Value, Parameters > &A, lu_numeric< Value > &fac)
 Refactorize IN PLACE: recompute fac's numeric values from a matrix with the SAME sparsity pattern, reusing its symbolic structure and pivot sequence – no BTF/ordering, no reach DFS, no pivot search – and install them while KEEPING the factor pattern and the coupled solve schedules (#310).
template<typename Value, typename Parameters>
requires OrderedField<Value>
lu_numeric< Value > sparse_lu_refactor (const mat::compressed2D< Value, Parameters > &A, const lu_numeric< Value > &prev)
 Refactorize into a NEW factorization object, leaving prev untouched: a copy of prev (symbolic analysis, permutations, factor pattern and solve schedules) refactorized in place.
template<typename Accumulator = void, typename Value, typename Parameters, typename VecX, typename VecB, typename Ordering>
requires OrderedField<Value>
void sparse_lu_solve (const mat::compressed2D< Value, Parameters > &A, VecX &x, const VecB &b, const Ordering &ordering, Value threshold=Value{1})
 One-shot sparse LU solve: factor and solve A*x = b.
template<typename Accumulator = void, typename Value, typename Parameters, typename VecX, typename VecB>
void sparse_lu_solve (const mat::compressed2D< Value, Parameters > &A, VecX &x, const VecB &b)
 One-shot sparse LU solve without ordering (natural ordering).
template<typename Value, typename Parameters, typename Ordering>
qr_symbolic sparse_qr_symbolic (const mat::compressed2D< Value, Parameters > &A, const Ordering &ordering)
 Symbolic QR analysis with ordering.
template<typename Value, typename Parameters>
qr_symbolic sparse_qr_symbolic (const mat::compressed2D< Value, Parameters > &A)
 Symbolic QR analysis without ordering.
template<typename Accumulator = void, typename Value, typename Parameters>
requires OrderedField<Value>
qr_numeric< Value > sparse_qr_numeric (const mat::compressed2D< Value, Parameters > &A, const qr_symbolic &sym)
 Numeric QR factorization.
template<typename Accumulator = void, typename Value, typename Parameters, typename VecX, typename VecB, typename Ordering>
requires OrderedField<Value>
void sparse_qr_solve (const mat::compressed2D< Value, Parameters > &A, VecX &x, const VecB &b, const Ordering &ordering)
 One-shot sparse QR solve with ordering.
template<typename Accumulator = void, typename Value, typename Parameters, typename VecX, typename VecB>
requires OrderedField<Value>
void sparse_qr_solve (const mat::compressed2D< Value, Parameters > &A, VecX &x, const VecB &b)
 One-shot sparse QR solve without ordering.
template<typename Value, typename Parameters, typename Ordering>
supernodal_symbolic supernodal_ldlt_symbolic (const mat::compressed2D< Value, Parameters > &A, const Ordering &ordering, std::size_t relax=0)
 Symbolic supernodal analysis with a fill-reducing ordering.
template<typename Value, typename Parameters>
supernodal_symbolic supernodal_ldlt_symbolic (const mat::compressed2D< Value, Parameters > &A)
 Symbolic supernodal analysis using the natural ordering (with postorder only).
template<typename Accumulator = void, typename Value, typename Parameters>
requires OrderedField<Value>
supernodal_ldlt_factor< Value > supernodal_ldlt_numeric (const mat::compressed2D< Value, Parameters > &A, const supernodal_symbolic &sym)
 Numeric supernodal LDL^T factorization.
template<typename Accumulator = void, typename Value, typename Parameters, typename VecX, typename VecB, typename Ordering>
void supernodal_ldlt_solve (const mat::compressed2D< Value, Parameters > &A, VecX &x, const VecB &b, const Ordering &ordering)
 One-shot supernodal LDL^T solve with a fill-reducing ordering.
template<typename Accumulator = void, typename Value, typename Parameters, typename VecX, typename VecB>
void supernodal_ldlt_solve (const mat::compressed2D< Value, Parameters > &A, VecX &x, const VecB &b)
 One-shot supernodal LDL^T solve using the natural ordering.
template<typename FactorValue, typename Accumulator = FactorValue, typename Residual, typename Parameters, typename Ordering>
refine_result supernodal_ldlt_solve_refined (const mat::compressed2D< Residual, Parameters > &A, vec::dense_vector< Residual > &x, const vec::dense_vector< Residual > &b, const Ordering &ordering, const refine_options &opt={})
 Mixed-precision solve with iterative refinement: factor in FactorValue (e.g.
template<typename Value, typename Parameters, typename Ordering>
supernodal_lu_symbolic supernodal_lu_symbolic_analyze (const mat::compressed2D< Value, Parameters > &A, const Ordering &ordering)
 Symbolic supernodal LU analysis with a fill-reducing column ordering.
template<typename Accumulator = void, typename Value, typename Parameters>
requires OrderedField<Value>
supernodal_lu_factor< Value > supernodal_lu_numeric (const mat::compressed2D< Value, Parameters > &A, const supernodal_lu_symbolic &sym, Value threshold=Value{1}, std::size_t max_super=64, bool scale=false, Value pivot_perturb=Value{0}, std::size_t panel=supernodal_lu_default_panel)
 Numeric supernodal LU factorization with threshold partial pivoting.
template<typename Value, typename Parameters>
requires OrderedField<Value>
void supernodal_lu_refactor_in_place (const mat::compressed2D< Value, Parameters > &A, supernodal_lu_factor< Value > &fac)
 Refactorize IN PLACE: recompute fac's numeric values from a matrix with the SAME sparsity pattern, reusing its analyze + pivot/supernode pattern – no ordering, no reach DFS, no pivot search, no supernode detection – and install them while KEEPING the factor pattern and the coupled solve schedules (#310).
template<typename Value, typename Parameters>
requires OrderedField<Value>
supernodal_lu_factor< Value > supernodal_lu_refactor (const mat::compressed2D< Value, Parameters > &A, const supernodal_lu_factor< Value > &prev)
 Refactorize into a NEW factor object, leaving prev untouched: a copy of prev (symbolic analysis, permutations, supernode boundaries, factor pattern and solve schedules) refactorized in place.
template<typename Accumulator = void, typename Value, typename Parameters, typename VecX, typename VecB, typename Ordering>
requires OrderedField<Value>
void supernodal_lu_solve (const mat::compressed2D< Value, Parameters > &A, VecX &x, const VecB &b, const Ordering &ordering, Value threshold=Value{1})
 One-shot supernodal LU solve with a fill-reducing column ordering.
template<typename FactorValue, typename Accumulator = FactorValue, typename Residual, typename Parameters, typename Ordering>
refine_result supernodal_lu_solve_refined (const mat::compressed2D< Residual, Parameters > &A, vec::dense_vector< Residual > &x, const vec::dense_vector< Residual > &b, const Ordering &ordering, const refine_options &opt={}, FactorValue pivot_perturb=FactorValue{0})
 Mixed-precision solve with iterative refinement: factor in FactorValue (e.g.
std::size_t reach (const std::vector< std::size_t > &L_col_ptr, const std::vector< std::size_t > &L_row_ind, std::size_t n, const std::vector< std::size_t > &b_indices, std::vector< std::size_t > &xi, std::vector< std::size_t > &stack_workspace, std::vector< std::size_t > &pos_workspace, std::vector< bool > &marked)
 Compute the topological ordering of nodes reachable from the nonzero pattern of b in the graph of L (given in CSC).
std::size_t reach (const std::vector< std::size_t > &L_col_ptr, const std::vector< std::size_t > &L_row_ind, std::size_t n, const std::vector< std::size_t > &b_indices, std::vector< std::size_t > &xi, std::vector< std::size_t > &stack_workspace, std::vector< bool > &marked)
 reach() with its own position workspace: allocates O(n) per call.
template<typename Value, typename SizeType>
void sparse_lower_solve (const util::csc_matrix< Value, SizeType > &L, std::vector< Value > &x, const std::vector< std::size_t > &xi, std::size_t top)
 Sparse triangular solve: solve Lx = b where L is lower triangular in CSC and b is sparse.
template<typename Value, typename SizeType>
void dense_lower_solve (const util::csc_matrix< Value, SizeType > &L, std::vector< Value > &x)
 Dense lower triangular solve: solve Lx = b where L is in CSC format.
template<typename Value, typename SizeType>
void dense_upper_solve (const util::csc_matrix< Value, SizeType > &U, std::vector< Value > &x)
 Dense upper triangular solve: solve Ux = b where U is in CSC format.
template<typename Value, typename SizeType>
void dense_lower_transpose_solve (const util::csc_matrix< Value, SizeType > &L, std::vector< Value > &x)
 Dense lower triangular transpose solve: solve L^T x = b where L is in CSC.
template<typename Value, typename SizeType>
void dense_unit_lower_solve (const util::csc_matrix< Value, SizeType > &L, std::vector< Value > &x)
 Dense unit lower triangular solve: solve Lx = b where L is unit lower triangular in CSC format (diagonal entries in L are ignored; assumed 1).
template<typename Value, typename SizeType>
void dense_unit_lower_transpose_solve (const util::csc_matrix< Value, SizeType > &L, std::vector< Value > &x)
 Dense unit lower triangular transpose solve: solve L^T x = b where L is unit lower triangular in CSC (diagonal entries ignored; assumed 1).

Variables

constexpr std::size_t supernodal_ldlt_kk_outer_width = 2
 Source-supernode width from which the LDL^T block update runs with the supernode's columns outermost (issue 908; see the update loop).
constexpr std::size_t supernodal_lu_default_panel = 16
 The default panel of supernodal_lu_numeric (#195): the columns whose updates from the supernodes closed before them are applied together, so each supernode block is read once per panel instead of once per column.
constexpr std::size_t unvisited = std::numeric_limits<std::size_t>::max()
 Sentinel for unvisited nodes in DFS.

Typedef Documentation

◆ ldlt_symbolic

Symbolic analysis result - identical to Cholesky since sparsity of L is the same for LDL^T and LL^T.

Enumeration Type Documentation

◆ diagonal_check

Level-scheduled lower-triangular forward solve: solve L x = b with x holding b on entry and the solution on exit.

Values are read from L (so a same-pattern re-factorization is picked up), using the positions cached in the schedule. Bit-identical to dense_lower_solve; the rows of each level are solved in parallel on the thread pool (serial when MTL5_NUM_THREADS=1). Who checks the triangular factor's diagonal for zeros. The level-scheduled solves check it on every call (issue 907), an O(n) strided pass before the solve: a caller may change the values after the schedule was built. The factor classes (lu_numeric, supernodal_lu_factor, cholesky_numeric) check it once, when values are installed (set_factor, set_factor_values), and pass done_by_caller, so their solves skip the pass (issue 926).

Enumerator
every_solve 
done_by_caller 

Function Documentation

◆ build_lower_solve_schedule()

template<typename Value, typename SizeType>
lower_solve_schedule mtl::sparse::factorization::build_lower_solve_schedule ( const util::csc_matrix< Value, SizeType > & L)

Build the forward-solve schedule from a lower-triangular L (CSC).

The first stored entry of each column must be the diagonal (row j), matching the layout dense_lower_solve expects.

◆ build_lower_transpose_solve_schedule()

template<typename Value, typename SizeType>
lower_transpose_solve_schedule mtl::sparse::factorization::build_lower_transpose_solve_schedule ( const util::csc_matrix< Value, SizeType > & L)

Build the transpose-solve schedule from a lower-triangular L (CSC).

◆ build_unit_lower_solve_schedule()

template<typename Value, typename SizeType>
unit_lower_solve_schedule mtl::sparse::factorization::build_unit_lower_solve_schedule ( const util::csc_matrix< Value, SizeType > & L)

◆ build_unit_lower_transpose_solve_schedule()

template<typename Value, typename SizeType>
unit_lower_transpose_solve_schedule mtl::sparse::factorization::build_unit_lower_transpose_solve_schedule ( const util::csc_matrix< Value, SizeType > & L)

◆ build_upper_solve_schedule()

template<typename Value, typename SizeType>
upper_solve_schedule mtl::sparse::factorization::build_upper_solve_schedule ( const util::csc_matrix< Value, SizeType > & U)

Build the upper-solve schedule from an upper-triangular U (CSC, diagonal last).

◆ dense_lower_solve()

template<typename Value, typename SizeType>
void mtl::sparse::factorization::dense_lower_solve ( const util::csc_matrix< Value, SizeType > & L,
std::vector< Value > & x )

Dense lower triangular solve: solve Lx = b where L is in CSC format.

b is overwritten with the solution x. This processes all columns (no reach computation needed for dense b).

◆ dense_lower_transpose_solve()

template<typename Value, typename SizeType>
void mtl::sparse::factorization::dense_lower_transpose_solve ( const util::csc_matrix< Value, SizeType > & L,
std::vector< Value > & x )

Dense lower triangular transpose solve: solve L^T x = b where L is in CSC.

Processes columns in reverse order.

◆ dense_unit_lower_solve()

template<typename Value, typename SizeType>
void mtl::sparse::factorization::dense_unit_lower_solve ( const util::csc_matrix< Value, SizeType > & L,
std::vector< Value > & x )

Dense unit lower triangular solve: solve Lx = b where L is unit lower triangular in CSC format (diagonal entries in L are ignored; assumed 1).

b is overwritten with the solution x.

◆ dense_unit_lower_transpose_solve()

template<typename Value, typename SizeType>
void mtl::sparse::factorization::dense_unit_lower_transpose_solve ( const util::csc_matrix< Value, SizeType > & L,
std::vector< Value > & x )

Dense unit lower triangular transpose solve: solve L^T x = b where L is unit lower triangular in CSC (diagonal entries ignored; assumed 1).

Processes columns in reverse order. b is overwritten with x.

◆ dense_upper_solve()

template<typename Value, typename SizeType>
void mtl::sparse::factorization::dense_upper_solve ( const util::csc_matrix< Value, SizeType > & U,
std::vector< Value > & x )

Dense upper triangular solve: solve Ux = b where U is in CSC format.

b is overwritten with the solution x.

◆ level_scheduled_lower_solve()

template<typename Accumulator = void, typename Value, typename SizeType>
void mtl::sparse::factorization::level_scheduled_lower_solve ( const util::csc_matrix< Value, SizeType > & L,
const lower_solve_schedule & s,
std::vector< Value > & x,
diagonal_check check = diagonal_check::every_solve )

◆ level_scheduled_lower_transpose_solve()

template<typename Accumulator = void, typename Value, typename SizeType>
void mtl::sparse::factorization::level_scheduled_lower_transpose_solve ( const util::csc_matrix< Value, SizeType > & L,
const lower_transpose_solve_schedule & s,
std::vector< Value > & x,
diagonal_check check = diagonal_check::every_solve )

Level-scheduled transpose solve: solve L^T x = b with x holding b on entry and the solution on exit.

Reads L's values at solve time. Bit-identical to dense_lower_transpose_solve; each level's columns are solved in parallel (serial when MTL5_NUM_THREADS=1).

◆ level_scheduled_unit_lower_solve()

template<typename Accumulator = void, typename Value, typename SizeType>
void mtl::sparse::factorization::level_scheduled_unit_lower_solve ( const util::csc_matrix< Value, SizeType > & L,
const unit_lower_solve_schedule & s,
std::vector< Value > & x )

Level-scheduled UNIT lower forward solve.

Bit-identical to dense_unit_lower_solve (no diagonal division).

◆ level_scheduled_unit_lower_transpose_solve()

template<typename Accumulator = void, typename Value, typename SizeType>
void mtl::sparse::factorization::level_scheduled_unit_lower_transpose_solve ( const util::csc_matrix< Value, SizeType > & L,
const unit_lower_transpose_solve_schedule & s,
std::vector< Value > & x )

Level-scheduled UNIT lower transpose solve.

Bit-identical to dense_unit_lower_transpose_solve (no diagonal division).

◆ level_scheduled_upper_solve()

template<typename Accumulator = void, typename Value, typename SizeType>
void mtl::sparse::factorization::level_scheduled_upper_solve ( const util::csc_matrix< Value, SizeType > & U,
const upper_solve_schedule & s,
std::vector< Value > & x,
diagonal_check check = diagonal_check::every_solve )

Level-scheduled upper-triangular solve: solve U x = b with x holding b on entry and the solution on exit.

Reads U's values at solve time. Bit-identical to dense_upper_solve; each level's rows are solved in parallel (serial when MTL5_NUM_THREADS=1).

◆ native_klu_factor()

template<typename Accumulator = void, typename Value, typename Parameters>
requires OrderedField<Value>
klu_numeric< Value > mtl::sparse::factorization::native_klu_factor ( const mat::compressed2D< Value, Parameters > & A,
Value threshold = Value{1},
bool scale = true,
Value pivot_perturb = Value{0} )

Factor A using native KLU: BTF, then a left-looking LU of each diagonal block with threshold partial pivoting.

The optional leading Accumulator selects the per-block numeric accumulator policy (see sparse_lu's accumulator_traits): the default void accumulates in Value (ordinary arithmetic), while native_klu_factor<Acc>(A) injects an exact/extended-precision accumulator (e.g. a super-accumulator) for the inner products of every block.

The optional pivot_perturb (default 0 = off) enables opt-in zero-pivot perturbation in each block's LU (see sparse_lu_numeric): a pivot that cancellation has driven below pivot_perturb * ||column|| is replaced by that floor instead of failing. This keeps a low-precision factorization going on stiff blocks; klu_numeric::num_perturbed reports how many pivots were perturbed, and the result is meant to be cleaned up by iterative refinement.

Exceptions
std::invalid_argumentif A is not square.
std::runtime_errorif A is structurally singular (no perfect matching) or a diagonal block is numerically singular and perturbation is off (or the block's pivot column is numerically zero).

◆ native_klu_refactor() [1/2]

template<typename Value, typename Parameters>
requires OrderedField<Value>
klu_numeric< Value > mtl::sparse::factorization::native_klu_refactor ( const mat::compressed2D< Value, Parameters > & A,
const klu_numeric< Value > & prev )

Refactorize a matrix with the SAME sparsity pattern as a prior native KLU factorization, reusing its BTF permutation, per-block orderings, and per-block pivot sequences – recomputing only the numeric values.

This is the analyze- once / factor-many fast path: BTF, the per-block fill-reducing orderings, the reach DFS, and per-block pivot search are all skipped (each block goes through sparse_lu_refactor). Row scaling is recomputed for the new values.

Intended for repeated solves of a fixed circuit-matrix pattern with changing values (SPICE transient analysis; the mp-spice mixed-precision study).

A reused pivot that the new values make exactly zero throws. One they make tiny but not zero does NOT: the refactorization returns normally, with num_perturbed 0, and its solve can be wrong in every digit (issue 946: a 2 x 2 block pivoted on 2, refactored with 1e-20 in its place). Check rgrowth() on the result – near 1 is good, a tiny value means the kept pivots no longer fit – and call native_klu_factor afresh when it fails. rcond() is a cheaper, cruder check, and condest(A) an estimate of the condition number itself. The overload taking klu_refactor_options makes the growth check and throws klu_growth_error.

Exceptions
std::invalid_argumentif A's dimensions do not match prev, or A has an entry outside the prior BTF and factor pattern.
std::runtime_errorif a reused pivot is exactly zero for the new values (prior pivot sequence invalid).

◆ native_klu_refactor() [2/2]

template<typename Value, typename Parameters>
requires OrderedField<Value>
klu_numeric< Value > mtl::sparse::factorization::native_klu_refactor ( const mat::compressed2D< Value, Parameters > & A,
const klu_numeric< Value > & prev,
const std::type_identity_t< klu_refactor_options< Value > > & opt )

native_klu_refactor, then the check opt asks for: with opt.min_rgrowth

0, a result whose rgrowth() is below it, or NaN, throws klu_growth_error instead of being returned (issue 946). prev is untouched either way, as in the unchecked form.

try { fac = native_klu_refactor(A, fac, {.min_rgrowth = 1e-8}); }
catch (const klu_growth_error&) { fac = native_klu_factor(A); }
Exceptions
klu_growth_errorif the growth check fails.
asnative_klu_refactor(A, prev) otherwise.

◆ native_klu_solve()

template<typename Value, typename Parameters, typename VecX, typename VecB>
requires OrderedField<Value>
void mtl::sparse::factorization::native_klu_solve ( const mat::compressed2D< Value, Parameters > & A,
VecX & x,
const VecB & b,
Value threshold = Value{1} )

One-shot native KLU solve: factor and solve A*x = b.

◆ reach() [1/2]

std::size_t mtl::sparse::factorization::reach ( const std::vector< std::size_t > & L_col_ptr,
const std::vector< std::size_t > & L_row_ind,
std::size_t n,
const std::vector< std::size_t > & b_indices,
std::vector< std::size_t > & xi,
std::vector< std::size_t > & stack_workspace,
std::vector< bool > & marked )
inline

reach() with its own position workspace: allocates O(n) per call.

Callers that compute many reaches should pass a pos_workspace of their own.

◆ reach() [2/2]

std::size_t mtl::sparse::factorization::reach ( const std::vector< std::size_t > & L_col_ptr,
const std::vector< std::size_t > & L_row_ind,
std::size_t n,
const std::vector< std::size_t > & b_indices,
std::vector< std::size_t > & xi,
std::vector< std::size_t > & stack_workspace,
std::vector< std::size_t > & pos_workspace,
std::vector< bool > & marked )
inline

Compute the topological ordering of nodes reachable from the nonzero pattern of b in the graph of L (given in CSC).

This is the "reach" of b in L: the set of columns of L that will have nonzeros when solving Lx = b, ordered so that dependencies come first.

Parameters
L_col_ptrColumn pointers of L (CSC)
L_row_indRow indices of L (CSC)
nDimension of L
b_indicesNonzero row indices of the right-hand side b
xiOutput: topological order (filled from the back)
stack_workspacelength n: the DFS stack of nodes
pos_workspacelength n: for each stack level, the next entry of that node's column to scan
markedlength n, caller manages
Returns
Starting index in xi (the reach is xi[top..n-1])

The algorithm uses iterative DFS with an explicit stack. The output xi is filled from the end backward, so xi[return_value..n-1] gives the topological order. Each node's column is scanned once in all: a node resumes its scan where it left off when a child returns (as CSparse's cs_dfs), where a rescan from the start made a node with d children cost O(d^2) (issue 907).

◆ sparse_cholesky_numeric()

template<typename Accumulator = void, typename Value, typename Parameters>
cholesky_numeric< Value > mtl::sparse::factorization::sparse_cholesky_numeric ( const mat::compressed2D< Value, Parameters > & A,
const cholesky_symbolic & sym )

Perform numeric Cholesky factorization using pre-computed symbolic analysis.

This is the up-looking (left-looking) Cholesky algorithm: For each column j, compute L(:,j) by subtracting contributions from all previously factored columns k where L(j,k) != 0.

Parameters
ASymmetric positive definite sparse matrix in CSR format
symSymbolic analysis from sparse_cholesky_symbolic()
Returns
Numeric factorization result containing L in CSC
Exceptions
std::runtime_errorif the matrix is not positive definite (a diagonal entry becomes non-positive, NaN or infinite)
std::invalid_argumentif sym does not match A's size

◆ sparse_cholesky_solve() [1/2]

template<typename Accumulator = void, typename Value, typename Parameters, typename VecX, typename VecB>
void mtl::sparse::factorization::sparse_cholesky_solve ( const mat::compressed2D< Value, Parameters > & A,
VecX & x,
const VecB & b )

One-shot sparse Cholesky solve without ordering (natural ordering).

Accumulator (default void) is forwarded to both the numeric factorization and the solve, so one policy covers the whole solve path (#535).

◆ sparse_cholesky_solve() [2/2]

template<typename Accumulator = void, typename Value, typename Parameters, typename VecX, typename VecB, typename Ordering>
void mtl::sparse::factorization::sparse_cholesky_solve ( const mat::compressed2D< Value, Parameters > & A,
VecX & x,
const VecB & b,
const Ordering & ordering )

One-shot sparse Cholesky solve: factor and solve A*x = b.

Parameters
ASymmetric positive definite sparse matrix
xSolution vector (output)
bRight-hand side vector
orderingFill-reducing ordering functor Accumulator (default void) is forwarded to both the numeric factorization and the solve, so one policy covers the whole solve path (#535).

◆ sparse_cholesky_symbolic() [1/2]

template<typename Value, typename Parameters>
cholesky_symbolic mtl::sparse::factorization::sparse_cholesky_symbolic ( const mat::compressed2D< Value, Parameters > & A)

Overload without ordering: uses identity permutation (natural ordering).

◆ sparse_cholesky_symbolic() [2/2]

template<typename Value, typename Parameters, typename Ordering>
cholesky_symbolic mtl::sparse::factorization::sparse_cholesky_symbolic ( const mat::compressed2D< Value, Parameters > & A,
const Ordering & ordering )

Perform symbolic Cholesky analysis on a symmetric sparse matrix.

Computes the elimination tree, fill-reducing ordering, and predicted sparsity structure of L. This result can be reused for multiple matrices with the same nonzero pattern.

Parameters
ASymmetric sparse matrix in CSR format
orderingFill-reducing ordering functor (e.g., ordering::rcm{})
Returns
Symbolic analysis result

◆ sparse_ldlt_numeric()

template<typename Accumulator = void, typename Value, typename Parameters>
ldlt_numeric< Value > mtl::sparse::factorization::sparse_ldlt_numeric ( const mat::compressed2D< Value, Parameters > & A,
const ldlt_symbolic & sym )

Perform numeric LDL^T factorization using pre-computed symbolic analysis.

Up-looking (left-looking) LDL^T using marker-based reach and single-pass scatter for O(nnz(L)) work. For each column j:

  1. Scatter lower-triangular entries of permuted A(:,j) into workspace
  2. Compute reach of j in the etree using markers (no sort/unique needed)
  3. For each reached column k, scatter L(j,k)*D(k)*L(:,k) in one pass
  4. Store D(j) and L(j+1:n, j) = x/D(j)
Parameters
ASymmetric sparse matrix in CSR format
symSymbolic analysis from sparse_ldlt_symbolic()
Returns
Numeric factorization result containing L (unit lower, no diagonal stored) and D
Exceptions
std::runtime_errorif a pivot D(j) is zero, NaN or infinite
std::invalid_argumentif sym does not match A's size

◆ sparse_ldlt_solve() [1/2]

template<typename Accumulator = void, typename Value, typename Parameters, typename VecX, typename VecB>
void mtl::sparse::factorization::sparse_ldlt_solve ( const mat::compressed2D< Value, Parameters > & A,
VecX & x,
const VecB & b )

One-shot sparse LDL^T solve without ordering (natural ordering).

Accumulator (default void) is forwarded to both the numeric factorization and the solve, so one policy covers the whole solve path (#535).

◆ sparse_ldlt_solve() [2/2]

template<typename Accumulator = void, typename Value, typename Parameters, typename VecX, typename VecB, typename Ordering>
void mtl::sparse::factorization::sparse_ldlt_solve ( const mat::compressed2D< Value, Parameters > & A,
VecX & x,
const VecB & b,
const Ordering & ordering )

One-shot sparse LDL^T solve: factor and solve A*x = b.

Accumulator (default void) is forwarded to both the numeric factorization and the solve, so one policy covers the whole solve path (#535).

◆ sparse_ldlt_symbolic() [1/2]

template<typename Value, typename Parameters>
ldlt_symbolic mtl::sparse::factorization::sparse_ldlt_symbolic ( const mat::compressed2D< Value, Parameters > & A)

Overload without ordering: uses identity permutation (natural ordering).

◆ sparse_ldlt_symbolic() [2/2]

template<typename Value, typename Parameters, typename Ordering>
ldlt_symbolic mtl::sparse::factorization::sparse_ldlt_symbolic ( const mat::compressed2D< Value, Parameters > & A,
const Ordering & ordering )

Perform symbolic LDL^T analysis on a symmetric sparse matrix.

Delegates to sparse_cholesky_symbolic since the sparsity structure is identical.

◆ sparse_lower_solve()

template<typename Value, typename SizeType>
void mtl::sparse::factorization::sparse_lower_solve ( const util::csc_matrix< Value, SizeType > & L,
std::vector< Value > & x,
const std::vector< std::size_t > & xi,
std::size_t top )

Sparse triangular solve: solve Lx = b where L is lower triangular in CSC and b is sparse.

Parameters
LLower triangular matrix in CSC format
bDense right-hand side vector (overwritten with solution x)
xiTopological order from reach() - xi[top..n-1]
topStarting index in xi (from reach())

On entry, b contains the right-hand side. On exit, b contains the solution. Only the entries in the reach are touched.

◆ sparse_lu_numeric()

template<typename Accumulator = void, typename Value, typename Parameters>
requires OrderedField<Value>
lu_numeric< Value > mtl::sparse::factorization::sparse_lu_numeric ( const mat::compressed2D< Value, Parameters > & A,
const lu_symbolic & sym,
Value threshold = Value{1},
Value pivot_perturb = Value{0} )

Perform numeric LU factorization with threshold partial pivoting.

Uses the left-looking algorithm: for each column k, performs a sparse triangular solve with the already-factored columns of L, then selects a pivot from the remaining entries.

Parameters
ASquare sparse matrix in CSR format
symSymbolic analysis from sparse_lu_symbolic()
thresholdPivoting threshold in (0, 1]. A pivot candidate at row i is acceptable if |a(i,k)| >= threshold * max|a(j,k)| for j>=k. Default 1.0 = full partial pivoting. Smaller values trade stability for sparsity preservation.
pivot_perturbOpt-in zero-pivot perturbation (default 0 = off). When > 0, a chosen pivot whose magnitude is below pivot_perturb * ||column||_inf is replaced (sign-preserving) by that floor and num_perturbed is incremented, instead of throwing. This keeps a low-precision factorization going when cancellation drives a structurally-nonzero pivot numerically to zero; the result is meant to be cleaned up by iterative refinement (see mtl::sparse::iterative_refine). With the default 0, behavior is byte-identical to before (hard throw).
Returns
Numeric factorization result containing L, U, and permutations
Exceptions
std::runtime_errorif a zero pivot is encountered and perturbation is off, or the whole pivot column is numerically zero (truly singular: nothing to perturb).

◆ sparse_lu_refactor()

template<typename Value, typename Parameters>
requires OrderedField<Value>
lu_numeric< Value > mtl::sparse::factorization::sparse_lu_refactor ( const mat::compressed2D< Value, Parameters > & A,
const lu_numeric< Value > & prev )

Refactorize into a NEW factorization object, leaving prev untouched: a copy of prev (symbolic analysis, permutations, factor pattern and solve schedules) refactorized in place.

Prefer sparse_lu_refactor_in_place in a transient loop that overwrites its factorization anyway – it skips this copy. Same preconditions and exceptions as sparse_lu_refactor_in_place; on a throw prev is untouched (the copy is discarded).

◆ sparse_lu_refactor_in_place()

template<typename Value, typename Parameters>
requires OrderedField<Value>
void mtl::sparse::factorization::sparse_lu_refactor_in_place ( const mat::compressed2D< Value, Parameters > & A,
lu_numeric< Value > & fac )

Refactorize IN PLACE: recompute fac's numeric values from a matrix with the SAME sparsity pattern, reusing its symbolic structure and pivot sequence – no BTF/ordering, no reach DFS, no pivot search – and install them while KEEPING the factor pattern and the coupled solve schedules (#310).

This is the allocation-light form of the fast path for repeated solves of a fixed pattern with changing values (e.g. SPICE transient analysis: one factor, many refactor); nothing is copied but the recomputed values.

Preconditions: A has the same column ordering (fac.symbolic) and its nonzero pattern lies inside the factor's (A's pattern at factor time, plus fill). Checked: an entry outside it throws std::invalid_argument. Relies on fac.L / fac.U columns being stored in ascending row order (as sparse_lu_numeric produces).

Strong exception guarantee: the values are computed into scratch arrays and installed only after the last column succeeds, so a throw leaves fac exactly as it was – still solvable with its previous values.

A reused pivot that the new values make tiny but not zero is accepted, and the solve can then be wrong (issue 946). Check fac.rgrowth(A) afterwards: a tiny value means the kept pivots no longer fit; factor afresh.

Exceptions
std::runtime_errorif a reused pivot is exactly zero for the new values (the prior pivot sequence is no longer valid).
std::invalid_argumentif A has an entry outside the factor's pattern.

◆ sparse_lu_solve() [1/2]

template<typename Accumulator = void, typename Value, typename Parameters, typename VecX, typename VecB>
void mtl::sparse::factorization::sparse_lu_solve ( const mat::compressed2D< Value, Parameters > & A,
VecX & x,
const VecB & b )

One-shot sparse LU solve without ordering (natural ordering).

Accumulator (default void) is forwarded to both the numeric factorization and the solve, so one policy covers the whole solve path (#535).

◆ sparse_lu_solve() [2/2]

template<typename Accumulator = void, typename Value, typename Parameters, typename VecX, typename VecB, typename Ordering>
requires OrderedField<Value>
void mtl::sparse::factorization::sparse_lu_solve ( const mat::compressed2D< Value, Parameters > & A,
VecX & x,
const VecB & b,
const Ordering & ordering,
Value threshold = Value{1} )

One-shot sparse LU solve: factor and solve A*x = b.

Accumulator (default void) is forwarded to both the numeric factorization and the solve, so one policy covers the whole solve path (#535).

◆ sparse_lu_symbolic() [1/2]

template<typename Value, typename Parameters>
lu_symbolic mtl::sparse::factorization::sparse_lu_symbolic ( const mat::compressed2D< Value, Parameters > & A)

Overload without ordering: uses identity permutation (natural ordering).

◆ sparse_lu_symbolic() [2/2]

template<typename Value, typename Parameters, typename Ordering>
lu_symbolic mtl::sparse::factorization::sparse_lu_symbolic ( const mat::compressed2D< Value, Parameters > & A,
const Ordering & ordering )

Perform symbolic LU analysis on a square sparse matrix.

Computes the column permutation for fill reduction.

Parameters
ASquare sparse matrix in CSR format
orderingFill-reducing ordering functor
Returns
Symbolic analysis result

◆ sparse_qr_numeric()

template<typename Accumulator = void, typename Value, typename Parameters>
requires OrderedField<Value>
qr_numeric< Value > mtl::sparse::factorization::sparse_qr_numeric ( const mat::compressed2D< Value, Parameters > & A,
const qr_symbolic & sym )

Numeric QR factorization.

Dense-workspace column-by-column Householder QR on the column-permuted matrix. For each column k:

  1. Scatter column k into dense workspace
  2. Apply H_0, ..., H_{k-1} to transform it
  3. Extract R(0:k, k) from rows 0..k
  4. Compute Householder reflector for rows k..m-1

Householder convention (Golub & Van Loan): Given x = w[k:m-1], define: alpha = -sign(x[0]) * ||x|| v = x; v[0] -= alpha beta = 2 / (v^T * v) Then H = I - beta * v * v^T satisfies H*x = alpha * e_1.

◆ sparse_qr_solve() [1/2]

template<typename Accumulator = void, typename Value, typename Parameters, typename VecX, typename VecB>
requires OrderedField<Value>
void mtl::sparse::factorization::sparse_qr_solve ( const mat::compressed2D< Value, Parameters > & A,
VecX & x,
const VecB & b )

One-shot sparse QR solve without ordering.

Accumulator (default void) is forwarded to both the numeric factorization and the solve, so one policy covers the whole solve path (#535).

◆ sparse_qr_solve() [2/2]

template<typename Accumulator = void, typename Value, typename Parameters, typename VecX, typename VecB, typename Ordering>
requires OrderedField<Value>
void mtl::sparse::factorization::sparse_qr_solve ( const mat::compressed2D< Value, Parameters > & A,
VecX & x,
const VecB & b,
const Ordering & ordering )

One-shot sparse QR solve with ordering.

Accumulator (default void) is forwarded to both the numeric factorization and the solve, so one policy covers the whole solve path (#535).

◆ sparse_qr_symbolic() [1/2]

template<typename Value, typename Parameters>
qr_symbolic mtl::sparse::factorization::sparse_qr_symbolic ( const mat::compressed2D< Value, Parameters > & A)

Symbolic QR analysis without ordering.

◆ sparse_qr_symbolic() [2/2]

template<typename Value, typename Parameters, typename Ordering>
qr_symbolic mtl::sparse::factorization::sparse_qr_symbolic ( const mat::compressed2D< Value, Parameters > & A,
const Ordering & ordering )

Symbolic QR analysis with ordering.

◆ supernodal_ldlt_numeric()

template<typename Accumulator = void, typename Value, typename Parameters>
requires OrderedField<Value>
supernodal_ldlt_factor< Value > mtl::sparse::factorization::supernodal_ldlt_numeric ( const mat::compressed2D< Value, Parameters > & A,
const supernodal_symbolic & sym )

Numeric supernodal LDL^T factorization.

Left-looking over supernodes: each supernode's dense panel is assembled from A, updated by every earlier supernode whose off-diagonal rows reach into its columns (the dense block update – the mixed-precision hot spot), then factored in place. The panel lives in Accumulator; it is read out and rounded to Value exactly once per entry on store.

Exceptions
std::runtime_erroron a zero pivot (D(j) == 0).

◆ supernodal_ldlt_solve() [1/2]

template<typename Accumulator = void, typename Value, typename Parameters, typename VecX, typename VecB>
void mtl::sparse::factorization::supernodal_ldlt_solve ( const mat::compressed2D< Value, Parameters > & A,
VecX & x,
const VecB & b )

One-shot supernodal LDL^T solve using the natural ordering.

Accumulator (default void) is forwarded to both the numeric factorization and the solve, so one policy covers the whole solve path (#535).

◆ supernodal_ldlt_solve() [2/2]

template<typename Accumulator = void, typename Value, typename Parameters, typename VecX, typename VecB, typename Ordering>
void mtl::sparse::factorization::supernodal_ldlt_solve ( const mat::compressed2D< Value, Parameters > & A,
VecX & x,
const VecB & b,
const Ordering & ordering )

One-shot supernodal LDL^T solve with a fill-reducing ordering.

Accumulator (default void) is forwarded to both the numeric factorization and the solve, so one policy covers the whole solve path (#535).

◆ supernodal_ldlt_solve_refined()

template<typename FactorValue, typename Accumulator = FactorValue, typename Residual, typename Parameters, typename Ordering>
refine_result mtl::sparse::factorization::supernodal_ldlt_solve_refined ( const mat::compressed2D< Residual, Parameters > & A,
vec::dense_vector< Residual > & x,
const vec::dense_vector< Residual > & b,
const Ordering & ordering,
const refine_options & opt = {} )

Mixed-precision solve with iterative refinement: factor in FactorValue (e.g.

float) with accumulation in Accumulator, then refine the residual in Residual (e.g. double) through the low-precision factor. Reuses the generic iterative_refine loop. FactorValue is the only required template argument: supernodal_ldlt_solve_refined<float>(A, x, b, ordering); supernodal_ldlt_solve_refined<float, double>(A, x, b, ordering); // wider Acc

No pivot perturbation: supernodal_lu_solve_refined takes a pivot_perturb floor for a pivot that cancels to zero in the low precision (#185), but supernodal_ldlt_numeric has no such option to forward, so a zero pivot in the FactorValue copy throws std::runtime_error here, as the factorization does (issue 926). Use the LU driver with a floor for a symmetric matrix that needs one.

◆ supernodal_ldlt_symbolic() [1/2]

template<typename Value, typename Parameters>
supernodal_symbolic mtl::sparse::factorization::supernodal_ldlt_symbolic ( const mat::compressed2D< Value, Parameters > & A)

Symbolic supernodal analysis using the natural ordering (with postorder only).

◆ supernodal_ldlt_symbolic() [2/2]

template<typename Value, typename Parameters, typename Ordering>
supernodal_symbolic mtl::sparse::factorization::supernodal_ldlt_symbolic ( const mat::compressed2D< Value, Parameters > & A,
const Ordering & ordering,
std::size_t relax = 0 )

Symbolic supernodal analysis with a fill-reducing ordering.

◆ supernodal_lu_numeric()

template<typename Accumulator = void, typename Value, typename Parameters>
requires OrderedField<Value>
supernodal_lu_factor< Value > mtl::sparse::factorization::supernodal_lu_numeric ( const mat::compressed2D< Value, Parameters > & A,
const supernodal_lu_symbolic & sym,
Value threshold = Value{1},
std::size_t max_super = 64,
bool scale = false,
Value pivot_perturb = Value{0},
std::size_t panel = supernodal_lu_default_panel )

Numeric supernodal LU factorization with threshold partial pivoting.

Parameters
thresholdpivoting threshold in (0,1]; 1 = full partial pivoting.
max_supermaximum supernode width (relaxation cap).
scaleopt-in row equilibration (factor R*A; RHS scaled in solve()).
pivot_perturbopt-in zero-pivot perturbation (default 0 = off). When > 0, a chosen pivot whose magnitude is below pivot_perturb * ||column||_inf is replaced (sign-preserving) by that floor and num_perturbed is incremented, instead of throwing – keeping a low-precision factorization going when cancellation drives a structurally-nonzero pivot numerically to zero (clean up with iterative_refine). Default 0 is byte-identical to before (hard throw). Mirrors sparse_lu.
Exceptions
std::runtime_erroron a singular (zero) pivot when perturbation is off, or when the whole pivot column is numerically zero.

◆ supernodal_lu_refactor()

template<typename Value, typename Parameters>
requires OrderedField<Value>
supernodal_lu_factor< Value > mtl::sparse::factorization::supernodal_lu_refactor ( const mat::compressed2D< Value, Parameters > & A,
const supernodal_lu_factor< Value > & prev )

Refactorize into a NEW factor object, leaving prev untouched: a copy of prev (symbolic analysis, permutations, supernode boundaries, factor pattern and solve schedules) refactorized in place.

Prefer supernodal_lu_refactor_in_place in a transient loop that overwrites its factorization anyway – it skips this copy. Same preconditions and exceptions as supernodal_lu_refactor_in_place; on a throw prev is untouched (the copy is discarded).

◆ supernodal_lu_refactor_in_place()

template<typename Value, typename Parameters>
requires OrderedField<Value>
void mtl::sparse::factorization::supernodal_lu_refactor_in_place ( const mat::compressed2D< Value, Parameters > & A,
supernodal_lu_factor< Value > & fac )

Refactorize IN PLACE: recompute fac's numeric values from a matrix with the SAME sparsity pattern, reusing its analyze + pivot/supernode pattern – no ordering, no reach DFS, no pivot search, no supernode detection – and install them while KEEPING the factor pattern and the coupled solve schedules (#310).

The allocation-light fast path for repeated solves of a fixed pattern with changing values (transient SPICE: one analyze+factor, many refactors); nothing is copied but the recomputed values. The stored L/U columns are in topological (ascending-row) order, so the values replay directly. Mirrors sparse_lu_refactor_in_place.

Preconditions: A uses fac's column ordering, and its nonzero pattern lies inside the factor's (A's at factor time, plus fill). Checked: an entry outside it throws std::invalid_argument. Strong exception guarantee: values are computed into scratch arrays and installed only after the last column succeeds, so a throw leaves fac exactly as it was.

Exceptions
std::runtime_errorif a reused pivot is numerically zero for the new values (the prior pivot sequence is no longer valid).

◆ supernodal_lu_solve()

template<typename Accumulator = void, typename Value, typename Parameters, typename VecX, typename VecB, typename Ordering>
requires OrderedField<Value>
void mtl::sparse::factorization::supernodal_lu_solve ( const mat::compressed2D< Value, Parameters > & A,
VecX & x,
const VecB & b,
const Ordering & ordering,
Value threshold = Value{1} )

One-shot supernodal LU solve with a fill-reducing column ordering.

Accumulator (default void) is forwarded to both the numeric factorization and the solve, so one policy covers the whole solve path (#535).

◆ supernodal_lu_solve_refined()

template<typename FactorValue, typename Accumulator = FactorValue, typename Residual, typename Parameters, typename Ordering>
refine_result mtl::sparse::factorization::supernodal_lu_solve_refined ( const mat::compressed2D< Residual, Parameters > & A,
vec::dense_vector< Residual > & x,
const vec::dense_vector< Residual > & b,
const Ordering & ordering,
const refine_options & opt = {},
FactorValue pivot_perturb = FactorValue{0} )

Mixed-precision solve with iterative refinement: factor in FactorValue (e.g.

float) with accumulation in Accumulator, then refine the residual in Residual (e.g. double) through the low-precision factor. FactorValue is the only required template argument.

pivot_perturb (default 0 = off, a hard throw as before) is forwarded to supernodal_lu_numeric: a pivot that cancellation in FactorValue drives below pivot_perturb * ||column||_inf is replaced by that floor instead of throwing, and refine_result::num_perturbed counts them (#185). This is the path where it matters: a matrix nonsingular in Residual can have an exact zero pivot in a low-precision factor. The solve then completes, and the refinement does what it can. A pivot cancelled exactly to zero in precision u means a condition number of order 1/u or more, so full Residual accuracy is not promised then; check rel_residual.

◆ supernodal_lu_symbolic_analyze()

template<typename Value, typename Parameters, typename Ordering>
supernodal_lu_symbolic mtl::sparse::factorization::supernodal_lu_symbolic_analyze ( const mat::compressed2D< Value, Parameters > & A,
const Ordering & ordering )

Symbolic supernodal LU analysis with a fill-reducing column ordering.

Variable Documentation

◆ supernodal_ldlt_kk_outer_width

std::size_t mtl::sparse::factorization::supernodal_ldlt_kk_outer_width = 2
inlineconstexpr

Source-supernode width from which the LDL^T block update runs with the supernode's columns outermost (issue 908; see the update loop).

A fixed constant, not a macro: a value that differed between translation units would break the one-definition rule for this header's templates.

◆ supernodal_lu_default_panel

std::size_t mtl::sparse::factorization::supernodal_lu_default_panel = 16
inlineconstexpr

The default panel of supernodal_lu_numeric (#195): the columns whose updates from the supernodes closed before them are applied together, so each supernode block is read once per panel instead of once per column.

1 is the column-at-a-time update; at most 64.

◆ unvisited

std::size_t mtl::sparse::factorization::unvisited = std::numeric_limits<std::size_t>::max()
inlineconstexpr

Sentinel for unvisited nodes in DFS.