Skip to content

Commit c5f3b98

Browse files
chore(LinearAlgebra/Matrix/Defs): automated extraction from leanprover-community#41160 (leanprover-community#41770)
This PR was automatically created from PR leanprover-community#41160 by @paulcadman via a [review comment](leanprover-community#41160 (comment)) by @ocfnash. Co-authored-by: paulcadman <92877+paulcadman@users.noreply.github.com>
1 parent 50b6a3e commit c5f3b98

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

Mathlib/LinearAlgebra/Matrix/Defs.lean

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ Authors: Ellen Arlt, Blair Shi, Sean Leather, Mario Carneiro, Johan Commelin, Lu
66
module
77

88
public import Mathlib.Algebra.Module.Pi
9+
public import Mathlib.Data.Fin.Basic
910
public import Mathlib.Logic.Nontrivial.Basic
1011
public import Mathlib.Tactic.CrossRefAttribute
1112

@@ -94,6 +95,14 @@ theorem of_apply (f : m → n → α) (i j) : of f i j = f i j :=
9495
theorem of_symm_apply (f : Matrix m n α) (i j) : of.symm f i j = f i j :=
9596
rfl
9697

98+
/-- Construct a matrix from an array in row-major ordering. -/
99+
def ofArray {m n : ℕ} (A : Array R) (hA : A.size = m * n) : Matrix (Fin m) (Fin n) R :=
100+
fun i j => A[Fin.mkDivMod i j]
101+
102+
@[simp]
103+
theorem ofArray_apply {m n : ℕ} (A : Array R) (hA : A.size = m * n) (i : Fin m) (j : Fin n) :
104+
ofArray A hA i j = A[Fin.mkDivMod i j] := rfl
105+
97106
/-- `M.map f` is the matrix obtained by applying `f` to each entry of the matrix `M`.
98107
99108
This is available in bundled forms as:

0 commit comments

Comments
 (0)