This page describes the real, matrix-free three-term program. It stores a basis and tridiagonal coefficients; extracting eigenvalues or evaluating a matrix function is a subsequent algorithm.
Copy the current vector to the previous-vector buffer.
If \sigma>0, store \beta=\sqrt\sigma and normalize the next vector \mathbf{q}=\mathbf{w}/\beta.
Otherwise store a zero coefficient and a zero next vector.
Store the next basis column.
Return the initialized and computed output arrays, releasing scoped scratch.
Square roots and divisions are guarded. A zero starting vector returns zero outputs. A zero cap still initializes the arrays and normalizes a nonzero starting vector. After early breakdown, unused output entries remain zero.
The first two models are for the program of the listing, in which the matrix–vector product is an abstract operator call with its own work and workspace costs and the matrix is not a resident buffer. They differ in what the operations may return. The third model is for a program lowered from it: the matrix is stored entry by entry, and every matrix–vector product and vector operation is written out as scalar loops, so its only primitives are scalar operations and comparisons.
The result below uses exact real scalar arithmetic, exact dot products, vector updates, copies and normalization, and an exact application of \mathbf{A}. Matvec is an abstract operator call with its own work and workspace costs. The matrix itself is not supplied as a resident dense buffer in this program.
The operations form a standard operation model (Ops.Standard.Model): a scalar machine in the standard model with unit roundoff u, level-one vector operations whose dot products are summed sequentially, and a matrix–vector product with a normwise error allowance. The program is the same as in exact arithmetic. The Lean certificate is stated for any scheme of the standard profiles.
Scalar arithmetic is any machine in the standard model with unit roundoff u, and comparisons of stored numbers are exact. The certified program is Krylov.Lanczos.Stored.Rounded.scalarProgram: the listing with each vector operation and each matrix–vector product replaced by scalar loops over the stored entries. Its work is a count of instructions.
Operations and Storage
These budgets are at the level of vector operations and hold for the two models built from BLAS and matvec calls. The stored scalar program has its own instruction count, stated with its theorem.
Theorem (Operation budget). For dimension n and cap k, the static budget permits at most k matvecs, 1+2k length-n dot products, 2k vector updates, 1+2k vector copies, and 1+k vector normalizations.
It also permits 1+k square roots, 2k scalar negations, (k+2)n+2k+2 zero literals, and 1+2k positivity queries. Initialization is included; early stopping can reduce the actual calls. Work is obtained by charging these calls according to the chosen primitive costs. The displayed Lean statement identifies the complete primitive-call budget.
Lean statement and details
NLAlib.Krylov.Lanczos.stmtCost_solve {Op Tst : Type} [Ops.Has Ops.ScalarOp Op]
[Ops.Has Ops.Blas1Op Op] [Ops.Has Ops.OperatorOp Op] [Ops.Has Ops.CmpTst Tst] (n cap b v c : ℕ) :
Ops.stmtCost Krylov.Lanczos.solve [n, cap, b, v, c] = Krylov.Lanczos.solveCount n cap
Theorem (Scratch and output capacity). The scoped scratch bound is
2n+2+W(n),
where W(n) is the maximum declared workspace over the primitive calls used by this program. It does not grow with the cap.
The supplied basis output has (k+1)n cells, the coefficient output has 2k+2 cells, and the input has n cells. These supplied capacities are additional to scratch. Storage captured by an external operator is accounted for by that operator's model.
Lean statement and details
NLAlib.Krylov.Lanczos.stmtPeak_solve_le {Op Tst : Type} [Ops.Has Ops.ScalarOp Op]
[Ops.Has Ops.Blas1Op Op] [Ops.Has Ops.OperatorOp Op] [Ops.Has Ops.CmpTst Tst]
(W : Op → List ℕ → ℕ) (n cap b v c : ℕ) :
Ops.stmtPeak W Krylov.Lanczos.solve [n, cap, b, v, c] ≤ Krylov.Lanczos.solvePeak W n
Theorem (Exact execution correspondence). Under the exact primitive contracts, admissible dimension, live separated input/output buffers, and sufficient output capacity, the program executes successfully and stores the mathematical three-term recurrence for the supplied matrix, starting vector, and cap. It preserves the random-tape position and satisfies the call and scratch bounds above.
This correspondence holds for any real square matrix. Symmetry is additionally required to interpret the returned recurrence as Hermitian Lanczos and apply the tridiagonal spectral results on the mathematical method page. Zero input, zero cap, and early breakdown have the output conventions described above.
Lean statement and details
Exact arithmeticOracle: matrix–vector product
NLAlib.Krylov.Lanczos.runs_solve {K Op Tst : Type} [Inhabited K] [Ops.Has Ops.ScalarOp Op]
[Ops.Has Ops.Blas1Op Op] [Ops.Has Ops.OperatorOp Op] [Ops.Has Ops.CmpTst Tst] {M : Ops.Machine K}
{dec : K → ℝ} {n cap : ℕ} {A : Matrix (Fin n) (Fin n) ℝ} {I : Ops.Interp Op Tst K} {ok : ℕ → Prop}
(hS : Ops.IsScalar M I) (hM : Ops.ExactModel dec M) (hB : Ops.IsExactBlas1 dec ok I) (hok : ok n)
(hA : Ops.IsExactMatvec dec A I) (hCmp : Ops.IsCmp dec I) (W : Op → List ℕ → ℕ) {τ : Ops.Tape K}
{μ : Ops.Mem K} {B V C : ℕ × ℕ} {bs : List K} (hBV : B.1 ≠ V.1) (hBC : B.1 ≠ C.1)
(hVC : V.1 ≠ C.1) (hl : μ.Live [B, V, C]) (hb : μ.store.readBlock B.1 B.2 n = some bs)
(hz : μ.Room [V, C] [(cap + 1) * n, 2 * cap + 2]) :
Ops.ConditionalRuns I W τ Krylov.Lanczos.solve (Ops.Env.frame [n, cap] [B, V, C]) μ
(Krylov.Lanczos.solveCount n cap) (Krylov.Lanczos.solvePeak W n) fun μ' ↦
μ'.pos = μ.pos ∧
∃ vs cs,
μ'.store.readBlock V.1 V.2 ((cap + 1) * n) = some vs ∧
μ'.store.readBlock C.1 C.2 (2 * cap + 2) = some cs ∧
Krylov.Lanczos.Output dec A (Ops.decv dec n bs) cap vs cs
Definition (Rounded certificate of the same program). Let \mathbf{A} be the symmetric matrix of the operator. Assume that the scheme admits vectors of length n, that the matrix–vector allowance is at most e_m\|\mathbf{A}\|_2, and that an allowance E satisfies the accuracy envelope of the standard profiles for e_m, the unit roundoff and the level-one error coefficients at length n. No assumption is made on the spectrum.
Then, for every admitted size and every input, the program of the listing runs successfully within its static instruction budget, with the work and span that the weights of the model give to that budget. It stores vectors and coefficients that are either the initialized output of zero steps or the values of a rounded Lanczos run of some length at most the cap k, with local error allowance E (Lanczos.Rounded.Output). It stops before the cap only at a zero computed norm or coupling coefficient, and it leaves the tape position unchanged.
Lean statement and details
Standard roundingOracle: matrix–vector productWork: program manifest
NLAlib.Krylov.Lanczos.Certification.algorithm {K : Type} [Inhabited K] {domain : (Fin 2 → ℕ) → Prop}
{admitted : ∃ d, domain d}
(model : Ops.Standard.Model (Krylov.Lanczos.Certification.problem domain admitted) fun d ↦ d 0)
(cost : Ops.Standard.Costing) (matvecWork matvecScratch : List ℕ → ℕ)
(hresources : model.resources = Ops.Standard.resources model.scheme cost matvecWork matvecScratch)
(em E : (Fin 2 → ℕ) → ℝ) (hok : ∀ (d : Fin 2 → ℕ), domain d → model.scheme.admits (d 0))
(haccuracy :
∀ (d : Fin 2 → ℕ),
domain d →
Ops.Standard.Accuracy (em d) (model.scheme.roundoff model.unit) (E d)
(model.scheme.errors model.unit) (d 0))
(hbudget :
∀ (d : Fin 2 → ℕ),
domain d →
∀ (x : (Krylov.Lanczos.Certification.problem domain admitted).Input d),
model.scheme.roundoff (model.matvecAllowance d x) ≤ em d * specNorm (model.matrix d x))
(hAT :
∀ (d : Fin 2 → ℕ),
domain d →
∀ (x : (Krylov.Lanczos.Certification.problem domain admitted).Input d),
(model.matrix d x)ᵀ = model.matrix d x) :
Ops.Algorithm model.access (Krylov.Lanczos.Certification.specification model E)
Definition (Ritz residuals of the same run). If in addition kE\le1/100, the same program meets the same resource specification with the output strengthened by a bound on its Ritz residuals (Lanczos.Rounded.RitzOutput). A zero cap and a zero starting vector keep their initialized outputs.
Lean statement and details
Standard roundingOracle: matrix–vector productWork: program manifest
NLAlib.Krylov.Lanczos.Certification.ritzAlgorithm {K : Type} [Inhabited K]
{domain : (Fin 2 → ℕ) → Prop} {admitted : ∃ d, domain d}
(model : Ops.Standard.Model (Krylov.Lanczos.Certification.problem domain admitted) fun d ↦ d 0)
(E : (Fin 2 → ℕ) → ℝ)
(cert : Ops.Algorithm model.access (Krylov.Lanczos.Certification.specification model E))
(hsmall : ∀ (d : Fin 2 → ℕ), domain d → ↑(d 1) * E d ≤ 1 / 100) :
Ops.Algorithm model.access (Krylov.Lanczos.Certification.ritzSpecification model E)
Theorem (Termination, operation count and Ritz residuals). Let \mathbf{A}\in\mathbb{R}^{n\times n} be symmetric, stored entry by entry, let \mathbf{b}\in\mathbb{R}^n, and let k be the iteration cap. The program is the Lanczos recurrence in Paige's ordering started from \mathbf{b}, without reorthogonalization. Scalar arithmetic is any machine in the standard model with unit roundoff u, and comparisons of stored numbers are exact. Let E\le1/100 be an allowance that dominates the rounding of one scalar operation, of one dot product, vector update and scaling of length n, and of one row-by-row matrix–vector product (Lanczos.Rounded.Precision).
Then, for every such input and every tape, the run succeeds, and:
it executes at most 33n^2k+153nk+302k+58n+179 instructions, each of unit cost: scalar operations, comparisons, index arithmetic, operand addressing, loop control and allocation;
it performs some number m\le k of steps and stores the vectors \mathbf{v}_1,\dots,\mathbf{v}_{m+1}, the coefficients \alpha_1,\dots,\alpha_m and \beta_1,\dots,\beta_m, and the computed norm of \mathbf{b}. They are the values of a rounded Lanczos run with local error allowance E (Lanczos.Rounded.Output), which stops before the cap only at a zero computed norm or coupling coefficient;
if k>0, \mathbf{b}\ne\mathbf 0 and kE\le1/100, there is a length q with 1\le q\le k, whose stored \beta_q is zero when q<k, such that every \theta and unit vector \mathbf{y} with \mathbf{T}_q\mathbf{y}=\theta\mathbf{y} satisfy
where \mathbf{V}_q=[\mathbf{v}_1,\dots,\mathbf{v}_q] and \mathbf{T}_q is the leading q\times q stored tridiagonal matrix.
No orthogonality of the stored vectors is claimed. So \mathbf{V}_q\mathbf{y} need not be close to a unit vector, and the residual bound alone does not place \theta near an eigenvalue of \mathbf{A}. The instruction count is an upper bound read off the fixed program.
Lean statement and details
Standard rounding
NLAlib.Krylov.Lanczos.Rounded.Stored.Certification.exec_scalarProgram_work_le_and_ritzResidual
{domain : (Fin 2 → ℕ) → Prop} {admitted : ∃ d, domain d} (M : Ops.Machine ℝ) (u : ℝ)
(hM : Ops.StdModel u id M) (hu : 0 ≤ u) (E : (Fin 2 → ℕ) → ℝ)
(hprec :
∀ (d : Fin 2 → ℕ),
domain d →
Krylov.Lanczos.Rounded.Precision (Ops.ScalarProducts.roundoff u (d 0) * √↑(d 0)) u (E d)
(Ops.Blas.seq.err u) (d 0))
{d : Fin 2 → ℕ} (hd : domain d)
(x : (Krylov.Lanczos.Rounded.Stored.Certification.problem domain admitted).Input d)
(I : Ops.Interp Ops.ScalarOp Ops.CmpTst ℝ)
(hI :
(Ops.RoundedScalarBlas.model
(Krylov.Lanczos.Rounded.Stored.Certification.problem domain admitted) M).contracts
d x I)
(τ : Ops.Tape ℝ) :
∃ st,
Ops.Reference.Execution Krylov.Lanczos.Rounded.Stored.Certification.scalarProgram I
Ops.RoundedScalarBlas.resources
(Krylov.Lanczos.Rounded.Stored.Certification.problem domain admitted).formats τ d
((Krylov.Lanczos.Rounded.Stored.Certification.problem domain admitted).initial d x) st ∧
Ops.RoundedScalarBlas.resources.work st.cost ≤
33 * d 0 ^ 2 * d 1 + 153 * d 0 * d 1 + 302 * d 1 + 58 * d 0 + 179 ∧
∃ vs cs,
st.mem.store.readBlock 2 0 ((d 1 + 1) * d 0) = some vs ∧
st.mem.store.readBlock 3 0 (2 * d 1 + 2) = some cs ∧
Krylov.Lanczos.Rounded.Output id (↑x).1.1 (↑x).1.2 (E d) (d 1) vs cs ∧
(0 < d 1 →
(↑x).1.2 ≠ 0 →
↑(d 1) * E d ≤ 1 / 100 →
Krylov.Lanczos.Rounded.RitzResidual id (↑x).1.1 (E d) (d 1) vs cs)
The explicit Ritz residual bound of the rounded certificate; it is stated here only for the stored scalar program.
The exact and the BLAS-level rounded certificates of the stored program, in which the matrix is stored and the vector operations remain primitives, and the certificate of the program linked with sequential BLAS.
The finite-precision results about the Lanczos run model are on the theory page finite-precision Krylov methods, not on this page.