diff options
Diffstat (limited to 'packages/base/src/Internal/Modular.hs')
-rw-r--r-- | packages/base/src/Internal/Modular.hs | 26 |
1 files changed, 21 insertions, 5 deletions
diff --git a/packages/base/src/Internal/Modular.hs b/packages/base/src/Internal/Modular.hs index 36ffb57..0274607 100644 --- a/packages/base/src/Internal/Modular.hs +++ b/packages/base/src/Internal/Modular.hs | |||
@@ -30,6 +30,8 @@ import Internal.Matrix hiding (mat,size) | |||
30 | import Internal.Numeric | 30 | import Internal.Numeric |
31 | import Internal.Element | 31 | import Internal.Element |
32 | import Internal.Container | 32 | import Internal.Container |
33 | import Internal.Vectorized (prodI,sumI) | ||
34 | import Internal.LAPACK (multiplyI) | ||
33 | import Internal.Util(Indexable(..),gaussElim) | 35 | import Internal.Util(Indexable(..),gaussElim) |
34 | import GHC.TypeLits | 36 | import GHC.TypeLits |
35 | import Data.Proxy(Proxy) | 37 | import Data.Proxy(Proxy) |
@@ -145,8 +147,12 @@ instance forall m . KnownNat m => Container Vector (F m) | |||
145 | maxIndex' = maxIndex . f2i | 147 | maxIndex' = maxIndex . f2i |
146 | minElement' = Mod . minElement . f2i | 148 | minElement' = Mod . minElement . f2i |
147 | maxElement' = Mod . maxElement . f2i | 149 | maxElement' = Mod . maxElement . f2i |
148 | sumElements' = fromIntegral . sumElements . f2i -- FIXME | 150 | sumElements' = fromIntegral . sumI m' . f2i |
149 | prodElements' = fromIntegral . sumElements . f2i -- FIXME | 151 | where |
152 | m' = fromIntegral . natVal $ (undefined :: Proxy m) | ||
153 | prodElements' = fromIntegral . prodI m' . f2i | ||
154 | where | ||
155 | m' = fromIntegral . natVal $ (undefined :: Proxy m) | ||
150 | step' = i2f . step . f2i | 156 | step' = i2f . step . f2i |
151 | find' = findV | 157 | find' = findV |
152 | assoc' = assocV | 158 | assoc' = assocV |
@@ -170,14 +176,14 @@ instance Indexable (Vector (F m)) (F m) | |||
170 | 176 | ||
171 | type instance RealOf (F n) = I | 177 | type instance RealOf (F n) = I |
172 | 178 | ||
173 | |||
174 | instance KnownNat m => Product (F m) where | 179 | instance KnownNat m => Product (F m) where |
175 | norm2 = undefined | 180 | norm2 = undefined |
176 | absSum = undefined | 181 | absSum = undefined |
177 | norm1 = undefined | 182 | norm1 = undefined |
178 | normInf = undefined | 183 | normInf = undefined |
179 | multiply = lift2 multiply -- FIXME | 184 | multiply = lift2 (multiplyI m') |
180 | 185 | where | |
186 | m' = fromIntegral . natVal $ (undefined :: Proxy m) | ||
181 | 187 | ||
182 | instance KnownNat m => Numeric (F m) | 188 | instance KnownNat m => Numeric (F m) |
183 | 189 | ||
@@ -236,6 +242,9 @@ test = (ok, info) | |||
236 | ad = fromInt a :: Matrix Double | 242 | ad = fromInt a :: Matrix Double |
237 | bd = fromInt b :: Matrix Double | 243 | bd = fromInt b :: Matrix Double |
238 | 244 | ||
245 | g = (3><3) (repeat (40000)) :: Matrix I | ||
246 | gm = fromInt g :: Matrix (F 100000) | ||
247 | |||
239 | info = do | 248 | info = do |
240 | print v | 249 | print v |
241 | print m | 250 | print m |
@@ -247,10 +256,17 @@ test = (ok, info) | |||
247 | 256 | ||
248 | print $ am <> gaussElim am bm - bm | 257 | print $ am <> gaussElim am bm - bm |
249 | print $ ad <> gaussElim ad bd - bd | 258 | print $ ad <> gaussElim ad bd - bd |
259 | |||
260 | print g | ||
261 | print $ g <> g | ||
262 | print gm | ||
263 | print $ gm <> gm | ||
250 | 264 | ||
251 | ok = and | 265 | ok = and |
252 | [ toInt (m #> v) == cmod 11 (toInt m #> toInt v ) | 266 | [ toInt (m #> v) == cmod 11 (toInt m #> toInt v ) |
253 | , am <> gaussElim am bm == bm | 267 | , am <> gaussElim am bm == bm |
268 | , prodElements (konst (9:: F 10) (12::Int)) == product (replicate 12 (9:: F 10)) | ||
269 | , gm <> gm == konst 0 (3,3) | ||
254 | ] | 270 | ] |
255 | 271 | ||
256 | 272 | ||