Copyright | (c) Herbert Valerio Riedel 2014 |
---|---|
License | BSD3 |
Maintainer | ghc-devs@haskell.org |
Stability | provisional |
Portability | non-portable (GHC Extensions) |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
GHC.Integer.GMP.Internals
Contents
Description
Synopsis
- data Integer where
- isValidInteger# :: Integer -> Int#
- module GHC.Integer
- gcdInteger :: Integer -> Integer -> Integer
- gcdExtInteger :: Integer -> Integer -> (# Integer, Integer #)
- lcmInteger :: Integer -> Integer -> Integer
- sqrInteger :: Integer -> Integer
- powModInteger :: Integer -> Integer -> Integer -> Integer
- recipModInteger :: Integer -> Integer -> Integer
- wordToNegInteger :: Word# -> Integer
- bigNatToInteger :: BigNat -> Integer
- bigNatToNegInteger :: BigNat -> Integer
- data BigNat = BN# {}
- type GmpLimb = Word
- type GmpLimb# = Word#
- type GmpSize = Int
- type GmpSize# = Int#
- isValidBigNat# :: BigNat -> Int#
- sizeofBigNat# :: BigNat -> GmpSize#
- zeroBigNat :: BigNat
- oneBigNat :: BigNat
- byteArrayToBigNat# :: ByteArray# -> GmpSize# -> BigNat
- wordToBigNat :: Word# -> BigNat
- wordToBigNat2 :: Word# -> Word# -> BigNat
- bigNatToInt :: BigNat -> Int#
- bigNatToWord :: BigNat -> Word#
- indexBigNat# :: BigNat -> GmpSize# -> GmpLimb#
- plusBigNat :: BigNat -> BigNat -> BigNat
- plusBigNatWord :: BigNat -> GmpLimb# -> BigNat
- minusBigNat :: BigNat -> BigNat -> BigNat
- minusBigNatWord :: BigNat -> GmpLimb# -> BigNat
- timesBigNat :: BigNat -> BigNat -> BigNat
- timesBigNatWord :: BigNat -> GmpLimb# -> BigNat
- sqrBigNat :: BigNat -> BigNat
- quotRemBigNat :: BigNat -> BigNat -> (# BigNat, BigNat #)
- quotRemBigNatWord :: BigNat -> GmpLimb# -> (# BigNat, GmpLimb# #)
- quotBigNatWord :: BigNat -> GmpLimb# -> BigNat
- quotBigNat :: BigNat -> BigNat -> BigNat
- remBigNat :: BigNat -> BigNat -> BigNat
- remBigNatWord :: BigNat -> GmpLimb# -> Word#
- gcdBigNat :: BigNat -> BigNat -> BigNat
- gcdBigNatWord :: BigNat -> Word# -> Word#
- shiftRBigNat :: BigNat -> Int# -> BigNat
- shiftLBigNat :: BigNat -> Int# -> BigNat
- testBitBigNat :: BigNat -> Int# -> Bool
- clearBitBigNat :: BigNat -> Int# -> BigNat
- complementBitBigNat :: BigNat -> Int# -> BigNat
- setBitBigNat :: BigNat -> Int# -> BigNat
- andBigNat :: BigNat -> BigNat -> BigNat
- xorBigNat :: BigNat -> BigNat -> BigNat
- popCountBigNat :: BigNat -> Int#
- orBigNat :: BigNat -> BigNat -> BigNat
- bitBigNat :: Int# -> BigNat
- isZeroBigNat :: BigNat -> Bool
- compareBigNatWord :: BigNat -> GmpLimb# -> Ordering
- compareBigNat :: BigNat -> BigNat -> Ordering
- eqBigNatWord :: BigNat -> GmpLimb# -> Bool
- eqBigNatWord# :: BigNat -> GmpLimb# -> Int#
- eqBigNat :: BigNat -> BigNat -> Bool
- eqBigNat# :: BigNat -> BigNat -> Int#
- gtBigNatWord# :: BigNat -> GmpLimb# -> Int#
- sizeInBaseBigNat :: BigNat -> Int# -> Word#
- sizeInBaseInteger :: Integer -> Int# -> Word#
- sizeInBaseWord# :: Word# -> Int# -> Word#
- exportBigNatToAddr :: BigNat -> Addr# -> Int# -> IO Word
- exportIntegerToAddr :: Integer -> Addr# -> Int# -> IO Word
- exportBigNatToMutableByteArray :: BigNat -> MutableByteArray# RealWorld -> Word# -> Int# -> IO Word
- exportIntegerToMutableByteArray :: Integer -> MutableByteArray# RealWorld -> Word# -> Int# -> IO Word
- importBigNatFromAddr :: Addr# -> Word# -> Int# -> IO BigNat
- importIntegerFromAddr :: Addr# -> Word# -> Int# -> IO Integer
- importBigNatFromByteArray :: ByteArray# -> Word# -> Word# -> Int# -> BigNat
- importIntegerFromByteArray :: ByteArray# -> Word# -> Word# -> Int# -> Integer
The Integer
type
Arbitrary precision integers. In contrast with fixed-size integral types
such as Int
, the Integer
type represents the entire infinite range of
integers.
Integers are stored in a kind of sign-magnitude form, hence do not expect two's complement form when using bit operations.
If the value is small (fit into an Int
), IS
constructor is used.
Otherwise IP
and IN
constructors are used to store a BigNat
representing respectively the positive or the negative value magnitude.
Bundled Patterns
pattern S# :: Int# -> Integer | Deprecated: Use IS constructor instead |
pattern Jn# :: BigNat -> Integer | Deprecated: Use IN constructor instead |
pattern Jp# :: BigNat -> Integer | Deprecated: Use IP constructor instead |
Instances
Show Integer | Since: base-2.1 |
Eq Integer | |
Ord Integer | |
isValidInteger# :: Integer -> Int# #
Deprecated: Use integerCheck# instead
Basic Integer
operations
module GHC.Integer
Additional Integer
operations
gcdInteger :: Integer -> Integer -> Integer #
Deprecated: Use integerGcd instead
lcmInteger :: Integer -> Integer -> Integer #
Deprecated: Use integerLcm instead
sqrInteger :: Integer -> Integer #
Deprecated: Use integerSqr instead
recipModInteger :: Integer -> Integer -> Integer #
Deprecated: Use integerRecipMod# instead
Additional conversion operations to Integer
wordToNegInteger :: Word# -> Integer #
Deprecated: Use integerFromWordNeg# instead
bigNatToInteger :: BigNat -> Integer #
Deprecated: Use integerFromBigNat# instead
bigNatToNegInteger :: BigNat -> Integer #
Deprecated: Use integerFromBigNatNeg# instead
The BigNat
type
A lifted BigNat
Represented as an array of limbs (Word#) stored in little-endian order (Word# themselves use machine order).
Invariant (canonical representation): higher Word# is non-zero.
As a consequence, zero is represented with a WordArray# whose size is 0.
Instances
Eq BigNat | |
Ord BigNat | |
isValidBigNat# :: BigNat -> Int# #
Deprecated: Use bigNatCheck# instead
sizeofBigNat# :: BigNat -> GmpSize# #
Deprecated: Use bigNatSize# instead
zeroBigNat :: BigNat #
Deprecated: Use bigNatZero instead
Conversions to/from BigNat
byteArrayToBigNat# :: ByteArray# -> GmpSize# -> BigNat #
Deprecated: Use bigNatFromWordArray instead
wordToBigNat :: Word# -> BigNat #
wordToBigNat2 :: Word# -> Word# -> BigNat #
bigNatToInt :: BigNat -> Int# #
bigNatToWord :: BigNat -> Word# #
indexBigNat# :: BigNat -> GmpSize# -> GmpLimb# #
Deprecated: Use bigNatIndex# instead
BigNat
arithmetic operations
plusBigNat :: BigNat -> BigNat -> BigNat #
Deprecated: Use bigNatAdd instead
plusBigNatWord :: BigNat -> GmpLimb# -> BigNat #
Deprecated: Use bigNatAddWord# instead
minusBigNat :: BigNat -> BigNat -> BigNat #
Deprecated: Use bigNatSub instead
minusBigNatWord :: BigNat -> GmpLimb# -> BigNat #
Deprecated: Use bigNatSubWord# instead
timesBigNat :: BigNat -> BigNat -> BigNat #
Deprecated: Use bigNatMul instead
timesBigNatWord :: BigNat -> GmpLimb# -> BigNat #
Deprecated: Use bigNatMulWord# instead
quotRemBigNatWord :: BigNat -> GmpLimb# -> (# BigNat, GmpLimb# #) #
Deprecated: Use bigNatQuotRemWord# instead
quotBigNatWord :: BigNat -> GmpLimb# -> BigNat #
Deprecated: Use bigNatQuotWord# instead
quotBigNat :: BigNat -> BigNat -> BigNat #
Deprecated: Use bigNatQuot instead
remBigNatWord :: BigNat -> GmpLimb# -> Word# #
Deprecated: Use bigNatRemWord# instead
gcdBigNatWord :: BigNat -> Word# -> Word# #
Deprecated: Use bigNatGcdWord# instead
BigNat
logic operations
shiftRBigNat :: BigNat -> Int# -> BigNat #
Deprecated: Use bigNatShiftR# instead
shiftLBigNat :: BigNat -> Int# -> BigNat #
Deprecated: Use bigNatShiftL# instead
testBitBigNat :: BigNat -> Int# -> Bool #
Deprecated: Use bigNatTestBit# instead
clearBitBigNat :: BigNat -> Int# -> BigNat #
Deprecated: Use bigNatClearBit# instead
complementBitBigNat :: BigNat -> Int# -> BigNat #
Deprecated: Use bigNatComplementBit# instead
setBitBigNat :: BigNat -> Int# -> BigNat #
Deprecated: Use bigNatSetBit# instead
popCountBigNat :: BigNat -> Int# #
Deprecated: Use bigNatPopCount# instead
BigNat
comparison predicates
isZeroBigNat :: BigNat -> Bool #
Deprecated: Use bigNatIsZero instead
compareBigNatWord :: BigNat -> GmpLimb# -> Ordering #
Deprecated: Use bigNatCompareWord# instead
compareBigNat :: BigNat -> BigNat -> Ordering #
Deprecated: Use bigNatCompare instead
eqBigNatWord :: BigNat -> GmpLimb# -> Bool #
Deprecated: Use bigNatEqWord# instead
eqBigNatWord# :: BigNat -> GmpLimb# -> Int# #
Deprecated: Use bigNatEqWord# instead
gtBigNatWord# :: BigNat -> GmpLimb# -> Int# #
Deprecated: Use bigNatGtWord# instead
Import/export functions
Compute size of serialisation
sizeInBaseBigNat :: BigNat -> Int# -> Word# #
Deprecated: Use bigNatSizeInBase# instead
sizeInBaseInteger :: Integer -> Int# -> Word# #
Deprecated: Use integerSizeInBase# instead
sizeInBaseWord# :: Word# -> Int# -> Word# #
Deprecated: Use wordSizeInBase# instead
Export
exportBigNatToMutableByteArray :: BigNat -> MutableByteArray# RealWorld -> Word# -> Int# -> IO Word #
Deprecated: Use bigNatToMutableByteArray# instead
exportIntegerToMutableByteArray :: Integer -> MutableByteArray# RealWorld -> Word# -> Int# -> IO Word #
Deprecated: Use integerToMutableByteArray# instead
Import
importBigNatFromAddr :: Addr# -> Word# -> Int# -> IO BigNat #
Deprecated: Use bigNatFromAddr# instead
importIntegerFromAddr :: Addr# -> Word# -> Int# -> IO Integer #
Deprecated: Use integerFromAddr# instead
importBigNatFromByteArray :: ByteArray# -> Word# -> Word# -> Int# -> BigNat #
Deprecated: Use bigNatFromByteArray# instead
importIntegerFromByteArray :: ByteArray# -> Word# -> Word# -> Int# -> Integer #
Deprecated: Use integerFromByteArray# instead