Row and column matrices #
This file provides results about row and column matrices.
Main definitions #
Matrix.replicateRow ι r : Matrix ι n α: the matrix where every row is the vectorr : n → αMatrix.replicateCol ι c : Matrix m ι α: the matrix where every column is the vectorc : m → αMatrix.updateRow M i r: update theith row ofMtorMatrix.updateCol M j c: update thejth column ofMtoc
Matrix.replicateCol ι u is the matrix with all columns equal to the vector u.
To get a column matrix with exactly one column,
Matrix.replicateCol (Fin 1) u is the canonical choice.
Instances For
@[simp]
theorem
Matrix.replicateCol_apply
{m : Type u_2}
{α : Type v}
{ι : Type u_6}
(w : m → α)
(i : m)
(j : ι)
:
replicateCol ι w i j = w i
Matrix.replicateRow ι u is the matrix with all rows equal to the vector u.
To get a row matrix with exactly one row, Matrix.replicateRow (Fin 1) u is the canonical choice.
Instances For
@[simp]
theorem
Matrix.replicateRow_apply
{n : Type u_3}
{α : Type v}
{ι : Type u_6}
(v : n → α)
(i : ι)
(j : n)
:
replicateRow ι v i j = v j
@[simp]
theorem
Matrix.vecMulVec_one
{m : Type u_2}
{n : Type u_3}
{R : Type u_5}
[MulOneClass R]
(x : n → R)
:
vecMulVec x 1 = replicateCol m x
@[simp]
theorem
Matrix.one_vecMulVec
{m : Type u_2}
{n : Type u_3}
{R : Type u_5}
[MulOneClass R]
(x : n → R)
:
vecMulVec 1 x = replicateRow m x
theorem
Matrix.replicateCol_injective
{m : Type u_2}
{α : Type v}
{ι : Type u_6}
[Nonempty ι]
:
Function.Injective (replicateCol ι)
@[simp]
theorem
Matrix.replicateCol_inj
{m : Type u_2}
{α : Type v}
{ι : Type u_6}
[Nonempty ι]
{v w : m → α}
:
replicateCol ι v = replicateCol ι w ↔ v = w
@[simp]
theorem
Matrix.replicateCol_zero
{m : Type u_2}
{α : Type v}
{ι : Type u_6}
[Zero α]
:
replicateCol ι 0 = 0
@[simp]
theorem
Matrix.replicateCol_eq_zero
{m : Type u_2}
{α : Type v}
{ι : Type u_6}
[Zero α]
[Nonempty ι]
(v : m → α)
:
replicateCol ι v = 0 ↔ v = 0
@[simp]
theorem
Matrix.replicateCol_add
{m : Type u_2}
{α : Type v}
{ι : Type u_6}
[Add α]
(v w : m → α)
:
replicateCol ι (v + w) = replicateCol ι v + replicateCol ι w
@[simp]
theorem
Matrix.replicateCol_smul
{m : Type u_2}
{R : Type u_5}
{α : Type v}
{ι : Type u_6}
[SMul R α]
(x : R)
(v : m → α)
:
replicateCol ι (x • v) = x • replicateCol ι v
theorem
Matrix.replicateRow_injective
{n : Type u_3}
{α : Type v}
{ι : Type u_6}
[Nonempty ι]
:
Function.Injective (replicateRow ι)
@[simp]
theorem
Matrix.replicateRow_inj
{n : Type u_3}
{α : Type v}
{ι : Type u_6}
[Nonempty ι]
{v w : n → α}
:
replicateRow ι v = replicateRow ι w ↔ v = w
@[simp]
theorem
Matrix.replicateRow_zero
{n : Type u_3}
{α : Type v}
{ι : Type u_6}
[Zero α]
:
replicateRow ι 0 = 0
@[simp]
theorem
Matrix.replicateRow_eq_zero
{n : Type u_3}
{α : Type v}
{ι : Type u_6}
[Zero α]
[Nonempty ι]
(v : n → α)
:
replicateRow ι v = 0 ↔ v = 0
@[simp]
theorem
Matrix.replicateRow_add
{m : Type u_2}
{α : Type v}
{ι : Type u_6}
[Add α]
(v w : m → α)
:
replicateRow ι (v + w) = replicateRow ι v + replicateRow ι w
@[simp]
theorem
Matrix.replicateRow_smul
{m : Type u_2}
{R : Type u_5}
{α : Type v}
{ι : Type u_6}
[SMul R α]
(x : R)
(v : m → α)
:
replicateRow ι (x • v) = x • replicateRow ι v
@[simp]
theorem
Matrix.transpose_replicateCol
{m : Type u_2}
{α : Type v}
{ι : Type u_6}
(v : m → α)
:
(replicateCol ι v).transpose = replicateRow ι v
@[simp]
theorem
Matrix.transpose_replicateRow
{m : Type u_2}
{α : Type v}
{ι : Type u_6}
(v : m → α)
:
(replicateRow ι v).transpose = replicateCol ι v
@[simp]
theorem
Matrix.conjTranspose_replicateCol
{m : Type u_2}
{α : Type v}
{ι : Type u_6}
[Star α]
(v : m → α)
:
(replicateCol ι v).conjTranspose = replicateRow ι (star v)
@[simp]
theorem
Matrix.conjTranspose_replicateRow
{m : Type u_2}
{α : Type v}
{ι : Type u_6}
[Star α]
(v : m → α)
:
(replicateRow ι v).conjTranspose = replicateCol ι (star v)
theorem
Matrix.replicateRow_vecMul
{m : Type u_2}
{n : Type u_3}
{α : Type v}
{ι : Type u_6}
[Fintype m]
[NonUnitalNonAssocSemiring α]
(M : Matrix m n α)
(v : m → α)
:
replicateRow ι (vecMul v M) = replicateRow ι v * M
v ᵥ* M is the vector whose entries are those of replicateRow ι v * M.
theorem
Matrix.replicateCol_vecMul
{m : Type u_2}
{n : Type u_3}
{α : Type v}
{ι : Type u_6}
[Fintype m]
[NonUnitalNonAssocSemiring α]
(M : Matrix m n α)
(v : m → α)
:
replicateCol ι (vecMul v M) = (replicateRow ι v * M).transpose
theorem
Matrix.replicateCol_mulVec
{m : Type u_2}
{n : Type u_3}
{α : Type v}
{ι : Type u_6}
[Fintype n]
[NonUnitalNonAssocSemiring α]
(M : Matrix m n α)
(v : n → α)
:
replicateCol ι (M.mulVec v) = M * replicateCol ι v
M *ᵥ v is the vector whose entries are those of M * replicateCol ι v.
theorem
Matrix.replicateRow_mulVec
{m : Type u_2}
{n : Type u_3}
{α : Type v}
{ι : Type u_6}
[Fintype n]
[NonUnitalNonAssocSemiring α]
(M : Matrix m n α)
(v : n → α)
:
replicateRow ι (M.mulVec v) = (M * replicateCol ι v).transpose
theorem
Matrix.replicateRow_mulVec_eq_const
{m : Type u_2}
{α : Type v}
{ι : Type u_6}
[Fintype m]
[NonUnitalNonAssocSemiring α]
(v w : m → α)
:
(replicateRow ι v).mulVec w = Function.const ι (v ⬝ᵥ w)
theorem
Matrix.mulVec_replicateCol_eq_const
{m : Type u_2}
{α : Type v}
{ι : Type u_6}
[Fintype m]
[NonUnitalNonAssocSemiring α]
(v w : m → α)
:
vecMul v (replicateCol ι w) = Function.const ι (v ⬝ᵥ w)
theorem
Matrix.replicateRow_mul_replicateCol
{m : Type u_2}
{α : Type v}
{ι : Type u_6}
[Fintype m]
[Mul α]
[AddCommMonoid α]
(v w : m → α)
:
replicateRow ι v * replicateCol ι w = of fun (x x_1 : ι) => v ⬝ᵥ w
@[simp]
theorem
Matrix.replicateRow_mul_replicateCol_apply
{m : Type u_2}
{α : Type v}
{ι : Type u_6}
[Fintype m]
[Mul α]
[AddCommMonoid α]
(v w : m → α)
(i j : ι)
:
(replicateRow ι v * replicateCol ι w) i j = v ⬝ᵥ w
@[simp]
theorem
Matrix.diag_replicateCol_mul_replicateRow
{n : Type u_3}
{α : Type v}
{ι : Type u_6}
[Mul α]
[AddCommMonoid α]
[Unique ι]
(a b : n → α)
:
(replicateCol ι a * replicateRow ι b).diag = a * b
theorem
Matrix.vecMulVec_eq
{m : Type u_2}
{n : Type u_3}
{α : Type v}
(ι : Type u_6)
[Mul α]
[AddCommMonoid α]
[Unique ι]
(w : m → α)
(v : n → α)
:
vecMulVec w v = replicateCol ι w * replicateRow ι v
Updating rows and columns #
@[simp]
@[simp]
@[simp]
@[simp]
@[simp]
theorem
Matrix.updateCol_subsingleton
{m : Type u_2}
{n : Type u_3}
{R : Type u_5}
[Subsingleton n]
(A : Matrix m n R)
(i : n)
(b : m → R)
:
A.updateCol i b = (replicateCol (Fin 1) b).submatrix id (Function.const n 0)
@[simp]
theorem
Matrix.updateRow_subsingleton
{m : Type u_2}
{n : Type u_3}
{R : Type u_5}
[Subsingleton m]
(A : Matrix m n R)
(i : m)
(b : n → R)
:
A.updateRow i b = (replicateRow (Fin 1) b).submatrix (Function.const m 0) id
theorem
Matrix.updateRow_conjTranspose
{m : Type u_2}
{n : Type u_3}
{α : Type v}
{M : Matrix m n α}
{j : n}
{c : m → α}
[DecidableEq n]
[Star α]
:
M.conjTranspose.updateRow j (star c) = (M.updateCol j c).conjTranspose
theorem
Matrix.updateCol_conjTranspose
{m : Type u_2}
{n : Type u_3}
{α : Type v}
{M : Matrix m n α}
{i : m}
{b : n → α}
[DecidableEq m]
[Star α]
:
M.conjTranspose.updateCol i (star b) = (M.updateRow i b).conjTranspose
@[simp]
@[simp]
@[simp]
theorem
Matrix.updateRow_zero_zero
{m : Type u_2}
{n : Type u_3}
{α : Type v}
[DecidableEq m]
[Zero α]
(i : m)
:
updateRow 0 i 0 = 0
@[simp]
theorem
Matrix.updateCol_zero_zero
{m : Type u_2}
{n : Type u_3}
{α : Type v}
[DecidableEq n]
[Zero α]
(i : n)
:
updateCol 0 i 0 = 0
theorem
Matrix.diagonal_updateCol_single
{n : Type u_3}
{α : Type v}
[DecidableEq n]
[Zero α]
(v : n → α)
(i : n)
(x : α)
:
(diagonal v).updateCol i (Pi.single i x) = diagonal (Function.update v i x)
theorem
Matrix.diagonal_updateRow_single
{n : Type u_3}
{α : Type v}
[DecidableEq n]
[Zero α]
(v : n → α)
(i : n)
(x : α)
:
(diagonal v).updateRow i (Pi.single i x) = diagonal (Function.update v i x)
@[simp]
@[simp]
Updating rows and columns commutes in the obvious way with reindexing the matrix.
reindex versions of the above submatrix lemmas for convenience.
theorem
Matrix.updateRow_mulVec
{l : Type u_1}
{m : Type u_2}
{α : Type v}
[DecidableEq l]
[Fintype m]
[NonUnitalNonAssocSemiring α]
(A : Matrix l m α)
(i : l)
(c v : m → α)
:
(A.updateRow i c).mulVec v = Function.update (A.mulVec v) i (c ⬝ᵥ v)
theorem
Matrix.vecMul_updateCol
{m : Type u_2}
{n : Type u_3}
{α : Type v}
[DecidableEq n]
[Fintype m]
[NonUnitalNonAssocSemiring α]
(v : m → α)
(B : Matrix m n α)
(j : n)
(r : m → α)
:
vecMul v (B.updateCol j r) = Function.update (vecMul v B) j (v ⬝ᵥ r)
theorem
Matrix.update_vecMulVec
{m : Type u_2}
{n : Type u_3}
{α : Type v}
[DecidableEq m]
[Mul α]
(u : m → α)
(v : n → α)
(i : m)
(a : α)
:
vecMulVec (Function.update u i a) v = (vecMulVec u v).updateRow i (a • v)
theorem
Matrix.vecMulVec_update
{m : Type u_2}
{n : Type u_3}
{α : Type v}
[DecidableEq n]
[Mul α]
(u : m → α)
(v : n → α)
(j : n)
(a : α)
:
vecMulVec u (Function.update v j a) = (vecMulVec u v).updateCol j (MulOpposite.op a • u)
theorem
Matrix.mul_single_eq_updateCol_zero
{l : Type u_1}
{m : Type u_2}
{n : Type u_3}
{α : Type v}
[DecidableEq m]
[DecidableEq n]
[Fintype m]
[NonUnitalNonAssocSemiring α]
(A : Matrix l m α)
(i : m)
(j : n)
(r : α)
:
A * single i j r = updateCol 0 j (MulOpposite.op r • A.col i)
@[simp]