module Data.TDigest.Internal where

-- TODO: make newtypes
type Mean = Double
type Weight = Double
type Centroid = (Mean, Weight)
type Size = Int

-------------------------------------------------------------------------------
-- Assert
-------------------------------------------------------------------------------

{-# INLINE assert #-}
assert :: Bool -> String -> a -> a
assert :: Bool -> String -> a -> a
assert Bool
_ String
_ = a -> a
forall a. a -> a
id
{-
assert False msg _ = error msg
assert True  _   x = x
-}

-------------------------------------------------------------------------------
-- Double helpers
-------------------------------------------------------------------------------

eq :: Double -> Double -> Bool
eq :: Double -> Double -> Bool
eq Double
a Double
b = Double -> Double
forall a. Num a => a -> a
abs (Double
aDouble -> Double -> Double
forall a. Num a => a -> a -> a
-Double
b) Double -> Double -> Bool
forall a. Ord a => a -> a -> Bool
< Double
1e-6

negInf :: Double
negInf :: Double
negInf = Double -> Double
forall a. Num a => a -> a
negate Double
posInf

posInf :: Double
posInf :: Double
posInf = Double
1Double -> Double -> Double
forall a. Fractional a => a -> a -> a
/Double
0