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/Data/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.
See also dotProductEquiv.
Instances For
dotProduct v w is the sum of the entrywise products v i * w i.
See also dotProductEquiv.
Equations
- «term_⬝ᵥ_» = Lean.ParserDescr.trailingNode `«term_⬝ᵥ_» 72 72 (Lean.ParserDescr.binary `andthen (Lean.ParserDescr.symbol " ⬝ᵥ ") (Lean.ParserDescr.cat `term 73))
Instances For
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.
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 = { toNonUnitalNonAssocSemiring := Matrix.nonUnitalNonAssocSemiring, 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.
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.
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.
Put another way, M *ᵥ v is the vector whose entries are those of M * col v (see col_mulVec).
The notation has precedence 73, which comes immediately before ⬝ᵥ for dotProduct,
so that A *ᵥ v ⬝ᵥ B *ᵥ w is parsed as (A *ᵥ v) ⬝ᵥ (B *ᵥ w).
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.
Put another way, M *ᵥ v is the vector whose entries are those of M * col v (see col_mulVec).
The notation has precedence 73, which comes immediately before ⬝ᵥ for dotProduct,
so that A *ᵥ v ⬝ᵥ B *ᵥ w is parsed as (A *ᵥ v) ⬝ᵥ (B *ᵥ w).
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.
Put another way, v ᵥ* M is the vector whose entries are those of row v * M (see row_vecMul).
The notation has precedence 73, which comes immediately before ⬝ᵥ for dotProduct,
so that v ᵥ* A ⬝ᵥ w ᵥ* B is parsed as (v ᵥ* A) ⬝ᵥ (w ᵥ* B).
Equations
- Matrix.vecMul v M x✝ = v ⬝ᵥ fun (i : m) => M i x✝
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.
Put another way, v ᵥ* M is the vector whose entries are those of row v * M (see row_vecMul).
The notation has precedence 73, which comes immediately before ⬝ᵥ for dotProduct,
so that v ᵥ* A ⬝ᵥ w ᵥ* B is parsed as (v ᵥ* A) ⬝ᵥ (w ᵥ* B).
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 vectors to vectors.
Equations
Instances For
Alias of Matrix.smul_mulVec.
simp lemmas for Matrix.submatrixs interaction with Matrix.diagonal, 1, and Matrix.mul
for when the mappings are bundled.