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

Namespaces

namespace  analysis
namespace  factorization
namespace  ordering
namespace  util

Classes

class  shift_invert_operator
 LinearOperator applying (A - sigma*I)^{-1} via a cached sparse LU factorization: factor once, apply many. More...
struct  refine_options
 Controls for iterative_refine. More...
struct  refine_result
 Outcome of iterative_refine. More...

Concepts

concept  FillReducingOrdering
 Concept for a fill-reducing ordering algorithm.
concept  SparseDirectSolver
 Concept for sparse direct solver results.

Functions

template<typename Value, typename Parameters>
mat::compressed2D< Value > shift_diagonal (const mat::compressed2D< Value, Parameters > &A, Value sigma)
 Build B = A - sigma*I as a new CSR sparse matrix.
template<typename Accumulator = void, typename Value, typename Parameters>
itl::ritz_pairs< std::complex< Value > > sparse_eigs_shift_invert (const mat::compressed2D< Value, Parameters > &A, Value sigma, std::size_t k, std::size_t subspace=0, Value tol=Value(1e-8))
 Compute the k eigenvalues of a sparse matrix A nearest the shift sigma, with their eigenvectors, by Arnoldi on the shift-invert operator (A - sigma*I)^{-1}.
template<typename Accumulator = void, typename Value, typename Parameters>
itl::ritz_pairs< std::complex< Value > > sparse_eigs (const mat::compressed2D< Value, Parameters > &A, std::size_t k, itl::eigen_which which=itl::eigen_which::largest_magnitude, std::size_t subspace=0, Value tol=Value(1e-8))
 Compute the k eigenvalues of a sparse matrix A of largest magnitude (or per which) with eigenvectors, by Arnoldi applied directly to the sparse operator – no factorization.
template<typename Residual, typename Parameters, typename Factorization>
refine_result iterative_refine (const mat::compressed2D< Residual, Parameters > &A, const Factorization &fac, const vec::dense_vector< Residual > &b, vec::dense_vector< Residual > &x, const refine_options &opt={})
 Refine x in-place so that A x = b, using factorization fac.

Function Documentation

◆ iterative_refine()

template<typename Residual, typename Parameters, typename Factorization>
refine_result mtl::sparse::iterative_refine ( const mat::compressed2D< Residual, Parameters > & A,
const Factorization & fac,
const vec::dense_vector< Residual > & b,
vec::dense_vector< Residual > & x,
const refine_options & opt = {} )

Refine x in-place so that A x = b, using factorization fac.

x is the working (Residual) precision and may start at zero – the first step then produces the initial solve. A and b are in Residual precision; fac is a (possibly lower-precision) factorization exposing solve(dx, r).

Returns the BEST iterate found (refinement is stopped, and the best x kept, once the residual stops improving), so an over-long max_iter never degrades the result.

◆ shift_diagonal()

template<typename Value, typename Parameters>
mat::compressed2D< Value > mtl::sparse::shift_diagonal ( const mat::compressed2D< Value, Parameters > & A,
Value sigma )

Build B = A - sigma*I as a new CSR sparse matrix.

The diagonal entry is created if A has no stored element there.

◆ sparse_eigs()

template<typename Accumulator = void, typename Value, typename Parameters>
itl::ritz_pairs< std::complex< Value > > mtl::sparse::sparse_eigs ( const mat::compressed2D< Value, Parameters > & A,
std::size_t k,
itl::eigen_which which = itl::eigen_which::largest_magnitude,
std::size_t subspace = 0,
Value tol = Value(1e-8) )

Compute the k eigenvalues of a sparse matrix A of largest magnitude (or per which) with eigenvectors, by Arnoldi applied directly to the sparse operator – no factorization.

A thin convenience over itl::arnoldi. Accumulator is forwarded to it (dot products and matvec); void is unchanged.

◆ sparse_eigs_shift_invert()

template<typename Accumulator = void, typename Value, typename Parameters>
itl::ritz_pairs< std::complex< Value > > mtl::sparse::sparse_eigs_shift_invert ( const mat::compressed2D< Value, Parameters > & A,
Value sigma,
std::size_t k,
std::size_t subspace = 0,
Value tol = Value(1e-8) )

Compute the k eigenvalues of a sparse matrix A nearest the shift sigma, with their eigenvectors, by Arnoldi on the shift-invert operator (A - sigma*I)^{-1}.

Returns complex Ritz pairs: values are the eigenvalues of A (lambda = sigma + 1/theta), vectors are the corresponding eigenvectors.

subspace is the Krylov dimension (default: modest multiple of k, capped at n); tol flags convergence via the Arnoldi Ritz residual.

Accumulator reaches the factorization, the solves and Arnoldi's inner products (see the header note); void is unchanged.