NLAlib.Ops.ScalarProducts.sum_writes
Library ยท theorem
The streamed loop returns the exact sum, using only the declared accumulator and temporary. Inputs can share a buffer or repeat words; their accessed cells stay outside the two-cell write footprint. Empty products return literal zero. Shared by the trees of NLAlib.HutchPlusPlus.projectProbes, NLAlib.HutchPlusPlus.accumulate, NLAlib.CGS2.cgs2ExtendFinish and 17 more.
NLAlib.Ops.ScalarProducts.sum_writes {Op Tst : Type} [Ops.Has Ops.ScalarOp Op] {๐ : Type} [RCLike ๐]
{I : Ops.Interp Op Tst ๐} {tape : Ops.Tape ๐} {m : Ops.Mem ๐}
(hS : Ops.IsScalar Ops.RCLikeBlas.machine I) {n sx sy : โ} {x y t out : โ ร โ} (xs ys : โ โ ๐)
(hl : m.Live [x, y, t, out]) (hX : โ j < n, m.store.readBlock x.1 (x.2 + sx * j) 1 = some [xs j])
(hY : โ j < n, m.store.readBlock y.1 (y.2 + sy * j) 1 = some [ys j])
(hDX :
โ j < n,
(Ops.Store.inBlock t.1 t.2 1 โ Ops.Store.inBlock out.1 out.2 1).Disj
(Ops.Store.inBlock x.1 (x.2 + sx * j) 1))
(hDY :
โ j < n,
(Ops.Store.inBlock t.1 t.2 1 โ Ops.Store.inBlock out.1 out.2 1).Disj
(Ops.Store.inBlock y.1 (y.2 + sy * j) 1))
(hTO : Ops.Fp.Disj (Ops.Store.inBlock t.1 t.2 1) (Ops.Store.inBlock out.1 out.2 1))
(ht : t.2 + 1 โค m.store.len t.1) (ho : out.2 + 1 โค m.store.len out.1) :
Ops.Writes Ops.Mode.total I tape Ops.ScalarProducts.sum (Ops.Env.frame [n, sx, sy] [x, y, t, out])
(Ops.Store.inBlock t.1 t.2 1 โ Ops.Store.inBlock out.1 out.2 1)
(fun m' โฆ
m'.pos = m.pos โง m'.store.readBlock out.1 out.2 1 = some [โ j โ Finset.range n, xs j * ys j])
mImport NLAlib.Ops.Blas.ScalarProducts.