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

Data.Double.Shaman

Synopsis

Documentation

data Shaman Source #

Double-precision floating point numbers with error-bounds.

Some digits can be represented exactly and have essentially an infinitely number of significant digits:

>>> significativeDigits 1
Infinity

Some fractional numbers can also be represented exactly:

>>> significativeDigits 0.5
Infinity

Other numbers are merely approximations:

>>> significativeDigits 0.1
16.255619765854984

Pi is an irrational number so we can't represent it with infinite precision:

>>> significativeDigits pi
15.849679651557175

sin pi should theoretically be zero but we cannot do better than saying it is near zero:

>>> sin pi
1.2246467991473532e-16

The error margins are greater than value itself so we have no significant digits:

>>> significativeDigits (sin pi)
0.0

Since 'near zero' is not zero, the following fails when using Doubles:

>>> sin pi == (0 :: Double)
False

Equality testing for Shaman numbers tests whether the two intervals overlap:

>>> sin pi == (0 :: Shaman)
True

Instances

Instances details
Eq Shaman Source # 
Instance details

Defined in Data.Double.Shaman

Methods

(==) :: Shaman -> Shaman -> Bool #

(/=) :: Shaman -> Shaman -> Bool #

Floating Shaman Source # 
Instance details

Defined in Data.Double.Shaman

Fractional Shaman Source # 
Instance details

Defined in Data.Double.Shaman

Num Shaman Source # 
Instance details

Defined in Data.Double.Shaman

Ord Shaman Source # 
Instance details

Defined in Data.Double.Shaman

Read Shaman Source # 
Instance details

Defined in Data.Double.Shaman

Real Shaman Source # 
Instance details

Defined in Data.Double.Shaman

RealFloat Shaman Source # 
Instance details

Defined in Data.Double.Shaman

RealFrac Shaman Source # 
Instance details

Defined in Data.Double.Shaman

Methods

properFraction :: Integral b => Shaman -> (b, Shaman) #

truncate :: Integral b => Shaman -> b #

round :: Integral b => Shaman -> b #

ceiling :: Integral b => Shaman -> b #

floor :: Integral b => Shaman -> b #

Show Shaman Source # 
Instance details

Defined in Data.Double.Shaman

significativeBits :: Shaman -> Double Source #

Number of significant bits (base 2).

significativeDigits :: Shaman -> Double Source #

Number of significant digits (base 10).

data SDouble (n :: Nat) Source #

Double-precision floating point numbers that throw exceptions if the accumulated errors grow large enough to cause unstable branching.

If SDouble n works without throwing any exceptions, it'll be safe to use DoubleRelAbs n 0 instead for a sizable performance boost.

>>> sin pi == (0 :: SDouble 0)
*** Exception: Insufficient precision.
...

SDouble 0 failed so DoubleRelAbs 0 0 will lead to an unstable branch. In other words, it'll return False when it should have returned True:

>>> sin pi == (0 :: DoubleRelAbs 0 0)
False

Comparing to within 1 ULP stabalizes the branch:

>>> sin pi == (0 :: SDouble 1)
True
>>> sin pi == (0 :: DoubleRelAbs 1 0)
True

Instances

Instances details
KnownNat n => Eq (SDouble n) Source # 
Instance details

Defined in Data.Double.Shaman

Methods

(==) :: SDouble n -> SDouble n -> Bool #

(/=) :: SDouble n -> SDouble n -> Bool #

Floating (SDouble n) Source # 
Instance details

Defined in Data.Double.Shaman

Methods

pi :: SDouble n #

exp :: SDouble n -> SDouble n #

log :: SDouble n -> SDouble n #

sqrt :: SDouble n -> SDouble n #

(**) :: SDouble n -> SDouble n -> SDouble n #

logBase :: SDouble n -> SDouble n -> SDouble n #

sin :: SDouble n -> SDouble n #

cos :: SDouble n -> SDouble n #

tan :: SDouble n -> SDouble n #

asin :: SDouble n -> SDouble n #

acos :: SDouble n -> SDouble n #

atan :: SDouble n -> SDouble n #

sinh :: SDouble n -> SDouble n #

cosh :: SDouble n -> SDouble n #

tanh :: SDouble n -> SDouble n #

asinh :: SDouble n -> SDouble n #

acosh :: SDouble n -> SDouble n #

atanh :: SDouble n -> SDouble n #

log1p :: SDouble n -> SDouble n #

expm1 :: SDouble n -> SDouble n #

log1pexp :: SDouble n -> SDouble n #

log1mexp :: SDouble n -> SDouble n #

Fractional (SDouble n) Source # 
Instance details

Defined in Data.Double.Shaman

Methods

(/) :: SDouble n -> SDouble n -> SDouble n #

recip :: SDouble n -> SDouble n #

fromRational :: Rational -> SDouble n #

Num (SDouble n) Source # 
Instance details

Defined in Data.Double.Shaman

Methods

(+) :: SDouble n -> SDouble n -> SDouble n #

(-) :: SDouble n -> SDouble n -> SDouble n #

(*) :: SDouble n -> SDouble n -> SDouble n #

negate :: SDouble n -> SDouble n #

abs :: SDouble n -> SDouble n #

signum :: SDouble n -> SDouble n #

fromInteger :: Integer -> SDouble n #

KnownNat n => Ord (SDouble n) Source # 
Instance details

Defined in Data.Double.Shaman

Methods

compare :: SDouble n -> SDouble n -> Ordering #

(<) :: SDouble n -> SDouble n -> Bool #

(<=) :: SDouble n -> SDouble n -> Bool #

(>) :: SDouble n -> SDouble n -> Bool #

(>=) :: SDouble n -> SDouble n -> Bool #

max :: SDouble n -> SDouble n -> SDouble n #

min :: SDouble n -> SDouble n -> SDouble n #

Read (SDouble n) Source # 
Instance details

Defined in Data.Double.Shaman

KnownNat n => Real (SDouble n) Source # 
Instance details

Defined in Data.Double.Shaman

Methods

toRational :: SDouble n -> Rational #

KnownNat n => RealFloat (SDouble n) Source # 
Instance details

Defined in Data.Double.Shaman

KnownNat n => RealFrac (SDouble n) Source # 
Instance details

Defined in Data.Double.Shaman

Methods

properFraction :: Integral b => SDouble n -> (b, SDouble n) #

truncate :: Integral b => SDouble n -> b #

round :: Integral b => SDouble n -> b #

ceiling :: Integral b => SDouble n -> b #

floor :: Integral b => SDouble n -> b #

Show (SDouble n) Source # 
Instance details

Defined in Data.Double.Shaman

Methods

showsPrec :: Int -> SDouble n -> ShowS #

show :: SDouble n -> String #

showList :: [SDouble n] -> ShowS #