hgeometry-combinatorial-0.12.0.1: Data structures, and Data types.
Safe HaskellNone
LanguageHaskell2010

Data.Double.Approximate

Description

 
Synopsis

Documentation

type SafeDouble = DoubleRelAbs 10 10 Source #

Relatively safe double floating-point type with a relative error margin of 10 ULPs and an absolute margin around zero of 10*epsilon.

Warning: All numbers within 10*epsilon of zero will be considered zero.

>>> m_epsilon * 10
2.220446049250313e-15
>>> realToFrac (m_epsilon * 10) == (0::SafeDouble)
False
>>> realToFrac (m_epsilon * 9) == (0::SafeDouble)
True
>>> 1e-20 == (5e-20 :: Double)
False
>>> 1e-20 == (5e-20 :: SafeDouble)
True

pi and sin are approximations:

>>> sin pi
1.2246467991473532e-16
>>> sin pi == (0 :: Double)
False
>>> sin pi == (0 :: SafeDouble)
True

newtype DoubleRelAbs (abs :: Nat) (rel :: Nat) Source #

Custom double floating-point type with a relative error margin of rel number of ULPs and an absolute error margin of abs times epsilon.

The relative error margin is the primary tool for good numerical robustness and can relatively safely be set to a high number such as 100. The absolute error margin is a last ditch attempt at fixing broken algorithms and dramatically limits the resolution around zero. If possible, use a low absolute error margin.

Constructors

DoubleRelAbs Double 

Instances

Instances details
Enum (DoubleRelAbs abs rel) Source # 
Instance details

Defined in Data.Double.Approximate

Methods

succ :: DoubleRelAbs abs rel -> DoubleRelAbs abs rel #

pred :: DoubleRelAbs abs rel -> DoubleRelAbs abs rel #

toEnum :: Int -> DoubleRelAbs abs rel #

fromEnum :: DoubleRelAbs abs rel -> Int #

enumFrom :: DoubleRelAbs abs rel -> [DoubleRelAbs abs rel] #

enumFromThen :: DoubleRelAbs abs rel -> DoubleRelAbs abs rel -> [DoubleRelAbs abs rel] #

enumFromTo :: DoubleRelAbs abs rel -> DoubleRelAbs abs rel -> [DoubleRelAbs abs rel] #

enumFromThenTo :: DoubleRelAbs abs rel -> DoubleRelAbs abs rel -> DoubleRelAbs abs rel -> [DoubleRelAbs abs rel] #

(KnownNat abs, KnownNat rel) => Eq (DoubleRelAbs abs rel) Source # 
Instance details

Defined in Data.Double.Approximate

Methods

(==) :: DoubleRelAbs abs rel -> DoubleRelAbs abs rel -> Bool #

(/=) :: DoubleRelAbs abs rel -> DoubleRelAbs abs rel -> Bool #

Floating (DoubleRelAbs abs rel) Source # 
Instance details

Defined in Data.Double.Approximate

Methods

pi :: DoubleRelAbs abs rel #

exp :: DoubleRelAbs abs rel -> DoubleRelAbs abs rel #

log :: DoubleRelAbs abs rel -> DoubleRelAbs abs rel #

sqrt :: DoubleRelAbs abs rel -> DoubleRelAbs abs rel #

(**) :: DoubleRelAbs abs rel -> DoubleRelAbs abs rel -> DoubleRelAbs abs rel #

logBase :: DoubleRelAbs abs rel -> DoubleRelAbs abs rel -> DoubleRelAbs abs rel #

sin :: DoubleRelAbs abs rel -> DoubleRelAbs abs rel #

cos :: DoubleRelAbs abs rel -> DoubleRelAbs abs rel #

tan :: DoubleRelAbs abs rel -> DoubleRelAbs abs rel #

asin :: DoubleRelAbs abs rel -> DoubleRelAbs abs rel #

acos :: DoubleRelAbs abs rel -> DoubleRelAbs abs rel #

atan :: DoubleRelAbs abs rel -> DoubleRelAbs abs rel #

sinh :: DoubleRelAbs abs rel -> DoubleRelAbs abs rel #

cosh :: DoubleRelAbs abs rel -> DoubleRelAbs abs rel #

tanh :: DoubleRelAbs abs rel -> DoubleRelAbs abs rel #

asinh :: DoubleRelAbs abs rel -> DoubleRelAbs abs rel #

acosh :: DoubleRelAbs abs rel -> DoubleRelAbs abs rel #

atanh :: DoubleRelAbs abs rel -> DoubleRelAbs abs rel #

log1p :: DoubleRelAbs abs rel -> DoubleRelAbs abs rel #

expm1 :: DoubleRelAbs abs rel -> DoubleRelAbs abs rel #

log1pexp :: DoubleRelAbs abs rel -> DoubleRelAbs abs rel #

log1mexp :: DoubleRelAbs abs rel -> DoubleRelAbs abs rel #

Fractional (DoubleRelAbs abs rel) Source # 
Instance details

Defined in Data.Double.Approximate

Methods

(/) :: DoubleRelAbs abs rel -> DoubleRelAbs abs rel -> DoubleRelAbs abs rel #

