Hadamard product of matrices #
THIS FILE IS SYNCHRONIZED WITH MATHLIB4. Any changes to this file require a corresponding PR to mathlib4.
This file defines the Hadamard product matrix.hadamard
and contains basic properties about them.
Main definition #
matrix.hadamard
: defines the Hadamard product, which is the pointwise product of two matrices of the same size.
Notation #
⊙
: the Hadamard productmatrix.hadamard
;
References #
Tags #
hadamard product, hadamard
def
matrix.hadamard
{α : Type u_1}
{m : Type u_4}
{n : Type u_5}
[has_mul α]
(A B : matrix m n α) :
matrix m n α
matrix.hadamard
defines the Hadamard product,
which is the pointwise product of two matrices of the same size.
theorem
matrix.hadamard_comm
{α : Type u_1}
{m : Type u_4}
{n : Type u_5}
(A B : matrix m n α)
[comm_semigroup α] :
@[simp]
theorem
matrix.hadamard_zero
{α : Type u_1}
{m : Type u_4}
{n : Type u_5}
(A : matrix m n α)
[mul_zero_class α] :
@[simp]
theorem
matrix.zero_hadamard
{α : Type u_1}
{m : Type u_4}
{n : Type u_5}
(A : matrix m n α)
[mul_zero_class α] :
theorem
matrix.hadamard_one
{α : Type u_1}
{n : Type u_5}
[decidable_eq n]
[mul_zero_one_class α]
(M : matrix n n α) :
M.hadamard 1 = matrix.diagonal (λ (i : n), M i i)
theorem
matrix.one_hadamard
{α : Type u_1}
{n : Type u_5}
[decidable_eq n]
[mul_zero_one_class α]
(M : matrix n n α) :
1.hadamard M = matrix.diagonal (λ (i : n), M i i)
theorem
matrix.diagonal_hadamard_diagonal
{α : Type u_1}
{n : Type u_5}
[decidable_eq n]
[mul_zero_class α]
(v w : n → α) :
(matrix.diagonal v).hadamard (matrix.diagonal w) = matrix.diagonal (v * w)
theorem
matrix.dot_product_vec_mul_hadamard
{α : Type u_1}
{m : Type u_4}
{n : Type u_5}
(A B : matrix m n α)
[fintype m]
[fintype n]
[semiring α]
[decidable_eq m]
[decidable_eq n]
(v : m → α)
(w : n → α) :
matrix.dot_product (matrix.vec_mul v (A.hadamard B)) w = (((matrix.diagonal v).mul A).mul (B.mul (matrix.diagonal w)).transpose).trace