]> gitweb.michael.orlitzky.com - spline3.git/blobdiff - src/Comparisons.hs
Add a bunch of documentation.
[spline3.git] / src / Comparisons.hs
index f4462a083222b4000a42faeb58dadbbdb171b719..4bf4cebb69ece2947eb1deccf0dfa9cfda20f266 100644 (file)
@@ -1,10 +1,29 @@
+-- | Functions for comparing 'Double' values.
 module Comparisons
 where
 
+-- | epsilon is the value that will be used in all tests that require
+--   some measure of "closeness." Increasing it will make those tests
+--   more tolerant.
+epsilon :: Double
+epsilon = 0.0001
 
+
+-- | x almost equals y if x is within 'epsilon' of y.
 almost_equals :: Double -> Double -> Bool
-almost_equals x y = (abs (x - y)) < 0.0001
+almost_equals x y = (abs (x - y)) < epsilon
 
 infix 4 ~=
 (~=) :: Double -> Double -> Bool
 (~=) = almost_equals
+
+
+-- | x is very positive if it is 'epsilon' greater than zero.
+very_positive :: Double -> Bool
+very_positive x =  x - epsilon > 0
+
+
+-- | Takes a list of 'Double' and returns the ones which are not very
+--   positive.
+non_very_positive_entries :: [Double] -> [Double]
+non_very_positive_entries = filter (not . very_positive)