NLA-lib Explorer

NLAlib.Ops.Blas.seq_cost_dot

Library · theorem

The cost of dot in the profile of sequential summation: n multiplications, a literal, a copy if n ≥ 1, and n - 1 additions.

NLAlib.Ops.Blas.seq_cost_dot {Op Tst : Type} [Ops.Has Ops.ScalarOp Op] [Ops.Has Ops.Blas1Op Op]
  [Ops.Apart Ops.Blas1Op Ops.ScalarOp Op] (n : ℕ) :
  Ops.Blas.seq.cost (Ops.Has.inj Ops.Blas1Op.dot) [n] =
    n • Ops.Blas.sc Ops.ScalarOp.mul +
      (Ops.Blas.sc (Ops.ScalarOp.lit 0) +
        ((1 - (1 - n)) • Ops.Blas.sc Ops.ScalarOp.copy + (n - 1) • Ops.Blas.sc Ops.ScalarOp.add))

Full source on GitHub

Import NLAlib.Ops.Profiles.BlasCert.