Matrix multiplication #
This file defines vector and matrix multiplication
Main definitions #
dotProduct: the dot product between two vectorsMatrix.mul: multiplication of two matricesMatrix.mulVec: multiplication of a matrix with a vectorMatrix.vecMul: multiplication of a vector with a matrixMatrix.vecMulVec: multiplication of a vector with a vector to get a matrixMatrix.instRing: square matrices form a ring
Notation #
The scope Matrix gives the following notation:
⬝ᵥfordotProduct*ᵥforMatrix.mulVecᵥ*forMatrix.vecMul
See Mathlib/LinearAlgebra/Matrix/ConjTranspose.lean for
ᴴforMatrix.conjTranspose
Implementation notes #
For convenience, Matrix m n α is defined as m → n → α, as this allows elements of the matrix
to be accessed with A i j. However, it is not advisable to construct matrices using terms of the
form fun i j ↦ _ or even (fun i j ↦ _ : Matrix m n α), as these are not recognized by Lean
as having the right type. Instead, Matrix.of should be used.
TODO #
Under various conditions, multiplication of infinite matrices makes sense. These have not yet been implemented.
dotProduct v w is the sum of the entrywise products v i * w i.
This is available in bundled forms as:
Instances For
dotProduct v w is the sum of the entrywise products v i * w i.
This is available in bundled forms as:
Equations
- «term_⬝ᵥ_» = Lean.ParserDescr.trailingNode `«term_⬝ᵥ_» 72 72 (Lean.ParserDescr.binary `andthen (Lean.ParserDescr.symbol " ⬝ᵥ ") (Lean.ParserDescr.cat `term 73))
Instances For
Extending the left argument with zeros is the same as slicing the right argument.
Extending the right argument with zeros is the same as slicing the left argument.
For any vector a in a nontrivial commutative ring with nontrivial index,
there exists a non-zero vector b such that b ⬝ᵥ a = 0. In other words,
there exists a non-zero orthogonal vector.
M * N is the usual product of matrices M and N, i.e. we have that
(M * N) i k is the dot product of the i-th row of M by the k-th column of N.
This is currently only defined when m is finite.
This is available in bundled forms as:
Equations
Equations
- One or more equations did not get rendered due to their size.
Left multiplication by a matrix, as an AddMonoidHom from matrices to matrices.
Equations
Instances For
Right multiplication by a matrix, as an AddMonoidHom from matrices to matrices.
Equations
Instances For
This instance enables use with smul_mul_assoc.
This instance enables use with mul_smul_comm.
Equations
- One or more equations did not get rendered due to their size.
Equations
- Matrix.nonUnitalSemiring = let __src := Matrix.nonUnitalNonAssocSemiring; { toNonUnitalNonAssocSemiring := __src, mul_assoc := ⋯ }
Equations
- One or more equations did not get rendered due to their size.
Equations
- One or more equations did not get rendered due to their size.
Equations
- One or more equations did not get rendered due to their size.
Equations
- One or more equations did not get rendered due to their size.
Equations
- One or more equations did not get rendered due to their size.
A semiring is stably finite if every matrix ring over it is Dedekind-finite.
- isDedekindFiniteMonoid (n : ℕ) : IsDedekindFiniteMonoid (Matrix (Fin n) (Fin n) R)
Instances
For two vectors w and v, vecMulVec w v i j is defined to be w i * v j.
Put another way, vecMulVec w v is exactly replicateCol ι w * replicateRow ι v for
Unique ι; see vecMulVec_eq.
This is available in a bundled form as vecMulVecBilin.
Equations
- Matrix.vecMulVec w v = Matrix.of fun (x : m) (y : n) => w x * v y
Instances For
M *ᵥ v (notation for mulVec M v) is the matrix-vector product of matrix M and vector v,
where v is seen as a column vector.
The notation has precedence 73, which comes immediately before ⬝ᵥ for dotProduct,
so that A *ᵥ v ⬝ᵥ B *ᵥ w is parsed as (A *ᵥ v) ⬝ᵥ (B *ᵥ w).
This is available in bundled forms as:
Instances For
M *ᵥ v (notation for mulVec M v) is the matrix-vector product of matrix M and vector v,
where v is seen as a column vector.
The notation has precedence 73, which comes immediately before ⬝ᵥ for dotProduct,
so that A *ᵥ v ⬝ᵥ B *ᵥ w is parsed as (A *ᵥ v) ⬝ᵥ (B *ᵥ w).
This is available in bundled forms as:
Equations
- Matrix.«term_*ᵥ_» = Lean.ParserDescr.trailingNode `Matrix.«term_*ᵥ_» 73 74 (Lean.ParserDescr.binary `andthen (Lean.ParserDescr.symbol " *ᵥ ") (Lean.ParserDescr.cat `term 73))
Instances For
v ᵥ* M (notation for vecMul v M) is the vector-matrix product of vector v and matrix M,
where v is seen as a row vector.
The notation has precedence 73, which comes immediately before ⬝ᵥ for dotProduct,
so that v ᵥ* A ⬝ᵥ w ᵥ* B is parsed as (v ᵥ* A) ⬝ᵥ (w ᵥ* B).
This is available in bundled forms as:
Equations
- Matrix.vecMul v M x✝ = have j := x✝; v ⬝ᵥ fun (i : m) => M i j
Instances For
v ᵥ* M (notation for vecMul v M) is the vector-matrix product of vector v and matrix M,
where v is seen as a row vector.
The notation has precedence 73, which comes immediately before ⬝ᵥ for dotProduct,
so that v ᵥ* A ⬝ᵥ w ᵥ* B is parsed as (v ᵥ* A) ⬝ᵥ (w ᵥ* B).
This is available in bundled forms as:
Equations
- Matrix.«term_ᵥ*_» = Lean.ParserDescr.trailingNode `Matrix.«term_ᵥ*_» 73 73 (Lean.ParserDescr.binary `andthen (Lean.ParserDescr.symbol " ᵥ* ") (Lean.ParserDescr.cat `term 74))
Instances For
Left multiplication by a matrix, as an AddMonoidHom from matrices to vectors.
Equations
Instances For
Bilinear form identity: x ⬝ᵥ Aᵀ *ᵥ y = y ⬝ᵥ A *ᵥ x for commutative semirings.
Bilinear form identity: (x ᵥ* Aᵀ) ⬝ᵥ y = (y ᵥ* A) ⬝ᵥ x for commutative semirings.
simp lemmas for Matrix.submatrixs interaction with Matrix.diagonal, 1, and Matrix.mul
for when the mappings are bundled.
A version of mul_eq_one_comm that works for square matrices with rectangular types.