{-# LANGUAGE TypeFamilyDependencies #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE AllowAmbiguousTypes #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE ConstrainedClassMethods #-}
{-# LANGUAGE ConstraintKinds #-}
{-# LANGUAGE DerivingVia #-}
{-# LANGUAGE UndecidableInstances #-}
{-# LANGUAGE CPP #-}
{-# OPTIONS_GHC -Wno-unticked-promoted-constructors #-}
{-# OPTIONS_GHC -Wno-type-defaults #-}
module Posit.Internal.PositC
(PositC(..),
ES(..),
PositF(),
IntN,
FixedWidthInteger(),
Max,
Next
) where
import Prelude hiding (exponent,significand)
#ifndef O_NO_STORABLE_RANDOM
import Foreign.Storable (Storable, sizeOf, alignment, peek, poke)
import Foreign.Ptr (Ptr, plusPtr, castPtr)
import System.Random.Stateful (Uniform, uniformM)
#endif
import Data.Int (Int8,Int16,Int32,Int64)
import Data.DoubleWord (Word128,Int128,Int256,fromHiAndLo,hiWord,loWord,DoubleWord,BinaryWord)
import Data.Word (Word64)
import Data.Bits (Bits(..), shiftL, shift, testBit, (.&.), shiftR,FiniteBits)
import GHC.Natural (Natural)
import Data.Ratio ((%))
data ES = Z_3_2
| I_3_2
| II_3_2
| III_3_2
| IV_3_2
| V_3_2
| Z_2022
| I_2022
| II_2022
| III_2022
| IV_2022
| V_2022
type family IntN (es :: ES)
where
IntN Z_3_2 = Int8
IntN I_3_2 = Int16
IntN II_3_2 = Int32
IntN III_3_2 = Int64
#ifdef O_NO_STORABLE_RANDOM
IntN IV_3_2 = Int128
IntN V_3_2 = Int256
#else
IntN IV_3_2 = Int128_Storable_Random
IntN V_3_2 = Int256_Storable_Random
#endif
IntN Z_2022 = Int8
IntN I_2022 = Int16
IntN II_2022 = Int32
IntN III_2022 = Int64
#ifdef O_NO_STORABLE_RANDOM
IntN IV_2022 = Int128
IntN V_2022 = Int256
#else
IntN IV_2022 = Int128_Storable_Random
IntN V_2022 = Int256_Storable_Random
newtype Int128_Storable_Random = Int128_Storable_Random Int128
deriving (Eq Int128_Storable_Random
Int128_Storable_Random
Int -> Int128_Storable_Random
Int128_Storable_Random -> Bool
Int128_Storable_Random -> Int
Int128_Storable_Random -> Maybe Int
Int128_Storable_Random -> Int128_Storable_Random
Int128_Storable_Random -> Int -> Bool
Int128_Storable_Random -> Int -> Int128_Storable_Random
Int128_Storable_Random
-> Int128_Storable_Random -> Int128_Storable_Random
forall a.
Eq a
-> (a -> a -> a)
-> (a -> a -> a)
-> (a -> a -> a)
-> (a -> a)
-> (a -> Int -> a)
-> (a -> Int -> a)
-> a
-> (Int -> a)
-> (a -> Int -> a)
-> (a -> Int -> a)
-> (a -> Int -> a)
-> (a -> Int -> Bool)
-> (a -> Maybe Int)
-> (a -> Int)
-> (a -> Bool)
-> (a -> Int -> a)
-> (a -> Int -> a)
-> (a -> Int -> a)
-> (a -> Int -> a)
-> (a -> Int -> a)
-> (a -> Int -> a)
-> (a -> Int)
-> Bits a
popCount :: Int128_Storable_Random -> Int
$cpopCount :: Int128_Storable_Random -> Int
rotateR :: Int128_Storable_Random -> Int -> Int128_Storable_Random
$crotateR :: Int128_Storable_Random -> Int -> Int128_Storable_Random
rotateL :: Int128_Storable_Random -> Int -> Int128_Storable_Random
$crotateL :: Int128_Storable_Random -> Int -> Int128_Storable_Random
unsafeShiftR :: Int128_Storable_Random -> Int -> Int128_Storable_Random
$cunsafeShiftR :: Int128_Storable_Random -> Int -> Int128_Storable_Random
shiftR :: Int128_Storable_Random -> Int -> Int128_Storable_Random
$cshiftR :: Int128_Storable_Random -> Int -> Int128_Storable_Random
unsafeShiftL :: Int128_Storable_Random -> Int -> Int128_Storable_Random
$cunsafeShiftL :: Int128_Storable_Random -> Int -> Int128_Storable_Random
shiftL :: Int128_Storable_Random -> Int -> Int128_Storable_Random
$cshiftL :: Int128_Storable_Random -> Int -> Int128_Storable_Random
isSigned :: Int128_Storable_Random -> Bool
$cisSigned :: Int128_Storable_Random -> Bool
bitSize :: Int128_Storable_Random -> Int
$cbitSize :: Int128_Storable_Random -> Int
bitSizeMaybe :: Int128_Storable_Random -> Maybe Int
$cbitSizeMaybe :: Int128_Storable_Random -> Maybe Int
testBit :: Int128_Storable_Random -> Int -> Bool
$ctestBit :: Int128_Storable_Random -> Int -> Bool
complementBit :: Int128_Storable_Random -> Int -> Int128_Storable_Random
$ccomplementBit :: Int128_Storable_Random -> Int -> Int128_Storable_Random
clearBit :: Int128_Storable_Random -> Int -> Int128_Storable_Random
$cclearBit :: Int128_Storable_Random -> Int -> Int128_Storable_Random
setBit :: Int128_Storable_Random -> Int -> Int128_Storable_Random
$csetBit :: Int128_Storable_Random -> Int -> Int128_Storable_Random
bit :: Int -> Int128_Storable_Random
$cbit :: Int -> Int128_Storable_Random
zeroBits :: Int128_Storable_Random
$czeroBits :: Int128_Storable_Random
rotate :: Int128_Storable_Random -> Int -> Int128_Storable_Random
$crotate :: Int128_Storable_Random -> Int -> Int128_Storable_Random
shift :: Int128_Storable_Random -> Int -> Int128_Storable_Random
$cshift :: Int128_Storable_Random -> Int -> Int128_Storable_Random
complement :: Int128_Storable_Random -> Int128_Storable_Random
$ccomplement :: Int128_Storable_Random -> Int128_Storable_Random
xor :: Int128_Storable_Random
-> Int128_Storable_Random -> Int128_Storable_Random
$cxor :: Int128_Storable_Random
-> Int128_Storable_Random -> Int128_Storable_Random
.|. :: Int128_Storable_Random
-> Int128_Storable_Random -> Int128_Storable_Random
$c.|. :: Int128_Storable_Random
-> Int128_Storable_Random -> Int128_Storable_Random
.&. :: Int128_Storable_Random
-> Int128_Storable_Random -> Int128_Storable_Random
$c.&. :: Int128_Storable_Random
-> Int128_Storable_Random -> Int128_Storable_Random
Bits,Int128_Storable_Random
forall a. a -> a -> Bounded a
maxBound :: Int128_Storable_Random
$cmaxBound :: Int128_Storable_Random
minBound :: Int128_Storable_Random
$cminBound :: Int128_Storable_Random
Bounded,Int -> Int128_Storable_Random
Int128_Storable_Random -> Int
Int128_Storable_Random -> [Int128_Storable_Random]
Int128_Storable_Random -> Int128_Storable_Random
Int128_Storable_Random
-> Int128_Storable_Random -> [Int128_Storable_Random]
Int128_Storable_Random
-> Int128_Storable_Random
-> Int128_Storable_Random
-> [Int128_Storable_Random]
forall a.
(a -> a)
-> (a -> a)
-> (Int -> a)
-> (a -> Int)
-> (a -> [a])
-> (a -> a -> [a])
-> (a -> a -> [a])
-> (a -> a -> a -> [a])
-> Enum a
enumFromThenTo :: Int128_Storable_Random
-> Int128_Storable_Random
-> Int128_Storable_Random
-> [Int128_Storable_Random]
$cenumFromThenTo :: Int128_Storable_Random
-> Int128_Storable_Random
-> Int128_Storable_Random
-> [Int128_Storable_Random]
enumFromTo :: Int128_Storable_Random
-> Int128_Storable_Random -> [Int128_Storable_Random]
$cenumFromTo :: Int128_Storable_Random
-> Int128_Storable_Random -> [Int128_Storable_Random]
enumFromThen :: Int128_Storable_Random
-> Int128_Storable_Random -> [Int128_Storable_Random]
$cenumFromThen :: Int128_Storable_Random
-> Int128_Storable_Random -> [Int128_Storable_Random]
enumFrom :: Int128_Storable_Random -> [Int128_Storable_Random]
$cenumFrom :: Int128_Storable_Random -> [Int128_Storable_Random]
fromEnum :: Int128_Storable_Random -> Int
$cfromEnum :: Int128_Storable_Random -> Int
toEnum :: Int -> Int128_Storable_Random
$ctoEnum :: Int -> Int128_Storable_Random
pred :: Int128_Storable_Random -> Int128_Storable_Random
$cpred :: Int128_Storable_Random -> Int128_Storable_Random
succ :: Int128_Storable_Random -> Int128_Storable_Random
$csucc :: Int128_Storable_Random -> Int128_Storable_Random
Enum,Num Int128_Storable_Random
Ord Int128_Storable_Random
Int128_Storable_Random -> Rational
forall a. Num a -> Ord a -> (a -> Rational) -> Real a
toRational :: Int128_Storable_Random -> Rational
$ctoRational :: Int128_Storable_Random -> Rational
Real,Enum Int128_Storable_Random
Real Int128_Storable_Random
Int128_Storable_Random -> Integer
Int128_Storable_Random
-> Int128_Storable_Random
-> (Int128_Storable_Random, Int128_Storable_Random)
Int128_Storable_Random
-> Int128_Storable_Random -> Int128_Storable_Random
forall a.
Real a
-> Enum a
-> (a -> a -> a)
-> (a -> a -> a)
-> (a -> a -> a)
-> (a -> a -> a)
-> (a -> a -> (a, a))
-> (a -> a -> (a, a))
-> (a -> Integer)
-> Integral a
toInteger :: Int128_Storable_Random -> Integer
$ctoInteger :: Int128_Storable_Random -> Integer
divMod :: Int128_Storable_Random
-> Int128_Storable_Random
-> (Int128_Storable_Random, Int128_Storable_Random)
$cdivMod :: Int128_Storable_Random
-> Int128_Storable_Random
-> (Int128_Storable_Random, Int128_Storable_Random)
quotRem :: Int128_Storable_Random
-> Int128_Storable_Random
-> (Int128_Storable_Random, Int128_Storable_Random)
$cquotRem :: Int128_Storable_Random
-> Int128_Storable_Random
-> (Int128_Storable_Random, Int128_Storable_Random)
mod :: Int128_Storable_Random
-> Int128_Storable_Random -> Int128_Storable_Random
$cmod :: Int128_Storable_Random
-> Int128_Storable_Random -> Int128_Storable_Random
div :: Int128_Storable_Random
-> Int128_Storable_Random -> Int128_Storable_Random
$cdiv :: Int128_Storable_Random
-> Int128_Storable_Random -> Int128_Storable_Random
rem :: Int128_Storable_Random
-> Int128_Storable_Random -> Int128_Storable_Random
$crem :: Int128_Storable_Random
-> Int128_Storable_Random -> Int128_Storable_Random
quot :: Int128_Storable_Random
-> Int128_Storable_Random -> Int128_Storable_Random
$cquot :: Int128_Storable_Random
-> Int128_Storable_Random -> Int128_Storable_Random
Integral,Int128_Storable_Random -> Int128_Storable_Random -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Int128_Storable_Random -> Int128_Storable_Random -> Bool
$c/= :: Int128_Storable_Random -> Int128_Storable_Random -> Bool
== :: Int128_Storable_Random -> Int128_Storable_Random -> Bool
$c== :: Int128_Storable_Random -> Int128_Storable_Random -> Bool
Eq,Eq Int128_Storable_Random
Int128_Storable_Random -> Int128_Storable_Random -> Bool
Int128_Storable_Random -> Int128_Storable_Random -> Ordering
Int128_Storable_Random
-> Int128_Storable_Random -> Int128_Storable_Random
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: Int128_Storable_Random
-> Int128_Storable_Random -> Int128_Storable_Random
$cmin :: Int128_Storable_Random
-> Int128_Storable_Random -> Int128_Storable_Random
max :: Int128_Storable_Random
-> Int128_Storable_Random -> Int128_Storable_Random
$cmax :: Int128_Storable_Random
-> Int128_Storable_Random -> Int128_Storable_Random
>= :: Int128_Storable_Random -> Int128_Storable_Random -> Bool
$c>= :: Int128_Storable_Random -> Int128_Storable_Random -> Bool
> :: Int128_Storable_Random -> Int128_Storable_Random -> Bool
$c> :: Int128_Storable_Random -> Int128_Storable_Random -> Bool
<= :: Int128_Storable_Random -> Int128_Storable_Random -> Bool
$c<= :: Int128_Storable_Random -> Int128_Storable_Random -> Bool
< :: Int128_Storable_Random -> Int128_Storable_Random -> Bool
$c< :: Int128_Storable_Random -> Int128_Storable_Random -> Bool
compare :: Int128_Storable_Random -> Int128_Storable_Random -> Ordering
$ccompare :: Int128_Storable_Random -> Int128_Storable_Random -> Ordering
Ord,Integer -> Int128_Storable_Random
Int128_Storable_Random -> Int128_Storable_Random
Int128_Storable_Random
-> Int128_Storable_Random -> Int128_Storable_Random
forall a.
(a -> a -> a)
-> (a -> a -> a)
-> (a -> a -> a)
-> (a -> a)
-> (a -> a)
-> (a -> a)
-> (Integer -> a)
-> Num a
fromInteger :: Integer -> Int128_Storable_Random
$cfromInteger :: Integer -> Int128_Storable_Random
signum :: Int128_Storable_Random -> Int128_Storable_Random
$csignum :: Int128_Storable_Random -> Int128_Storable_Random
abs :: Int128_Storable_Random -> Int128_Storable_Random
$cabs :: Int128_Storable_Random -> Int128_Storable_Random
negate :: Int128_Storable_Random -> Int128_Storable_Random
$cnegate :: Int128_Storable_Random -> Int128_Storable_Random
* :: Int128_Storable_Random
-> Int128_Storable_Random -> Int128_Storable_Random
$c* :: Int128_Storable_Random
-> Int128_Storable_Random -> Int128_Storable_Random
- :: Int128_Storable_Random
-> Int128_Storable_Random -> Int128_Storable_Random
$c- :: Int128_Storable_Random
-> Int128_Storable_Random -> Int128_Storable_Random
+ :: Int128_Storable_Random
-> Int128_Storable_Random -> Int128_Storable_Random
$c+ :: Int128_Storable_Random
-> Int128_Storable_Random -> Int128_Storable_Random
Num,ReadPrec [Int128_Storable_Random]
ReadPrec Int128_Storable_Random
Int -> ReadS Int128_Storable_Random
ReadS [Int128_Storable_Random]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Int128_Storable_Random]
$creadListPrec :: ReadPrec [Int128_Storable_Random]
readPrec :: ReadPrec Int128_Storable_Random
$creadPrec :: ReadPrec Int128_Storable_Random
readList :: ReadS [Int128_Storable_Random]
$creadList :: ReadS [Int128_Storable_Random]
readsPrec :: Int -> ReadS Int128_Storable_Random
$creadsPrec :: Int -> ReadS Int128_Storable_Random
Read,Int -> Int128_Storable_Random -> ShowS
[Int128_Storable_Random] -> ShowS
Int128_Storable_Random -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Int128_Storable_Random] -> ShowS
$cshowList :: [Int128_Storable_Random] -> ShowS
show :: Int128_Storable_Random -> String
$cshow :: Int128_Storable_Random -> String
showsPrec :: Int -> Int128_Storable_Random -> ShowS
$cshowsPrec :: Int -> Int128_Storable_Random -> ShowS
Show,BinaryWord Int128_Storable_Random
SignedWord (LoWord Int128_Storable_Random)
-> Int128_Storable_Random
HiWord Int128_Storable_Random
-> LoWord Int128_Storable_Random -> Int128_Storable_Random
LoWord Int128_Storable_Random -> Int128_Storable_Random
Int128_Storable_Random -> HiWord Int128_Storable_Random
Int128_Storable_Random -> LoWord Int128_Storable_Random
forall w.
BinaryWord w
-> (w -> LoWord w)
-> (w -> HiWord w)
-> (HiWord w -> LoWord w -> w)
-> (LoWord w -> w)
-> (SignedWord (LoWord w) -> w)
-> DoubleWord w
signExtendLo :: SignedWord (LoWord Int128_Storable_Random)
-> Int128_Storable_Random
$csignExtendLo :: SignedWord (LoWord Int128_Storable_Random)
-> Int128_Storable_Random
extendLo :: LoWord Int128_Storable_Random -> Int128_Storable_Random
$cextendLo :: LoWord Int128_Storable_Random -> Int128_Storable_Random
fromHiAndLo :: HiWord Int128_Storable_Random
-> LoWord Int128_Storable_Random -> Int128_Storable_Random
$cfromHiAndLo :: HiWord Int128_Storable_Random
-> LoWord Int128_Storable_Random -> Int128_Storable_Random
hiWord :: Int128_Storable_Random -> HiWord Int128_Storable_Random
$chiWord :: Int128_Storable_Random -> HiWord Int128_Storable_Random
loWord :: Int128_Storable_Random -> LoWord Int128_Storable_Random
$cloWord :: Int128_Storable_Random -> LoWord Int128_Storable_Random
DoubleWord,FiniteBits (SignedWord Int128_Storable_Random)
FiniteBits (UnsignedWord Int128_Storable_Random)
FiniteBits Int128_Storable_Random
Int128_Storable_Random
Int128_Storable_Random -> Bool
Int128_Storable_Random -> Int
Int128_Storable_Random -> SignedWord Int128_Storable_Random
Int128_Storable_Random -> UnsignedWord Int128_Storable_Random
Int128_Storable_Random -> Int128_Storable_Random
Int128_Storable_Random
-> Int128_Storable_Random
-> (Int128_Storable_Random, UnsignedWord Int128_Storable_Random)
forall w.
FiniteBits w
-> FiniteBits (UnsignedWord w)
-> FiniteBits (SignedWord w)
-> (w -> UnsignedWord w)
-> (w -> SignedWord w)
-> (w -> w -> (w, UnsignedWord w))
-> (w -> w -> (w, UnsignedWord w))
-> (w -> Int)
-> (w -> Int)
-> w
-> w
-> w
-> w
-> (w -> Bool)
-> (w -> Bool)
-> (w -> w)
-> (w -> w)
-> (w -> w)
-> (w -> w)
-> BinaryWord w
clearLsb :: Int128_Storable_Random -> Int128_Storable_Random
$cclearLsb :: Int128_Storable_Random -> Int128_Storable_Random
clearMsb :: Int128_Storable_Random -> Int128_Storable_Random
$cclearMsb :: Int128_Storable_Random -> Int128_Storable_Random
setLsb :: Int128_Storable_Random -> Int128_Storable_Random
$csetLsb :: Int128_Storable_Random -> Int128_Storable_Random
setMsb :: Int128_Storable_Random -> Int128_Storable_Random
$csetMsb :: Int128_Storable_Random -> Int128_Storable_Random
testLsb :: Int128_Storable_Random -> Bool
$ctestLsb :: Int128_Storable_Random -> Bool
testMsb :: Int128_Storable_Random -> Bool
$ctestMsb :: Int128_Storable_Random -> Bool
lsb :: Int128_Storable_Random
$clsb :: Int128_Storable_Random
msb :: Int128_Storable_Random
$cmsb :: Int128_Storable_Random
allOnes :: Int128_Storable_Random
$callOnes :: Int128_Storable_Random
allZeroes :: Int128_Storable_Random
$callZeroes :: Int128_Storable_Random
trailingZeroes :: Int128_Storable_Random -> Int
$ctrailingZeroes :: Int128_Storable_Random -> Int
leadingZeroes :: Int128_Storable_Random -> Int
$cleadingZeroes :: Int128_Storable_Random -> Int
unwrappedMul :: Int128_Storable_Random
-> Int128_Storable_Random
-> (Int128_Storable_Random, UnsignedWord Int128_Storable_Random)
$cunwrappedMul :: Int128_Storable_Random
-> Int128_Storable_Random
-> (Int128_Storable_Random, UnsignedWord Int128_Storable_Random)
unwrappedAdd :: Int128_Storable_Random
-> Int128_Storable_Random
-> (Int128_Storable_Random, UnsignedWord Int128_Storable_Random)
$cunwrappedAdd :: Int128_Storable_Random
-> Int128_Storable_Random
-> (Int128_Storable_Random, UnsignedWord Int128_Storable_Random)
signedWord :: Int128_Storable_Random -> SignedWord Int128_Storable_Random
$csignedWord :: Int128_Storable_Random -> SignedWord Int128_Storable_Random
unsignedWord :: Int128_Storable_Random -> UnsignedWord Int128_Storable_Random
$cunsignedWord :: Int128_Storable_Random -> UnsignedWord Int128_Storable_Random
BinaryWord,Bits Int128_Storable_Random
Int128_Storable_Random -> Int
forall b.
Bits b -> (b -> Int) -> (b -> Int) -> (b -> Int) -> FiniteBits b
countTrailingZeros :: Int128_Storable_Random -> Int
$ccountTrailingZeros :: Int128_Storable_Random -> Int
countLeadingZeros :: Int128_Storable_Random -> Int
$ccountLeadingZeros :: Int128_Storable_Random -> Int
finiteBitSize :: Int128_Storable_Random -> Int
$cfiniteBitSize :: Int128_Storable_Random -> Int
FiniteBits)
via Int128
newtype Int256_Storable_Random = Int256_Storable_Random Int256
deriving (Eq Int256_Storable_Random
Int256_Storable_Random
Int -> Int256_Storable_Random
Int256_Storable_Random -> Bool
Int256_Storable_Random -> Int
Int256_Storable_Random -> Maybe Int
Int256_Storable_Random -> Int256_Storable_Random
Int256_Storable_Random -> Int -> Bool
Int256_Storable_Random -> Int -> Int256_Storable_Random
Int256_Storable_Random
-> Int256_Storable_Random -> Int256_Storable_Random
forall a.
Eq a
-> (a -> a -> a)
-> (a -> a -> a)
-> (a -> a -> a)
-> (a -> a)
-> (a -> Int -> a)
-> (a -> Int -> a)
-> a
-> (Int -> a)
-> (a -> Int -> a)
-> (a -> Int -> a)
-> (a -> Int -> a)
-> (a -> Int -> Bool)
-> (a -> Maybe Int)
-> (a -> Int)
-> (a -> Bool)
-> (a -> Int -> a)
-> (a -> Int -> a)
-> (a -> Int -> a)
-> (a -> Int -> a)
-> (a -> Int -> a)
-> (a -> Int -> a)
-> (a -> Int)
-> Bits a
popCount :: Int256_Storable_Random -> Int
$cpopCount :: Int256_Storable_Random -> Int
rotateR :: Int256_Storable_Random -> Int -> Int256_Storable_Random
$crotateR :: Int256_Storable_Random -> Int -> Int256_Storable_Random
rotateL :: Int256_Storable_Random -> Int -> Int256_Storable_Random
$crotateL :: Int256_Storable_Random -> Int -> Int256_Storable_Random
unsafeShiftR :: Int256_Storable_Random -> Int -> Int256_Storable_Random
$cunsafeShiftR :: Int256_Storable_Random -> Int -> Int256_Storable_Random
shiftR :: Int256_Storable_Random -> Int -> Int256_Storable_Random
$cshiftR :: Int256_Storable_Random -> Int -> Int256_Storable_Random
unsafeShiftL :: Int256_Storable_Random -> Int -> Int256_Storable_Random
$cunsafeShiftL :: Int256_Storable_Random -> Int -> Int256_Storable_Random
shiftL :: Int256_Storable_Random -> Int -> Int256_Storable_Random
$cshiftL :: Int256_Storable_Random -> Int -> Int256_Storable_Random
isSigned :: Int256_Storable_Random -> Bool
$cisSigned :: Int256_Storable_Random -> Bool
bitSize :: Int256_Storable_Random -> Int
$cbitSize :: Int256_Storable_Random -> Int
bitSizeMaybe :: Int256_Storable_Random -> Maybe Int
$cbitSizeMaybe :: Int256_Storable_Random -> Maybe Int
testBit :: Int256_Storable_Random -> Int -> Bool
$ctestBit :: Int256_Storable_Random -> Int -> Bool
complementBit :: Int256_Storable_Random -> Int -> Int256_Storable_Random
$ccomplementBit :: Int256_Storable_Random -> Int -> Int256_Storable_Random
clearBit :: Int256_Storable_Random -> Int -> Int256_Storable_Random
$cclearBit :: Int256_Storable_Random -> Int -> Int256_Storable_Random
setBit :: Int256_Storable_Random -> Int -> Int256_Storable_Random
$csetBit :: Int256_Storable_Random -> Int -> Int256_Storable_Random
bit :: Int -> Int256_Storable_Random
$cbit :: Int -> Int256_Storable_Random
zeroBits :: Int256_Storable_Random
$czeroBits :: Int256_Storable_Random
rotate :: Int256_Storable_Random -> Int -> Int256_Storable_Random
$crotate :: Int256_Storable_Random -> Int -> Int256_Storable_Random
shift :: Int256_Storable_Random -> Int -> Int256_Storable_Random
$cshift :: Int256_Storable_Random -> Int -> Int256_Storable_Random
complement :: Int256_Storable_Random -> Int256_Storable_Random
$ccomplement :: Int256_Storable_Random -> Int256_Storable_Random
xor :: Int256_Storable_Random
-> Int256_Storable_Random -> Int256_Storable_Random
$cxor :: Int256_Storable_Random
-> Int256_Storable_Random -> Int256_Storable_Random
.|. :: Int256_Storable_Random
-> Int256_Storable_Random -> Int256_Storable_Random
$c.|. :: Int256_Storable_Random
-> Int256_Storable_Random -> Int256_Storable_Random
.&. :: Int256_Storable_Random
-> Int256_Storable_Random -> Int256_Storable_Random
$c.&. :: Int256_Storable_Random
-> Int256_Storable_Random -> Int256_Storable_Random
Bits,Int256_Storable_Random
forall a. a -> a -> Bounded a
maxBound :: Int256_Storable_Random
$cmaxBound :: Int256_Storable_Random
minBound :: Int256_Storable_Random
$cminBound :: Int256_Storable_Random
Bounded,Int -> Int256_Storable_Random
Int256_Storable_Random -> Int
Int256_Storable_Random -> [Int256_Storable_Random]
Int256_Storable_Random -> Int256_Storable_Random
Int256_Storable_Random
-> Int256_Storable_Random -> [Int256_Storable_Random]
Int256_Storable_Random
-> Int256_Storable_Random
-> Int256_Storable_Random
-> [Int256_Storable_Random]
forall a.
(a -> a)
-> (a -> a)
-> (Int -> a)
-> (a -> Int)
-> (a -> [a])
-> (a -> a -> [a])
-> (a -> a -> [a])
-> (a -> a -> a -> [a])
-> Enum a
enumFromThenTo :: Int256_Storable_Random
-> Int256_Storable_Random
-> Int256_Storable_Random
-> [Int256_Storable_Random]
$cenumFromThenTo :: Int256_Storable_Random
-> Int256_Storable_Random
-> Int256_Storable_Random
-> [Int256_Storable_Random]
enumFromTo :: Int256_Storable_Random
-> Int256_Storable_Random -> [Int256_Storable_Random]
$cenumFromTo :: Int256_Storable_Random
-> Int256_Storable_Random -> [Int256_Storable_Random]
enumFromThen :: Int256_Storable_Random
-> Int256_Storable_Random -> [Int256_Storable_Random]
$cenumFromThen :: Int256_Storable_Random
-> Int256_Storable_Random -> [Int256_Storable_Random]
enumFrom :: Int256_Storable_Random -> [Int256_Storable_Random]
$cenumFrom :: Int256_Storable_Random -> [Int256_Storable_Random]
fromEnum :: Int256_Storable_Random -> Int
$cfromEnum :: Int256_Storable_Random -> Int
toEnum :: Int -> Int256_Storable_Random
$ctoEnum :: Int -> Int256_Storable_Random
pred :: Int256_Storable_Random -> Int256_Storable_Random
$cpred :: Int256_Storable_Random -> Int256_Storable_Random
succ :: Int256_Storable_Random -> Int256_Storable_Random
$csucc :: Int256_Storable_Random -> Int256_Storable_Random
Enum,Num Int256_Storable_Random
Ord Int256_Storable_Random
Int256_Storable_Random -> Rational
forall a. Num a -> Ord a -> (a -> Rational) -> Real a
toRational :: Int256_Storable_Random -> Rational
$ctoRational :: Int256_Storable_Random -> Rational
Real,Enum Int256_Storable_Random
Real Int256_Storable_Random
Int256_Storable_Random -> Integer
Int256_Storable_Random
-> Int256_Storable_Random
-> (Int256_Storable_Random, Int256_Storable_Random)
Int256_Storable_Random
-> Int256_Storable_Random -> Int256_Storable_Random
forall a.
Real a
-> Enum a
-> (a -> a -> a)
-> (a -> a -> a)
-> (a -> a -> a)
-> (a -> a -> a)
-> (a -> a -> (a, a))
-> (a -> a -> (a, a))
-> (a -> Integer)
-> Integral a
toInteger :: Int256_Storable_Random -> Integer
$ctoInteger :: Int256_Storable_Random -> Integer
divMod :: Int256_Storable_Random
-> Int256_Storable_Random
-> (Int256_Storable_Random, Int256_Storable_Random)
$cdivMod :: Int256_Storable_Random
-> Int256_Storable_Random
-> (Int256_Storable_Random, Int256_Storable_Random)
quotRem :: Int256_Storable_Random
-> Int256_Storable_Random
-> (Int256_Storable_Random, Int256_Storable_Random)
$cquotRem :: Int256_Storable_Random
-> Int256_Storable_Random
-> (Int256_Storable_Random, Int256_Storable_Random)
mod :: Int256_Storable_Random
-> Int256_Storable_Random -> Int256_Storable_Random
$cmod :: Int256_Storable_Random
-> Int256_Storable_Random -> Int256_Storable_Random
div :: Int256_Storable_Random
-> Int256_Storable_Random -> Int256_Storable_Random
$cdiv :: Int256_Storable_Random
-> Int256_Storable_Random -> Int256_Storable_Random
rem :: Int256_Storable_Random
-> Int256_Storable_Random -> Int256_Storable_Random
$crem :: Int256_Storable_Random
-> Int256_Storable_Random -> Int256_Storable_Random
quot :: Int256_Storable_Random
-> Int256_Storable_Random -> Int256_Storable_Random
$cquot :: Int256_Storable_Random
-> Int256_Storable_Random -> Int256_Storable_Random
Integral,Int256_Storable_Random -> Int256_Storable_Random -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Int256_Storable_Random -> Int256_Storable_Random -> Bool
$c/= :: Int256_Storable_Random -> Int256_Storable_Random -> Bool
== :: Int256_Storable_Random -> Int256_Storable_Random -> Bool
$c== :: Int256_Storable_Random -> Int256_Storable_Random -> Bool
Eq,Eq Int256_Storable_Random
Int256_Storable_Random -> Int256_Storable_Random -> Bool
Int256_Storable_Random -> Int256_Storable_Random -> Ordering
Int256_Storable_Random
-> Int256_Storable_Random -> Int256_Storable_Random
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: Int256_Storable_Random
-> Int256_Storable_Random -> Int256_Storable_Random
$cmin :: Int256_Storable_Random
-> Int256_Storable_Random -> Int256_Storable_Random
max :: Int256_Storable_Random
-> Int256_Storable_Random -> Int256_Storable_Random
$cmax :: Int256_Storable_Random
-> Int256_Storable_Random -> Int256_Storable_Random
>= :: Int256_Storable_Random -> Int256_Storable_Random -> Bool
$c>= :: Int256_Storable_Random -> Int256_Storable_Random -> Bool
> :: Int256_Storable_Random -> Int256_Storable_Random -> Bool
$c> :: Int256_Storable_Random -> Int256_Storable_Random -> Bool
<= :: Int256_Storable_Random -> Int256_Storable_Random -> Bool
$c<= :: Int256_Storable_Random -> Int256_Storable_Random -> Bool
< :: Int256_Storable_Random -> Int256_Storable_Random -> Bool
$c< :: Int256_Storable_Random -> Int256_Storable_Random -> Bool
compare :: Int256_Storable_Random -> Int256_Storable_Random -> Ordering
$ccompare :: Int256_Storable_Random -> Int256_Storable_Random -> Ordering
Ord,Integer -> Int256_Storable_Random
Int256_Storable_Random -> Int256_Storable_Random
Int256_Storable_Random
-> Int256_Storable_Random -> Int256_Storable_Random
forall a.
(a -> a -> a)
-> (a -> a -> a)
-> (a -> a -> a)
-> (a -> a)
-> (a -> a)
-> (a -> a)
-> (Integer -> a)
-> Num a
fromInteger :: Integer -> Int256_Storable_Random
$cfromInteger :: Integer -> Int256_Storable_Random
signum :: Int256_Storable_Random -> Int256_Storable_Random
$csignum :: Int256_Storable_Random -> Int256_Storable_Random
abs :: Int256_Storable_Random -> Int256_Storable_Random
$cabs :: Int256_Storable_Random -> Int256_Storable_Random
negate :: Int256_Storable_Random -> Int256_Storable_Random
$cnegate :: Int256_Storable_Random -> Int256_Storable_Random
* :: Int256_Storable_Random
-> Int256_Storable_Random -> Int256_Storable_Random
$c* :: Int256_Storable_Random
-> Int256_Storable_Random -> Int256_Storable_Random
- :: Int256_Storable_Random
-> Int256_Storable_Random -> Int256_Storable_Random
$c- :: Int256_Storable_Random
-> Int256_Storable_Random -> Int256_Storable_Random
+ :: Int256_Storable_Random
-> Int256_Storable_Random -> Int256_Storable_Random
$c+ :: Int256_Storable_Random
-> Int256_Storable_Random -> Int256_Storable_Random
Num,ReadPrec [Int256_Storable_Random]
ReadPrec Int256_Storable_Random
Int -> ReadS Int256_Storable_Random
ReadS [Int256_Storable_Random]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Int256_Storable_Random]
$creadListPrec :: ReadPrec [Int256_Storable_Random]
readPrec :: ReadPrec Int256_Storable_Random
$creadPrec :: ReadPrec Int256_Storable_Random
readList :: ReadS [Int256_Storable_Random]
$creadList :: ReadS [Int256_Storable_Random]
readsPrec :: Int -> ReadS Int256_Storable_Random
$creadsPrec :: Int -> ReadS Int256_Storable_Random
Read,Int -> Int256_Storable_Random -> ShowS
[Int256_Storable_Random] -> ShowS
Int256_Storable_Random -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Int256_Storable_Random] -> ShowS
$cshowList :: [Int256_Storable_Random] -> ShowS
show :: Int256_Storable_Random -> String
$cshow :: Int256_Storable_Random -> String
showsPrec :: Int -> Int256_Storable_Random -> ShowS
$cshowsPrec :: Int -> Int256_Storable_Random -> ShowS
Show,BinaryWord Int256_Storable_Random
SignedWord (LoWord Int256_Storable_Random)
-> Int256_Storable_Random
HiWord Int256_Storable_Random
-> LoWord Int256_Storable_Random -> Int256_Storable_Random
LoWord Int256_Storable_Random -> Int256_Storable_Random
Int256_Storable_Random -> HiWord Int256_Storable_Random
Int256_Storable_Random -> LoWord Int256_Storable_Random
forall w.
BinaryWord w
-> (w -> LoWord w)
-> (w -> HiWord w)
-> (HiWord w -> LoWord w -> w)
-> (LoWord w -> w)
-> (SignedWord (LoWord w) -> w)
-> DoubleWord w
signExtendLo :: SignedWord (LoWord Int256_Storable_Random)
-> Int256_Storable_Random
$csignExtendLo :: SignedWord (LoWord Int256_Storable_Random)
-> Int256_Storable_Random
extendLo :: LoWord Int256_Storable_Random -> Int256_Storable_Random
$cextendLo :: LoWord Int256_Storable_Random -> Int256_Storable_Random
fromHiAndLo :: HiWord Int256_Storable_Random
-> LoWord Int256_Storable_Random -> Int256_Storable_Random
$cfromHiAndLo :: HiWord Int256_Storable_Random
-> LoWord Int256_Storable_Random -> Int256_Storable_Random
hiWord :: Int256_Storable_Random -> HiWord Int256_Storable_Random
$chiWord :: Int256_Storable_Random -> HiWord Int256_Storable_Random
loWord :: Int256_Storable_Random -> LoWord Int256_Storable_Random
$cloWord :: Int256_Storable_Random -> LoWord Int256_Storable_Random
DoubleWord,FiniteBits (SignedWord Int256_Storable_Random)
FiniteBits (UnsignedWord Int256_Storable_Random)
FiniteBits Int256_Storable_Random
Int256_Storable_Random
Int256_Storable_Random -> Bool
Int256_Storable_Random -> Int
Int256_Storable_Random -> SignedWord Int256_Storable_Random
Int256_Storable_Random -> UnsignedWord Int256_Storable_Random
Int256_Storable_Random -> Int256_Storable_Random
Int256_Storable_Random
-> Int256_Storable_Random
-> (Int256_Storable_Random, UnsignedWord Int256_Storable_Random)
forall w.
FiniteBits w
-> FiniteBits (UnsignedWord w)
-> FiniteBits (SignedWord w)
-> (w -> UnsignedWord w)
-> (w -> SignedWord w)
-> (w -> w -> (w, UnsignedWord w))
-> (w -> w -> (w, UnsignedWord w))
-> (w -> Int)
-> (w -> Int)
-> w
-> w
-> w
-> w
-> (w -> Bool)
-> (w -> Bool)
-> (w -> w)
-> (w -> w)
-> (w -> w)
-> (w -> w)
-> BinaryWord w
clearLsb :: Int256_Storable_Random -> Int256_Storable_Random
$cclearLsb :: Int256_Storable_Random -> Int256_Storable_Random
clearMsb :: Int256_Storable_Random -> Int256_Storable_Random
$cclearMsb :: Int256_Storable_Random -> Int256_Storable_Random
setLsb :: Int256_Storable_Random -> Int256_Storable_Random
$csetLsb :: Int256_Storable_Random -> Int256_Storable_Random
setMsb :: Int256_Storable_Random -> Int256_Storable_Random
$csetMsb :: Int256_Storable_Random -> Int256_Storable_Random
testLsb :: Int256_Storable_Random -> Bool
$ctestLsb :: Int256_Storable_Random -> Bool
testMsb :: Int256_Storable_Random -> Bool
$ctestMsb :: Int256_Storable_Random -> Bool
lsb :: Int256_Storable_Random
$clsb :: Int256_Storable_Random
msb :: Int256_Storable_Random
$cmsb :: Int256_Storable_Random
allOnes :: Int256_Storable_Random
$callOnes :: Int256_Storable_Random
allZeroes :: Int256_Storable_Random
$callZeroes :: Int256_Storable_Random
trailingZeroes :: Int256_Storable_Random -> Int
$ctrailingZeroes :: Int256_Storable_Random -> Int
leadingZeroes :: Int256_Storable_Random -> Int
$cleadingZeroes :: Int256_Storable_Random -> Int
unwrappedMul :: Int256_Storable_Random
-> Int256_Storable_Random
-> (Int256_Storable_Random, UnsignedWord Int256_Storable_Random)
$cunwrappedMul :: Int256_Storable_Random
-> Int256_Storable_Random
-> (Int256_Storable_Random, UnsignedWord Int256_Storable_Random)
unwrappedAdd :: Int256_Storable_Random
-> Int256_Storable_Random
-> (Int256_Storable_Random, UnsignedWord Int256_Storable_Random)
$cunwrappedAdd :: Int256_Storable_Random
-> Int256_Storable_Random
-> (Int256_Storable_Random, UnsignedWord Int256_Storable_Random)
signedWord :: Int256_Storable_Random -> SignedWord Int256_Storable_Random
$csignedWord :: Int256_Storable_Random -> SignedWord Int256_Storable_Random
unsignedWord :: Int256_Storable_Random -> UnsignedWord Int256_Storable_Random
$cunsignedWord :: Int256_Storable_Random -> UnsignedWord Int256_Storable_Random
BinaryWord,Bits Int256_Storable_Random
Int256_Storable_Random -> Int
forall b.
Bits b -> (b -> Int) -> (b -> Int) -> (b -> Int) -> FiniteBits b
countTrailingZeros :: Int256_Storable_Random -> Int
$ccountTrailingZeros :: Int256_Storable_Random -> Int
countLeadingZeros :: Int256_Storable_Random -> Int
$ccountLeadingZeros :: Int256_Storable_Random -> Int
finiteBitSize :: Int256_Storable_Random -> Int
$cfiniteBitSize :: Int256_Storable_Random -> Int
FiniteBits)
via Int256
newtype Word128_Storable_Random = Word128_Storable_Random Word128
deriving (Eq Word128_Storable_Random
Word128_Storable_Random
Int -> Word128_Storable_Random
Word128_Storable_Random -> Bool
Word128_Storable_Random -> Int
Word128_Storable_Random -> Maybe Int
Word128_Storable_Random -> Word128_Storable_Random
Word128_Storable_Random -> Int -> Bool
Word128_Storable_Random -> Int -> Word128_Storable_Random
Word128_Storable_Random
-> Word128_Storable_Random -> Word128_Storable_Random
forall a.
Eq a
-> (a -> a -> a)
-> (a -> a -> a)
-> (a -> a -> a)
-> (a -> a)
-> (a -> Int -> a)
-> (a -> Int -> a)
-> a
-> (Int -> a)
-> (a -> Int -> a)
-> (a -> Int -> a)
-> (a -> Int -> a)
-> (a -> Int -> Bool)
-> (a -> Maybe Int)
-> (a -> Int)
-> (a -> Bool)
-> (a -> Int -> a)
-> (a -> Int -> a)
-> (a -> Int -> a)
-> (a -> Int -> a)
-> (a -> Int -> a)
-> (a -> Int -> a)
-> (a -> Int)
-> Bits a
popCount :: Word128_Storable_Random -> Int
$cpopCount :: Word128_Storable_Random -> Int
rotateR :: Word128_Storable_Random -> Int -> Word128_Storable_Random
$crotateR :: Word128_Storable_Random -> Int -> Word128_Storable_Random
rotateL :: Word128_Storable_Random -> Int -> Word128_Storable_Random
$crotateL :: Word128_Storable_Random -> Int -> Word128_Storable_Random
unsafeShiftR :: Word128_Storable_Random -> Int -> Word128_Storable_Random
$cunsafeShiftR :: Word128_Storable_Random -> Int -> Word128_Storable_Random
shiftR :: Word128_Storable_Random -> Int -> Word128_Storable_Random
$cshiftR :: Word128_Storable_Random -> Int -> Word128_Storable_Random
unsafeShiftL :: Word128_Storable_Random -> Int -> Word128_Storable_Random
$cunsafeShiftL :: Word128_Storable_Random -> Int -> Word128_Storable_Random
shiftL :: Word128_Storable_Random -> Int -> Word128_Storable_Random
$cshiftL :: Word128_Storable_Random -> Int -> Word128_Storable_Random
isSigned :: Word128_Storable_Random -> Bool
$cisSigned :: Word128_Storable_Random -> Bool
bitSize :: Word128_Storable_Random -> Int
$cbitSize :: Word128_Storable_Random -> Int
bitSizeMaybe :: Word128_Storable_Random -> Maybe Int
$cbitSizeMaybe :: Word128_Storable_Random -> Maybe Int
testBit :: Word128_Storable_Random -> Int -> Bool
$ctestBit :: Word128_Storable_Random -> Int -> Bool
complementBit :: Word128_Storable_Random -> Int -> Word128_Storable_Random
$ccomplementBit :: Word128_Storable_Random -> Int -> Word128_Storable_Random
clearBit :: Word128_Storable_Random -> Int -> Word128_Storable_Random
$cclearBit :: Word128_Storable_Random -> Int -> Word128_Storable_Random
setBit :: Word128_Storable_Random -> Int -> Word128_Storable_Random
$csetBit :: Word128_Storable_Random -> Int -> Word128_Storable_Random
bit :: Int -> Word128_Storable_Random
$cbit :: Int -> Word128_Storable_Random
zeroBits :: Word128_Storable_Random
$czeroBits :: Word128_Storable_Random
rotate :: Word128_Storable_Random -> Int -> Word128_Storable_Random
$crotate :: Word128_Storable_Random -> Int -> Word128_Storable_Random
shift :: Word128_Storable_Random -> Int -> Word128_Storable_Random
$cshift :: Word128_Storable_Random -> Int -> Word128_Storable_Random
complement :: Word128_Storable_Random -> Word128_Storable_Random
$ccomplement :: Word128_Storable_Random -> Word128_Storable_Random
xor :: Word128_Storable_Random
-> Word128_Storable_Random -> Word128_Storable_Random
$cxor :: Word128_Storable_Random
-> Word128_Storable_Random -> Word128_Storable_Random
.|. :: Word128_Storable_Random
-> Word128_Storable_Random -> Word128_Storable_Random
$c.|. :: Word128_Storable_Random
-> Word128_Storable_Random -> Word128_Storable_Random
.&. :: Word128_Storable_Random
-> Word128_Storable_Random -> Word128_Storable_Random
$c.&. :: Word128_Storable_Random
-> Word128_Storable_Random -> Word128_Storable_Random
Bits,Word128_Storable_Random
forall a. a -> a -> Bounded a
maxBound :: Word128_Storable_Random
$cmaxBound :: Word128_Storable_Random
minBound :: Word128_Storable_Random
$cminBound :: Word128_Storable_Random
Bounded,Int -> Word128_Storable_Random
Word128_Storable_Random -> Int
Word128_Storable_Random -> [Word128_Storable_Random]
Word128_Storable_Random -> Word128_Storable_Random
Word128_Storable_Random
-> Word128_Storable_Random -> [Word128_Storable_Random]
Word128_Storable_Random
-> Word128_Storable_Random
-> Word128_Storable_Random
-> [Word128_Storable_Random]
forall a.
(a -> a)
-> (a -> a)
-> (Int -> a)
-> (a -> Int)
-> (a -> [a])
-> (a -> a -> [a])
-> (a -> a -> [a])
-> (a -> a -> a -> [a])
-> Enum a
enumFromThenTo :: Word128_Storable_Random
-> Word128_Storable_Random
-> Word128_Storable_Random
-> [Word128_Storable_Random]
$cenumFromThenTo :: Word128_Storable_Random
-> Word128_Storable_Random
-> Word128_Storable_Random
-> [Word128_Storable_Random]
enumFromTo :: Word128_Storable_Random
-> Word128_Storable_Random -> [Word128_Storable_Random]
$cenumFromTo :: Word128_Storable_Random
-> Word128_Storable_Random -> [Word128_Storable_Random]
enumFromThen :: Word128_Storable_Random
-> Word128_Storable_Random -> [Word128_Storable_Random]
$cenumFromThen :: Word128_Storable_Random
-> Word128_Storable_Random -> [Word128_Storable_Random]
enumFrom :: Word128_Storable_Random -> [Word128_Storable_Random]
$cenumFrom :: Word128_Storable_Random -> [Word128_Storable_Random]
fromEnum :: Word128_Storable_Random -> Int
$cfromEnum :: Word128_Storable_Random -> Int
toEnum :: Int -> Word128_Storable_Random
$ctoEnum :: Int -> Word128_Storable_Random
pred :: Word128_Storable_Random -> Word128_Storable_Random
$cpred :: Word128_Storable_Random -> Word128_Storable_Random
succ :: Word128_Storable_Random -> Word128_Storable_Random
$csucc :: Word128_Storable_Random -> Word128_Storable_Random
Enum,Num Word128_Storable_Random
Ord Word128_Storable_Random
Word128_Storable_Random -> Rational
forall a. Num a -> Ord a -> (a -> Rational) -> Real a
toRational :: Word128_Storable_Random -> Rational
$ctoRational :: Word128_Storable_Random -> Rational
Real,Enum Word128_Storable_Random
Real Word128_Storable_Random
Word128_Storable_Random -> Integer
Word128_Storable_Random
-> Word128_Storable_Random
-> (Word128_Storable_Random, Word128_Storable_Random)
Word128_Storable_Random
-> Word128_Storable_Random -> Word128_Storable_Random
forall a.
Real a
-> Enum a
-> (a -> a -> a)
-> (a -> a -> a)
-> (a -> a -> a)
-> (a -> a -> a)
-> (a -> a -> (a, a))
-> (a -> a -> (a, a))
-> (a -> Integer)
-> Integral a
toInteger :: Word128_Storable_Random -> Integer
$ctoInteger :: Word128_Storable_Random -> Integer
divMod :: Word128_Storable_Random
-> Word128_Storable_Random
-> (Word128_Storable_Random, Word128_Storable_Random)
$cdivMod :: Word128_Storable_Random
-> Word128_Storable_Random
-> (Word128_Storable_Random, Word128_Storable_Random)
quotRem :: Word128_Storable_Random
-> Word128_Storable_Random
-> (Word128_Storable_Random, Word128_Storable_Random)
$cquotRem :: Word128_Storable_Random
-> Word128_Storable_Random
-> (Word128_Storable_Random, Word128_Storable_Random)
mod :: Word128_Storable_Random
-> Word128_Storable_Random -> Word128_Storable_Random
$cmod :: Word128_Storable_Random
-> Word128_Storable_Random -> Word128_Storable_Random
div :: Word128_Storable_Random
-> Word128_Storable_Random -> Word128_Storable_Random
$cdiv :: Word128_Storable_Random
-> Word128_Storable_Random -> Word128_Storable_Random
rem :: Word128_Storable_Random
-> Word128_Storable_Random -> Word128_Storable_Random
$crem :: Word128_Storable_Random
-> Word128_Storable_Random -> Word128_Storable_Random
quot :: Word128_Storable_Random
-> Word128_Storable_Random -> Word128_Storable_Random
$cquot :: Word128_Storable_Random
-> Word128_Storable_Random -> Word128_Storable_Random
Integral,Word128_Storable_Random -> Word128_Storable_Random -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Word128_Storable_Random -> Word128_Storable_Random -> Bool
$c/= :: Word128_Storable_Random -> Word128_Storable_Random -> Bool
== :: Word128_Storable_Random -> Word128_Storable_Random -> Bool
$c== :: Word128_Storable_Random -> Word128_Storable_Random -> Bool
Eq,Eq Word128_Storable_Random
Word128_Storable_Random -> Word128_Storable_Random -> Bool
Word128_Storable_Random -> Word128_Storable_Random -> Ordering
Word128_Storable_Random
-> Word128_Storable_Random -> Word128_Storable_Random
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: Word128_Storable_Random
-> Word128_Storable_Random -> Word128_Storable_Random
$cmin :: Word128_Storable_Random
-> Word128_Storable_Random -> Word128_Storable_Random
max :: Word128_Storable_Random
-> Word128_Storable_Random -> Word128_Storable_Random
$cmax :: Word128_Storable_Random
-> Word128_Storable_Random -> Word128_Storable_Random
>= :: Word128_Storable_Random -> Word128_Storable_Random -> Bool
$c>= :: Word128_Storable_Random -> Word128_Storable_Random -> Bool
> :: Word128_Storable_Random -> Word128_Storable_Random -> Bool
$c> :: Word128_Storable_Random -> Word128_Storable_Random -> Bool
<= :: Word128_Storable_Random -> Word128_Storable_Random -> Bool
$c<= :: Word128_Storable_Random -> Word128_Storable_Random -> Bool
< :: Word128_Storable_Random -> Word128_Storable_Random -> Bool
$c< :: Word128_Storable_Random -> Word128_Storable_Random -> Bool
compare :: Word128_Storable_Random -> Word128_Storable_Random -> Ordering
$ccompare :: Word128_Storable_Random -> Word128_Storable_Random -> Ordering
Ord,Integer -> Word128_Storable_Random
Word128_Storable_Random -> Word128_Storable_Random
Word128_Storable_Random
-> Word128_Storable_Random -> Word128_Storable_Random
forall a.
(a -> a -> a)
-> (a -> a -> a)
-> (a -> a -> a)
-> (a -> a)
-> (a -> a)
-> (a -> a)
-> (Integer -> a)
-> Num a
fromInteger :: Integer -> Word128_Storable_Random
$cfromInteger :: Integer -> Word128_Storable_Random
signum :: Word128_Storable_Random -> Word128_Storable_Random
$csignum :: Word128_Storable_Random -> Word128_Storable_Random
abs :: Word128_Storable_Random -> Word128_Storable_Random
$cabs :: Word128_Storable_Random -> Word128_Storable_Random
negate :: Word128_Storable_Random -> Word128_Storable_Random
$cnegate :: Word128_Storable_Random -> Word128_Storable_Random
* :: Word128_Storable_Random
-> Word128_Storable_Random -> Word128_Storable_Random
$c* :: Word128_Storable_Random
-> Word128_Storable_Random -> Word128_Storable_Random
- :: Word128_Storable_Random
-> Word128_Storable_Random -> Word128_Storable_Random
$c- :: Word128_Storable_Random
-> Word128_Storable_Random -> Word128_Storable_Random
+ :: Word128_Storable_Random
-> Word128_Storable_Random -> Word128_Storable_Random
$c+ :: Word128_Storable_Random
-> Word128_Storable_Random -> Word128_Storable_Random
Num,ReadPrec [Word128_Storable_Random]
ReadPrec Word128_Storable_Random
Int -> ReadS Word128_Storable_Random
ReadS [Word128_Storable_Random]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Word128_Storable_Random]
$creadListPrec :: ReadPrec [Word128_Storable_Random]
readPrec :: ReadPrec Word128_Storable_Random
$creadPrec :: ReadPrec Word128_Storable_Random
readList :: ReadS [Word128_Storable_Random]
$creadList :: ReadS [Word128_Storable_Random]
readsPrec :: Int -> ReadS Word128_Storable_Random
$creadsPrec :: Int -> ReadS Word128_Storable_Random
Read,Int -> Word128_Storable_Random -> ShowS
[Word128_Storable_Random] -> ShowS
Word128_Storable_Random -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Word128_Storable_Random] -> ShowS
$cshowList :: [Word128_Storable_Random] -> ShowS
show :: Word128_Storable_Random -> String
$cshow :: Word128_Storable_Random -> String
showsPrec :: Int -> Word128_Storable_Random -> ShowS
$cshowsPrec :: Int -> Word128_Storable_Random -> ShowS
Show,BinaryWord Word128_Storable_Random
SignedWord (LoWord Word128_Storable_Random)
-> Word128_Storable_Random
HiWord Word128_Storable_Random
-> LoWord Word128_Storable_Random -> Word128_Storable_Random
LoWord Word128_Storable_Random -> Word128_Storable_Random
Word128_Storable_Random -> HiWord Word128_Storable_Random
Word128_Storable_Random -> LoWord Word128_Storable_Random
forall w.
BinaryWord w
-> (w -> LoWord w)
-> (w -> HiWord w)
-> (HiWord w -> LoWord w -> w)
-> (LoWord w -> w)
-> (SignedWord (LoWord w) -> w)
-> DoubleWord w
signExtendLo :: SignedWord (LoWord Word128_Storable_Random)
-> Word128_Storable_Random
$csignExtendLo :: SignedWord (LoWord Word128_Storable_Random)
-> Word128_Storable_Random
extendLo :: LoWord Word128_Storable_Random -> Word128_Storable_Random
$cextendLo :: LoWord Word128_Storable_Random -> Word128_Storable_Random
fromHiAndLo :: HiWord Word128_Storable_Random
-> LoWord Word128_Storable_Random -> Word128_Storable_Random
$cfromHiAndLo :: HiWord Word128_Storable_Random
-> LoWord Word128_Storable_Random -> Word128_Storable_Random
hiWord :: Word128_Storable_Random -> HiWord Word128_Storable_Random
$chiWord :: Word128_Storable_Random -> HiWord Word128_Storable_Random
loWord :: Word128_Storable_Random -> LoWord Word128_Storable_Random
$cloWord :: Word128_Storable_Random -> LoWord Word128_Storable_Random
DoubleWord,FiniteBits (SignedWord Word128_Storable_Random)
FiniteBits (UnsignedWord Word128_Storable_Random)
FiniteBits Word128_Storable_Random
Word128_Storable_Random
Word128_Storable_Random -> Bool
Word128_Storable_Random -> Int
Word128_Storable_Random -> SignedWord Word128_Storable_Random
Word128_Storable_Random -> UnsignedWord Word128_Storable_Random
Word128_Storable_Random -> Word128_Storable_Random
Word128_Storable_Random
-> Word128_Storable_Random
-> (Word128_Storable_Random, UnsignedWord Word128_Storable_Random)
forall w.
FiniteBits w
-> FiniteBits (UnsignedWord w)
-> FiniteBits (SignedWord w)
-> (w -> UnsignedWord w)
-> (w -> SignedWord w)
-> (w -> w -> (w, UnsignedWord w))
-> (w -> w -> (w, UnsignedWord w))
-> (w -> Int)
-> (w -> Int)
-> w
-> w
-> w
-> w
-> (w -> Bool)
-> (w -> Bool)
-> (w -> w)
-> (w -> w)
-> (w -> w)
-> (w -> w)
-> BinaryWord w
clearLsb :: Word128_Storable_Random -> Word128_Storable_Random
$cclearLsb :: Word128_Storable_Random -> Word128_Storable_Random
clearMsb :: Word128_Storable_Random -> Word128_Storable_Random
$cclearMsb :: Word128_Storable_Random -> Word128_Storable_Random
setLsb :: Word128_Storable_Random -> Word128_Storable_Random
$csetLsb :: Word128_Storable_Random -> Word128_Storable_Random
setMsb :: Word128_Storable_Random -> Word128_Storable_Random
$csetMsb :: Word128_Storable_Random -> Word128_Storable_Random
testLsb :: Word128_Storable_Random -> Bool
$ctestLsb :: Word128_Storable_Random -> Bool
testMsb :: Word128_Storable_Random -> Bool
$ctestMsb :: Word128_Storable_Random -> Bool
lsb :: Word128_Storable_Random
$clsb :: Word128_Storable_Random
msb :: Word128_Storable_Random
$cmsb :: Word128_Storable_Random
allOnes :: Word128_Storable_Random
$callOnes :: Word128_Storable_Random
allZeroes :: Word128_Storable_Random
$callZeroes :: Word128_Storable_Random
trailingZeroes :: Word128_Storable_Random -> Int
$ctrailingZeroes :: Word128_Storable_Random -> Int
leadingZeroes :: Word128_Storable_Random -> Int
$cleadingZeroes :: Word128_Storable_Random -> Int
unwrappedMul :: Word128_Storable_Random
-> Word128_Storable_Random
-> (Word128_Storable_Random, UnsignedWord Word128_Storable_Random)
$cunwrappedMul :: Word128_Storable_Random
-> Word128_Storable_Random
-> (Word128_Storable_Random, UnsignedWord Word128_Storable_Random)
unwrappedAdd :: Word128_Storable_Random
-> Word128_Storable_Random
-> (Word128_Storable_Random, UnsignedWord Word128_Storable_Random)
$cunwrappedAdd :: Word128_Storable_Random
-> Word128_Storable_Random
-> (Word128_Storable_Random, UnsignedWord Word128_Storable_Random)
signedWord :: Word128_Storable_Random -> SignedWord Word128_Storable_Random
$csignedWord :: Word128_Storable_Random -> SignedWord Word128_Storable_Random
unsignedWord :: Word128_Storable_Random -> UnsignedWord Word128_Storable_Random
$cunsignedWord :: Word128_Storable_Random -> UnsignedWord Word128_Storable_Random
BinaryWord,Bits Word128_Storable_Random
Word128_Storable_Random -> Int
forall b.
Bits b -> (b -> Int) -> (b -> Int) -> (b -> Int) -> FiniteBits b
countTrailingZeros :: Word128_Storable_Random -> Int
$ccountTrailingZeros :: Word128_Storable_Random -> Int
countLeadingZeros :: Word128_Storable_Random -> Int
$ccountLeadingZeros :: Word128_Storable_Random -> Int
finiteBitSize :: Word128_Storable_Random -> Int
$cfiniteBitSize :: Word128_Storable_Random -> Int
FiniteBits)
via Word128
#endif
type family Max (es :: ES)
where
Max Z_3_2 = V_3_2
Max I_3_2 = V_3_2
Max II_3_2 = V_3_2
Max III_3_2 = V_3_2
Max IV_3_2 = V_3_2
Max V_3_2 = V_3_2
Max Z_2022 = V_2022
Max I_2022 = V_2022
Max II_2022 = V_2022
Max III_2022 = V_2022
Max IV_2022 = V_2022
Max V_2022 = V_2022
type family Next (es :: ES)
where
Next Z_3_2 = I_3_2
Next I_3_2 = II_3_2
Next II_3_2 = III_3_2
Next III_3_2 = IV_3_2
Next IV_3_2 = V_3_2
Next V_3_2 = V_3_2
Next Z_2022 = I_2022
Next I_2022 = II_2022
Next II_2022 = III_2022
Next III_2022 = IV_2022
Next IV_2022 = V_2022
Next V_2022 = V_2022
type FixedWidthInteger a =
(Bits a
,Bounded a
,Enum a
,Integral a
,Eq a
,Ord a
,Num a
,Read a
,Show a
#ifndef O_NO_STORABLE_RANDOM
,Storable a
,Uniform a
#endif
)
class (FixedWidthInteger (IntN es)) => PositC (es :: ES) where
encode :: Maybe Rational -> IntN es
encode Maybe Rational
Nothing = forall (es :: ES). PositC es => IntN es
unReal @es
encode (Just Rational
0) = IntN es
0
encode (Just Rational
r)
| Rational
r forall a. Ord a => a -> a -> Bool
> forall (es :: ES). PositC es => Rational
maxPosRat @es = forall (es :: ES). PositC es => IntN es
mostPosVal @es
| Rational
r forall a. Ord a => a -> a -> Bool
< forall (es :: ES). PositC es => Rational
minNegRat @es = forall (es :: ES). PositC es => IntN es
mostNegVal @es
| Rational
r forall a. Ord a => a -> a -> Bool
> Rational
0 Bool -> Bool -> Bool
&& Rational
r forall a. Ord a => a -> a -> Bool
< forall (es :: ES). PositC es => Rational
minPosRat @es = forall (es :: ES). PositC es => IntN es
leastPosVal @es
| Rational
r forall a. Ord a => a -> a -> Bool
< Rational
0 Bool -> Bool -> Bool
&& Rational
r forall a. Ord a => a -> a -> Bool
> forall (es :: ES). PositC es => Rational
maxNegRat @es = forall (es :: ES). PositC es => IntN es
leastNegVal @es
| Bool
otherwise = forall (es :: ES). PositC es => Rational -> IntN es
buildIntRep @es Rational
r
decode :: IntN es -> Maybe Rational
decode IntN es
int
| IntN es
int forall a. Eq a => a -> a -> Bool
== forall (es :: ES). PositC es => IntN es
unReal @es = forall a. Maybe a
Nothing
| IntN es
int forall a. Eq a => a -> a -> Bool
== IntN es
0 = forall a. a -> Maybe a
Just Rational
0
| Bool
otherwise =
let sgn :: Bool
sgn = IntN es
int forall a. Ord a => a -> a -> Bool
< IntN es
0
int' :: IntN es
int' = if Bool
sgn
then forall a. Num a => a -> a
negate IntN es
int
else IntN es
int
(Integer
regime,Int
nR) = forall (es :: ES). PositC es => IntN es -> (Integer, Int)
regime2Integer @es IntN es
int'
exponent :: Natural
exponent = forall (es :: ES). PositC es => Int -> IntN es -> Natural
exponent2Nat @es Int
nR IntN es
int'
rat :: Rational
rat = forall (es :: ES). PositC es => Int -> IntN es -> Rational
fraction2Posit @es Int
nR IntN es
int'
in forall (es :: ES).
PositC es =>
(Bool, Integer, Natural, Rational) -> Maybe Rational
tupPosit2Posit @es (Bool
sgn,Integer
regime,Natural
exponent,Rational
rat)
exponentSize :: Natural
exponentSize = Natural
2
nBytes :: Natural
nBytes = Natural
2forall a b. (Num a, Integral b) => a -> b -> a
^(forall (es :: ES). PositC es => Natural
exponentSize @es)
nBits :: Natural
nBits = Natural
8 forall a. Num a => a -> a -> a
* (forall (es :: ES). PositC es => Natural
nBytes @es)
signBitSize :: Natural
signBitSize = Natural
1
uSeed :: Natural
uSeed = Natural
2forall a b. (Num a, Integral b) => a -> b -> a
^Integer
2forall a b. (Num a, Integral b) => a -> b -> a
^(forall (es :: ES). PositC es => Natural
exponentSize @es)
unReal :: IntN es
unReal = forall a. Bounded a => a
minBound @(IntN es)
mostPosVal :: IntN es
mostPosVal = forall a. Bounded a => a
maxBound @(IntN es)
leastPosVal :: IntN es
leastPosVal = IntN es
1
leastNegVal :: IntN es
leastNegVal = -IntN es
1
mostNegVal :: IntN es
mostNegVal = forall a. Num a => a -> a
negate (forall (es :: ES). PositC es => IntN es
mostPosVal @es)
maxPosRat :: Rational
maxPosRat = (forall a b. (Integral a, Num b) => a -> b
fromIntegral (forall (es :: ES). PositC es => Natural
uSeed @es)forall a b. (Num a, Integral b) => a -> b -> a
^(forall (es :: ES). PositC es => Natural
nBits @es forall a. Num a => a -> a -> a
- Natural
2)) forall a. Integral a => a -> a -> Ratio a
% Integer
1
minPosRat :: Rational
minPosRat = forall a. Fractional a => a -> a
recip (forall (es :: ES). PositC es => Rational
maxPosRat @es)
maxNegRat :: Rational
maxNegRat = forall a. Num a => a -> a
negate (forall (es :: ES). PositC es => Rational
minPosRat @es)
minNegRat :: Rational
minNegRat = forall a. Num a => a -> a
negate (forall (es :: ES). PositC es => Rational
maxPosRat @es)
log_uSeed :: (Integer, Rational) -> (Integer, Rational)
log_uSeed (Integer
regime,Rational
r)
| Rational
r forall a. Ord a => a -> a -> Bool
< Rational
1 = forall (es :: ES).
PositC es =>
(Integer, Rational) -> (Integer, Rational)
log_uSeed @es (Integer
regimeforall a. Num a => a -> a -> a
-Integer
1,Rational
r forall a. Num a => a -> a -> a
* forall a. Fractional a => Rational -> a
fromRational (forall a. Integral a => a -> Integer
toInteger (forall (es :: ES). PositC es => Natural
uSeed @es) forall a. Integral a => a -> a -> Ratio a
% Integer
1))
| Rational
r forall a. Ord a => a -> a -> Bool
>= forall a. Fractional a => Rational -> a
fromRational (forall a. Integral a => a -> Integer
toInteger (forall (es :: ES). PositC es => Natural
uSeed @es) forall a. Integral a => a -> a -> Ratio a
% Integer
1) = forall (es :: ES).
PositC es =>
(Integer, Rational) -> (Integer, Rational)
log_uSeed @es (Integer
regimeforall a. Num a => a -> a -> a
+Integer
1,Rational
r forall a. Num a => a -> a -> a
* forall a. Fractional a => Rational -> a
fromRational (Integer
1 forall a. Integral a => a -> a -> Ratio a
% forall a. Integral a => a -> Integer
toInteger (forall (es :: ES). PositC es => Natural
uSeed @es)))
| Bool
otherwise = (Integer
regime,Rational
r)
getRegime :: Rational -> (Integer, Rational)
getRegime Rational
r = forall (es :: ES).
PositC es =>
(Integer, Rational) -> (Integer, Rational)
log_uSeed @es (Integer
0,Rational
r)
posit2TupPosit :: Rational -> (Bool, Integer, Natural, Rational)
posit2TupPosit Rational
r =
let (Bool
sgn,Rational
r') = Rational -> (Bool, Rational)
getSign Rational
r
(Integer
regime,Rational
r'') = forall (es :: ES). PositC es => Rational -> (Integer, Rational)
getRegime @es Rational
r'
(Natural
exponent,Rational
significand) = Rational -> (Natural, Rational)
getExponent Rational
r''
in (Bool
sgn,Integer
regime,Natural
exponent,Rational
significand)
buildIntRep :: Rational -> IntN es
buildIntRep Rational
r =
let (Bool
signBit,Integer
regime,Natural
exponent,Rational
significand) = forall (es :: ES).
PositC es =>
Rational -> (Bool, Integer, Natural, Rational)
posit2TupPosit @es Rational
r
intRep :: IntN es
intRep = forall (es :: ES).
PositC es =>
Integer -> Natural -> Rational -> IntN es
mkIntRep @es Integer
regime Natural
exponent Rational
significand
in if Bool
signBit
then forall a. Num a => a -> a
negate IntN es
intRep
else IntN es
intRep
mkIntRep :: Integer -> Natural -> Rational -> IntN es
mkIntRep Integer
regime Natural
exponent Rational
significand =
let (IntN es
regime', Integer
offset) = forall (es :: ES). PositC es => Integer -> (IntN es, Integer)
formRegime @es Integer
regime
(IntN es
exponent', Integer
offset') = forall (es :: ES).
PositC es =>
Natural -> Integer -> (IntN es, Integer)
formExponent @es Natural
exponent Integer
offset
fraction :: IntN es
fraction = forall (es :: ES). PositC es => Rational -> Integer -> IntN es
formFraction @es Rational
significand Integer
offset'
in IntN es
regime' forall a. Num a => a -> a -> a
+ IntN es
exponent' forall a. Num a => a -> a -> a
+ IntN es
fraction
formRegime :: Integer -> (IntN es, Integer)
formRegime Integer
power
| Integer
0 forall a. Ord a => a -> a -> Bool
<= Integer
power =
let offset :: Integer
offset = (forall a b. (Integral a, Num b) => a -> b
fromIntegral (forall (es :: ES). PositC es => Natural
nBits @es forall a. Num a => a -> a -> a
- Natural
1) forall a. Num a => a -> a -> a
- Integer
power forall a. Num a => a -> a -> a
- Integer
1)
in (forall a b. (Integral a, Num b) => a -> b
fromIntegral (Integer
2forall a b. (Num a, Integral b) => a -> b -> a
^(Integer
power forall a. Num a => a -> a -> a
+ Integer
1) forall a. Num a => a -> a -> a
- Integer
1) forall a. Bits a => a -> Int -> a
`shiftL` forall a. Num a => Integer -> a
fromInteger Integer
offset, Integer
offset forall a. Num a => a -> a -> a
- Integer
1)
| Bool
otherwise =
let offset :: Integer
offset = (forall a b. (Integral a, Num b) => a -> b
fromIntegral (forall (es :: ES). PositC es => Natural
nBits @es forall a. Num a => a -> a -> a
- Natural
1) forall a. Num a => a -> a -> a
- forall a. Num a => a -> a
abs Integer
power forall a. Num a => a -> a -> a
- Integer
1)
in (IntN es
1 forall a. Bits a => a -> Int -> a
`shiftL` forall a. Num a => Integer -> a
fromInteger Integer
offset, Integer
offset)
formExponent :: Natural -> Integer -> (IntN es, Integer)
formExponent Natural
power Integer
offset =
let offset' :: Integer
offset' = Integer
offset forall a. Num a => a -> a -> a
- forall a b. (Integral a, Num b) => a -> b
fromIntegral (forall (es :: ES). PositC es => Natural
exponentSize @es)
in (forall a b. (Integral a, Num b) => a -> b
fromIntegral Natural
power forall a. Bits a => a -> Int -> a
`shift` forall a. Num a => Integer -> a
fromInteger Integer
offset', Integer
offset')
formFraction :: Rational -> Integer -> IntN es
formFraction Rational
r Integer
offset =
let numFractionBits :: Integer
numFractionBits = Integer
offset
fractionSize :: Rational
fractionSize = Rational
2forall a b. (Num a, Integral b) => a -> b -> a
^Integer
numFractionBits
normFraction :: Integer
normFraction = forall a b. (RealFrac a, Integral b) => a -> b
round forall a b. (a -> b) -> a -> b
$ (Rational
r forall a. Num a => a -> a -> a
- Rational
1) forall a. Num a => a -> a -> a
* Rational
fractionSize
in if Integer
numFractionBits forall a. Ord a => a -> a -> Bool
>= Integer
1
then forall a. Num a => Integer -> a
fromInteger Integer
normFraction
else IntN es
0
tupPosit2Posit :: (Bool,Integer,Natural,Rational) -> Maybe Rational
tupPosit2Posit (Bool
sgn,Integer
regime,Natural
exponent,Rational
rat) =
let pow2 :: Rational
pow2 = forall a. Real a => a -> Rational
toRational (forall (es :: ES). PositC es => Natural
uSeed @es)forall a b. (Fractional a, Integral b) => a -> b -> a
^^Integer
regime forall a. Num a => a -> a -> a
* Rational
2forall a b. (Num a, Integral b) => a -> b -> a
^Natural
exponent
scale :: Rational
scale = if Bool
sgn
then forall a. Num a => a -> a
negate Rational
pow2
else Rational
pow2
in forall a. a -> Maybe a
Just forall a b. (a -> b) -> a -> b
$ Rational
scale forall a. Num a => a -> a -> a
* Rational
rat
regime2Integer :: IntN es -> (Integer, Int)
regime2Integer IntN es
posit =
let regimeFormat :: Bool
regimeFormat = forall (es :: ES). PositC es => IntN es -> Bool
findRegimeFormat @es IntN es
posit
regimeCount :: Int
regimeCount = forall (es :: ES). PositC es => Bool -> IntN es -> Int
countRegimeBits @es Bool
regimeFormat IntN es
posit
regime :: Integer
regime = Bool -> Int -> Integer
calcRegimeInt Bool
regimeFormat Int
regimeCount
in (Integer
regime, Int
regimeCount forall a. Num a => a -> a -> a
+ Int
1)
findRegimeFormat :: IntN es -> Bool
findRegimeFormat IntN es
posit = forall a. Bits a => a -> Int -> Bool
testBit IntN es
posit (forall a b. (Integral a, Num b) => a -> b
fromIntegral (forall (es :: ES). PositC es => Natural
nBits @es) forall a. Num a => a -> a -> a
- Int
1 forall a. Num a => a -> a -> a
- forall a b. (Integral a, Num b) => a -> b
fromIntegral (forall (es :: ES). PositC es => Natural
signBitSize @es))
countRegimeBits :: Bool -> IntN es -> Int
countRegimeBits Bool
format IntN es
posit = Int -> Int -> Int
go (forall a b. (Integral a, Num b) => a -> b
fromIntegral (forall (es :: ES). PositC es => Natural
nBits @es) forall a. Num a => a -> a -> a
- Int
1 forall a. Num a => a -> a -> a
- forall a b. (Integral a, Num b) => a -> b
fromIntegral (forall (es :: ES). PositC es => Natural
signBitSize @es)) Int
0
where
go :: Int -> Int -> Int
go (-1) Int
acc = Int
acc
go Int
index Int
acc
| Bool -> Bool -> Bool
xnor Bool
format (forall a. Bits a => a -> Int -> Bool
testBit IntN es
posit Int
index) = Int -> Int -> Int
go (Int
index forall a. Num a => a -> a -> a
- Int
1) (Int
acc forall a. Num a => a -> a -> a
+ Int
1)
| Bool
otherwise = Int
acc
exponent2Nat :: Int -> IntN es -> Natural
exponent2Nat Int
numBitsRegime IntN es
posit =
let bitsRemaining :: Int
bitsRemaining = forall a b. (Integral a, Num b) => a -> b
fromIntegral (forall (es :: ES). PositC es => Natural
nBits @es) forall a. Num a => a -> a -> a
- Int
numBitsRegime forall a. Num a => a -> a -> a
- forall a b. (Integral a, Num b) => a -> b
fromIntegral (forall (es :: ES). PositC es => Natural
signBitSize @es)
signNRegimeMask :: IntN es
signNRegimeMask = IntN es
2forall a b. (Num a, Integral b) => a -> b -> a
^Int
bitsRemaining forall a. Num a => a -> a -> a
- IntN es
1
int :: IntN es
int = IntN es
posit forall a. Bits a => a -> a -> a
.&. IntN es
signNRegimeMask
nBitsToTheRight :: Int
nBitsToTheRight = forall a b. (Integral a, Num b) => a -> b
fromIntegral (forall (es :: ES). PositC es => Natural
nBits @es) forall a. Num a => a -> a -> a
- Int
numBitsRegime forall a. Num a => a -> a -> a
- forall a b. (Integral a, Num b) => a -> b
fromIntegral (forall (es :: ES). PositC es => Natural
signBitSize @es) forall a. Num a => a -> a -> a
- forall a b. (Integral a, Num b) => a -> b
fromIntegral (forall (es :: ES). PositC es => Natural
exponentSize @es)
in if Int
bitsRemaining forall a. Ord a => a -> a -> Bool
<=Int
0
then Natural
0
else if Int
nBitsToTheRight forall a. Ord a => a -> a -> Bool
< Int
0
then forall a b. (Integral a, Num b) => a -> b
fromIntegral forall a b. (a -> b) -> a -> b
$ IntN es
int forall a. Bits a => a -> Int -> a
`shiftL` forall a. Num a => a -> a
negate Int
nBitsToTheRight
else forall a b. (Integral a, Num b) => a -> b
fromIntegral forall a b. (a -> b) -> a -> b
$ IntN es
int forall a. Bits a => a -> Int -> a
`shiftR` Int
nBitsToTheRight
fraction2Posit :: Int -> IntN es -> Rational
fraction2Posit Int
numBitsRegime IntN es
posit =
let offset :: Integer
offset = forall a b. (Integral a, Num b) => a -> b
fromIntegral forall a b. (a -> b) -> a -> b
$ (forall (es :: ES). PositC es => Natural
signBitSize @es) forall a. Num a => a -> a -> a
+ forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
numBitsRegime forall a. Num a => a -> a -> a
+ (forall (es :: ES). PositC es => Natural
exponentSize @es)
fractionSize :: Integer
fractionSize = forall a b. (Integral a, Num b) => a -> b
fromIntegral (forall (es :: ES). PositC es => Natural
nBits @es) forall a. Num a => a -> a -> a
- Integer
offset
fractionBits :: IntN es
fractionBits = IntN es
posit forall a. Bits a => a -> a -> a
.&. (IntN es
2forall a b. (Num a, Integral b) => a -> b -> a
^Integer
fractionSize forall a. Num a => a -> a -> a
- IntN es
1)
in if Integer
fractionSize forall a. Ord a => a -> a -> Bool
>= Integer
1
then (Integer
2forall a b. (Num a, Integral b) => a -> b -> a
^Integer
fractionSize forall a. Num a => a -> a -> a
+ forall a. Integral a => a -> Integer
toInteger IntN es
fractionBits) forall a. Integral a => a -> a -> Ratio a
% Integer
2forall a b. (Num a, Integral b) => a -> b -> a
^Integer
fractionSize
else Integer
1 forall a. Integral a => a -> a -> Ratio a
% Integer
1
displayBin :: IntN es -> String
displayBin IntN es
int = String
"0b" forall a. [a] -> [a] -> [a]
++ Int -> String
go (forall a b. (Integral a, Num b) => a -> b
fromIntegral (forall (es :: ES). PositC es => Natural
nBits @es) forall a. Num a => a -> a -> a
- Int
1)
where
go :: Int -> String
go :: Int -> String
go Int
0 = if forall a. Bits a => a -> Int -> Bool
testBit IntN es
int Int
0
then String
"1"
else String
"0"
go Int
idx = if forall a. Bits a => a -> Int -> Bool
testBit IntN es
int Int
idx
then String
"1" forall a. [a] -> [a] -> [a]
++ Int -> String
go (Int
idx forall a. Num a => a -> a -> a
- Int
1)
else String
"0" forall a. [a] -> [a] -> [a]
++ Int -> String
go (Int
idx forall a. Num a => a -> a -> a
- Int
1)
decimalPrec :: Int
decimalPrec = forall a b. (Integral a, Num b) => a -> b
fromIntegral forall a b. (a -> b) -> a -> b
$ Natural
2 forall a. Num a => a -> a -> a
* (forall (es :: ES). PositC es => Natural
nBytes @es) forall a. Num a => a -> a -> a
+ Natural
1
{-# MINIMAL exponentSize | nBytes #-}
instance PositC Z_3_2 where
exponentSize :: Natural
exponentSize = Natural
0
instance PositC I_3_2 where
exponentSize :: Natural
exponentSize = Natural
1
instance PositC II_3_2 where
exponentSize :: Natural
exponentSize = Natural
2
instance PositC III_3_2 where
exponentSize :: Natural
exponentSize = Natural
3
instance PositC IV_3_2 where
exponentSize :: Natural
exponentSize = Natural
4
instance PositC V_3_2 where
exponentSize :: Natural
exponentSize = Natural
5
instance PositC Z_2022 where
nBytes :: Natural
nBytes = Natural
2forall a b. (Num a, Integral b) => a -> b -> a
^Integer
0
instance PositC I_2022 where
nBytes :: Natural
nBytes = Natural
2forall a b. (Num a, Integral b) => a -> b -> a
^Integer
1
instance PositC II_2022 where
nBytes :: Natural
nBytes = Natural
2forall a b. (Num a, Integral b) => a -> b -> a
^Integer
2
instance PositC III_2022 where
nBytes :: Natural
nBytes = Natural
2forall a b. (Num a, Integral b) => a -> b -> a
^Integer
3
instance PositC IV_2022 where
nBytes :: Natural
nBytes = Natural
2forall a b. (Num a, Integral b) => a -> b -> a
^Integer
4
instance PositC V_2022 where
nBytes :: Natural
nBytes = Natural
2forall a b. (Num a, Integral b) => a -> b -> a
^Integer
5
type PositF es = (PositC es, PositC (Next es))
getSign :: Rational -> (Bool, Rational)
getSign :: Rational -> (Bool, Rational)
getSign Rational
r =
let s :: Bool
s = Rational
r forall a. Ord a => a -> a -> Bool
<= Rational
0
absPosit :: Rational
absPosit =
if Bool
s
then forall a. Num a => a -> a
negate Rational
r
else Rational
r
in (Bool
s,Rational
absPosit)
getExponent :: Rational -> (Natural, Rational)
getExponent :: Rational -> (Natural, Rational)
getExponent Rational
r = (Natural, Rational) -> (Natural, Rational)
log_2 (Natural
0,Rational
r)
log_2 :: (Natural, Rational) -> (Natural, Rational)
log_2 :: (Natural, Rational) -> (Natural, Rational)
log_2 (Natural
exponent,Rational
r) | Rational
r forall a. Ord a => a -> a -> Bool
< Rational
1 = forall a. HasCallStack => String -> a
error String
"Should never happen, exponent should be a natural number, i.e. positive integer."
| Rational
r forall a. Ord a => a -> a -> Bool
>= (Integer
2 forall a. Integral a => a -> a -> Ratio a
% Integer
1) = (Natural, Rational) -> (Natural, Rational)
log_2 (Natural
exponentforall a. Num a => a -> a -> a
+Natural
1,Rational
r forall a. Num a => a -> a -> a
* (Integer
1 forall a. Integral a => a -> a -> Ratio a
% Integer
2))
| Bool
otherwise = (Natural
exponent,Rational
r)
calcRegimeInt :: Bool -> Int -> Integer
calcRegimeInt :: Bool -> Int -> Integer
calcRegimeInt Bool
format Int
count | Bool
format = forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int
count forall a. Num a => a -> a -> a
- Int
1)
| Bool
otherwise = forall a b. (Integral a, Num b) => a -> b
fromIntegral forall a b. (a -> b) -> a -> b
$ forall a. Num a => a -> a
negate Int
count
xnor :: Bool -> Bool -> Bool
xnor :: Bool -> Bool -> Bool
xnor Bool
a Bool
b = Bool -> Bool
not forall a b. (a -> b) -> a -> b
$ (Bool
a Bool -> Bool -> Bool
|| Bool
b) Bool -> Bool -> Bool
&& Bool -> Bool
not (Bool
b Bool -> Bool -> Bool
&& Bool
a)
#ifndef O_NO_STORABLE_RANDOM
instance Storable Word128_Storable_Random where
sizeOf :: Word128_Storable_Random -> Int
sizeOf Word128_Storable_Random
_ = Int
16
alignment :: Word128_Storable_Random -> Int
alignment Word128_Storable_Random
_ = Int
16
peek :: Ptr Word128_Storable_Random -> IO Word128_Storable_Random
peek Ptr Word128_Storable_Random
ptr = do
Word64
hi <- forall a. Storable a => Ptr a -> IO a
peek forall a b. (a -> b) -> a -> b
$ Int -> Ptr Word64
offsetWord Int
0
Word64
lo <- forall a. Storable a => Ptr a -> IO a
peek forall a b. (a -> b) -> a -> b
$ Int -> Ptr Word64
offsetWord Int
1
forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ forall w. DoubleWord w => HiWord w -> LoWord w -> w
fromHiAndLo Word64
hi Word64
lo
where
offsetWord :: Int -> Ptr Word64
offsetWord Int
i = (forall a b. Ptr a -> Ptr b
castPtr Ptr Word128_Storable_Random
ptr :: Ptr Word64) forall a b. Ptr a -> Int -> Ptr b
`plusPtr` (Int
iforall a. Num a => a -> a -> a
*Int
8)
poke :: Ptr Word128_Storable_Random -> Word128_Storable_Random -> IO ()
poke Ptr Word128_Storable_Random
ptr Word128_Storable_Random
int = do
forall a. Storable a => Ptr a -> a -> IO ()
poke (Int -> Ptr Word64
offsetWord Int
0) (forall w. DoubleWord w => w -> HiWord w
hiWord Word128_Storable_Random
int)
forall a. Storable a => Ptr a -> a -> IO ()
poke (Int -> Ptr Word64
offsetWord Int
1) (forall w. DoubleWord w => w -> LoWord w
loWord Word128_Storable_Random
int)
where
offsetWord :: Int -> Ptr Word64
offsetWord Int
i = (forall a b. Ptr a -> Ptr b
castPtr Ptr Word128_Storable_Random
ptr :: Ptr Word64) forall a b. Ptr a -> Int -> Ptr b
`plusPtr` (Int
iforall a. Num a => a -> a -> a
*Int
8)
instance Storable Int128_Storable_Random where
sizeOf :: Int128_Storable_Random -> Int
sizeOf Int128_Storable_Random
_ = Int
16
alignment :: Int128_Storable_Random -> Int
alignment Int128_Storable_Random
_ = Int
16
peek :: Ptr Int128_Storable_Random -> IO Int128_Storable_Random
peek Ptr Int128_Storable_Random
ptr = do
Int64
hi <- forall a. Storable a => Ptr a -> IO a
peek forall a b. (a -> b) -> a -> b
$ Int -> Ptr Int64
offsetInt Int
0
Word64
lo <- forall a. Storable a => Ptr a -> IO a
peek forall a b. (a -> b) -> a -> b
$ Int -> Ptr Word64
offsetWord Int
1
forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ forall w. DoubleWord w => HiWord w -> LoWord w -> w
fromHiAndLo Int64
hi Word64
lo
where
offsetInt :: Int -> Ptr Int64
offsetInt Int
i = (forall a b. Ptr a -> Ptr b
castPtr Ptr Int128_Storable_Random
ptr :: Ptr Int64) forall a b. Ptr a -> Int -> Ptr b
`plusPtr` (Int
iforall a. Num a => a -> a -> a
*Int
8)
offsetWord :: Int -> Ptr Word64
offsetWord Int
i = (forall a b. Ptr a -> Ptr b
castPtr Ptr Int128_Storable_Random
ptr :: Ptr Word64) forall a b. Ptr a -> Int -> Ptr b
`plusPtr` (Int
iforall a. Num a => a -> a -> a
*Int
8)
poke :: Ptr Int128_Storable_Random -> Int128_Storable_Random -> IO ()
poke Ptr Int128_Storable_Random
ptr Int128_Storable_Random
int = do
forall a. Storable a => Ptr a -> a -> IO ()
poke (Int -> Ptr Int64
offsetInt Int
0) (forall w. DoubleWord w => w -> HiWord w
hiWord Int128_Storable_Random
int)
forall a. Storable a => Ptr a -> a -> IO ()
poke (Int -> Ptr Word64
offsetWord Int
1) (forall w. DoubleWord w => w -> LoWord w
loWord Int128_Storable_Random
int)
where
offsetInt :: Int -> Ptr Int64
offsetInt Int
i = (forall a b. Ptr a -> Ptr b
castPtr Ptr Int128_Storable_Random
ptr :: Ptr Int64) forall a b. Ptr a -> Int -> Ptr b
`plusPtr` (Int
iforall a. Num a => a -> a -> a
*Int
8)
offsetWord :: Int -> Ptr Word64
offsetWord Int
i = (forall a b. Ptr a -> Ptr b
castPtr Ptr Int128_Storable_Random
ptr :: Ptr Word64) forall a b. Ptr a -> Int -> Ptr b
`plusPtr` (Int
iforall a. Num a => a -> a -> a
*Int
8)
instance Storable Int256_Storable_Random where
sizeOf :: Int256_Storable_Random -> Int
sizeOf Int256_Storable_Random
_ = Int
32
alignment :: Int256_Storable_Random -> Int
alignment Int256_Storable_Random
_ = Int
32
peek :: Ptr Int256_Storable_Random -> IO Int256_Storable_Random
peek Ptr Int256_Storable_Random
ptr = do
(Int128_Storable_Random Int128
hi) <- forall a. Storable a => Ptr a -> IO a
peek forall a b. (a -> b) -> a -> b
$ Int -> Ptr Int128_Storable_Random
offsetInt Int
0
(Word128_Storable_Random Word128
lo) <- forall a. Storable a => Ptr a -> IO a
peek forall a b. (a -> b) -> a -> b
$ Int -> Ptr Word128_Storable_Random
offsetWord Int
1
forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ forall w. DoubleWord w => HiWord w -> LoWord w -> w
fromHiAndLo Int128
hi Word128
lo
where
offsetInt :: Int -> Ptr Int128_Storable_Random
offsetInt Int
i = (forall a b. Ptr a -> Ptr b
castPtr Ptr Int256_Storable_Random
ptr :: Ptr Int128_Storable_Random) forall a b. Ptr a -> Int -> Ptr b
`plusPtr` (Int
iforall a. Num a => a -> a -> a
*Int
16)
offsetWord :: Int -> Ptr Word128_Storable_Random
offsetWord Int
i = (forall a b. Ptr a -> Ptr b
castPtr Ptr Int256_Storable_Random
ptr :: Ptr Word128_Storable_Random) forall a b. Ptr a -> Int -> Ptr b
`plusPtr` (Int
iforall a. Num a => a -> a -> a
*Int
16)
poke :: Ptr Int256_Storable_Random -> Int256_Storable_Random -> IO ()
poke Ptr Int256_Storable_Random
ptr Int256_Storable_Random
int = do
forall a. Storable a => Ptr a -> a -> IO ()
poke (Int -> Ptr Int128_Storable_Random
offsetInt Int
0) (Int128 -> Int128_Storable_Random
Int128_Storable_Random forall a b. (a -> b) -> a -> b
$ forall w. DoubleWord w => w -> HiWord w
hiWord Int256_Storable_Random
int)
forall a. Storable a => Ptr a -> a -> IO ()
poke (Int -> Ptr Word128_Storable_Random
offsetWord Int
1) (Word128 -> Word128_Storable_Random
Word128_Storable_Random forall a b. (a -> b) -> a -> b
$ forall w. DoubleWord w => w -> LoWord w
loWord Int256_Storable_Random
int)
where
offsetInt :: Int -> Ptr Int128_Storable_Random
offsetInt Int
i = (forall a b. Ptr a -> Ptr b
castPtr Ptr Int256_Storable_Random
ptr :: Ptr Int128_Storable_Random) forall a b. Ptr a -> Int -> Ptr b
`plusPtr` (Int
iforall a. Num a => a -> a -> a
*Int
16)
offsetWord :: Int -> Ptr Word128_Storable_Random
offsetWord Int
i = (forall a b. Ptr a -> Ptr b
castPtr Ptr Int256_Storable_Random
ptr :: Ptr Word128_Storable_Random) forall a b. Ptr a -> Int -> Ptr b
`plusPtr` (Int
iforall a. Num a => a -> a -> a
*Int
16)
instance Uniform Word128_Storable_Random where
uniformM :: forall g (m :: * -> *).
StatefulGen g m =>
g -> m Word128_Storable_Random
uniformM g
g = do
Word64
hi <- forall a g (m :: * -> *). (Uniform a, StatefulGen g m) => g -> m a
uniformM g
g
Word64
lo <- forall a g (m :: * -> *). (Uniform a, StatefulGen g m) => g -> m a
uniformM g
g
forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ forall w. DoubleWord w => HiWord w -> LoWord w -> w
fromHiAndLo Word64
hi Word64
lo
instance Uniform Int128_Storable_Random where
uniformM :: forall g (m :: * -> *).
StatefulGen g m =>
g -> m Int128_Storable_Random
uniformM g
g = do
Int64
hi <- forall a g (m :: * -> *). (Uniform a, StatefulGen g m) => g -> m a
uniformM g
g
Word64
lo <- forall a g (m :: * -> *). (Uniform a, StatefulGen g m) => g -> m a
uniformM g
g
forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ forall w. DoubleWord w => HiWord w -> LoWord w -> w
fromHiAndLo Int64
hi Word64
lo
instance Uniform Int256_Storable_Random where
uniformM :: forall g (m :: * -> *).
StatefulGen g m =>
g -> m Int256_Storable_Random
uniformM g
g = do
Int128_Storable_Random Int128
hi <- forall a g (m :: * -> *). (Uniform a, StatefulGen g m) => g -> m a
uniformM g
g
Word128_Storable_Random Word128
lo <- forall a g (m :: * -> *). (Uniform a, StatefulGen g m) => g -> m a
uniformM g
g
forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ forall w. DoubleWord w => HiWord w -> LoWord w -> w
fromHiAndLo Int128
hi Word128
lo
#endif