NLA-lib Explorer

Cholesky refinement in three precisions

Implementation of Iterative refinement

This is the library's mixed-precision program. Every arithmetic operation is a scalar operation at one of three precision tags, conversions between precisions are explicit operations, and the matrix is stored and read by the program. No operation is an oracle.

Mathematical method

Algorithm

input: A (n x n, positive definite), b, x, stored at the working precision
L := A narrowed to precision F
L := Cholesky(L), left-looking, in place, at precision F
A_R := A, b_R := b, widened to precision R
repeat k times:
    x_R := x widened to precision R
    r_R := b_R - A_R x_R, at precision R
    r   := r_R narrowed to precision W
    d   := r narrowed to precision F
    solve L y = d, then L^T d = y, in place, at precision F
    d_W := d widened to precision W
    x   := x + d_W, at precision W
output: x

The number of steps k is fixed: the program has no stopping test. It is the routine LinearSystems.Refinement.Rounded.solve, built from Cholesky.leftLooking, TriangularSolve.forward, TriangularSolve.backward, Refinement.residualRows, Refinement.addInPlace and Refinement.castLoop. The matrix is stored by columns.

Buffer Content
0 The n^2 words of \mathbf{A}, read only
1 The n words of \mathbf{b}, read only
2 The n words of \mathbf{x}_0, overwritten by the output

Model of arithmetic

All statements on this page are for

Standard rounding at three precisions

Definitions of the arithmetic models · Other programs of this algorithm: Residual, solve and update as operations (Prescribed accuracy of each operation)

There are three machines, each in the standard model on all its operands, with unit roundoffs u_f (factorization), u (working) and u_r (residual), and four casts:

Cast Assumption
Working to factorization relative error at most u_f
Factorization to working exact
Working to residual exact
Residual to working relative error at most u

The theorem does not assume an order among u_f,u,u_r, but the exact widening casts are what the usual order u_r\le u\le u_f provides. Overflow and underflow are not modelled, and the machines are abstract: no IEEE format is fixed.

Operations and Storage

Each scalar operation, cast and structural instruction counts one. The work and span are at most

52n^3+104n^2k+97n^2+125nk+38n+113k+119

instructions, so factorization is O(n^3) and each refinement step O(n^2). The count does not distinguish the cost of an operation at different precisions. The supplied buffers hold n^2+2n words, and the scratch is bounded by the static count of the program. Storage is in abstract cells of one size: the low-precision factor is not credited with using fewer bytes.

Accuracy

Theorem (Forward error of the stored output). Let \mathbf{A} be positive definite of order n, \kappa=\kappa_2(\mathbf{A}), (n+1)u_r<1, and

\theta=48(n+1)^2\kappa u_f\le1,\qquad\eta=(1+u)(n+1)\gamma_{n+1}(u_r),\qquad\gamma_m=(1-u_r)^{-m}-1,

\varphi=(1+u)\bigl(\theta+(1+\theta)\kappa(u+\eta)\bigr)<1,\qquad\xi=(1+u)(1+\theta)\,2\kappa\eta+u.

At an admitted size, for every \mathbf{b} and \mathbf{x}_0, every interpretation satisfying the model and every tape, the run of the fixed program succeeds within the instruction bound above, and buffer 2 then holds \hat{\mathbf{x}} with, for \mathbf{A}\mathbf{x}_\star=\mathbf{b},

\|\mathbf{x}_\star-\hat{\mathbf{x}}\|\le\varphi^k\|\mathbf{x}_\star-\mathbf{x}_0\|+\frac{\xi}{1-\varphi}\|\mathbf{x}_\star\|.

