-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Compensated floating-point arithmetic -- -- This package provides compensated floating point arithmetic. @package compensated @version 0.7.3 -- | This module provides a fairly extensive API for compensated floating -- point arithmetic based on Knuth's error free transformation, various -- algorithms by Ogita, Rump and Oishi, Hida, Li and Bailey, Kahan -- summation, etc. with custom compensated arithmetic circuits to do -- multiplication, division, etc. of compensated numbers. -- -- In general if a has x bits of significand, Compensated -- a gives you twice that. You can iterate this construction for -- arbitrary precision. -- -- References: -- -- module Numeric.Compensated class (RealFrac a, Precise a, Floating a) => Compensable a where { -- | This provides a numeric data type with effectively doubled precision -- by using Knuth's error free transform and a number of custom -- compensated arithmetic circuits. -- -- This construction can be iterated, doubling precision each time. -- --
    --   >>> round (Prelude.product [2..100] :: Compensated (Compensated (Compensated Double)))
    --   93326215443944152681699238856266700490715968264381621468592963895217599993229915608941463976156518286253697920827223758251185210916864000000000000000000000000
    --   
-- --
    --   >>> Prelude.product [2..100]
    --   93326215443944152681699238856266700490715968264381621468592963895217599993229915608941463976156518286253697920827223758251185210916864000000000000000000000000
    --   
