Skip to content

num::lanczos

Defined in header <linear/eigen/lanczos.hpp>

template <class Op>
requires self_adjoint_operator<Op, vec<real>>
lanczos_result lanczos(const Op &A, idx k, real tol = 1e-10, idx max_steps = 0);  // (1)

lanczos_result lanczos(const with_law<mat<real>, law::self_adjoint> &A, idx k,
                       real tol = 1e-10, idx max_steps = 0);  // (2)

(1) Compute the largest \(k\) extremal Ritz pairs of a symmetric / self-adjoint operator using Lanczos iteration.

Builds an orthonormal Krylov basis with modified Gram-Schmidt reorthogonalization, generates a symmetric tridiagonal projection \(T_m\), and extracts Ritz values and Ritz vectors.

(2) Compute the largest \(k\) Ritz pairs of a matrix claiming law::self_adjoint.

Template parameters

Parameters

  • A: Self-adjoint linear operator (matrix-free callable, sparse, or dense wrapper).
  • k: Number of extremal eigenpairs to compute (\(0 < k \le n\)).
  • tol: Residual tolerance \(\|A v - \lambda v\|_2\) for declaring convergence (default: 1e-10).
  • max_steps: Maximum Lanczos steps to perform (defaults to \(\min(3k, n)\)).

Return value

lanczos_result containing Ritz values, column Ritz vectors, steps performed, and convergence flag.

lanczos_result with Ritz pairs and convergence metadata.

Exceptions

  • std::invalid_argument: If k is invalid or operator is not square.

See also

eig_sym, power_iteration