Lean statement and details
NLAlib.LinearSystems.Refinement.Rounded.Certification.algorithm_checked {Mf Mw Mr : Ops.Machine ℝ}
  {cWF cFW cWR cRW : ℝ → ℝ} {uf u ur : ℝ}
  (hS :
    LinearSystems.Refinement.Rounded.Certification.IsArithmetic Mf Mw Mr cWF cFW cWR cRW uf u ur)
  (hur1 : ur < 1) (d : Fin 2 → ℕ)
  (hd : LinearSystems.Refinement.Rounded.Certification.valid uf u ur d)
  (A : Matrix (Fin (d 0)) (Fin (d 0)) ℝ) (rhs x₀ : Fin (d 0) → ℝ) (hA : A.PosDef)
  (hsmall : 24 * (↑(d 0) + 1) ^ 2 * (uf + uf) * pseudoConditionNumber A ≤ 1)
  (hφ :
    refinementContractionFactor (pseudoConditionNumber A)
        (24 * (↑(d 0) + 1) ^ 2 * (uf + uf) * pseudoConditionNumber A)
        ((1 + u) * ((↑(d 0) + 1) * Computation.roundingFactor (d 0 + 1) ur)) u u <
      1)
  (I : Ops.Interp LinearSystems.Refinement.Rounded.Signature Ops.CmpTst ℝ)
  (hI :
    (LinearSystems.Refinement.Rounded.Certification.model Mf Mw Mr cWF cFW cWR cRW uf u ur
          hur1).contracts
      d
      ((LinearSystems.Refinement.Rounded.Certification.inputs uf u ur hur1).input d (A, rhs, x₀) ⋯)
      I)
  (τ : Ops.Tape ℝ) :
  ∃ st,
    Ops.Reference.Execution LinearSystems.Refinement.Rounded.Certification.program I
        (LinearSystems.Refinement.Rounded.Certification.model Mf Mw Mr cWF cFW cWR cRW uf u ur
            hur1).resources
        (LinearSystems.Refinement.Rounded.Certification.inputs uf u ur hur1).formats τ d
        ((LinearSystems.Refinement.Rounded.Certification.inputs uf u ur hur1).memory d (A, rhs, x₀))
        st ∧
      (LinearSystems.Refinement.Rounded.Certification.model Mf Mw Mr cWF cFW cWR cRW uf u ur
                  hur1).resources.work
            st.cost ≤
          52 * d 0 ^ 3 + 104 * d 0 ^ 2 * d 1 + 97 * d 0 ^ 2 + 125 * d 0 * d 1 + 38 * d 0 +
              113 * d 1 +
            119 ∧
        (LinearSystems.Refinement.Rounded.Certification.inputs uf u ur hur1).bytes d + st.peak ≤
            (LinearSystems.Refinement.Rounded.Certification.inputs uf u ur hur1).bytes d +
              Ops.staticPeak
                (LinearSystems.Refinement.Rounded.Certification.model Mf Mw Mr cWF cFW cWR cRW uf u
                    ur hur1).resources
                LinearSystems.Refinement.Rounded.Certification.program d ∧
          ∃ x,
            st.mem.Holds (Ops.Codec.vector (d 0)) 2 x ∧
              ∀ (xstar : Fin (d 0) → ℝ),
                A *ᵥ xstar = rhs →
                  ‖WithLp.toLp 2 (xstar - x)‖ ≤
                    refinementContractionFactor (pseudoConditionNumber A)
                            (24 * (↑(d 0) + 1) ^ 2 * (uf + uf) * pseudoConditionNumber A)
                            ((1 + u) * ((↑(d 0) + 1) * Computation.roundingFactor (d 0 + 1) ur)) u
                            u ^
                          d 1 *
                        ‖WithLp.toLp 2 (xstar - x₀)‖ +
                      refinementAccuracyBound (pseudoConditionNumber A)
                            (24 * (↑(d 0) + 1) ^ 2 * (uf + uf) * pseudoConditionNumber A)
                            ((1 + u) * ((↑(d 0) + 1) * Computation.roundingFactor (d 0 + 1) ur)) u /
                          (1 -
                            refinementContractionFactor (pseudoConditionNumber A)
                              (24 * (↑(d 0) + 1) ^ 2 * (uf + uf) * pseudoConditionNumber A)
                              ((1 + u) * ((↑(d 0) + 1) * Computation.roundingFactor (d 0 + 1) ur)) u
                              u) *
                        ‖WithLp.toLp 2 xstar‖

