rounded-hw-0.2.0: Directed rounding for built-in floating types
Safe HaskellNone
LanguageHaskell2010

Numeric.Rounded.Hardware

Synopsis

Documentation

newtype Rounded (r :: RoundingMode) a Source #

A type tagged with a rounding direction.

The rounding direction is effective for a single operation. You won't get the correctly-rounded result for a compound expression like (a - b * c) :: Rounded 'TowardInf Double.

In particular, a negative literal like -0.1 :: Rounded r Double doesn't yield the correctly-rounded value for -0.1. To get the correct value, call fromRational explicitly (i.e. fromRational (-0.1) :: Rounded r Double) or use NegativeLiterals extension.

Constructors

Rounded 

Fields

Instances

Instances details
Unbox a => Vector Vector (Rounded r a) Source # 
Instance details

Defined in Numeric.Rounded.Hardware.Internal.Rounding

Methods

basicUnsafeFreeze :: PrimMonad m => Mutable Vector (PrimState m) (Rounded r a) -> m (Vector (Rounded r a)) #

basicUnsafeThaw :: PrimMonad m => Vector (Rounded r a) -> m (Mutable Vector (PrimState m) (Rounded r a)) #

basicLength :: Vector (Rounded r a) -> Int #

basicUnsafeSlice :: Int -> Int -> Vector (Rounded r a) -> Vector (Rounded r a) #

basicUnsafeIndexM :: Monad m => Vector (Rounded r a) -> Int -> m (Rounded r a) #

basicUnsafeCopy :: PrimMonad m => Mutable Vector (PrimState m) (Rounded r a) -> Vector (Rounded r a) -> m () #

elemseq :: Vector (Rounded r a) -> Rounded r a -> b -> b #

Unbox a => MVector MVector (Rounded r a) Source # 
Instance details

Defined in Numeric.Rounded.Hardware.Internal.Rounding

Methods

basicLength :: MVector s (Rounded r a) -> Int #

basicUnsafeSlice :: Int -> Int -> MVector s (Rounded r a) -> MVector s (Rounded r a) #

basicOverlaps :: MVector s (Rounded r a) -> MVector s (Rounded r a) -> Bool #

basicUnsafeNew :: PrimMonad m => Int -> m (MVector (PrimState m) (Rounded r a)) #

basicInitialize :: PrimMonad m => MVector (PrimState m) (Rounded r a) -> m () #

basicUnsafeReplicate :: PrimMonad m => Int -> Rounded r a -> m (MVector (PrimState m) (Rounded r a)) #

basicUnsafeRead :: PrimMonad m => MVector (PrimState m) (Rounded r a) -> Int -> m (Rounded r a) #

basicUnsafeWrite :: PrimMonad m => MVector (PrimState m) (Rounded r a) -> Int -> Rounded r a -> m () #

basicClear :: PrimMonad m => MVector (PrimState m) (Rounded r a) -> m () #

basicSet :: PrimMonad m => MVector (PrimState m) (Rounded r a) -> Rounded r a -> m () #

basicUnsafeCopy :: PrimMonad m => MVector (PrimState m) (Rounded r a) -> MVector (PrimState m) (Rounded r a) -> m () #

basicUnsafeMove :: PrimMonad m => MVector (PrimState m) (Rounded r a) -> MVector (PrimState m) (Rounded r a) -> m () #

basicUnsafeGrow :: PrimMonad m => MVector (PrimState m) (Rounded r a) -> Int -> m (MVector (PrimState m) (Rounded r a)) #

Functor (Rounded r) Source # 
Instance details

Defined in Numeric.Rounded.Hardware.Internal.Rounding

Methods

fmap :: (a -> b) -> Rounded r a -> Rounded r b #

(<$) :: a -> Rounded r b -> Rounded r a #

Eq a => Eq (Rounded r a) Source # 
Instance details

Defined in Numeric.Rounded.Hardware.Internal.Rounding

