NLA-lib Explorer

NLAlib.coefficientsWithScratch_writes

Library · theorem

Exact arithmetic

Exact scalar arithmetic and the actual zero test compute the mathematical Givens coefficients for every pair, including the zero pair. The scratch buffer is separate from all inputs and outputs; the two output views are spatially disjoint and may share a buffer. Outputs may coincide with the original inputs because their components are captured first. [GolubVanLoan2013, Algorithm 5.1.3]. Shared by the trees of NLAlib.ShiftedQR.deflationRoutine, NLAlib.hessenbergReduceLast, NLAlib.ShiftedQR.scalarDecouple, NLAlib.ShiftedQR.shiftedStepRoutine, NLAlib.ShiftedQR.shqrSmallEigRoutine and NLAlib.SmallEig.smallEigRoutine, on their scratch.

NLAlib.coefficientsWithScratch_writes {Op Tst : Type} [Ops.Has Ops.ScalarOp Op]
  [Ops.Has Ops.CmpTst Tst] {M : Ops.Machine ℝ} {I : Ops.Interp Op Tst ℝ} (hS : Ops.IsScalar M I)
  (hE : Ops.ExactModel id M) (hCmp : Ops.IsCmp id I) {τ : Ops.Tape ℝ} {m : Ops.Mem ℝ}
  {a b t c s : ℕ × ℕ} {u v : ℂ} (hta : t.1 ≠ a.1) (htb : t.1 ≠ b.1) (htc : t.1 ≠ c.1)
  (hts : t.1 ≠ s.1) (hcs : Ops.Fp.Disj (Ops.Store.inBlock c.1 c.2 2) (Ops.Store.inBlock s.1 s.2 2))
  (hu0 : m.store.get a.1 a.2 = some u.re) (hu1 : m.store.get a.1 (a.2 + 1) = some u.im)
  (hv0 : m.store.get b.1 b.2 = some v.re) (hv1 : m.store.get b.1 (b.2 + 1) = some v.im)
  (ht : t.2 + 7 ≤ m.store.len t.1) (hc : c.2 + 2 ≤ m.store.len c.1)
  (hs : s.2 + 2 ≤ m.store.len s.1) :
  Ops.Writes Ops.Mode.total I τ coefficientsWithScratch (Ops.Env.frame [] [a, b, t, c, s])
    (Ops.Fp.blocks [t, c, s] [7, 2, 2])
    (fun m' ↦
      m'.pos = m.pos ∧
        m'.readBlocks [c, s] [2, 2] =
          some
            [[(givensCoeffs u v).1.re, (givensCoeffs u v).1.im],
              [(givensCoeffs u v).2.re, (givensCoeffs u v).2.im]])
    m

Full source on GitHub

Import NLAlib.Matrix.FinitePrecision.GivensCoefficients.