Documentation

CslibFrontier.Foundations.Data.List.DotProduct

Public padded list dot-product identities #

Mathlib's ListMatrix.dotProduct is a pure public operation, despite living under the matrix-tactic path. It sums exactly the requested number of products, with missing entries zero-padded. These identities reuse that operation instead of defining a second list product.

Main results #

theorem Mathlib.Tactic.Matrix.ListMatrix.dotProduct_eq_sum_map_range {R : Type u_1} [Mul R] [AddCommMonoid R] (n : ℕ) (a b : List R) :
dotProduct n a b = (List.map (fun (i : ℕ) => a.getD i 0 * b.getD i 0) (List.range n)).sum

The public recursive dot product equals the corresponding sum of padded list lookups.

theorem Mathlib.Tactic.Matrix.ListMatrix.dotProduct_ofFn {R : Type u_1} [Mul R] [AddCommMonoid R] {n : ℕ} (a b : Fin n → R) :
dotProduct n (List.ofFn a) (List.ofFn b) = ∑ i : Fin n, a i * b i

Canonical finite-vector lists give the ordinary dot-product sum.