All the infrastructure to eventually to modinv. Don't try to use any of this yet.

This commit is contained in:
2020-01-17 20:44:41 -08:00
parent e46cfe56d1
commit b3fcd4715e
10 changed files with 958 additions and 32 deletions

View File

@@ -10,6 +10,15 @@ generateNum g size =
x' = x `mod` (2 ^ size)
in (x', g')
generateSignedNum :: RandomGen g => g -> Word -> (Integer, g)
generateSignedNum g size =
let (x, g') = random g
s :: Integer
(s, g'') = random g'
x' = x `mod` (2 ^ size)
sign = if even s then 1 else -1
in (x' * sign, g'')
modulate :: (Integral a, Integral b) => a -> b -> Integer
modulate x size = x' `mod` (2 ^ size')
where