diff options
Diffstat (limited to 'packages/base/src/Internal/Modular.hs')
-rw-r--r-- | packages/base/src/Internal/Modular.hs | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/packages/base/src/Internal/Modular.hs b/packages/base/src/Internal/Modular.hs index 239c742..f3c59a8 100644 --- a/packages/base/src/Internal/Modular.hs +++ b/packages/base/src/Internal/Modular.hs | |||
@@ -72,7 +72,7 @@ instance (Ord t, KnownNat m) => Ord (Mod m t) | |||
72 | where | 72 | where |
73 | compare a b = compare (unMod a) (unMod b) | 73 | compare a b = compare (unMod a) (unMod b) |
74 | 74 | ||
75 | instance (Real t, KnownNat m, Integral (Mod m t)) => Real (Mod m t) | 75 | instance (Integral t, Real t, KnownNat m, Integral (Mod m t)) => Real (Mod m t) |
76 | where | 76 | where |
77 | toRational x = toInteger x % 1 | 77 | toRational x = toInteger x % 1 |
78 | 78 | ||
@@ -114,7 +114,7 @@ instance Show t => Show (Mod n t) | |||
114 | where | 114 | where |
115 | show = show . unMod | 115 | show = show . unMod |
116 | 116 | ||
117 | instance forall n t . (Integral t, KnownNat n) => Num (Mod n t) | 117 | instance (Integral t, KnownNat n) => Num (Mod n t) |
118 | where | 118 | where |
119 | (+) = l2 (\m a b -> (a + b) `mod` (fromIntegral m)) | 119 | (+) = l2 (\m a b -> (a + b) `mod` (fromIntegral m)) |
120 | (*) = l2 (\m a b -> (a * b) `mod` (fromIntegral m)) | 120 | (*) = l2 (\m a b -> (a * b) `mod` (fromIntegral m)) |
@@ -159,11 +159,11 @@ instance KnownNat m => Element (Mod m Z) | |||
159 | m' = fromIntegral . natVal $ (undefined :: Proxy m) | 159 | m' = fromIntegral . natVal $ (undefined :: Proxy m) |
160 | 160 | ||
161 | 161 | ||
162 | instance forall m . KnownNat m => CTrans (Mod m I) | 162 | instance KnownNat m => CTrans (Mod m I) |
163 | instance forall m . KnownNat m => CTrans (Mod m Z) | 163 | instance KnownNat m => CTrans (Mod m Z) |
164 | 164 | ||
165 | 165 | ||
166 | instance forall m . KnownNat m => Container Vector (Mod m I) | 166 | instance KnownNat m => Container Vector (Mod m I) |
167 | where | 167 | where |
168 | conj' = id | 168 | conj' = id |
169 | size' = dim | 169 | size' = dim |
@@ -203,7 +203,7 @@ instance forall m . KnownNat m => Container Vector (Mod m I) | |||
203 | fromZ' = vmod . fromZ' | 203 | fromZ' = vmod . fromZ' |
204 | toZ' = toZ' . f2i | 204 | toZ' = toZ' . f2i |
205 | 205 | ||
206 | instance forall m . KnownNat m => Container Vector (Mod m Z) | 206 | instance KnownNat m => Container Vector (Mod m Z) |
207 | where | 207 | where |
208 | conj' = id | 208 | conj' = id |
209 | size' = dim | 209 | size' = dim |
@@ -311,7 +311,7 @@ lift2 f a b = vmod (f (f2i a) (f2i b)) | |||
311 | 311 | ||
312 | lift2m f a b = liftMatrix vmod (f (f2iM a) (f2iM b)) | 312 | lift2m f a b = liftMatrix vmod (f (f2iM a) (f2iM b)) |
313 | 313 | ||
314 | instance forall m . KnownNat m => Num (Vector (Mod m I)) | 314 | instance KnownNat m => Num (Vector (Mod m I)) |
315 | where | 315 | where |
316 | (+) = lift2 (+) | 316 | (+) = lift2 (+) |
317 | (*) = lift2 (*) | 317 | (*) = lift2 (*) |
@@ -321,7 +321,7 @@ instance forall m . KnownNat m => Num (Vector (Mod m I)) | |||
321 | negate = lift1 negate | 321 | negate = lift1 negate |
322 | fromInteger x = fromInt (fromInteger x) | 322 | fromInteger x = fromInt (fromInteger x) |
323 | 323 | ||
324 | instance forall m . KnownNat m => Num (Vector (Mod m Z)) | 324 | instance KnownNat m => Num (Vector (Mod m Z)) |
325 | where | 325 | where |
326 | (+) = lift2 (+) | 326 | (+) = lift2 (+) |
327 | (*) = lift2 (*) | 327 | (*) = lift2 (*) |