Trace of a matrix #
THIS FILE IS SYNCHRONIZED WITH MATHLIB4. Any changes to this file require a corresponding PR to mathlib4.
This file defines the trace of a matrix, the map sending a matrix to the sum of its diagonal entries.
See also linear_algebra.trace
for the trace of an endomorphism.
Tags #
matrix, trace, diagonal
def
matrix.trace
{n : Type u_3}
{R : Type u_6}
[fintype n]
[add_comm_monoid R]
(A : matrix n n R) :
R
The trace of a square matrix. For more bundled versions, see:
Equations
- A.trace = finset.univ.sum (λ (i : n), A.diag i)
@[simp]
@[simp]
theorem
matrix.trace_smul
{n : Type u_3}
{α : Type u_5}
{R : Type u_6}
[fintype n]
[add_comm_monoid R]
[monoid α]
[distrib_mul_action α R]
(r : α)
(A : matrix n n R) :
@[simp]
theorem
matrix.trace_conj_transpose
{n : Type u_3}
{R : Type u_6}
[fintype n]
[add_comm_monoid R]
[star_add_monoid R]
(A : matrix n n R) :
matrix.trace
as an add_monoid_hom
Equations
- matrix.trace_add_monoid_hom n R = {to_fun := matrix.trace _inst_4, map_zero' := _, map_add' := _}
@[simp]
theorem
matrix.trace_add_monoid_hom_apply
(n : Type u_3)
(R : Type u_6)
[fintype n]
[add_comm_monoid R]
(A : matrix n n R) :
⇑(matrix.trace_add_monoid_hom n R) A = A.trace
@[simp]
theorem
matrix.trace_linear_map_apply
(n : Type u_3)
(α : Type u_5)
(R : Type u_6)
[fintype n]
[add_comm_monoid R]
[semiring α]
[module α R]
(A : matrix n n R) :
⇑(matrix.trace_linear_map n α R) A = A.trace
def
matrix.trace_linear_map
(n : Type u_3)
(α : Type u_5)
(R : Type u_6)
[fintype n]
[add_comm_monoid R]
[semiring α]
[module α R] :
matrix.trace
as a linear_map
Equations
- matrix.trace_linear_map n α R = {to_fun := matrix.trace _inst_4, map_add' := _, map_smul' := _}
@[simp]
theorem
matrix.trace_list_sum
{n : Type u_3}
{R : Type u_6}
[fintype n]
[add_comm_monoid R]
(l : list (matrix n n R)) :
@[simp]
theorem
matrix.trace_multiset_sum
{n : Type u_3}
{R : Type u_6}
[fintype n]
[add_comm_monoid R]
(s : multiset (matrix n n R)) :
s.sum.trace = (multiset.map matrix.trace s).sum
@[simp]
theorem
matrix.trace_one
{n : Type u_3}
{R : Type u_6}
[fintype n]
[decidable_eq n]
[add_comm_monoid_with_one R] :
1.trace = ↑(fintype.card n)
@[simp]
theorem
matrix.trace_col_mul_row
{n : Type u_3}
{R : Type u_6}
[fintype n]
[non_unital_non_assoc_semiring R]
(a b : n → R) :
((matrix.col a).mul (matrix.row b)).trace = matrix.dot_product a b
Special cases for fin n
#
While simp [fin.sum_univ_succ]
can prove these, we include them for convenience and consistency
with matrix.det_fin_two
etc.
@[simp]