The areas / V07. Linear algebra
Mathlib.LinearAlgebra.Matrix.Hadamard
34 declarations. Mathlib docs · Source
Hadamard product of matrices
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 E3 #
{α : Type u_1} → {m : Type u_2} → {n : Type u_3} → [Mul α] → Matrix m n α → Matrix m n α → Matrix m n α
Matrix.hadamard (denoted as ⊙ within the Matrix namespace) defines the Hadamard product,
which is the pointwise product of two matrices of the same size.
theorem Matrix.hadamard_apply E0 #
∀ {α : Type u_1} {m : Type u_2} {n : Type u_3} [inst : Mul α] (A B : Matrix m n α) (i : m) (j : n),
A.hadamard B i j = A i j * B i j
def Matrix.«term_⊙_» E1 #
Lean.TrailingParserDescr
Matrix.hadamard (denoted as ⊙ within the Matrix namespace) defines the Hadamard product,
which is the pointwise product of two matrices of the same size.
theorem Matrix.hadamard_comm E1 #
∀ {α : Type u_1} {m : Type u_2} {n : Type u_3} (A B : Matrix m n α) [inst : CommMagma α], A.hadamard B = B.hadamard A
theorem Matrix.hadamard_assoc E1 #
∀ {α : Type u_1} {m : Type u_2} {n : Type u_3} (A B C : Matrix m n α) [inst : Semigroup α],
(A.hadamard B).hadamard C = A.hadamard (B.hadamard C)
theorem Matrix.hadamard_add E1 #
∀ {α : Type u_1} {m : Type u_2} {n : Type u_3} (A B C : Matrix m n α) [inst : Distrib α],
A.hadamard (B + C) = A.hadamard B + A.hadamard C
theorem Matrix.add_hadamard E1 #
∀ {α : Type u_1} {m : Type u_2} {n : Type u_3} (A B C : Matrix m n α) [inst : Distrib α],
(B + C).hadamard A = B.hadamard A + C.hadamard A
theorem Matrix.smul_hadamard E0 #
∀ {α : Type u_1} {m : Type u_2} {n : Type u_3} {R : Type u_4} (A B : Matrix m n α) [inst : Mul α] [inst_1 : SMul R α]
[IsScalarTower R α α] (k : R), (k • A).hadamard B = k • A.hadamard B
theorem Matrix.hadamard_smul E0 #
∀ {α : Type u_1} {m : Type u_2} {n : Type u_3} {R : Type u_4} (A B : Matrix m n α) [inst : Mul α] [inst_1 : SMul R α]
[SMulCommClass R α α] (k : R), A.hadamard (k • B) = k • A.hadamard B
theorem Matrix.hadamard_zero E0 #
∀ {α : Type u_1} {m : Type u_2} {n : Type u_3} (A : Matrix m n α) [inst : MulZeroClass α], A.hadamard 0 = 0
theorem Matrix.zero_hadamard E0 #
∀ {α : Type u_1} {m : Type u_2} {n : Type u_3} (A : Matrix m n α) [inst : MulZeroClass α], Matrix.hadamard 0 A = 0
theorem Matrix.hadamard_diagonal E1 #
∀ {α : Type u_1} {n : Type u_3} [inst : DecidableEq n] [inst_1 : MulZeroClass α] (M : Matrix n n α) (w : n → α),
M.hadamard (Matrix.diagonal w) = Matrix.diagonal (M.diag * w)
theorem Matrix.diagonal_hadamard E1 #
∀ {α : Type u_1} {n : Type u_3} [inst : DecidableEq n] [inst_1 : MulZeroClass α] (M : Matrix n n α) (w : n → α),
(Matrix.diagonal w).hadamard M = Matrix.diagonal (w * M.diag)
theorem Matrix.diagonal_hadamard_diagonal E1 #
∀ {α : Type u_1} {n : Type u_3} [inst : DecidableEq n] [inst_1 : MulZeroClass α] (v w : n → α),
(Matrix.diagonal v).hadamard (Matrix.diagonal w) = Matrix.diagonal (v * w)
theorem Matrix.diagonal_hadamard_eq_diagonal_iff E0 #
∀ {α : Type u_1} {n : Type u_3} [inst : DecidableEq n] [inst_1 : MulZeroClass α] {A : Matrix n n α} {d e : n → α},
(Matrix.diagonal d).hadamard A = Matrix.diagonal e ↔ d * A.diag = e
theorem Matrix.hadamard_diagonal_eq_diagonal_iff E0 #
∀ {α : Type u_1} {n : Type u_3} [inst : DecidableEq n] [inst_1 : MulZeroClass α] {A : Matrix n n α} {d e : n → α},
A.hadamard (Matrix.diagonal d) = Matrix.diagonal e ↔ A.diag * d = e
theorem Matrix.hadamard_one E1 #
∀ {α : Type u_1} {n : Type u_3} [inst : DecidableEq n] [inst_1 : MulZeroOneClass α] (M : Matrix n n α),
M.hadamard 1 = Matrix.diagonal M.diag
theorem Matrix.one_hadamard E1 #
∀ {α : Type u_1} {n : Type u_3} [inst : DecidableEq n] [inst_1 : MulZeroOneClass α] (M : Matrix n n α),
Matrix.hadamard 1 M = Matrix.diagonal M.diag
theorem Matrix.one_hadamard_eq_diagonal_iff E0 #
∀ {α : Type u_1} {n : Type u_3} [inst : DecidableEq n] [inst_1 : MulZeroOneClass α] {A : Matrix n n α} {d : n → α},
Matrix.hadamard 1 A = Matrix.diagonal d ↔ A.diag = d
theorem Matrix.hadamard_one_eq_diagonal_iff E0 #
∀ {α : Type u_1} {n : Type u_3} [inst : DecidableEq n] [inst_1 : MulZeroOneClass α] {A : Matrix n n α} {d : n → α},
A.hadamard 1 = Matrix.diagonal d ↔ A.diag = d
theorem Matrix.one_hadamard_eq_zero_iff E0 #
∀ {α : Type u_1} {n : Type u_3} [inst : DecidableEq n] [inst_1 : MulZeroOneClass α] {A : Matrix n n α},
Matrix.hadamard 1 A = 0 ↔ A.diag = 0
theorem Matrix.hadamard_one_eq_zero_iff E0 #
∀ {α : Type u_1} {n : Type u_3} [inst : DecidableEq n] [inst_1 : MulZeroOneClass α] {A : Matrix n n α},
A.hadamard 1 = 0 ↔ A.diag = 0
theorem Matrix.one_hadamard_eq_one_iff E0 #
∀ {α : Type u_1} {n : Type u_3} [inst : DecidableEq n] [inst_1 : MulZeroOneClass α] {A : Matrix n n α},
Matrix.hadamard 1 A = 1 ↔ A.diag = 1
theorem Matrix.hadamard_one_eq_one_iff E0 #
∀ {α : Type u_1} {n : Type u_3} [inst : DecidableEq n] [inst_1 : MulZeroOneClass α] {A : Matrix n n α},
A.hadamard 1 = 1 ↔ A.diag = 1
theorem Matrix.hadamard_of_one E0 #
∀ {α : Type u_1} {m : Type u_2} {n : Type u_3} [inst : MulOneClass α] (A : Matrix m n α), A.hadamard (Matrix.of 1) = A
theorem Matrix.of_one_hadamard E0 #
∀ {α : Type u_1} {m : Type u_2} {n : Type u_3} [inst : MulOneClass α] (A : Matrix m n α), (Matrix.of 1).hadamard A = A
theorem Matrix.hadamard_self_eq_self_iff E0 #
∀ {α : Type u_1} {m : Type u_2} {n : Type u_3} [inst : Mul α] {A : Matrix m n α},
A.hadamard A = A ↔ ∀ (i : m) (j : n), IsIdempotentElem (A i j)
theorem Matrix.submatrix_hadamard E1 #
∀ {α : Type u_1} {m : Type u_2} {n : Type u_3} {l : Type u_5} {o : Type u_6} [inst : Mul α] (A B : Matrix m n α)
(e : l → m) (f : o → n), (A.hadamard B).submatrix e f = (A.submatrix e f).hadamard (B.submatrix e f)
theorem Matrix.transpose_hadamard E1 #
∀ {α : Type u_1} {m : Type u_2} {n : Type u_3} [inst : Mul α] (A B : Matrix m n α),
(A.hadamard B).transpose = A.transpose.hadamard B.transpose
theorem Matrix.conjTranspose_hadamard E1 #
∀ {α : Type u_1} {m : Type u_2} {n : Type u_3} [inst : Mul α] [inst_1 : StarMul α] (A B : Matrix m n α),
(A.hadamard B).conjTranspose = B.conjTranspose.hadamard A.conjTranspose
theorem Matrix.single_hadamard_single_eq E0 #
∀ {α : Type u_1} {m : Type u_2} {n : Type u_3} [inst : DecidableEq m] [inst_1 : DecidableEq n] [inst_2 : MulZeroClass α]
(i : m) (j : n) (a b : α), (Matrix.single i j a).hadamard (Matrix.single i j b) = Matrix.single i j (a * b)
theorem Matrix.single_hadamard_single_of_ne E1 #
∀ {α : Type u_1} {m : Type u_2} {n : Type u_3} [inst : DecidableEq m] [inst_1 : DecidableEq n] [inst_2 : MulZeroClass α]
{ia : m} {ja : n} {ib : m} {jb : n},
¬(ia = ib ∧ ja = jb) → ∀ (a b : α), (Matrix.single ia ja a).hadamard (Matrix.single ib jb b) = 0
theorem Matrix.sum_hadamard_eq E0 #
∀ {α : Type u_1} {m : Type u_2} {n : Type u_3} (A B : Matrix m n α) [inst : Fintype m] [inst_1 : Fintype n]
[inst_2 : NonUnitalSemiring α], ∑ i, ∑ j, A.hadamard B i j = (A * B.transpose).trace
theorem Matrix.dotProduct_vecMul_hadamard E1 #
∀ {α : Type u_1} {m : Type u_2} {n : Type u_3} (A B : Matrix m n α) [inst : Fintype m] [inst_1 : Fintype n]
[inst_2 : NonUnitalSemiring α] [inst_3 : DecidableEq m] [inst_4 : DecidableEq n] (v : m → α) (w : n → α),
Matrix.vecMul v (A.hadamard B) ⬝ᵥ w = (Matrix.diagonal v * A * (B * Matrix.diagonal w).transpose).trace