NLA-lib Explorer

NLAlib.SpectralBisection.nodePrepare_writes

Library · theorem

Preparation computes the existing capped-sign projectors while retaining every original input and the signed half-radius words needed by the selected branch. A fragment of NLAlib.SpectralBisection.bisectionRoutine.

NLAlib.SpectralBisection.nodePrepare_writes {K Op Tst : Type} [Inhabited K]
  [Ops.Has Ops.ScalarOp Op] [Ops.Has Ops.IndexOp Op] [Ops.Has Ops.MatrixOp Op]
  [Ops.Has Ops.CmpTst Tst] (M : Ops.Machine K) (dec : K → ℝ) (mm : MatMulMap (K × K))
  (qr : QRMap (K × K)) {I : Ops.Interp Op Tst K} (hS : Ops.IsScalar M I) (hL : Ops.IsIndexLit M I)
  (hC : Ops.IsCmp dec I) (hMM : Ops.IsMatrixMul (Ops.EntryCodec.pair K) (fun {l m n} ↦ mm) I)
  {τ : Ops.Tape K} {μ : Ops.Mem K} {n L fuel d lo k : ℕ}
  {par lv su sg ma qa sz kd ks c t sp w b tm pp pm : ℕ × ℕ} (R0 beta R eps U : K)
  (S : ℕ → ℕ → K × K) (A : Matrix (Fin k) (Fin k) (K × K)) (h01 : dec (M.lit 0) ≠ dec (M.lit 1))
  (hl : μ.Live [par, lv, su, sg, ma, qa, sz, kd, ks, c, t, sp, w, b, tm, pp, pm])
  (hread :
    μ.readBlocks (SpectralBisection.nodeInputs n d lo par lv su sg ma c)
        (SpectralBisection.nodeInputLengths n k) =
      some (SpectralBisection.nodeInputWords M n R0 beta R eps U S A))
  (hsroom : μ.Room [t, sp, w, b, tm, pp, pm] (SpectralBisection.nodeScratchLengths k))
  (hsap : Ops.Fp.Apart [t, sp, w, b, tm, pp, pm] (SpectralBisection.nodeScratchLengths k))
  (hsprotect :
    (Ops.Fp.blocks [t, sp, w, b, tm, pp, pm] (SpectralBisection.nodeScratchLengths k)).Disj
      (Ops.Fp.blocks (SpectralBisection.nodeInputs n d lo par lv su sg ma c)
        (SpectralBisection.nodeInputLengths n k))) :
  have F :=
    M.toFloatMachine dec (fun {l m n} ↦ mm) (fun {m n} ↦ qr) M.mul fun z ↦ M.normalWords z.1 z.2;
  have W := F.hermShift A (M.mul (M.div R (M.lit ↑(L + d))) U);
  have B := newtonSchulzSign F beta (M.mul (M.lit 2) R) fuel W;
  have Pp := F.hermScale (F.hermShift B (M.neg (M.lit 1))) (M.lit 2);
  have Pm := F.hermScale (F.negMat (F.hermShift B (M.lit 1))) (M.lit 2);
  Ops.Writes Ops.Mode.total I τ SpectralBisection.nodePrepare
    (Ops.Env.frame [n, L, fuel, d, lo, k]
      [par, lv, su, sg, ma, qa, sz, kd, ks, c, t, sp, w, b, tm, pp, pm])
    (Ops.Fp.blocks [t, sp, w, b, tm, pp, pm] (SpectralBisection.nodeScratchLengths k))
    (fun μ' ↦
      μ'.pos = μ.pos ∧
        μ'.readBlocks ([pp, pm, t] ++ SpectralBisection.nodeInputs n d lo par lv su sg ma c)
            ([2 * (k * k), 2 * (k * k), 2] ++ SpectralBisection.nodeInputLengths n k) =
          some
            ([(Ops.EntryCodec.pair K).packFinMatrix Pp, (Ops.EntryCodec.pair K).packFinMatrix Pm,
                [M.div R (M.lit 2), M.neg (M.div R (M.lit 2))]] ++
              SpectralBisection.nodeInputWords M n R0 beta R eps U S A))
    μ

Full source on GitHub

Import NLAlib.Eigensolvers.SpectralBisection.NodePrepare.