recip :: DoubleRelAbs abs rel -> DoubleRelAbs abs rel #

fromRational :: Rational -> DoubleRelAbs abs rel #

Num (DoubleRelAbs abs rel) Source # 
Instance details

Defined in Data.Double.Approximate

Methods

(+) :: DoubleRelAbs abs rel -> DoubleRelAbs abs rel -> DoubleRelAbs abs rel #

(-) :: DoubleRelAbs abs rel -> DoubleRelAbs abs rel -> DoubleRelAbs abs rel #

(*) :: DoubleRelAbs abs rel -> DoubleRelAbs abs rel -> DoubleRelAbs abs rel #

negate :: DoubleRelAbs abs rel -> DoubleRelAbs abs rel #

abs :: DoubleRelAbs abs rel -> DoubleRelAbs abs rel #

signum :: DoubleRelAbs abs rel -> DoubleRelAbs abs rel #

fromInteger :: Integer -> DoubleRelAbs abs rel #

(KnownNat abs, KnownNat rel) => Ord (DoubleRelAbs abs rel) Source # 
Instance details

Defined in Data.Double.Approximate

Methods

compare :: DoubleRelAbs abs rel -> DoubleRelAbs abs rel -> Ordering #

(<) :: DoubleRelAbs abs rel -> DoubleRelAbs abs rel -> Bool #

(<=) :: DoubleRelAbs abs rel -> DoubleRelAbs abs rel -> Bool #

(>) :: DoubleRelAbs abs rel -> DoubleRelAbs abs rel -> Bool #

(>=) :: DoubleRelAbs abs rel -> DoubleRelAbs abs rel -> Bool #

max :: DoubleRelAbs abs rel -> DoubleRelAbs abs rel -> DoubleRelAbs abs rel #

min :: DoubleRelAbs abs rel -> DoubleRelAbs abs rel -> DoubleRelAbs abs rel #

Read (DoubleRelAbs abs rel) Source # 
Instance details

Defined in Data.Double.Approximate

(KnownNat abs, KnownNat rel) => Real (DoubleRelAbs abs rel) Source # 
Instance details

Defined in Data.Double.Approximate

Methods

toRational :: DoubleRelAbs abs rel -> Rational #

(KnownNat abs, KnownNat rel) => RealFloat (DoubleRelAbs abs rel) Source # 
Instance details

Defined in Data.Double.Approximate

Methods

floatRadix :: DoubleRelAbs abs rel -> Integer #

floatDigits :: DoubleRelAbs abs rel -> Int #

floatRange :: DoubleRelAbs abs rel -> (Int, Int) #

decodeFloat :: DoubleRelAbs abs rel -> (Integer, Int) #

encodeFloat :: Integer -> Int -> DoubleRelAbs abs rel #

exponent :: DoubleRelAbs abs rel -> Int #

significand :: DoubleRelAbs abs rel -> DoubleRelAbs abs rel #

scaleFloat :: Int -> DoubleRelAbs abs rel -> DoubleRelAbs abs rel #

isNaN :: DoubleRelAbs abs rel -> Bool #

isInfinite :: DoubleRelAbs abs rel -> Bool #

isDenormalized :: DoubleRelAbs abs rel -> Bool #

isNegativeZero :: DoubleRelAbs abs rel -> Bool #

isIEEE :: DoubleRelAbs abs rel -> Bool #

atan2 :: DoubleRelAbs abs rel -> DoubleRelAbs abs rel -> DoubleRelAbs abs rel #

(KnownNat abs, KnownNat rel) => RealFrac (DoubleRelAbs abs rel) Source # 
Instance details

Defined in Data.Double.Approximate

Methods

properFraction :: Integral b => DoubleRelAbs abs rel -> (b, DoubleRelAbs abs rel) #

truncate :: Integral b => DoubleRelAbs abs rel -> b #

round :: Integral b => DoubleRelAbs abs rel -> b #

ceiling :: Integral b => DoubleRelAbs abs rel -> b #

floor :: Integral b => DoubleRelAbs abs rel -> b #

Show (DoubleRelAbs abs rel) Source # 
Instance details

Defined in Data.Double.Approximate

Methods

showsPrec :: Int -> DoubleRelAbs abs rel -> ShowS #

show :: DoubleRelAbs abs rel -> String #

showList :: [DoubleRelAbs abs rel] -> ShowS #

Random (DoubleRelAbs abs rel) Source # 
Instance details

Defined in Data.Double.Approximate

Methods

randomR :: RandomGen g => (DoubleRelAbs abs rel, DoubleRelAbs abs rel) -> g -> (DoubleRelAbs abs rel, g) #

random :: RandomGen g => g -> (DoubleRelAbs abs rel, g) #

randomRs :: RandomGen g => (DoubleRelAbs abs rel, DoubleRelAbs abs rel) -> g -> [DoubleRelAbs abs rel] #

randoms :: RandomGen g => g -> [DoubleRelAbs abs rel] #

NFData (DoubleRelAbs abs rel) Source # 
Instance details

Defined in Data.Double.Approximate

Methods

rnf :: DoubleRelAbs abs rel -> () #