Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
- Main Exported Types
- Patterns for Matching Exported Types
- Fused Operation Interface defined by the Posit Standard
- Posits are Convertable between different Posit representations
- Additional functions to show the Posit in different formats
- Additional Special Functions
- Functions to lift functions of Integers or Rationals to operate on Posit Types
Library implementing standard Posit Numbers (Posit Standard version 3.2, with some improvements) a fixed width word size of 2^es bytes.
Synopsis
- data Posit (es :: ES)
- type Posit8 = Posit Z
- type Posit16 = Posit I
- type Posit32 = Posit II
- type Posit64 = Posit III
- type Posit128 = Posit IV
- type Posit256 = Posit V
- pattern NaR :: forall es. PositC es => Posit es
- pattern R :: forall es. PositC es => Rational -> Posit es
- class Num a => FusedOps a where
- fma :: a -> a -> a -> a
- fam :: a -> a -> a -> a
- fmms :: a -> a -> a -> a -> a
- fsum3 :: a -> a -> a -> a
- fsum4 :: a -> a -> a -> a -> a
- fsumL :: Foldable t => t a -> a
- fdot3 :: a -> a -> a -> a -> a -> a -> a
- fdot4 :: a -> a -> a -> a -> a -> a -> a -> a -> a
- fdotL :: Foldable t => t a -> t a -> a
- fsm :: a -> a -> a -> a
- class Convertible a b where
- convert :: a -> b
- class AltShow a where
- displayBinary :: a -> String
- displayIntegral :: a -> String
- displayRational :: a -> String
- displayDecimal :: a -> String
- class AltFloating p where
- viaIntegral :: PositC es => (IntN es -> IntN es) -> Posit es -> Posit es
- viaRational :: PositC es => (Rational -> Rational) -> Posit es -> Posit es
- viaRational2 :: PositC es => (Rational -> Rational -> Rational) -> Posit es -> Posit es -> Posit es
- viaRational3 :: PositC es => (Rational -> Rational -> Rational -> Rational) -> Posit es -> Posit es -> Posit es -> Posit es
- viaRational4 :: PositC es => (Rational -> Rational -> Rational -> Rational -> Rational) -> Posit es -> Posit es -> Posit es -> Posit es -> Posit es
- viaRational6 :: PositC es => (Rational -> Rational -> Rational -> Rational -> Rational -> Rational -> Rational) -> Posit es -> Posit es -> Posit es -> Posit es -> Posit es -> Posit es -> Posit es
- viaRational8 :: PositC es => (Rational -> Rational -> Rational -> Rational -> Rational -> Rational -> Rational -> Rational -> Rational) -> Posit es -> Posit es -> Posit es -> Posit es -> Posit es -> Posit es -> Posit es -> Posit es -> Posit es
Documentation
data Posit (es :: ES) Source #
Base GADT rapper type, that uses the Exponent Size kind to index the various implementations
Instances
Main Exported Types
An 8-bit Posit number with es
~ Z
An 16-bit Posit number with es
~ I
An 32-bit Posit number with es
~ II
An 64-bit Posit number with es
~ III
An 128-bit Posit number with es
~ IV
An 256-bit Posit number with es
~ V
Patterns for Matching Exported Types
pattern NaR :: forall es. PositC es => Posit es Source #
Not a Real Number, the Posit is like a Maybe type, it's either a real number or not
A pattern for Exception handling when a value is Not a Real number (NaR).
pattern R :: forall es. PositC es => Rational -> Posit es Source #
A Real or at least Rational Number, rounded to the nearest Posit Rational representation
A pattern for the non-Exceptional case, yielding a Rational, will make a total function when paired with NaR, if the Rational implementation is total.
Fused Operation Interface defined by the Posit Standard
class Num a => FusedOps a where Source #
A class that delays the rounding operation until the end for some operations
fma :: a -> a -> a -> a Source #
Fused Multiply Add: (a * b) + c
fam :: a -> a -> a -> a Source #
Fused Add Multiply: (a + b) * c
fmms :: a -> a -> a -> a -> a Source #
Fused Multiply Multiply Subtract: (a * b) - (c * d)
fsum3 :: a -> a -> a -> a Source #
Fused Sum of 3 values: a + b + c
fsum4 :: a -> a -> a -> a -> a Source #
Fused Sum of 4 values: a + b + c + d
fsumL :: Foldable t => t a -> a Source #
Fused Sum of a List of Posits
fdot3 :: a -> a -> a -> a -> a -> a -> a Source #
Fused Dot Product of 3 element vector: (a1 * b1) + (a2 * b2) + (a3 * b3)
fdot4 :: a -> a -> a -> a -> a -> a -> a -> a -> a Source #
Fused Dot Product of 4 element vector: (a0 * b0) + (a1 * b1) + (a2 * b2) + (a3 * b3)
fdotL :: Foldable t => t a -> t a -> a Source #
Fused Dot Product of Two Lists
fsm :: a -> a -> a -> a Source #
Fused Subtract Multiply: a - (b * c)
Instances
Posits are Convertable between different Posit representations
class Convertible a b where Source #
A Convertible class that will cast or convert
between two different Posit es types
Additional functions to show the Posit in different formats
class AltShow a where Source #
A Alternative to the typical Show
class to assist in displaying the Posit es type in different formats
displayBinary :: a -> String Source #
Display the Posit in its Binary Representation
displayIntegral :: a -> String Source #
Display the Posit in its Integral Representation
displayRational :: a -> String Source #
Display the Posit as a Rational
displayDecimal :: a -> String Source #
Display the Posit as a Decimal until the Repetend occurs
Additional Special Functions
class AltFloating p where Source #
Functions to lift functions of Integers or Rationals to operate on Posit Types
viaRational2 :: PositC es => (Rational -> Rational -> Rational) -> Posit es -> Posit es -> Posit es Source #
viaRational3 :: PositC es => (Rational -> Rational -> Rational -> Rational) -> Posit es -> Posit es -> Posit es -> Posit es Source #
viaRational4 :: PositC es => (Rational -> Rational -> Rational -> Rational -> Rational) -> Posit es -> Posit es -> Posit es -> Posit es -> Posit es Source #