NLA-lib Explorer

NLAlib.SpectralBisection.deflate_writes

Library · theorem

Deflation executes sample scaling, the supplied multiplication and QR routines, and copies the first requested QR columns. All four scratch matrices are scoped. The output may alias an original input: its copy occurs after every input-dependent computation. A fragment of NLAlib.SpectralBisection.bisectionRoutine.

NLAlib.SpectralBisection.deflate_writes {K Op Tst : Type} [Inhabited K] [Ops.Has Ops.ScalarOp Op]
  [Ops.Has Ops.MatrixOp Op] {M : Ops.Machine K} {I : Ops.Interp Op Tst K} (hS : Ops.IsScalar M I)
  {mm :
    {l m n : ℕ} →
      Matrix (Fin l) (Fin m) (K × K) →
        Matrix (Fin m) (Fin n) (K × K) → Matrix (Fin l) (Fin n) (K × K)}
  {qr :
    {m n : ℕ} →
      Matrix (Fin m) (Fin n) (K × K) →
        Matrix (Fin m) (Fin m) (K × K) × Matrix (Fin m) (Fin n) (K × K)}
  (hMM : Ops.IsMatrixMul (Ops.EntryCodec.pair K) (fun {l m n} ↦ mm) I)
  (hQR : Ops.IsMatrixQR (Ops.EntryCodec.pair K) (fun {m n} ↦ qr) I) {τ : Ops.Tape K} {μ : Ops.Mem K}
  {n k r lo side : ℕ} {sg sq p z : ℕ × ℕ} (S : ℕ → ℕ → K × K) (a : K)
  (P : Matrix (Fin k) (Fin k) (K × K)) (hside : side < 2) (hslot : lo + k ≤ n) (hr : r ≤ k)
  (hl : μ.Live [sg, sq, p, z])
  (hsg :
    μ.store.HoldsEntries (Ops.EntryCodec.pair K)
      { buf := sg.1, off := sg.2, rows := n, cols := 2 * n, ld := n } S)
  (hsq : μ.store.get sq.1 sq.2 = some a)
  (hP : μ.store.readBlock p.1 p.2 (2 * (k * k)) = some ((Ops.EntryCodec.pair K).packFinMatrix P))
  (hz : z.2 + 2 * (k * r) ≤ μ.store.len z.1) :
  Ops.Writes Ops.Mode.total I τ SpectralBisection.deflate
    (Ops.Env.frame [n, k, r, lo, side] [sg, sq, p, z]) (Ops.Store.inBlock z.1 z.2 (2 * (k * r)))
    (fun μ' ↦
      μ'.pos = μ.pos ∧
        μ'.store.readBlock z.1 z.2 (2 * (k * r)) =
          some
            ((Ops.EntryCodec.pair K).packFinMatrix
              ((qr (mm P (SpectralBisection.sampledGaussian M k lo side S a))).1.submatrix id
                (Fin.castLE hr))))
    μ

Full source on GitHub

Import NLAlib.Eigensolvers.SpectralBisection.Deflation.