data family Compensated a; } -- | This extracts both the primal and residual components of -- a Compensated number. with :: (Compensable a, Compensable a) => Compensated a -> (a -> a -> r) -> r -- | Used internally to construct compensated values that satisfy -- our residual contract. -- -- When in doubt, use add a b compensated instead -- of compensated a b compensated :: (Compensable a, Compensable a) => a -> a -> Compensated a -- | This magic number is used to split the significand in -- half, so we can multiply them separately without losing precision in -- times. magic :: Compensable a => a -- | This provides the isomorphism between the compact representation we -- store these in internally and the naive pair of the primal and -- residual components. _Compensated :: Compensable a => Iso' (Compensated a) (a, a) type Overcompensated a = Compensated (Compensated a) -- | This Lens lets us edit the primal directly, leaving the -- residual untouched. primal :: Compensable a => Lens' (Compensated a) a -- | This Lens lets us edit the residual directly, leaving -- the primal untouched. residual :: Compensable a => Lens' (Compensated a) a -- | Extract the primal component of a compensated value, -- when and if compensation is no longer required. uncompensated :: Compensable a => Compensated a -> a -- | fadd a b k computes k x y such that -- --
--   x + y = a + b
--   x = fl(a + b)
--   
-- -- but only under the assumption that abs a >= -- abs b. If you aren't sure, use add. -- -- Which is to say that x is the floating point image of (a -- + b) and y stores the residual error term. fadd :: Num a => a -> a -> (a -> a -> r) -> r -- | add a b k computes k x y such that -- --
--   x + y = a + b
--   x = fl(a + b)
--   
-- -- Which is to say that x is the floating point image of (a -- + b) and y stores the residual error term. add :: Num a => a -> a -> (a -> a -> r) -> r -- | times a b k computes k x y such that -- --
--   x + y = a * b
--   x = fl(a * b)
--   
-- -- Which is to say that x is the floating point image of (a -- * b) and y stores the residual error term. -- -- This could be nicer if we had access to a hardware fused multiply-add. times :: Compensable a => a -> a -> (a -> a -> r) -> r -- | squared a k computes k x y such that -- --
--   x + y = a * a
--   x = fl(a * a)
--   
-- -- Which is to say that x is the floating point image of (a -- * a) and y stores the residual error term. squared :: Compensable a => a -> (a -> a -> r) -> r divide :: Compensable a => a -> a -> (a -> a -> r) -> r -- | error-free split of a floating point number into two parts. -- -- Note: these parts do not satisfy the compensated contract split :: Compensable a => a -> (a -> a -> r) -> r -- | Perform Kahan summation over a list. kahan :: (Foldable f, Compensable a) => f a -> Compensated a -- | Calculate a scalar + compensated sum with Kahan summation. (+^) :: Compensable a => a -> Compensated a -> Compensated a -- | Compute a * Compensated a (*^) :: Compensable a => a -> Compensated a -> Compensated a -- | Calculate a fast square of a compensated number. square :: Compensable a => Compensated a -> Compensated a instance Numeric.Compensated.Compensable GHC.Types.Double instance Numeric.Compensated.Compensable GHC.Types.Float instance Numeric.Compensated.Compensable a => Numeric.Compensated.Compensable (Numeric.Compensated.Compensated a) instance (Numeric.Compensated.Compensable a, Data.Hashable.Class.Hashable a) => Data.Hashable.Class.Hashable (Numeric.Compensated.Compensated a) instance (Numeric.Compensated.Compensable a, Data.Data.Data a) => Data.Data.Data (Numeric.Compensated.Compensated a) instance (Numeric.Compensated.Compensable a, Control.DeepSeq.NFData a) => Control.DeepSeq.NFData (Numeric.Compensated.Compensated a) instance (Numeric.Compensated.Compensable a, GHC.Show.Show a) => GHC.Show.Show (Numeric.Compensated.Compensated a) instance (Numeric.Compensated.Compensable a, GHC.Read.Read a) => GHC.Read.Read (Numeric.Compensated.Compensated a) instance (Numeric.Compensated.Compensable a, Numeric.Compensated.Compensable b) => Control.Lens.Each.Each (Numeric.Compensated.Compensated a) (Numeric.Compensated.Compensated b) a b instance Numeric.Compensated.Compensable a => GHC.Classes.Eq (Numeric.Compensated.Compensated a) instance Numeric.Compensated.Compensable a => GHC.Classes.Ord (Numeric.Compensated.Compensated a) instance Numeric.Compensated.Compensable a => GHC.Base.Semigroup (Numeric.Compensated.Compensated a) instance Numeric.Compensated.Compensable a => GHC.Base.Monoid (Numeric.Compensated.Compensated a) instance Numeric.Compensated.Compensable a => GHC.Num.Num (Numeric.Compensated.Compensated a) instance Numeric.Compensated.Compensable a => GHC.Enum.Enum (Numeric.Compensated.Compensated a) instance Numeric.Compensated.Compensable a => GHC.Real.Fractional (Numeric.Compensated.Compensated a) instance Numeric.Compensated.Compensable a => GHC.Real.Real (Numeric.Compensated.Compensated a) instance Numeric.Compensated.Compensable a => GHC.Real.RealFrac (Numeric.Compensated.Compensated a) instance (Numeric.Compensated.Compensable a, Data.Binary.Class.Binary a) => Data.Binary.Class.Binary (Numeric.Compensated.Compensated a) instance (Numeric.Compensated.Compensable a, Data.Serialize.Serialize a) => Data.Serialize.Serialize (Numeric.Compensated.Compensated a) instance (Numeric.Compensated.Compensable a, Data.Bytes.Serial.Serial a) => Data.Bytes.Serial.Serial (Numeric.Compensated.Compensated a) instance (Numeric.Compensated.Compensable a, Data.Serialize.Serialize a) => Data.SafeCopy.SafeCopy.SafeCopy (Numeric.Compensated.Compensated a) instance (Numeric.Compensated.Compensable a, Foreign.Storable.Storable a) => Foreign.Storable.Storable (Numeric.Compensated.Compensated a) instance (Numeric.Compensated.Compensable a, Data.Vector.Unboxed.Base.Unbox a) => Data.Vector.Generic.Mutable.Base.MVector Data.Vector.Unboxed.Base.MVector (Numeric.Compensated.Compensated a) instance (Numeric.Compensated.Compensable a, Data.Vector.Unboxed.Base.Unbox a) => Data.Vector.Generic.Base.Vector Data.Vector.Unboxed.Base.Vector (Numeric.Compensated.Compensated a) instance Numeric.Compensated.Compensable a => GHC.Float.Floating (Numeric.Compensated.Compensated a) instance (Numeric.Compensated.Compensable a, Numeric.Log.Precise a) => Numeric.Log.Precise (Numeric.Compensated.Compensated a)