Documentation

Mathlib.Data.Vector.Zip

The zipWith operation on vectors. #

def Vector.zipWith {α : Type u_1} {β : Type u_2} {γ : Type u_3} {n : } (f : αβγ) :
Vector α nVector β nVector γ n

Apply the function f : α → β → γ to each corresponding pair of elements from two vectors.

Equations
Instances For
    @[simp]
    theorem Vector.zipWith_toList {α : Type u_1} {β : Type u_2} {γ : Type u_3} {n : } (f : αβγ) (x : Vector α n) (y : Vector β n) :
    (Vector.zipWith f x y).toList = List.zipWith f x.toList y.toList
    @[simp]
    theorem Vector.zipWith_get {α : Type u_1} {β : Type u_2} {γ : Type u_3} {n : } (f : αβγ) (x : Vector α n) (y : Vector β n) (i : Fin n) :
    (Vector.zipWith f x y).get i = f (x.get i) (y.get i)
    @[simp]
    theorem Vector.zipWith_tail {α : Type u_1} {β : Type u_2} {γ : Type u_3} {n : } (f : αβγ) (x : Vector α n) (y : Vector β n) :
    (Vector.zipWith f x y).tail = Vector.zipWith f x.tail y.tail
    theorem Vector.sum_add_sum_eq_sum_zipWith {α : Type u_1} {n : } [AddCommMonoid α] (x : Vector α n) (y : Vector α n) :
    x.toList.sum + y.toList.sum = (Vector.zipWith (fun (x x_1 : α) => x + x_1) x y).toList.sum
    theorem Vector.prod_mul_prod_eq_prod_zipWith {α : Type u_1} {n : } [CommMonoid α] (x : Vector α n) (y : Vector α n) :
    x.toList.prod * y.toList.prod = (Vector.zipWith (fun (x x_1 : α) => x * x_1) x y).toList.prod