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.
See also dotProductEquiv.
Instances For
dotProduct v w is the sum of the entrywise products v i * w i.
See also dotProductEquiv.
Instances For
Permuting a vector on the left of a dot product can be transferred to the right.
Permuting a vector on the right of a dot product can be transferred to the left.
Permuting vectors on both sides of a dot product is a no-op.
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.
Left multiplication by a matrix, as an AddMonoidHom from matrices to matrices.
Instances For
Right multiplication by a matrix, as an AddMonoidHom from matrices to matrices.
Instances For
This instance enables use with smul_mul_assoc.
This instance enables use with mul_smul_comm.
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.
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).
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).
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).
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).
Instances For
Left multiplication by a matrix, as an AddMonoidHom from vectors to vectors.
Instances For
Associate the dot product of mulVec to the left.
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.