{-# OPTIONS --safe #-}
module Cubical.Experiments.IntegerMatrix where
open import Cubical.Foundations.Prelude
open import Cubical.Data.Nat
open import Cubical.Data.Int
open import Cubical.Data.FinData
open import Cubical.Data.List
open import Cubical.Algebra.CommRing
open import Cubical.Algebra.CommRing.Instances.Int
open import Cubical.Algebra.Matrix
open import Cubical.Algebra.Matrix.CommRingCoefficient
open import Cubical.Algebra.IntegerMatrix.Smith
open import Cubical.Algebra.IntegerMatrix.Diagonalization
private
variable
m n : ℕ
open Coefficient ℤCommRing
open isSmithNormal
open Smith
open isDiagonal
open Diag
getElemDiv : Mat m n → List ℤ
getElemDiv M = smith M .isnormal .divs .fst
getDiagDiv : Mat m n → List ℤ
getDiagDiv M = diagonalize M .isdiag .divs .fst
makeMat2×2 : ℤ → ℤ → ℤ → ℤ → Mat 2 2
makeMat2×2 a00 _ _ _ zero zero = a00
makeMat2×2 _ a01 _ _ zero one = a01
makeMat2×2 _ _ a10 _ one zero = a10
makeMat2×2 _ _ _ a11 one one = a11
makeMat3×3 : ℤ → ℤ → ℤ → ℤ → ℤ → ℤ → ℤ → ℤ → ℤ → Mat 3 3
makeMat3×3 a00 _ _ _ _ _ _ _ _ zero zero = a00
makeMat3×3 _ a01 _ _ _ _ _ _ _ zero one = a01
makeMat3×3 _ _ a02 _ _ _ _ _ _ zero two = a02
makeMat3×3 _ _ _ a10 _ _ _ _ _ one zero = a10
makeMat3×3 _ _ _ _ a11 _ _ _ _ one one = a11
makeMat3×3 _ _ _ _ _ a12 _ _ _ one two = a12
makeMat3×3 _ _ _ _ _ _ a20 _ _ two zero = a20
makeMat3×3 _ _ _ _ _ _ _ a21 _ two one = a21
makeMat3×3 _ _ _ _ _ _ _ _ a22 two two = a22
mat1 = makeMat2×2
1 0
0 1
test1 = getElemDiv mat1
test1' = getDiagDiv mat1
mat2 = makeMat2×2
2 0
0 1
test2 = getElemDiv mat2
test2' = getDiagDiv mat2
mat3 = makeMat2×2
2 1
3 5
test3 = getElemDiv mat3
test3' = getDiagDiv mat3
mat4 = makeMat2×2
4 2
2 4
test4 = getElemDiv mat4
test4' = getDiagDiv mat4
mat5 = makeMat3×3
1 0 0
0 0 0
0 0 0
test5 = getElemDiv mat5
test5' = getDiagDiv mat5
mat6 = makeMat3×3
1 0 0
0 1 0
0 0 1
test6 = getElemDiv mat6
test6' = getDiagDiv mat6
mat7 = makeMat3×3
1 1 0
3 2 1
2 0 1
test7 = getElemDiv mat7
test7' = getDiagDiv mat7
mat8 = makeMat3×3
2 3 1
2 2 3
1 1 0
test8 = getElemDiv mat8
test8' = getDiagDiv mat8