HepLean Documentation

Mathlib.Data.Matrix.Diagonal

Diagonal matrices #

This file defines diagonal matrices and the AddCommMonoidWithOne structure on matrices.

Main definitions #

def Matrix.diagonal {n : Type u_3} {α : Type v} [DecidableEq n] [Zero α] (d : nα) :
Matrix n n α

diagonal d is the square matrix such that (diagonal d) i i = d i and (diagonal d) i j = 0 if i ≠ j.

Note that bundled versions exist as:

  • Matrix.diagonalAddMonoidHom
  • Matrix.diagonalLinearMap
  • Matrix.diagonalRingHom
  • Matrix.diagonalAlgHom
Equations
Instances For
    theorem Matrix.diagonal_apply {n : Type u_3} {α : Type v} [DecidableEq n] [Zero α] (d : nα) (i j : n) :
    Matrix.diagonal d i j = if i = j then d i else 0
    @[simp]
    theorem Matrix.diagonal_apply_eq {n : Type u_3} {α : Type v} [DecidableEq n] [Zero α] (d : nα) (i : n) :
    Matrix.diagonal d i i = d i
    @[simp]
    theorem Matrix.diagonal_apply_ne {n : Type u_3} {α : Type v} [DecidableEq n] [Zero α] (d : nα) {i j : n} (h : i j) :
    theorem Matrix.diagonal_apply_ne' {n : Type u_3} {α : Type v} [DecidableEq n] [Zero α] (d : nα) {i j : n} (h : j i) :
    @[simp]
    theorem Matrix.diagonal_eq_diagonal_iff {n : Type u_3} {α : Type v} [DecidableEq n] [Zero α] {d₁ d₂ : nα} :
    Matrix.diagonal d₁ = Matrix.diagonal d₂ ∀ (i : n), d₁ i = d₂ i
    theorem Matrix.diagonal_injective {n : Type u_3} {α : Type v} [DecidableEq n] [Zero α] :
    Function.Injective Matrix.diagonal
    @[simp]
    theorem Matrix.diagonal_zero {n : Type u_3} {α : Type v} [DecidableEq n] [Zero α] :
    (Matrix.diagonal fun (x : n) => 0) = 0
    @[simp]
    theorem Matrix.diagonal_transpose {n : Type u_3} {α : Type v} [DecidableEq n] [Zero α] (v : nα) :
    @[simp]
    theorem Matrix.diagonal_add {n : Type u_3} {α : Type v} [DecidableEq n] [AddZeroClass α] (d₁ d₂ : nα) :
    Matrix.diagonal d₁ + Matrix.diagonal d₂ = Matrix.diagonal fun (i : n) => d₁ i + d₂ i
    @[simp]
    theorem Matrix.diagonal_smul {n : Type u_3} {R : Type u_7} {α : Type v} [DecidableEq n] [Zero α] [SMulZeroClass R α] (r : R) (d : nα) :
    @[simp]
    theorem Matrix.diagonal_neg {n : Type u_3} {α : Type v} [DecidableEq n] [NegZeroClass α] (d : nα) :
    -Matrix.diagonal d = Matrix.diagonal fun (i : n) => -d i
    @[simp]
    theorem Matrix.diagonal_sub {n : Type u_3} {α : Type v} [DecidableEq n] [SubNegZeroMonoid α] (d₁ d₂ : nα) :
    Matrix.diagonal d₁ - Matrix.diagonal d₂ = Matrix.diagonal fun (i : n) => d₁ i - d₂ i
    instance Matrix.instNatCastOfZero {n : Type u_3} {α : Type v} [DecidableEq n] [Zero α] [NatCast α] :
    NatCast (Matrix n n α)
    Equations
    theorem Matrix.diagonal_natCast {n : Type u_3} {α : Type v} [DecidableEq n] [Zero α] [NatCast α] (m : ) :
    (Matrix.diagonal fun (x : n) => m) = m
    theorem Matrix.diagonal_natCast' {n : Type u_3} {α : Type v} [DecidableEq n] [Zero α] [NatCast α] (m : ) :
    Matrix.diagonal m = m
    theorem Matrix.diagonal_ofNat {n : Type u_3} {α : Type v} [DecidableEq n] [Zero α] [NatCast α] (m : ) [m.AtLeastTwo] :
    theorem Matrix.diagonal_ofNat' {n : Type u_3} {α : Type v} [DecidableEq n] [Zero α] [NatCast α] (m : ) [m.AtLeastTwo] :
    instance Matrix.instIntCastOfZero {n : Type u_3} {α : Type v} [DecidableEq n] [Zero α] [IntCast α] :
    IntCast (Matrix n n α)
    Equations
    theorem Matrix.diagonal_intCast {n : Type u_3} {α : Type v} [DecidableEq n] [Zero α] [IntCast α] (m : ) :
    (Matrix.diagonal fun (x : n) => m) = m
    theorem Matrix.diagonal_intCast' {n : Type u_3} {α : Type v} [DecidableEq n] [Zero α] [IntCast α] (m : ) :
    Matrix.diagonal m = m
    @[simp]
    theorem Matrix.diagonal_map {n : Type u_3} {α : Type v} {β : Type w} [DecidableEq n] [Zero α] [Zero β] {f : αβ} (h : f 0 = 0) {d : nα} :
    (Matrix.diagonal d).map f = Matrix.diagonal fun (m : n) => f (d m)
    theorem Matrix.map_natCast {n : Type u_3} {α : Type v} {β : Type w} [DecidableEq n] [AddMonoidWithOne α] [AddMonoidWithOne β] {f : αβ} (h : f 0 = 0) (d : ) :
    (↑d).map f = Matrix.diagonal fun (x : n) => f d
    theorem Matrix.map_ofNat {n : Type u_3} {α : Type v} {β : Type w} [DecidableEq n] [AddMonoidWithOne α] [AddMonoidWithOne β] {f : αβ} (h : f 0 = 0) (d : ) [d.AtLeastTwo] :
    (OfNat.ofNat d).map f = Matrix.diagonal fun (x : n) => f (OfNat.ofNat d)
    theorem Matrix.map_intCast {n : Type u_3} {α : Type v} {β : Type w} [DecidableEq n] [AddGroupWithOne α] [AddGroupWithOne β] {f : αβ} (h : f 0 = 0) (d : ) :
    (↑d).map f = Matrix.diagonal fun (x : n) => f d
    theorem Matrix.diagonal_unique {m : Type u_2} {α : Type v} [Unique m] [DecidableEq m] [Zero α] (d : mα) :
    Matrix.diagonal d = Matrix.of fun (x x : m) => d default
    instance Matrix.one {n : Type u_3} {α : Type v} [DecidableEq n] [Zero α] [One α] :
    One (Matrix n n α)
    Equations
    @[simp]
    theorem Matrix.diagonal_one {n : Type u_3} {α : Type v} [DecidableEq n] [Zero α] [One α] :
    (Matrix.diagonal fun (x : n) => 1) = 1
    theorem Matrix.one_apply {n : Type u_3} {α : Type v} [DecidableEq n] [Zero α] [One α] {i j : n} :
    1 i j = if i = j then 1 else 0
    @[simp]
    theorem Matrix.one_apply_eq {n : Type u_3} {α : Type v} [DecidableEq n] [Zero α] [One α] (i : n) :
    1 i i = 1
    @[simp]
    theorem Matrix.one_apply_ne {n : Type u_3} {α : Type v} [DecidableEq n] [Zero α] [One α] {i j : n} :
    i j1 i j = 0
    theorem Matrix.one_apply_ne' {n : Type u_3} {α : Type v} [DecidableEq n] [Zero α] [One α] {i j : n} :
    j i1 i j = 0
    @[simp]
    theorem Matrix.map_one {n : Type u_3} {α : Type v} {β : Type w} [DecidableEq n] [Zero α] [One α] [Zero β] [One β] (f : αβ) (h₀ : f 0 = 0) (h₁ : f 1 = 1) :
    theorem Matrix.one_eq_pi_single {n : Type u_3} {α : Type v} [DecidableEq n] [Zero α] [One α] {i j : n} :
    1 i j = Pi.single i 1 j
    Equations
    Equations
    Equations
    Equations
    def Matrix.diag {n : Type u_3} {α : Type v} (A : Matrix n n α) (i : n) :
    α

    The diagonal of a square matrix.

    Equations
    • A.diag i = A i i
    Instances For
      @[simp]
      theorem Matrix.diag_apply {n : Type u_3} {α : Type v} (A : Matrix n n α) (i : n) :
      A.diag i = A i i
      @[simp]
      theorem Matrix.diag_diagonal {n : Type u_3} {α : Type v} [DecidableEq n] [Zero α] (a : nα) :
      (Matrix.diagonal a).diag = a
      @[simp]
      theorem Matrix.diag_transpose {n : Type u_3} {α : Type v} (A : Matrix n n α) :
      A.transpose.diag = A.diag
      @[simp]
      theorem Matrix.diag_zero {n : Type u_3} {α : Type v} [Zero α] :
      @[simp]
      theorem Matrix.diag_add {n : Type u_3} {α : Type v} [Add α] (A B : Matrix n n α) :
      (A + B).diag = A.diag + B.diag
      @[simp]
      theorem Matrix.diag_sub {n : Type u_3} {α : Type v} [Sub α] (A B : Matrix n n α) :
      (A - B).diag = A.diag - B.diag
      @[simp]
      theorem Matrix.diag_neg {n : Type u_3} {α : Type v} [Neg α] (A : Matrix n n α) :
      (-A).diag = -A.diag
      @[simp]
      theorem Matrix.diag_smul {n : Type u_3} {R : Type u_7} {α : Type v} [SMul R α] (r : R) (A : Matrix n n α) :
      (r A).diag = r A.diag
      @[simp]
      theorem Matrix.diag_one {n : Type u_3} {α : Type v} [DecidableEq n] [Zero α] [One α] :
      theorem Matrix.diag_map {n : Type u_3} {α : Type v} {β : Type w} {f : αβ} {A : Matrix n n α} :
      (A.map f).diag = f A.diag
      @[simp]
      theorem Matrix.transpose_eq_diagonal {n : Type u_3} {α : Type v} [DecidableEq n] [Zero α] {M : Matrix n n α} {v : nα} :
      @[simp]
      theorem Matrix.transpose_one {n : Type u_3} {α : Type v} [DecidableEq n] [Zero α] [One α] :
      @[simp]
      theorem Matrix.transpose_eq_one {n : Type u_3} {α : Type v} [DecidableEq n] [Zero α] [One α] {M : Matrix n n α} :
      M.transpose = 1 M = 1
      @[simp]
      theorem Matrix.transpose_natCast {n : Type u_3} {α : Type v} [DecidableEq n] [AddMonoidWithOne α] (d : ) :
      (↑d).transpose = d
      @[simp]
      theorem Matrix.transpose_eq_natCast {n : Type u_3} {α : Type v} [DecidableEq n] [AddMonoidWithOne α] {M : Matrix n n α} {d : } :
      M.transpose = d M = d
      @[simp]
      theorem Matrix.transpose_ofNat {n : Type u_3} {α : Type v} [DecidableEq n] [AddMonoidWithOne α] (d : ) [d.AtLeastTwo] :
      (OfNat.ofNat d).transpose = OfNat.ofNat d
      @[simp]
      theorem Matrix.transpose_eq_ofNat {n : Type u_3} {α : Type v} [DecidableEq n] [AddMonoidWithOne α] {M : Matrix n n α} {d : } [d.AtLeastTwo] :
      M.transpose = OfNat.ofNat d M = OfNat.ofNat d
      @[simp]
      theorem Matrix.transpose_intCast {n : Type u_3} {α : Type v} [DecidableEq n] [AddGroupWithOne α] (d : ) :
      (↑d).transpose = d
      @[simp]
      theorem Matrix.transpose_eq_intCast {n : Type u_3} {α : Type v} [DecidableEq n] [AddGroupWithOne α] {M : Matrix n n α} {d : } :
      M.transpose = d M = d
      theorem Matrix.submatrix_diagonal {l : Type u_1} {m : Type u_2} {α : Type v} [Zero α] [DecidableEq m] [DecidableEq l] (d : mα) (e : lm) (he : Function.Injective e) :
      (Matrix.diagonal d).submatrix e e = Matrix.diagonal (d e)

      Given a (m × m) diagonal matrix defined by a map d : m → α, if the reindexing map e is injective, then the resulting matrix is again diagonal.

      theorem Matrix.submatrix_one {l : Type u_1} {m : Type u_2} {α : Type v} [Zero α] [One α] [DecidableEq m] [DecidableEq l] (e : lm) (he : Function.Injective e) :
      theorem Matrix.diag_submatrix {l : Type u_1} {m : Type u_2} {α : Type v} (A : Matrix m m α) (e : lm) :
      (A.submatrix e e).diag = A.diag e

      simp lemmas for Matrix.submatrixs interaction with Matrix.diagonal, 1, and Matrix.mul for when the mappings are bundled.

      @[simp]
      theorem Matrix.submatrix_diagonal_embedding {l : Type u_1} {m : Type u_2} {α : Type v} [Zero α] [DecidableEq m] [DecidableEq l] (d : mα) (e : l m) :
      (Matrix.diagonal d).submatrix e e = Matrix.diagonal (d e)
      @[simp]
      theorem Matrix.submatrix_diagonal_equiv {l : Type u_1} {m : Type u_2} {α : Type v} [Zero α] [DecidableEq m] [DecidableEq l] (d : mα) (e : l m) :
      (Matrix.diagonal d).submatrix e e = Matrix.diagonal (d e)
      @[simp]
      theorem Matrix.submatrix_one_embedding {l : Type u_1} {m : Type u_2} {α : Type v} [Zero α] [One α] [DecidableEq m] [DecidableEq l] (e : l m) :
      Matrix.submatrix 1 e e = 1
      @[simp]
      theorem Matrix.submatrix_one_equiv {l : Type u_1} {m : Type u_2} {α : Type v} [Zero α] [One α] [DecidableEq m] [DecidableEq l] (e : l m) :
      Matrix.submatrix 1 e e = 1