NLA-lib Explorer

NLAlib.SpectralBisection.nodeProjectors_writes

Library · theorem

The actual capped sign matrix yields both actual rounded projector matrices. Functional operation contracts, readable inputs, writable separated regions and distinguishable zero/one flags suffice for total execution; convergence assumptions are reserved for numerical bounds. A fragment of NLAlib.SpectralBisection.bisectionRoutine.

NLAlib.SpectralBisection.nodeProjectors_writes {K Su Sg Op Tst : Type} [Inhabited K]
  [Ops.Has Ops.ScalarOp Op] [Ops.Has Ops.MatrixOp Op] [Ops.Has Ops.IndexOp Op]
  [Ops.Has Ops.CmpTst Tst] {M : Ops.Machine K} {dec : K → ℝ} {mm : MatMulMap (K × K)}
  {qr : QRMap (K × K)} {unif : K → Su → K} {normal : Sg → K × K} {I : Ops.Interp Op Tst K}
  (hS : Ops.IsScalar M I) (hC : Ops.IsCmp dec I)
  (hMM : Ops.IsMatrixMul (Ops.EntryCodec.pair K) (fun {l m n} ↦ mm) I) (hIndex : Ops.IsIndexLit M I)
  {τ : Ops.Tape K} {k fuel : ℕ} (A : Matrix (Fin k) (Fin k) (K × K)) (eps scale : K)
  {w sp c b t pp pm : ℕ × ℕ} {m : Ops.Mem K} (h01 : dec (M.lit 0) ≠ dec (M.lit 1))
  (hl : m.Live [w, sp, c, b, t, pp, pm])
  (hAP :
    Ops.Fp.Apart [w, sp, c, b, t, pp, pm]
      [2 * (k * k), 2, 4, 2 * (k * k), 2 * (k * k), 2 * (k * k), 2 * (k * k)])
  (hA : m.store.readBlock w.1 w.2 (2 * (k * k)) = some ((Ops.EntryCodec.pair K).packFinMatrix A))
  (hSp : m.store.readBlock sp.1 sp.2 2 = some [eps, scale])
  (hc :
    m.store.readBlock c.1 c.2 4 =
      some [M.lit 1, M.lit 2, M.div (M.lit 1) (M.lit 2), M.neg (M.lit 1)])
  (hb : b.2 + 2 * (k * k) ≤ m.store.len b.1) (ht : t.2 + 2 * (k * k) ≤ m.store.len t.1)
  (hp : pp.2 + 2 * (k * k) ≤ m.store.len pp.1) (hm : pm.2 + 2 * (k * k) ≤ m.store.len pm.1) :
  Ops.Writes Ops.Mode.total I τ SpectralBisection.nodeProjectors
    (Ops.Env.frame [k, fuel] [w, sp, c, b, t, pp, pm])
    (Ops.Fp.blocks [b, t, pp, pm] [2 * (k * k), 2 * (k * k), 2 * (k * k), 2 * (k * k)])
    (fun μ ↦
      μ.pos = m.pos ∧
        μ.readBlocks [pp, pm] [2 * (k * k), 2 * (k * k)] =
          some
            [(Ops.EntryCodec.pair K).packFinMatrix
                ((M.toFloatMachine dec (fun {l m n} ↦ mm) (fun {m n} ↦ qr) unif normal).hermScale
                  ((M.toFloatMachine dec (fun {l m n} ↦ mm) (fun {m n} ↦ qr) unif normal).hermShift
                    (newtonSchulzSign
                      (M.toFloatMachine dec (fun {l m n} ↦ mm) (fun {m n} ↦ qr) unif normal) eps
                      scale fuel A)
                    (M.neg (M.lit 1)))
                  (M.lit 2)),
              (Ops.EntryCodec.pair K).packFinMatrix
                ((M.toFloatMachine dec (fun {l m n} ↦ mm) (fun {m n} ↦ qr) unif normal).hermScale
                  ((M.toFloatMachine dec (fun {l m n} ↦ mm) (fun {m n} ↦ qr) unif normal).negMat
                    ((M.toFloatMachine dec (fun {l m n} ↦ mm) (fun {m n} ↦ qr) unif
                          normal).hermShift
                      (newtonSchulzSign
                        (M.toFloatMachine dec (fun {l m n} ↦ mm) (fun {m n} ↦ qr) unif normal) eps
                        scale fuel A)
                      (M.lit 1)))
                  (M.lit 2))])
    m

Full source on GitHub

Import NLAlib.Eigensolvers.SpectralBisection.Projectors.