rounded-hw-0.4.0: Directed rounding for built-in floating types
Safe HaskellSafe-Inferred
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 :: Mutable Vector s (Rounded r a) -> ST s (Vector (Rounded r a)) #

basicUnsafeThaw :: Vector (Rounded r a) -> ST s (Mutable Vector s (Rounded r a)) #

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

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

basicUnsafeIndexM :: Vector (Rounded r a) -> Int -> Box (Rounded r a) #

basicUnsafeCopy :: Mutable Vector s (Rounded r a) -> Vector (Rounded r a) -> ST s () #

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 :: Int -> ST s (MVector s (Rounded r a)) #

basicInitialize :: MVector s (Rounded r a) -> ST s () #

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

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

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

basicClear :: MVector s (Rounded r a) -> ST s () #

basicSet :: MVector s (Rounded r a) -> Rounded r a -> ST s () #

basicUnsafeCopy :: MVector s (Rounded r a) -> MVector s (Rounded r a) -> ST s () #

basicUnsafeMove :: MVector s (Rounded r a) -> MVector s (Rounded r a) -> ST s () #

basicUnsafeGrow :: MVector s (Rounded r a) -> Int -> ST s (MVector s (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 #

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 () #

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 #

(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 #

(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, 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 #

(Rounding r, 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 #

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

Defined in Numeric.Rounded.Hardware.Internal.Rounding

Methods

rnf :: 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 #

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 #

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.4.0-3WAAI20vt2HBtLAkTAeX6n" '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

Generic RoundingMode Source # 
Instance details

Defined in Numeric.Rounded.Hardware.Internal.Rounding

Associated Types

type Rep RoundingMode :: Type -> Type #

Read RoundingMode Source # 
Instance details

Defined in Numeric.Rounded.Hardware.Internal.Rounding

Show RoundingMode Source # 
Instance details

Defined in Numeric.Rounded.Hardware.Internal.Rounding

NFData RoundingMode Source # 
Instance details

Defined in Numeric.Rounded.Hardware.Internal.Rounding

Methods

rnf :: RoundingMode -> () #

Eq RoundingMode Source # 
Instance details

Defined in Numeric.Rounded.Hardware.Internal.Rounding

Ord RoundingMode Source # 
Instance details

Defined in Numeric.Rounded.Hardware.Internal.Rounding

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.4.0-3WAAI20vt2HBtLAkTAeX6n" '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 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

RoundedRing Integer Source # 
Instance details

Defined in Numeric.Rounded.Hardware.Internal.Class

RoundedRing Double Source # 
Instance details

Defined in Numeric.Rounded.Hardware.Backend.Default

RoundedRing Float Source # 
Instance details

Defined in Numeric.Rounded.Hardware.Backend.Default

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 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

RoundedFractional Integer Source # 
Instance details

Defined in Numeric.Rounded.Hardware.Internal.Class

RoundedFractional Double Source # 
Instance details

Defined in Numeric.Rounded.Hardware.Backend.Default

RoundedFractional Float Source # 
Instance details

Defined in Numeric.Rounded.Hardware.Backend.Default

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 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

RoundedSqrt Double Source # 
Instance details

Defined in Numeric.Rounded.Hardware.Backend.Default

RoundedSqrt Float Source # 
Instance details

Defined in Numeric.Rounded.Hardware.Backend.Default

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

Defined in Numeric.Rounded.Hardware.Backend.ViaRational