+
+
+-- | Like 'almost_equals', except much more tolerant. The difference
+-- between the two arguments must be less than one percent of the sum
+-- of their magnitudes.
+--
+-- Only used in tests.
+--
+kinda_equals :: Double -> Double -> Bool
+kinda_equals x y =
+ (abs (x - y)) < threshold
+ where
+ threshold = ((abs x) + (abs y)) / 100.0
+
+infix 4 ~~=
+(~~=) :: Double -> Double -> Bool
+(~~=) = kinda_equals
+
+
+-- | x is very positive if it is 'epsilon' greater than zero.
+--
+-- Only used in tests.
+--
+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)