Portability | portable (FFI) |
---|---|
Stability | provisional |
Maintainer | Matt Morrow <mjm2002@gmail.com> |
Safe Haskell | None |
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.
- withIeeeDo :: ([ieeeMutex :: MVar ()] => IO a) -> IO a
- newtype IEEE a = IEEE {}
- runIEEE :: [ieeeMutex :: MVar ()] => IEEE a -> IO a
- getRound :: IEEE RoundMode
- setRound :: RoundMode -> IEEE Bool
- clearFloatExcepts :: [ArithException] -> IEEE Bool
- getFloatExcepts :: IEEE [ArithException]
- calculate :: a -> IEEE a
- calculate' :: a -> IEEE (a, [ArithException])
- withRoundMode :: RoundMode -> IEEE a -> IEEE a
- perturb' :: ([ieeeMutex :: MVar ()], Floating b) => (forall a. Floating a => IEEE a) -> IO (b, b, b, b)
- perturb :: ([ieeeMutex :: MVar ()], Floating b) => (forall a. Floating a => IEEE a) -> IO b
- perturbedMag :: ([ieeeMutex :: MVar ()], Floating b) => (forall a. Floating a => IEEE a) -> IO b
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.
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.