Methods

(==) :: Rounded r a -> Rounded r a -> Bool #

(/=) :: Rounded r a -> Rounded r a -> Bool #

(Rounding r, Num a, RoundedFractional a) => Fractional (Rounded r a) Source # 
Instance details

Defined in Numeric.Rounded.Hardware.Internal.Class

Methods

(/) :: Rounded r a -> Rounded r a -> Rounded r a #

recip :: Rounded r a -> Rounded r a #

fromRational :: Rational -> Rounded r a #

(Rounding r, Num a, RoundedRing a) => Num (Rounded r a) Source # 
Instance details

Defined in Numeric.Rounded.Hardware.Internal.Class

Methods

(+) :: Rounded r a -> Rounded r a -> Rounded r a #

(-) :: Rounded r a -> Rounded r a -> Rounded r a #

(*) :: Rounded r a -> Rounded r a -> Rounded r a #

negate :: Rounded r a -> Rounded r a #

abs :: Rounded r a -> Rounded r a #

signum :: Rounded r a -> Rounded r a #

fromInteger :: Integer -> Rounded r a #

Ord a => Ord (Rounded r a) Source # 
Instance details

Defined in Numeric.Rounded.Hardware.Internal.Rounding

Methods

compare :: Rounded r a -> Rounded r a -> Ordering #

(<) :: Rounded r a -> Rounded r a -> Bool #

(<=) :: Rounded r a -> Rounded r a -> Bool #

(>) :: Rounded r a -> Rounded r a -> Bool #

(>=) :: Rounded r a -> Rounded r a -> Bool #

max :: Rounded r a -> Rounded r a -> Rounded r a #

min :: Rounded r a -> Rounded r a -> Rounded r a #

(Rounding r, Real a, RoundedFractional a) => Real (Rounded r a) Source # 
Instance details

Defined in Numeric.Rounded.Hardware.Internal.Class

Methods

toRational :: Rounded r a -> Rational #

(Rounding r, RealFrac a, RoundedFractional a) => RealFrac (Rounded r a) Source # 
Instance details

Defined in Numeric.Rounded.Hardware.Internal.Class

Methods

properFraction :: Integral b => Rounded r a -> (b, Rounded r a) #

truncate :: Integral b => Rounded r a -> b #

round :: Integral b => Rounded r a -> b #

ceiling :: Integral b => Rounded r a -> b #

floor :: Integral b => Rounded r a -> b #

Show a => Show (Rounded r a) Source # 
Instance details

Defined in Numeric.Rounded.Hardware.Internal.Rounding

Methods

showsPrec :: Int -> Rounded r a -> ShowS #

show :: Rounded r a -> String #

showList :: [Rounded r a] -> ShowS #

Generic (Rounded r a) Source # 
Instance details

Defined in Numeric.Rounded.Hardware.Internal.Rounding

Associated Types

type Rep (Rounded r a) :: Type -> Type #

Methods

from :: Rounded r a -> Rep (Rounded r a) x #

to :: Rep (Rounded r a) x -> Rounded r a #

Storable a => Storable (Rounded r a) Source # 
Instance details

Defined in Numeric.Rounded.Hardware.Internal.Rounding

Methods

sizeOf :: Rounded r a -> Int #

alignment :: Rounded r a -> Int #

peekElemOff :: Ptr (Rounded r a) -> Int -> IO (Rounded r a) #

pokeElemOff :: Ptr (Rounded r a) -> Int -> Rounded r a -> IO () #

peekByteOff :: Ptr b -> Int -> IO (Rounded r a) #

pokeByteOff :: Ptr b -> Int -> Rounded r a -> IO () #

peek :: Ptr (Rounded r a) -> IO (Rounded r a) #

poke :: Ptr (Rounded r a) -> Rounded r a -> IO () #

NFData a => NFData (Rounded r a) Source # 
Instance details

