diff options
author | Herbert Valerio Riedel <hvr@gnu.org> | 2014-11-29 14:34:41 +0100 |
---|---|---|
committer | Herbert Valerio Riedel <hvr@gnu.org> | 2014-11-29 18:47:50 +0100 |
commit | 83c48438c800986c537d3cae682d53ee8ed326ed (patch) | |
tree | 8a687a5f0da8d886c9b2b7665512f8d9fb15d167 /testsuite/tests/lib | |
parent | 859680f6fe952ecbef3395fa4f299530d0f10c58 (diff) | |
download | haskell-83c48438c800986c537d3cae682d53ee8ed326ed.tar.gz |
Re-implement `recipModInteger` (#9281)
This also exposes the following two type-specialised modular
exponentiation variants of `recipModInteger` useful for implementing a
`recipModNatural` operation.
recipModBigNat :: BigNat -> BigNat -> BigNat
recipModWord :: Word# -> Word# -> Word#
`recipModInteger` has been available since `integer-gmp-0.5.1`
(added via 4d516855241b70eb687d95e3c121428de885e83e)
Diffstat (limited to 'testsuite/tests/lib')
-rw-r--r-- | testsuite/tests/lib/integer/integerGmpInternals.hs | 11 |
1 files changed, 1 insertions, 10 deletions
diff --git a/testsuite/tests/lib/integer/integerGmpInternals.hs b/testsuite/tests/lib/integer/integerGmpInternals.hs index d281b739d4..2f49a755a1 100644 --- a/testsuite/tests/lib/integer/integerGmpInternals.hs +++ b/testsuite/tests/lib/integer/integerGmpInternals.hs @@ -17,17 +17,8 @@ import qualified GHC.Integer.GMP.Internals as I -- so we use naive reference-implementations instead for the meantime -- in order to keep the reference-output untouched. --- FIXME: Lacks GMP2 version --- stolen from `arithmoi` package recipModInteger :: Integer -> Integer -> Integer -recipModInteger k 0 = if k == 1 || k == (-1) then k else 0 -recipModInteger k m = case gcdExtInteger k' m' of - (1, u) -> if u < 0 then m' + u else u - _ -> 0 - where - m' = abs m - k' | k >= m' || k < 0 = k `mod` m' - | otherwise = k +recipModInteger = I.recipModInteger -- FIXME: Lacks GMP2 version gcdExtInteger :: Integer -> Integer -> (Integer, Integer) |