MTL5 -- Matrix Template Library C++ API
mtl:: -- C++20 header-only linear algebra for mixed-precision algorithm design
Loading...
Searching...
No Matches
sparse_lu.hpp File Reference
#include <algorithm>
#include <cmath>
#include <cstddef>
#include <cstdint>
#include <limits>
#include <stdexcept>
#include <string>
#include <vector>
#include <type_traits>
#include <mtl/mat/compressed2D.hpp>
#include <mtl/vec/dense_vector.hpp>
#include <mtl/concepts/scalar.hpp>
#include <mtl/math/accumulator_traits.hpp>
#include <mtl/math/pow2_scaling.hpp>
#include <mtl/sparse/util/csc.hpp>
#include <mtl/sparse/util/permutation.hpp>
#include <mtl/sparse/factorization/triangular_solve.hpp>
#include <mtl/sparse/factorization/level_schedule.hpp>

Classes

struct  mtl::sparse::factorization::lu_symbolic
 Result of symbolic LU analysis. More...
struct  mtl::sparse::factorization::lu_numeric< Value >
 Result of numeric LU factorization. More...
struct  mtl::sparse::factorization::accumulator_traits< Acc, Value >
 Accumulator policy for the numeric workspace of the left-looking solve. More...

Namespaces

namespace  mtl
namespace  mtl::sparse
namespace  mtl::sparse::factorization
namespace  mtl::sparse::factorization::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.

Functions

template<typename Value, typename SizeType>
bool mtl::sparse::factorization::detail::lu_fold_pivots (const util::csc_matrix< Value, SizeType > &U, Value &lo, Value &hi, bool &seen)
 Folds |u_kk| over U's diagonal (the last entry of each column) into [lo, hi]; seen says whether lo and hi hold a value yet.
template<typename Value, typename SizeType, typename ColMax>
Value mtl::sparse::factorization::detail::lu_rgrowth (const util::csc_matrix< Value, SizeType > &U, ColMax &&amax_of, Value g=Value{1})
 min(g, min over U's columns k of amax_of(k) / max_i |U(i, k)|), where amax_of(k) is the largest |entry| of the factored matrix's column that became U's column k.
template<typename Value, typename Parameters>
Value mtl::sparse::factorization::detail::csr_norm1_scaled (const mat::compressed2D< Value, Parameters > &A, int &e)
 ||A||_1, the largest column sum of |A(i, j)|, for a square CSR A, as m 2^e: 2^e <= max |A(i, j)| < 2^(e+1), so m is in [1, 2n) and neither the sums nor m overflow, whatever A's scale (e = 0 and m = 0 for A = 0).
template<typename Value, typename Parameters>
Value mtl::sparse::factorization::detail::csr_norm1 (const mat::compressed2D< Value, Parameters > &A)
 ||A||_1 itself (it overflows where the norm does).
template<typename Value, typename Solve, typename SolveT>
Value mtl::sparse::factorization::detail::inverse_norm1_estimate (std::size_t n, Solve &&solve_raw, SolveT &&solve_t_raw, int probe_exp=0)
 An estimate of ||A^{-1}||_1 from solves with A and A^T: Hager's method with Higham's refinements (Higham, "FORTRAN codes for estimating the one-norm of a real or complex matrix", ACM TOMS 14(4), 1988; Algorithm 4.1), as SuiteSparse's klu_condest.
template<typename Value, typename Parameters, typename Solve, typename SolveT>
Value mtl::sparse::factorization::detail::condest_1 (const mat::compressed2D< Value, Parameters > &A, Solve &&solve, SolveT &&solve_t)
 ||A||_1 ||A^{-1}||_1, estimated, for condest(): from solve(y, x) = A^{-1} x and solve_t(z, x) = A^{-T} x.
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.
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).
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.
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).
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.
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.
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).