Defined in Numeric.Rounded.Hardware.Internal.Rounding

Methods

rnf :: Rounded r a -> () #

Unbox a => Unbox (Rounded r a) Source # 
Instance details

Defined in Numeric.Rounded.Hardware.Internal.Rounding

newtype MVector s (Rounded r a) Source # 
Instance details

Defined in Numeric.Rounded.Hardware.Internal.Rounding

newtype MVector s (Rounded r a) = MV_Rounded (MVector s a)
type Rep (Rounded r a) Source # 
Instance details

Defined in Numeric.Rounded.Hardware.Internal.Rounding

type Rep (Rounded r a) = D1 ('MetaData "Rounded" "Numeric.Rounded.Hardware.Internal.Rounding" "rounded-hw-0.2.0-G2mMTdTBXOG87Ub6xfZ4rG" 'True) (C1 ('MetaCons "Rounded" 'PrefixI 'True) (S1 ('MetaSel ('Just "getRounded") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 a)))
newtype Vector (Rounded r a) Source # 
Instance details

Defined in Numeric.Rounded.Hardware.Internal.Rounding

newtype Vector (Rounded r a) = V_Rounded (Vector a)

data RoundingMode Source #

The type for IEEE754 rounding-direction attributes.

Constructors

ToNearest

Round to the nearest value (IEEE754 roundTiesToEven)

TowardNegInf

Round downward (IEEE754 roundTowardNegative)

TowardInf

Round upward (IEEE754 roundTowardPositive)

TowardZero

Round toward zero (IEEE754 roundTowardZero)

Instances

Instances details
Bounded RoundingMode Source # 
Instance details

Defined in Numeric.Rounded.Hardware.Internal.Rounding

Enum RoundingMode Source # 
Instance details

Defined in Numeric.Rounded.Hardware.Internal.Rounding

Eq RoundingMode Source # 
Instance details

Defined in Numeric.Rounded.Hardware.Internal.Rounding

Ord RoundingMode Source # 
Instance details

Defined in Numeric.Rounded.Hardware.Internal.Rounding

Read RoundingMode Source # 
Instance details

Defined in Numeric.Rounded.Hardware.Internal.Rounding

Show RoundingMode Source # 
Instance details

Defined in Numeric.Rounded.Hardware.Internal.Rounding

Generic RoundingMode Source # 
Instance details

Defined in Numeric.Rounded.Hardware.Internal.Rounding

Associated Types

type Rep RoundingMode :: Type -> Type #

NFData RoundingMode Source # 
Instance details

Defined in Numeric.Rounded.Hardware.Internal.Rounding

Methods

rnf :: RoundingMode -> () #

type Rep RoundingMode Source # 
Instance details

Defined in Numeric.Rounded.Hardware.Internal.Rounding

type Rep RoundingMode = D1 ('MetaData "RoundingMode" "Numeric.Rounded.Hardware.Internal.Rounding" "rounded-hw-0.2.0-G2mMTdTBXOG87Ub6xfZ4rG" 'False) ((C1 ('MetaCons "ToNearest" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "TowardNegInf" 'PrefixI 'False) (U1 :: Type -> Type)) :+: (C1 ('MetaCons "TowardInf" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "TowardZero" 'PrefixI 'False) (U1 :: Type -> Type)))

class Rounding (r :: RoundingMode) Source #

This class allows you to recover the runtime value from a type-level rounding mode.

See rounding.

Minimal complete definition

roundingT

class Ord a => RoundedRing a Source #

Rounding-controlled version of Num.

Instances

Instances details
RoundedRing Double Source # 
Instance details

Defined in Numeric.Rounded.Hardware.Backend.Default

RoundedRing Float Source # 
Instance details

Defined in Numeric.Rounded.Hardware.Backend.Default

RoundedRing Integer Source # 
Instance details

Defined in Numeric.Rounded.Hardware.Internal.Class

RoundedRing LongDouble Source #

Only available on x86/x86_64 systems. Note that LongDouble may not work correctly on Win64.

Instance details

Defined in Numeric.Rounded.Hardware.Backend.X87LongDouble

Methods

roundedAdd :: RoundingMode -> LongDouble -> LongDouble -> LongDouble Source #

roundedSub :: RoundingMode -> LongDouble -> LongDouble -> LongDouble Source #

roundedMul :: RoundingMode -> LongDouble -> LongDouble -> LongDouble Source #

roundedFusedMultiplyAdd :: RoundingMode -> LongDouble -> LongDouble -> LongDouble -> LongDouble Source #

roundedFromInteger :: RoundingMode -> Integer -> LongDouble Source #

intervalAdd :: Rounded 'TowardNegInf LongDouble -> Rounded 'TowardInf LongDouble -> Rounded 'TowardNegInf LongDouble -> Rounded 'TowardInf LongDouble -> (Rounded 'TowardNegInf LongDouble, Rounded 'TowardInf LongDouble) Source #

intervalSub :: Rounded 'TowardNegInf LongDouble -> Rounded 'TowardInf LongDouble -> Rounded 'TowardNegInf LongDouble -> Rounded 'TowardInf LongDouble -> (Rounded 'TowardNegInf LongDouble, Rounded 'TowardInf LongDouble) Source #

intervalMul :: Rounded 'TowardNegInf LongDouble -> Rounded 'TowardInf LongDouble -> Rounded 'TowardNegInf LongDouble -> Rounded 'TowardInf LongDouble -> (Rounded 'TowardNegInf LongDouble, Rounded 'TowardInf LongDouble) Source #

intervalMulAdd :: Rounded 'TowardNegInf LongDouble -> Rounded 'TowardInf LongDouble -> Rounded 'TowardNegInf LongDouble -> Rounded 'TowardInf LongDouble -> Rounded 'TowardNegInf LongDouble -> Rounded 'TowardInf LongDouble -> (Rounded 'TowardNegInf LongDouble, Rounded 'TowardInf LongDouble) Source #

intervalFromInteger :: Integer -> (Rounded 'TowardNegInf LongDouble, Rounded 'TowardInf LongDouble) Source #

backendNameT :: Tagged LongDouble String Source #

RoundedRing CDouble Source # 
Instance details

Defined in Numeric.Rounded.Hardware.Backend.C

RoundedRing CFloat Source # 
Instance details

Defined in Numeric.Rounded.Hardware.Backend.C

RoundedRing CDouble Source # 
Instance details

Defined in Numeric.Rounded.Hardware.Backend.FastFFI

Integral a => RoundedRing (Ratio a) Source # 
Instance details

Defined in Numeric.Rounded.Hardware.Internal.Class

(RealFloat a, Num a, RealFloatConstants a) => RoundedRing (ViaRational a) Source # 
Instance details

Defined in Numeric.Rounded.Hardware.Backend.ViaRational

Methods

roundedAdd :: RoundingMode -> ViaRational a -> ViaRational a -> ViaRational a Source #

roundedSub :: RoundingMode -> ViaRational a -> ViaRational a -> ViaRational a Source #

roundedMul :: RoundingMode -> ViaRational a -> ViaRational a -> ViaRational a Source #

roundedFusedMultiplyAdd :: RoundingMode -> ViaRational a -> ViaRational a -> ViaRational a -> ViaRational a Source #

roundedFromInteger :: RoundingMode -> Integer -> ViaRational a Source #

intervalAdd :: Rounded 'TowardNegInf (ViaRational a) -> Rounded 'TowardInf (ViaRational a) -> Rounded 'TowardNegInf (ViaRational a) -> Rounded 'TowardInf (ViaRational a) -> (Rounded 'TowardNegInf (ViaRational a), Rounded 'TowardInf (ViaRational a)) Source #

intervalSub :: Rounded 'TowardNegInf (ViaRational a) -> Rounded 'TowardInf (ViaRational a) -> Rounded 'TowardNegInf (ViaRational a) -> Rounded 'TowardInf (ViaRational a) -> (Rounded 'TowardNegInf (ViaRational a), Rounded 'TowardInf (ViaRational a)) Source #

intervalMul :: Rounded 'TowardNegInf (ViaRational a) -> Rounded 'TowardInf (ViaRational a) -> Rounded 'TowardNegInf (ViaRational a) -> Rounded 'TowardInf (ViaRational a) -> (Rounded 'TowardNegInf (ViaRational a), Rounded 'TowardInf (ViaRational a)) Source #

intervalMulAdd :: Rounded 'TowardNegInf (ViaRational a) -> Rounded 'TowardInf (ViaRational a) -> Rounded 'TowardNegInf (ViaRational a) -> Rounded 'TowardInf (ViaRational a) -> Rounded 'TowardNegInf (ViaRational a) -> Rounded 'TowardInf (ViaRational a) -> (Rounded 'TowardNegInf (ViaRational a), Rounded 'TowardInf (ViaRational a)) Source #

intervalFromInteger :: Integer -> (Rounded 'TowardNegInf (ViaRational a), Rounded 'TowardInf (ViaRational a)) Source #

backendNameT :: Tagged (ViaRational a) String Source #

class RoundedRing a => RoundedFractional a Source #

Rounding-controlled version of Fractional.

Minimal complete definition

roundedDiv

Instances

Instances details
RoundedFractional Double Source # 
Instance details

Defined in Numeric.Rounded.Hardware.Backend.Default

RoundedFractional Float Source # 
Instance details

Defined in Numeric.Rounded.Hardware.Backend.Default

RoundedFractional Integer Source # 
Instance details

Defined in Numeric.Rounded.Hardware.Internal.Class

RoundedFractional LongDouble Source #

Only available on x86/x86_64 systems. Note that LongDouble may not work correctly on Win64.

Instance details

Defined in Numeric.Rounded.Hardware.Backend.X87LongDouble

RoundedFractional CDouble Source # 
Instance details

Defined in Numeric.Rounded.Hardware.Backend.C

RoundedFractional CFloat Source # 
Instance details

Defined in Numeric.Rounded.Hardware.Backend.C

RoundedFractional CDouble Source # 
Instance details

Defined in Numeric.Rounded.Hardware.Backend.FastFFI

Integral a => RoundedFractional (Ratio a) Source # 
Instance details

Defined in Numeric.Rounded.Hardware.Internal.Class

(RealFloat a, Num a, RealFloatConstants a) => RoundedFractional (ViaRational a) Source # 
Instance details

Defined in Numeric.Rounded.Hardware.Backend.ViaRational

class RoundedRing a => RoundedSqrt a Source #

Rounding-controlled version of sqrt.

Minimal complete definition

roundedSqrt

Instances

Instances details
RoundedSqrt Double Source # 
Instance details

Defined in Numeric.Rounded.Hardware.Backend.Default

RoundedSqrt Float Source # 
Instance details

Defined in Numeric.Rounded.Hardware.Backend.Default

RoundedSqrt LongDouble Source #

Only available on x86/x86_64 systems. Note that LongDouble may not work correctly on Win64.

Instance details

Defined in Numeric.Rounded.Hardware.Backend.X87LongDouble

RoundedSqrt CDouble Source # 
Instance details

Defined in Numeric.Rounded.Hardware.Backend.C

RoundedSqrt CFloat Source # 
Instance details

Defined in Numeric.Rounded.Hardware.Backend.C

RoundedSqrt CDouble Source # 
Instance details

Defined in Numeric.Rounded.Hardware.Backend.FastFFI

(RealFloat a, RealFloatConstants a) => RoundedSqrt (ViaRational a) Source # 
Instance details

Defined in Numeric.Rounded.Hardware.Backend.ViaRational