@@ -1,6 +1,8 @@
11module Data.Matrix
22
3−import Control.Algebra
3+import Control.Algebra
4+import Control.Algebra.VectorSpace
5+import public Control.Algebra.NumericInstances
46
57import Data.Complex
68import Data.ZZ
@@ -40,8 +42,7 @@ instance Ring a => Ring (Vect n a) where
4042instance RingWithUnity a => RingWithUnity (Vect n a) where
4143 unity {n} = replicate n unity
4244
43−instance Field a => Field (Vect n a) where
44− inverseM = map inverseM
45+--instance Field a => Field (Vect n a) where
4546
4647instance RingWithUnity a => Module a (Vect n a) where
4748 (<#>) r v = map (r <.>) v
@@ -147,104 +148,3 @@ Id {d} = map (\n => basis n) $ allN d
147148
148149-- TODO: Prove properties of matrix algebra for 'Verified' algebraic classes
149150
150−-----------------------------------------------------------------------
151−-- Numberic data types as rings
152−-----------------------------------------------------------------------
153−
154−instance Semigroup Integer where
155− (<+>) = (+)
156−
157−instance Monoid Integer where
158− neutral = 0
159−
160−instance Group Integer where
161− inverse = (* -1)
162−
163−instance AbelianGroup Integer
164−
165−instance Ring Integer where
166− (<.>) = (*)
167−
168−instance RingWithUnity Integer where
169− unity = 1
170−
171−
172−instance Semigroup Int where
173− (<+>) = (+)
174−
175−instance Monoid Int where
176− neutral = 0
177−
178−instance Group Int where
179− inverse = (* -1)
180−
181−instance AbelianGroup Int
182−
183−instance Ring Int where
184− (<.>) = (*)
185−
186−instance RingWithUnity Int where
187− unity = 1
188−
189−
190−instance Semigroup Float where
191− (<+>) = (+)
192−
193−instance Monoid Float where
194− neutral = 0
195−
196−instance Group Float where
197− inverse = (* -1)
198−
199−instance AbelianGroup Float
200−
201−instance Ring Float where
202− (<.>) = (*)
203−
204−instance RingWithUnity Float where
205− unity = 1
206−
207−instance Field Float where
208− inverseM f = 1 / f
209−
210−
211−instance Semigroup Nat where
212− (<+>) = (+)
213−
214−instance Monoid Nat where
215− neutral = 0
216−
217−instance Semigroup ZZ where
218− (<+>) = (+)
219−
220−instance Monoid ZZ where
221− neutral = 0
222−
223−instance Group ZZ where
224− inverse = (* -1)
225−
226−instance AbelianGroup ZZ
227−
228−instance Ring ZZ where
229− (<.>) = (*)
230−
231−instance RingWithUnity ZZ where
232− unity = 1
233−
234−
235−instance Semigroup a => Semigroup (Complex a) where
236− (<+>) (a :+ b) (c :+ d) = (a <+> c) :+ (b <+> d)
237−
238−instance Monoid a => Monoid (Complex a) where
239− neutral = (neutral :+ neutral)
240−
241−instance Group a => Group (Complex a) where
242− inverse (r :+ i) = (inverse r :+ inverse i)
243−
244−instance Ring a => AbelianGroup (Complex a) where {}
245−
246−instance Ring a => Ring (Complex a) where
247− (<.>) (a :+ b) (c :+ d) = (a <.> c <-> b <.> d) :+ (a <.> d <+> b <.> c)
248−
249−instance RingWithUnity a => RingWithUnity (Complex a) where
250− unity = (unity :+ neutral)