Build a matrix from an entry function.
1.2. The dense matrix type
Hex.Matrix.ofFn builds a matrix from an entry function
Fin n → Fin m → R. row and col return its rows and columns, and
transpose swaps them.
The i-th row of a matrix.
The j-th column of a matrix.
The transpose of a dense matrix.
Hex.Matrix.transpose_transpose.{u} {R : Type u} {n m : ℕ} (M : Hex.Matrix R n m) : M.transpose.transpose = MHex.Matrix.transpose_transpose.{u} {R : Type u} {n m : ℕ} (M : Hex.Matrix R n m) : M.transpose.transpose = M
Transposing a dense matrix twice returns the original matrix.
The zero and identity matrices:
The all-zero matrix.
The identity matrix.
Matrix-vector and matrix-matrix multiplication are both written *.
Each product entry is a row-by-column dot product.
Dot product of two vectors.
This List.finRange form is the reference definition the entry lemmas reason
about; compiled code runs the allocation-free Fin.foldl loop dotProductImpl
via the @[csimp] below.
Hex.Matrix.mulVec.{u} {R : Type u} {n m : ℕ} [Mul R] [Add R] [OfNat R 0] (M : Hex.Matrix R n m) (v : Vector R m) : Vector R nHex.Matrix.mulVec.{u} {R : Type u} {n m : ℕ} [Mul R] [Add R] [OfNat R 0] (M : Hex.Matrix R n m) (v : Vector R m) : Vector R n
Multiply a matrix by a column vector.
Hex.Matrix.mul.{u} {R : Type u} {n m k : ℕ} [Mul R] [Add R] [OfNat R 0] (M : Hex.Matrix R n m) (N : Hex.Matrix R m k) : Hex.Matrix R n kHex.Matrix.mul.{u} {R : Type u} {n m k : ℕ} [Mul R] [Add R] [OfNat R 0] (M : Hex.Matrix R n m) (N : Hex.Matrix R m k) : Hex.Matrix R n k
Multiply two matrices, using the naive algorithm.
This reads each column col N j and is the reference definition the entry lemmas
reason about. Compiled code runs mulImpl, which transposes N once (via the
@[csimp] below) so each column is materialized a single time instead of being
rebuilt for every row of M.
We intend to provide Strassen-Winograd with a customizable algorithm for small sizes later.
The identity is a left and right unit, and multiplication is associative.
Hex.Matrix.identity_mul.{u_1} {R : Type u_1} {n m : ℕ} [Lean.Grind.Ring R] (M : Hex.Matrix R n m) : Hex.Matrix.identity n * M = MHex.Matrix.identity_mul.{u_1} {R : Type u_1} {n m : ℕ} [Lean.Grind.Ring R] (M : Hex.Matrix R n m) : Hex.Matrix.identity n * M = M
Left-multiplication by the identity matrix leaves a matrix unchanged.
Hex.Matrix.mul_identity.{u_1} {R : Type u_1} {n m : ℕ} [Lean.Grind.Ring R] (M : Hex.Matrix R n m) : M * Hex.Matrix.identity m = MHex.Matrix.mul_identity.{u_1} {R : Type u_1} {n m : ℕ} [Lean.Grind.Ring R] (M : Hex.Matrix R n m) : M * Hex.Matrix.identity m = M
Right-multiplication by the identity matrix leaves a matrix unchanged.
Hex.Matrix.mul_assoc.{u_1} {R : Type u_1} {n m k l : ℕ} [Lean.Grind.Ring R] (A : Hex.Matrix R n m) (B : Hex.Matrix R m k) (C : Hex.Matrix R k l) : A * B * C = A * (B * C)Hex.Matrix.mul_assoc.{u_1} {R : Type u_1} {n m k l : ℕ} [Lean.Grind.Ring R] (A : Hex.Matrix R n m) (B : Hex.Matrix R m k) (C : Hex.Matrix R k l) : A * B * C = A * (B * C)
Matrix multiplication is associative.
The Gram matrix of the rows and the leading principal submatrices used by the Bareiss recurrence:
Hex.Matrix.gramMatrix.{u_1} {R : Type u_1} {n m : ℕ} [Mul R] [Add R] [OfNat R 0] (M : Hex.Matrix R n m) : Hex.Matrix R n nHex.Matrix.gramMatrix.{u_1} {R : Type u_1} {n m : ℕ} [Mul R] [Add R] [OfNat R 0] (M : Hex.Matrix R n m) : Hex.Matrix R n n
Gram matrix of the rows of a dense matrix.
Hex.Matrix.principalSubmatrix.{u_1} {R : Type u_1} {n : ℕ} (M : Hex.Matrix R n n) (k : ℕ) (hk : k ≤ n) : Hex.Matrix R k kHex.Matrix.principalSubmatrix.{u_1} {R : Type u_1} {n : ℕ} (M : Hex.Matrix R n n) (k : ℕ) (hk : k ≤ n) : Hex.Matrix R k k
Leading principal k × k submatrix of a square matrix: the top-left block
indexed by {0, …, k-1} along both axes. Includes the empty submatrix
(k = 0) and is convenient for Bareiss pivot/minor statements.