on master help sign in
Merge pull request #2492 from BlackBrane/master

Refinement & reorganization of Data.Matrix

commit2c7563c4e3b79210aa957fde74557e1d29dfd5a2 authorNiklas Larsson <metaniklas@gmail.com> dateSat 1 Aug 2015, 15:50 (11 years ago) parent546458ed649f2e
8 files changed+335−133
idris.cabal+1 libs/base/Data/Complex.idr+6−1 libs/contrib/Control/Algebra.idr+7−7 libs/contrib/Control/Algebra/NumericInstances.idr+9 libs/contrib/Data/Matrix.idr+32−124 libs/contrib/Data/Matrix/Algebraic.idr+149 libs/contrib/Data/Matrix/Numeric.idr+129 libs/contrib/contrib.ipkg+2−1
idris.cabal+1
@@ -118,6 +118,7 @@ Extra-source-files:
118118 libs/contrib/Data/*.idr
119119 libs/contrib/Data/Nat/*.idr
120120 libs/contrib/Data/Nat/DivMod/*.idr
121+ libs/contrib/Data/Matrix/*.idr
121122 libs/contrib/Decidable/*.idr
122123 libs/contrib/Network/*.idr
123124 libs/contrib/System/Concurrency/*.idr
libs/base/Data/Complex.idr+6−1
@@ -27,7 +27,6 @@ instance Show a => Show (Complex a) where
2727 plus_i = User 6
2828
2929
30−
3130-- when we have a type class 'Fractional' (which contains Float and Double),
3231-- we can do:
3332{-
@@ -61,6 +60,12 @@ phase (x:+y) = atan2 y x
6160conjugate : Num a => Complex a -> Complex a
6261conjugate (r:+i) = (r :+ (0-i))
6362
63+instance Functor Complex where
64+ map f (r :+ i) = f r :+ f i
65+
66+instance Neg a => Neg (Complex a) where
67+ negate = map negate
68+
6469-- We can't do "instance Num a => Num (Complex a)" because
6570-- we need "abs" which needs "magnitude" which needs "sqrt" which needs Float
6671instance Num (Complex Float) where
libs/contrib/Control/Algebra.idr+7−7
@@ -115,15 +115,15 @@ class Ring a => RingWithUnity a where
115115class RingWithUnity a => Field a where
116116 inverseM : (x : a) -> Not (x = neutral) -> a
117117
118−sum : (Foldable t, Monoid a) => t a -> a
119−sum = foldr (<+>) neutral
118+sum' : (Foldable t, Monoid a) => t a -> a
119+sum' = foldr (<+>) neutral
120120
121−product : (Foldable t, RingWithUnity a) => t a -> a
122−product = foldr (<.>) unity
121+product' : (Foldable t, RingWithUnity a) => t a -> a
122+product' = foldr (<.>) unity
123123
124−power : RingWithUnity a => a -> Nat -> a
125−power _ Z = unity
126−power x (S n) = x <.> (Algebra.power x n)
124+pow' : RingWithUnity a => a -> Nat -> a
125+pow' _ Z = unity
126+pow' x (S n) = x <.> pow' x n
127127
128128
129129-- XXX todo:
libs/contrib/Control/Algebra/NumericInstances.idr+9
@@ -1,6 +1,9 @@
1+||| Instances of algebraic classes (group, ring, etc) for numeric data types,
2+||| and Complex number types.
13module Control.Algebra.NumericInstances
24
35import Control.Algebra
6+import Control.Algebra.VectorSpace
47import Data.Complex
58import Data.ZZ
69
@@ -102,3 +105,9 @@ instance Ring a => Ring (Complex a) where
102105
103106instance RingWithUnity a => RingWithUnity (Complex a) where
104107 unity = (unity :+ neutral)
108+
109+instance RingWithUnity a => Module a (Complex a) where
110+ (<#>) x = map (x <.>)
111+
112+instance RingWithUnity a => InnerProductSpace a (Complex a) where
113+ (x :+ y) <||> z = realPart $ (x :+ inverse y) <.> z
libs/contrib/Data/Matrix.idr+32−124
@@ -1,150 +1,58 @@
1+||| Basic matrix operations with dimensionalities enforced
2+||| at the type level
13module Data.Matrix
24
3−import Control.Algebra
4−import Control.Algebra.VectorSpace
5−import public Control.Algebra.NumericInstances
6−
7−import Data.Complex
8−import Data.ZZ
9−import Data.Fin
10−import Data.Vect
5+import public Data.Vect
116
127%default total
138
14−infixr 2 <:> -- vector inner product
15−infixr 2 >< -- vector outer product
16−infixr 2 <<>> -- matrix commutator
17−infixr 2 >><< -- matrix anticommutator
18−infixl 3 <\> -- row times a matrix
19−infixr 4 </> -- matrix times a column
20−infixr 5 <> -- matrix multiplication
21−infixr 7 \&\ -- vector tensor product
22−infixr 7 <&> -- matrix tensor product
23−
24−-----------------------------------------------------------------------
25−-- Vectors as members of algebraic classes
26−-----------------------------------------------------------------------
27−
28−instance Semigroup a => Semigroup (Vect n a) where
29− (<+>) v w = zipWith (<+>) v w
30−
31−instance Monoid a => Monoid (Vect n a) where
32− neutral {n} = replicate n neutral
33−
34−instance Group a => Group (Vect n a) where
35− inverse = map inverse
36−
37−instance AbelianGroup a => AbelianGroup (Vect n a) where {}
38−
39−instance Ring a => Ring (Vect n a) where
40− (<.>) v w = zipWith (<.>) v w
41−
42−instance RingWithUnity a => RingWithUnity (Vect n a) where
43− unity {n} = replicate n unity
44−
45−--instance Field a => Field (Vect n a) where
46−
47−instance RingWithUnity a => Module a (Vect n a) where
48− (<#>) r v = map (r <.>) v
49−
50−instance RingWithUnity a => Module a (Vect n (Vect l a)) where
51− (<#>) r m = map (r <#>) m
52−-- should be Module a b => Module a (Vect n b), but results in 'overlapping instance'
53−
54−-----------------------------------------------------------------------
55−-- (Ring) Vector functions
56−-----------------------------------------------------------------------
57−
58−||| Inner product of ring vectors
59−(<:>) : Ring a => Vect n a -> Vect n a -> a
60−(<:>) w v = foldr (<+>) neutral (zipWith (<.>) w v)
61−
62−||| Tensor multiply (⊗) ring vectors
63−(\&\) : Ring a => Vect n a -> Vect m a -> Vect (n * m) a
64−(\&\) {n} {m} v w = zipWith (<.>) (oextend m v) (orep n w) where
65− orep : (n : Nat) -> Vect m a -> Vect (n * m) a
66− orep n v = concat $ replicate n v
67− oextend : (n : Nat) -> Vect k a -> Vect (k * n) a
68− oextend n w = concat $ map (replicate n) w
69−
70−||| Standard basis vector with one nonzero entry, ring data type and vector-length unfixed
71−basis : RingWithUnity a => {d : Nat} -> (Fin d) -> Vect d a
72−basis i = replaceAt i unity $ neutral
73−
74−-----------------------------------------------------------------------
75−-- Matrix functions
76−-----------------------------------------------------------------------
77−
789||| Matrix with n rows and m columns
7910Matrix : Nat -> Nat -> Type -> Type
8011Matrix n m a = Vect n (Vect m a)
8112
82−||| Gets the specified column of a matrix. For rows use the vector function 'index'
13+||| Get the specified column of a matrix
8314getCol : Fin m -> Matrix n m a -> Vect n a
84−getCol fm q = map (index fm) q
15+getCol f = map (index f)
8516
86−||| Deletes the specified column of a matrix. For rows use the vector function 'deleteAt'
87−deleteCol : Fin (S m) -> Matrix n (S m) a -> Matrix n m a
88−deleteCol f m = map (deleteAt f) m
17+||| Get the specified row of a matrix
18+getRow : Fin n -> Matrix n m a -> Vect m a
19+getRow = index
8920
90−||| Matrix element at specified row and column indices
91−indices : Fin n -> Fin m -> Matrix n m a -> a
92−indices f1 f2 m = index f2 (index f1 m)
21+||| Delete the specified column of a matrix
22+deleteCol : Fin (S m) -> Matrix n (S m) a -> Matrix n m a
23+deleteCol f = map (deleteAt f)
9324
94−||| Matrix times a column vector
95−(</>) : Ring a => Matrix n m a -> Vect m a -> Vect n a
96−(</>) m v = map (v <:>) m
25+||| Delete the specified row of a matrix
26+deleteRow : Fin (S n) -> Matrix (S n) m a -> Matrix n m a
27+deleteRow = deleteAt
9728
98−||| Matrix times a row vector
99−(<\>) : Ring a => Vect n a -> Matrix n m a -> Vect m a
100−(<\>) r m = map (r <:>) $ transpose m
29+insertRow : Fin (S n) -> Vect m a -> Matrix n m a -> Matrix (S n) m a
30+insertRow = insertAt
10131
102−||| Matrix multiplication
103−(<>) : Ring a => Matrix n k a ->
104− Matrix k m a ->
105− Matrix n m a
106−(<>) m1 m2 = map (<\> m2) m1
32+insertCol : Fin (S m) -> Vect n a -> Matrix n m a -> Matrix n (S m) a
33+insertCol f = zipWith (insertAt f)
10734
108−||| Tensor multiply (⊗) for ring matrices
109−(<&>) : Ring a => Matrix h1 w1 a -> Matrix h2 w2 a -> Matrix (h1 * h2) (w1 * w2) a
110−(<&>) m1 m2 = zipWith (\&\) (stepOne m1 m2) (stepTwo m1 m2) where
111− stepOne : Matrix h1 w1 a -> Matrix h2 w2 a -> Matrix (h1 * h2) w1 a
112− stepOne {h2} m1 m2 = concat $ map (replicate h2) m1
113− stepTwo : Matrix h1 w1 a -> Matrix h2 w2 a -> Matrix (h1 * h2) w2 a
114− stepTwo {h1} m1 m2 = concat $ (Vect.replicate h1) m2
35+||| Matrix element at specified row and column indices
36+indices : Fin n -> Fin m -> Matrix n m a -> a
37+indices f1 f2 = index f2 . index f1
11538
11639||| Cast a vector from a standard Vect to a proper n x 1 matrix
11740col : Vect n a -> Matrix n 1 a
118−col v = map (\x => [x]) v
41+col = map (\x => [x])
11942
12043||| Cast a row from a standard Vect to a proper 1 x n matrix
12144row : Vect n a -> Matrix 1 n a
12245row r = [r]
12346
124−||| Outer product between ring vectors
125−(><) : Ring a => Vect n a -> Vect m a -> Matrix n m a
126−(><) x y = (col x) <> (row y)
127−
128−||| All finite numbers up to the given bound
129−allN : (n : Nat) -> Vect n (Fin n)
130−allN Z = Nil
131−allN (S n) = FZ :: (map FS $ allN n)
132−
133−||| Identity matrix
134−Id : RingWithUnity a => {d : Nat} -> Matrix d d a
135−Id {d} = map (\n => basis n) $ allN d
136−
137−||| Matrix commutator
138−(<<>>) : Ring a => Matrix n n a -> Matrix n n a -> Matrix n n a
139−(<<>>) m1 m2 = (m1 <> m2) <-> (m2 <> m1)
140−
141−||| Matrix anti-commutator
142−(>><<) : Ring a => Matrix n n a -> Matrix n n a -> Matrix n n a
143−(>><<) m1 m2 = (m1 <> m2) <+> (m2 <> m1)
144−
145−-----------------------------------------------------------------------
146−-- Matrix Algebra Properties
147−-----------------------------------------------------------------------
47+||| Matrix formed by deleting specified row and col
48+subMatrix : Fin (S n) -> Fin (S m) -> Matrix (S n) (S m) a -> Matrix n m a
49+subMatrix r c = deleteRow r . deleteCol c
14850
149−-- TODO: Prove properties of matrix algebra for 'Verified' algebraic classes
51+||| Flatten a matrix of matrices
52+concatMatrix : Matrix n m (Matrix x y a) -> Matrix (n * x) (m * y) a
53+concatMatrix = Vect.concat . map (map Vect.concat) . map transpose
15054
55+||| All finite numbers of the specified level
56+fins : (n : Nat) -> Vect n (Fin n)
57+fins Z = Nil
58+fins (S n) = FZ :: (map FS $ fins n)
libs/contrib/Data/Matrix/Algebraic.idrnew file+149
@@ -0,0 +1,149 @@
1+||| Matrix operations with vector space dimensionalities enforced
2+||| at the type level. Uses operations from classes in `Control.Algebra`
3+||| and `Control.Algebra.VectorSpace`.
4+module Data.Matrix.Algebraic
5+
6+import public Control.Algebra
7+import public Control.Algebra.VectorSpace
8+import public Control.Algebra.NumericInstances
9+
10+import public Data.Matrix
11+
12+
13+%default total
14+
15+infixr 2 <:> -- vector inner product
16+infixr 2 >< -- vector outer product
17+infixr 2 <<>> -- matrix commutator
18+infixr 2 >><< -- matrix anticommutator
19+infixl 3 <\> -- row times a matrix
20+infixr 4 </> -- matrix times a column
21+infixr 5 <> -- matrix multiplication
22+infixr 7 \&\ -- vector tensor product
23+infixr 7 <&> -- matrix tensor product
24+
25+-----------------------------------------------------------------------
26+-- Vectors as members of algebraic classes
27+-----------------------------------------------------------------------
28+
29+instance Semigroup a => Semigroup (Vect n a) where
30+ (<+>)= zipWith (<+>)
31+
32+instance Monoid a => Monoid (Vect n a) where
33+ neutral {n} = replicate n neutral
34+
35+instance Group a => Group (Vect n a) where
36+ inverse = map inverse
37+
38+instance AbelianGroup a => AbelianGroup (Vect n a) where {}
39+
40+instance Ring a => Ring (Vect n a) where
41+ (<.>) = zipWith (<.>)
42+
43+instance RingWithUnity a => RingWithUnity (Vect n a) where
44+ unity {n} = replicate n unity
45+
46+instance RingWithUnity a => Module a (Vect n a) where
47+ (<#>) r = map (r <.>)
48+
49+instance RingWithUnity a => Module a (Vect n (Vect l a)) where
50+ (<#>) r = map (r <#>)
51+-- should be Module a b => Module a (Vect n b), but results in 'overlapping instance'
52+
53+-----------------------------------------------------------------------
54+-- (Ring) Vector functions
55+-----------------------------------------------------------------------
56+
57+||| Inner product of ring vectors
58+(<:>) : Ring a => Vect n a -> Vect n a -> a
59+(<:>) w v = foldr (<+>) neutral (zipWith (<.>) w v)
60+
61+||| Tensor multiply (⊗) ring vectors
62+(\&\) : Ring a => Vect n a -> Vect m a -> Vect (n * m) a
63+(\&\) {n} {m} v w = zipWith (<.>) (oextend m v) (orep n w) where
64+ orep : (n : Nat) -> Vect m a -> Vect (n * m) a
65+ orep n v = concat $ replicate n v
66+ oextend : (n : Nat) -> Vect k a -> Vect (k * n) a
67+ oextend n w = concat $ map (replicate n) w
68+
69+||| Standard basis vector with one nonzero entry, ring data type and vector-length unfixed
70+basis : RingWithUnity a => (Fin d) -> Vect d a
71+basis i = replaceAt i unity neutral
72+
73+-----------------------------------------------------------------------
74+-- Ring Matrix functions
75+-----------------------------------------------------------------------
76+
77+||| Matrix times a column vector
78+(</>) : Ring a => Matrix n m a -> Vect m a -> Vect n a
79+(</>) m v = map (v <:>) m
80+
81+||| Matrix times a row vector
82+(<\>) : Ring a => Vect n a -> Matrix n m a -> Vect m a
83+(<\>) r m = map (r <:>) $ transpose m
84+
85+||| Matrix multiplication
86+(<>) : Ring a => Matrix n k a ->
87+ Matrix k m a ->
88+ Matrix n m a
89+(<>) m1 m2 = map (<\> m2) m1
90+
91+||| Tensor multiply (⊗) for ring matrices
92+(<&>) : Ring a => Matrix h1 w1 a -> Matrix h2 w2 a -> Matrix (h1 * h2) (w1 * w2) a
93+(<&>) m1 m2 = zipWith (\&\) (stepOne m1 m2) (stepTwo m1 m2) where
94+ stepOne : Matrix h1 w1 a -> Matrix h2 w2 a -> Matrix (h1 * h2) w1 a
95+ stepOne {h2} m1 m2 = concat $ map (replicate h2) m1
96+ stepTwo : Matrix h1 w1 a -> Matrix h2 w2 a -> Matrix (h1 * h2) w2 a
97+ stepTwo {h1} m1 m2 = concat $ replicate h1 m2
98+
99+||| Outer product between ring vectors
100+(><) : Ring a => Vect n a -> Vect m a -> Matrix n m a
101+(><) x y = col x <> row y
102+
103+||| Matrix commutator
104+(<<>>) : Ring a => Matrix n n a -> Matrix n n a -> Matrix n n a
105+(<<>>) m1 m2 = (m1 <> m2) <-> (m2 <> m1)
106+
107+||| Matrix anti-commutator
108+(>><<) : Ring a => Matrix n n a -> Matrix n n a -> Matrix n n a
109+(>><<) m1 m2 = (m1 <> m2) <+> (m2 <> m1)
110+
111+||| Identity matrix
112+Id : RingWithUnity a => Matrix d d a
113+Id = map (\n => basis n) (fins _)
114+
115+||| Square matrix from diagonal elements
116+diag_ : Monoid a => Vect n a -> Matrix n n a
117+diag_ = zipWith (\f => \x => replaceAt f x neutral) (fins _)
118+
119+||| Combine two matrices to make a new matrix in block diagonal form
120+blockDiag : Monoid a => Matrix n n a -> Matrix m m a -> Matrix (n+m) (n+m) a
121+blockDiag g h = map (++ replicate _ neutral) g ++ map ((replicate _ neutral) ++) h
122+
123+
124+-----------------------------------------------------------------------
125+-- Determinants
126+-----------------------------------------------------------------------
127+
128+||| Alternating sum
129+altSum : Group a => Vect n a -> a
130+altSum (x::y::zs) = (x <-> y) <+> altSum zs
131+altSum [x] = x
132+altSum [] = neutral
133+
134+||| Determinant of a 2-by-2 matrix
135+det2 : Ring a => Matrix 2 2 a -> a
136+det2 [[x1,x2],[y1,y2]] = x1 <.> y2 <-> x2 <.> y1
137+
138+||| Determinant of a square matrix
139+det : Ring a => Matrix (S (S n)) (S (S n)) a -> a
140+det {n} m = case n of
141+ Z => det2 m
142+ (S k) => altSum . map (\c => indices FZ c m <.> det (subMatrix FZ c m))
143+ $ fins (S (S (S k)))
144+
145+-----------------------------------------------------------------------
146+-- Matrix Algebra Properties
147+-----------------------------------------------------------------------
148+
149+-- TODO: Prove properties of matrix algebra for 'Verified' algebraic classes
libs/contrib/Data/Matrix/Numeric.idrnew file+129
@@ -0,0 +1,129 @@
1+||| Matrix operations with vector space dimensionalities enforced
2+||| at the type level. Uses operations from the Num type class.
3+module Data.Matrix.Numeric
4+
5+import public Data.Matrix
6+
7+%default total
8+
9+infixr 2 <:> -- vector inner product
10+infixr 2 >< -- vector outer product
11+infixr 2 <<>> -- matrix commutator
12+infixr 2 >><< -- matrix anticommutator
13+infixl 3 <\> -- row times a matrix
14+infixr 4 </> -- matrix times a column
15+infixr 5 <> -- matrix multiplication
16+infixl 5 <#> -- matrix rescale
17+infixl 5 <# -- vector rescale
18+infixr 7 \&\ -- vector tensor product
19+infixr 7 <&> -- matrix tensor product
20+
21+-----------------------------------------------------------------------
22+-- Vectors as members of Num
23+-----------------------------------------------------------------------
24+
25+instance Num a => Num (Vect n a) where
26+ (+) = zipWith (+)
27+ (-) = zipWith (+)
28+ (*) = zipWith (*)
29+ abs = id
30+ fromInteger n = replicate _ (fromInteger n)
31+
32+-----------------------------------------------------------------------
33+-- Vector functions
34+-----------------------------------------------------------------------
35+
36+||| Inner product of ring vectors
37+(<:>) : Num a => Vect n a -> Vect n a -> a
38+(<:>) w v = sum $ zipWith (*) w v
39+
40+||| Scale a numeric vector by a scalar
41+(<#) : Num a => a -> Vect n a -> Vect n a
42+(<#) r = map (r *)
43+
44+||| Tensor multiply (⊗) numeric vectors
45+(\&\) : Num a => Vect n a -> Vect m a -> Vect (n * m) a
46+(\&\) {n} {m} v w = zipWith (*) (oextend m v) (orep n w) where
47+ orep : (n : Nat) -> Vect m a -> Vect (n * m) a
48+ orep n v = concat $ replicate n v
49+ oextend : (n : Nat) -> Vect k a -> Vect (k * n) a
50+ oextend n w = concat $ map (replicate n) w
51+
52+||| Standard basis vector with one nonzero entry, numeric data type and vector-length unfixed
53+basis : Num a => (Fin d) -> Vect d a
54+basis i = replaceAt i 1 0
55+
56+-----------------------------------------------------------------------
57+-- Matrix functions
58+-----------------------------------------------------------------------
59+
60+||| Matrix times a column vector
61+(</>) : Num a => Matrix n m a -> Vect m a -> Vect n a
62+(</>) m v = map (v <:>) m
63+
64+||| Matrix times a row vector
65+(<\>) : Num a => Vect n a -> Matrix n m a -> Vect m a
66+(<\>) r m = map (r <:>) $ transpose m
67+
68+||| Matrix multiplication
69+(<>) : Num a => Matrix n k a ->
70+ Matrix k m a ->
71+ Matrix n m a
72+(<>) m1 m2 = map (<\> m2) m1
73+
74+||| Scale matrix by a scalar
75+(<#>) : Num a => a -> Matrix n m a -> Matrix n m a
76+(<#>) r = map (r <#)
77+
78+||| Tensor multiply (⊗) for numeric matrices
79+(<&>) : Num a => Matrix h1 w1 a -> Matrix h2 w2 a -> Matrix (h1 * h2) (w1 * w2) a
80+(<&>) m1 m2 = zipWith (\&\) (stepOne m1 m2) (stepTwo m1 m2) where
81+ stepOne : Matrix h1 w1 a -> Matrix h2 w2 a -> Matrix (h1 * h2) w1 a
82+ stepOne {h2} m1 m2 = concat $ map (replicate h2) m1
83+ stepTwo : Matrix h1 w1 a -> Matrix h2 w2 a -> Matrix (h1 * h2) w2 a
84+ stepTwo {h1} m1 m2 = concat $ replicate h1 m2
85+
86+||| Outer product between numeric vectors
87+(><) : Num a => Vect n a -> Vect m a -> Matrix n m a
88+(><) x y = col x <> row y
89+
90+||| Matrix commutator
91+(<<>>) : Num a => Matrix n n a -> Matrix n n a -> Matrix n n a
92+(<<>>) m1 m2 = (m1 <> m2) - (m2 <> m1)
93+
94+||| Matrix anti-commutator
95+(>><<) : Num a => Matrix n n a -> Matrix n n a -> Matrix n n a
96+(>><<) m1 m2 = (m1 <> m2) + (m2 <> m1)
97+
98+||| Identity matrix
99+Id : Num a => Matrix d d a
100+Id = map (\n => basis n) (fins _)
101+
102+||| Square matrix from diagonal elements
103+diag_ : Num a => Vect n a -> Matrix n n a
104+diag_ = zipWith (\f => \x => replaceAt f x 0) (fins _)
105+
106+||| Combine two matrices to make a new matrix in block diagonal form
107+blockDiag : Num a => Matrix n n a -> Matrix m m a -> Matrix (n+m) (n+m) a
108+blockDiag {n} {m} g h = map (++ replicate m 0) g ++ map ((replicate n 0) ++) h
109+
110+-----------------------------------------------------------------------
111+-- Determinants
112+-----------------------------------------------------------------------
113+
114+||| Alternating sum
115+altSum : Num a => Vect n a -> a
116+altSum (x::y::zs) = (x - y) + altSum zs
117+altSum [x] = x
118+altSum [] = 0
119+
120+||| Determinant of a 2-by-2 matrix
121+det2 : Num a => Matrix 2 2 a -> a
122+det2 [[x1,x2],[y1,y2]] = x1*y2 - x2*y1
123+
124+||| Determinant of a square matrix
125+det : Num a => Matrix (S (S n)) (S (S n)) a -> a
126+det {n} m = case n of
127+ Z => det2 m
128+ (S k) => altSum . map (\c => indices FZ c m * det (subMatrix FZ c m))
129+ $ fins (S (S (S k)))
libs/contrib/contrib.ipkg+2−1
@@ -9,7 +9,8 @@ modules = Control.Algebra,
99 Control.WellFounded,
1010 Classes.Verified,
1111 Data.Fun, Data.Rel,
12− Data.Hash, Data.Matrix,
12+ Data.Hash,
13+ Data.Matrix, Data.Matrix.Algebraic, Data.Matrix.Numeric,
1314 Data.Nat.DivMod, Data.Nat.DivMod.IteratedSubtraction,
1415 Data.ZZ, Data.Sign,
1516 Data.BoundedList,