ieee-utils-tempfix-0.4.0.1: ieee-utils

Portabilityportable (FFI)
Stabilityprovisional
MaintainerMatt Morrow <mjm2002@gmail.com>
Safe HaskellNone

Numeric.IEEE.Monad

Description

The IEEE monad provides tools for enforcing sequencing of calculations such that fine grained control is provided over triggering exceptions, evaluations within particular rounding modes, etc. The perturb family of functions is built using this, allowing pure computations paramaterized over an arbitrary Floating type to be tested for numeric stability.

Synopsis

Documentation

withIeeeDo :: ([ieeeMutex :: MVar ()] => IO a) -> IO aSource

All uses of the IEEE monad need to be wrapped inside a top level call to withIeeeDo. This ensures that access to floating point internals is serialized properly, even between multiple threads.

newtype IEEE a Source

Constructors

IEEE 

Fields

unIEEE :: IO a
 

runIEEE :: [ieeeMutex :: MVar ()] => IEEE a -> IO aSource

calculate :: a -> IEEE aSource

Forces strict evaluation of the enclosed numeric argument.

calculate' :: a -> IEEE (a, [ArithException])Source

Calculate, but also returns any floating exceptions triggered.

withRoundMode :: RoundMode -> IEEE a -> IEEE aSource

Executes the specified IEEE action within a specific round mode.

perturb' :: ([ieeeMutex :: MVar ()], Floating b) => (forall a. Floating a => IEEE a) -> IO (b, b, b, b)Source

Given something of (forall a. Floating a => IEEE a) produces a four-tuple of the value as calculated rounding up, down, to nearest, and towards zero.

perturb :: ([ieeeMutex :: MVar ()], Floating b) => (forall a. Floating a => IEEE a) -> IO bSource

Given something that produces a Floating, returns a representation of the absolute difference between the results as calculated rounding upwards and downwards.

perturbedMag :: ([ieeeMutex :: MVar ()], Floating b) => (forall a. Floating a => IEEE a) -> IO bSource

Given something that produces a Floating, returns the magnitude of instability introduced by perturbing the equation by rounding upwards and then downwards. This is the absolute difference between the results as calculated rounding upwards and downwards, and then divided by the averaged result.