Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Library implementing standard 'Posit-3.2', and 'Posit-2022' numbers, as defined by the Posit Working Group 23 June 2018, and in 2022 respectively.
Synopsis
- class FixedWidthInteger (IntN es) => PositC (es :: ES) where
- encode :: Maybe Rational -> IntN es
- decode :: IntN es -> Maybe Rational
- exponentSize :: Natural
- nBytes :: Natural
- nBits :: Natural
- signBitSize :: Natural
- uSeed :: Natural
- unReal :: IntN es
- mostPosVal :: IntN es
- leastPosVal :: IntN es
- leastNegVal :: IntN es
- mostNegVal :: IntN es
- maxPosRat :: Rational
- minPosRat :: Rational
- maxNegRat :: Rational
- minNegRat :: Rational
- log_uSeed :: (Integer, Rational) -> (Integer, Rational)
- getRegime :: Rational -> (Integer, Rational)
- posit2TupPosit :: Rational -> (Bool, Integer, Natural, Rational)
- buildIntRep :: Rational -> IntN es
- mkIntRep :: Integer -> Natural -> Rational -> IntN es
- formRegime :: Integer -> (IntN es, Integer)
- formExponent :: Natural -> Integer -> (IntN es, Integer)
- formFraction :: Rational -> Integer -> IntN es
- tupPosit2Posit :: (Bool, Integer, Natural, Rational) -> Maybe Rational
- regime2Integer :: IntN es -> (Integer, Int)
- findRegimeFormat :: IntN es -> Bool
- countRegimeBits :: Bool -> IntN es -> Int
- exponent2Nat :: Int -> IntN es -> Natural
- fraction2Posit :: Int -> IntN es -> Rational
- displayBin :: IntN es -> String
- decimalPrec :: Int
- data ES
- type PositF es = (PositC es, PositC (Next es))
- type family IntN (es :: ES) where ...
- type FixedWidthInteger a = (Bits a, Bounded a, Enum a, Integral a, Eq a, Ord a, Num a, Read a, Show a, Storable a, Uniform a)
- type family Max (es :: ES) where ...
- type family Next (es :: ES) where ...
Documentation
class FixedWidthInteger (IntN es) => PositC (es :: ES) where Source #
The Posit
class is an approximation of ℝ, it is like a sampling
on the Projective Real line ℙ(ℝ) with Maybe ℚ as the internal type.
The es
is an index that controlls the log2 word size of the Posit's
fininte precision representation.
:: Maybe Rational | |
-> IntN es | Maybe you have some Rational Number and you want to encode it as some integer with a finite integer log2 word size. |
Transform to/from the Infinite Precision Representation
:: IntN es | |
-> Maybe Rational | You have an integer with a finite integer log2 word size decode it and Maybe it is Rational |
:: Natural | The exponent size, |
Exponent Size based on the Posit Exponent kind ES, Posit-2022 sets the default to 2.
Various other size definitions used in the Posit format with their default definitions
:: Natural |
|
Integer Representation of common bounds
mostPosVal :: IntN es Source #
leastPosVal :: IntN es Source #
leastNegVal :: IntN es Source #
mostNegVal :: IntN es Source #
maxPosRat :: Rational Source #
minPosRat :: Rational Source #
maxNegRat :: Rational Source #
minNegRat :: Rational Source #
log_uSeed :: (Integer, Rational) -> (Integer, Rational) Source #
getRegime :: Rational -> (Integer, Rational) Source #
posit2TupPosit :: Rational -> (Bool, Integer, Natural, Rational) Source #
buildIntRep :: Rational -> IntN es Source #
mkIntRep :: Integer -> Natural -> Rational -> IntN es Source #
formRegime :: Integer -> (IntN es, Integer) Source #
formExponent :: Natural -> Integer -> (IntN es, Integer) Source #
formFraction :: Rational -> Integer -> IntN es Source #
tupPosit2Posit :: (Bool, Integer, Natural, Rational) -> Maybe Rational Source #
regime2Integer :: IntN es -> (Integer, Int) Source #
findRegimeFormat :: IntN es -> Bool Source #
countRegimeBits :: Bool -> IntN es -> Int Source #
exponent2Nat :: Int -> IntN es -> Natural Source #
fraction2Posit :: Int -> IntN es -> Rational Source #
displayBin :: IntN es -> String Source #
decimalPrec :: Int Source #
Instances
The Exponent Size ES
kind, the constructor for the Type is a Roman Numeral.
type PositF es = (PositC es, PositC (Next es)) Source #
PositF
Constraint Synonym for things that need both the word size and the next higher word size
type family IntN (es :: ES) where ... Source #
Type of the Finite Precision Representation, in our case Int8, Int16, Int32, Int64, Int128, Int256.
IntN Z_3_2 = Int8 | |
IntN I_3_2 = Int16 | |
IntN II_3_2 = Int32 | |
IntN III_3_2 = Int64 | |
IntN IV_3_2 = Int128_Storable_Random | |
IntN V_3_2 = Int256_Storable_Random | |
IntN Z_2022 = Int8 | |
IntN I_2022 = Int16 | |
IntN II_2022 = Int32 | |
IntN III_2022 = Int64 | |
IntN IV_2022 = Int128_Storable_Random | |
IntN V_2022 = Int256_Storable_Random |
type FixedWidthInteger a = (Bits a, Bounded a, Enum a, Integral a, Eq a, Ord a, Num a, Read a, Show a, Storable a, Uniform a) Source #
The FixedWidthInteger
is a Constraint Synonym that contains all
of the constraints provided by the IntN
Type Family. It is a super
class for the Posit Class.