mirror of
https://gitlab.com/sheaf/metabrush.git
synced 2024-12-24 14:24:07 +00:00
58ca70c1bd
* use PrimArray to represent polynomials * add some strictness annotations * turn on some optimisation flags * use quadratic formula for quadratic polynomials
16 lines
407 B
Haskell
16 lines
407 B
Haskell
{-# LANGUAGE ScopedTypeVariables #-}
|
|
|
|
module Math.Epsilon
|
|
( epsilon, nearZero )
|
|
where
|
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
{-# SPECIALISE epsilon :: Float #-}
|
|
{-# SPECIALISE epsilon :: Double #-}
|
|
epsilon :: forall r. RealFloat r => r
|
|
epsilon = encodeFloat 1 ( 5 - floatDigits ( 0 :: r ) )
|
|
|
|
nearZero :: RealFloat r => r -> Bool
|
|
nearZero x = abs x < epsilon
|