Full source on GitHub

Copy link

An admitted size is one where these conditions hold for the identity matrix, so that the certificate covers at least one input at each size. Success is proved, not assumed: under the hypotheses every computed pivot is positive.

Theorem (Cholesky does not break down). If \mathbf{A} is positive definite of order n, read with relative error \mathbf{v} and factored at unit roundoff u, with 4(n+1)^2(u+\mathbf{v})\kappa_2(\mathbf{A})\le1, then every computed pivot is positive and

\|\mathbf{A}-\hat{\mathbf{L}}\hat{\mathbf{L}}^{\mathsf{T}}\|_2\le2(n+1)^2(u+\mathbf{v})\|\mathbf{A}\|_2.

Lean statement and details
NLAlib.Computation.IsCholTrace.pos_and_specNorm_sub_le {n : ℕ} {A : Matrix (Fin n) (Fin n) ℝ}
  {a L : ℕ → ℕ → ℝ} {u v : ℝ} (h : Computation.IsCholTrace u a L n) (hA : A.PosDef) (hu : 0 ≤ u)
  (hv : 0 ≤ v) (ha : ∀ (i j : Fin n), j ≤ i → |a ↑i ↑j - A i j| ≤ v * |A i j|)
  (hsmall : 4 * (↑n + 1) ^ 2 * (u + v) * pseudoConditionNumber A ≤ 1) :
  (∀ j < n, 0 < L j j) ∧
    specNorm (A - Computation.lowerOf L n * (Computation.lowerOf L n)ᵀ) ≤
      2 * (↑n + 1) ^ 2 * (u + v) * specNorm A

Full source on GitHub

Copy link

Theorem (The solve with the computed factors). With a computed Cholesky factor as above, 24(n+1)^2(u+\mathbf{v})\kappa_2(\mathbf{A})\le1, a right-hand side read with relative error \mathbf{v}, and forward and back substitution at unit roundoff u, the computed \mathbf{d} satisfies

\|\mathbf{A}^{-1}\mathbf{r}-\mathbf{d}\|\le24(n+1)^2(u+\mathbf{v})\kappa_2(\mathbf{A})\|\mathbf{A}^{-1}\mathbf{r}\|.

Lean statement and details
NLAlib.Computation.norm_inv_mulVec_sub_le_of_isCholTrace {n : ℕ} {A : Matrix (Fin n) (Fin n) ℝ}
  {a L : ℕ → ℕ → ℝ} {u v : ℝ} (h : Computation.IsCholTrace u a L n) (hA : A.PosDef) (hu : 0 ≤ u)
  (hv : 0 ≤ v) (ha : ∀ (i j : Fin n), j ≤ i → |a ↑i ↑j - A i j| ≤ v * |A i j|)
  (hsmall : 24 * (↑n + 1) ^ 2 * (u + v) * pseudoConditionNumber A ≤ 1) {r : Fin n → ℝ}
  {rh y d : ℕ → ℝ} (hr : ∀ (i : Fin n), |rh ↑i - r i| ≤ v * |r i|)
  (hy : Computation.IsSubstTrace (fun x ↦ Computation.RelErr u) L rh n y)
  (hd : Computation.IsBackSubstTrace u L y n d) :
  ‖WithLp.toLp 2 (A⁻¹ *ᵥ r - fun i ↦ d ↑i)‖ ≤
    24 * (↑n + 1) ^ 2 * (u + v) * pseudoConditionNumber A * ‖WithLp.toLp 2 (A⁻¹ *ᵥ r)‖

Full source on GitHub

Copy link

The bound is normwise in the 2-norm. Its condition on u_f carries a factor (n+1)^2 and its limiting term a factor of order (n+1)^2\kappa u_r; neither constant is claimed to be sharp.

Not yet presented

  • LU with pivoting, for matrices that are not positive definite.
  • Concrete IEEE formats, overflow and underflow, and byte widths per precision.
  • A stopping test, componentwise bounds with \operatorname{cond}(\mathbf{A},\mathbf{x}), and the backward-error results of Carson and Higham.