Portability | BangPatterns |
---|---|
Stability | unstable |
Maintainer | claude@mathr.co.uk |
Safe Haskell | Safe-Inferred |
Implementations of various floating point algorithms. Accuracy has not been extensively verified, and termination has not been proven.
Everything assumes that floatRadix
is 2. This is *not* checked.
Functions taking an accuracy
parameter may fail to terminate if
accuracy
is too small. Accuracy is measured in least significant
bits, similarly to '(=~=)'.
In this documentation, basic functionality denotes that methods used are from classes:
Further, basic RealFloat functionality denotes basic functionality with the addition of:
The intention behind the used functionality documentation is to help users decide when it is appropriate to use these generic implementations to implement instances.
- recodeFloat :: (RealFloat a, RealFloat b) => a -> b
- viaDouble :: (RealFloat a, RealFloat b) => (Double -> Double) -> a -> b
- (=~=) :: RealFloat a => a -> a -> Int -> Bool
- genericRecip :: RealFloat a => Int -> a -> a
- genericSqrt :: RealFloat a => Int -> a -> a
- genericExp :: RealFloat a => Int -> a -> a
- genericLog :: RealFloat a => Int -> a -> a
- genericLog' :: RealFloat a => Int -> a -> a -> a
- genericLog2 :: RealFloat a => Int -> a
- genericLog'' :: RealFloat a => Int -> a -> a
- genericPi :: RealFloat a => Int -> a
- genericSin :: RealFloat a => Int -> a -> a -> a
- genericPositiveZero :: RealFloat a => a
- genericNegativeZero :: RealFloat a => a
- genericPositiveInfinity :: RealFloat a => a
- genericNegativeInfinity :: RealFloat a => a
- genericNotANumber :: RealFloat a => a
- sameSign :: (Ord a, Num a) => a -> a -> Bool
Documentation
recodeFloat :: (RealFloat a, RealFloat b) => a -> bSource
Convert between generic RealFloat
types more efficiently than
realToFrac
. Tries hard to preserve special values like
infinities and negative zero, but any NaN payload is lost.
Uses only basic RealFloat functionality.
viaDouble :: (RealFloat a, RealFloat b) => (Double -> Double) -> a -> bSource
Lift a function from Double to generic RealFloat
types.
(=~=) :: RealFloat a => a -> a -> Int -> BoolSource
Approximate equality.
(a =~= b) c
when adding the difference to the larger in magnitude
changes at most c
least significant mantissa bits.
Uses only basic RealFloat functionality.
Compute a reciprocal using the Newton-Raphson division algorithm, as described in http://en.wikipedia.org/wiki/Division_%28digital%29#Newton.E2.80.93Raphson_division.
Uses only basic RealFloat functionality.
Compute a square root using Newton's method.
Uses basic RealFloat functionality and '(/)'.
Compute an exponential using power series.
Uses basic RealFloat functionality, '(/)' and recip
.
Compute a logarithm.
See genericLog''
for algorithmic references.
Compute a logarithm using decomposition and a value for log 2
.
See genericLog''
for algorithmic references.
Compute log 2.
See genericLog''
for algorithmic references.
Compute a logarithm for a value in [0.5,1) using the AGM method as described in section 7 of The Logarithmic Constant: log 2 Xavier Gourdon and Pascal Sebah, May 18, 2010, http://numbers.computation.free.fr/Constants/Log2/log2.ps.
The precondition is not checked.
Compute pi using the method described in section 8 of Multiple-precision zero-finding methods and the complexity of elementary function evaluation Richard P Brent, 1975 (revised May 30, 2010), http://arxiv.org/abs/1004.3412.
Uses basic RealFloat functionality, '(/)', and sqrt
.
Compute sin
using the method described in section 3 of
Efficient multiple-precision evaluation of elementary functions
David M Smith, 1989,
http://digitalcommons.lmu.edu/math_fac/1/
Requires a value for pi.
Uses basic RealFloat functionality, '(/)', and sqrt.
genericPositiveZero :: RealFloat a => aSource
Special values implemented using basic RealFloat functionality.
genericNegativeZero :: RealFloat a => aSource
Special values implemented using basic RealFloat functionality.
genericPositiveInfinity :: RealFloat a => aSource
Special values implemented using basic RealFloat functionality.
genericNegativeInfinity :: RealFloat a => aSource
Special values implemented using basic RealFloat functionality.
genericNotANumber :: RealFloat a => aSource
Special values implemented using basic RealFloat functionality.