linear-0.2: src/Linear/Epsilon.hs
-----------------------------------------------------------------------------
-- |
-- Module : Linear.Epsilon
-- Copyright : (C) 2012 Edward Kmett
-- License : BSD-style (see the file LICENSE)
-- Maintainer : Edward Kmett <ekmett@gmail.com>
-- Stability : provisional
-- Portability : portable
--
-----------------------------------------------------------------------------
module Linear.Epsilon
( Epsilon(..)
) where
-- | Provides a fairly subjective test to see if a quantity is near zero.
class Num a => Epsilon a where
-- | Determine if a quantity is near zero.
nearZero :: a -> Bool
-- | @'abs' a '<=' 1e-6@
instance Epsilon Float where
nearZero a = abs a <= 1e-6
-- | @'abs' a '<=' 1e-12@
instance Epsilon Double where
nearZero a = abs a <= 1e-12