-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | variable-precision floating point -- -- Software floating point with type-tagged variable mantissa precision, -- implemented using a strict pair of Integer and Int -- scaled alike to decodeFloat. -- -- Instances of the usual numeric type classes are provided, along with -- additional operators (with carefully chosen fixities) to coerce, -- adjust and reify precisions. -- -- The intention with this library is to be relatively simple but still -- useful, refer to the documentation for caveats concerning accuracy and -- assorted ill-behaviour. @package variable-precision @version 0.1.1 -- | Boilerplate definitions generated by: -- --
-- flip mapM_ [16..53] $ \p -> let s = show p in -- putStrLn $ "type N" ++ s ++ " = SuccessorTo N" ++ show (p - 1) ++ -- " ; n" ++ s ++ " :: N" ++ s ++ " ; n" ++ s ++ " = undefined" ---- -- Using this module in ghc-7.0.4 might require -- -fcontext-stack=100. module TypeLevel.NaturalNumber.ExtraNumbers type N16 = SuccessorTo N15 n16 :: N16 type N17 = SuccessorTo N16 n17 :: N17 type N18 = SuccessorTo N17 n18 :: N18 type N19 = SuccessorTo N18 n19 :: N19 type N20 = SuccessorTo N19 n20 :: N20 type N21 = SuccessorTo N20 n21 :: N21 type N22 = SuccessorTo N21 n22 :: N22 type N23 = SuccessorTo N22 n23 :: N23 type N24 = SuccessorTo N23 n24 :: N24 type N25 = SuccessorTo N24 n25 :: N25 type N26 = SuccessorTo N25 n26 :: N26 type N27 = SuccessorTo N26 n27 :: N27 type N28 = SuccessorTo N27 n28 :: N28 type N29 = SuccessorTo N28 n29 :: N29 type N30 = SuccessorTo N29 n30 :: N30 type N31 = SuccessorTo N30 n31 :: N31 type N32 = SuccessorTo N31 n32 :: N32 type N33 = SuccessorTo N32 n33 :: N33 type N34 = SuccessorTo N33 n34 :: N34 type N35 = SuccessorTo N34 n35 :: N35 type N36 = SuccessorTo N35 n36 :: N36 type N37 = SuccessorTo N36 n37 :: N37 type N38 = SuccessorTo N37 n38 :: N38 type N39 = SuccessorTo N38 n39 :: N39 type N40 = SuccessorTo N39 n40 :: N40 type N41 = SuccessorTo N40 n41 :: N41 type N42 = SuccessorTo N41 n42 :: N42 type N43 = SuccessorTo N42 n43 :: N43 type N44 = SuccessorTo N43 n44 :: N44 type N45 = SuccessorTo N44 n45 :: N45 type N46 = SuccessorTo N45 n46 :: N46 type N47 = SuccessorTo N46 n47 :: N47 type N48 = SuccessorTo N47 n48 :: N48 type N49 = SuccessorTo N48 n49 :: N49 type N50 = SuccessorTo N49 n50 :: N50 type N51 = SuccessorTo N50 n51 :: N51 type N52 = SuccessorTo N51 n52 :: N52 type N53 = SuccessorTo N52 n53 :: N53 -- | Classes for types with precision represented by a type-level natural -- number, and variable precision types. -- -- Note that performance may be (even) slow(er) with some versions of the -- type-level-natural-number package. module Numeric.VariablePrecision.Precision -- | A class for types with precision. Minimal complete definition: (none). class HasPrecision t where precisionOf _ = error "Numeric.VariablePrecision.Precision.HasPrecision.precisionOf: result evaluated" precisionOf :: (HasPrecision t, NaturalNumber p) => t p -> p -- | Much like naturalNumberAsInt combined with precisionOf. precision :: (HasPrecision t, NaturalNumber p) => t p -> Int -- | Much like const with a restricted type. atPrecision :: (HasPrecision t, NaturalNumber p) => t p -> p -> t p -- | Much like const with a restricted type. atPrecisionOf :: (HasPrecision t, HasPrecision s, NaturalNumber p) => t p -> s p -> t p -- | An alias for atPrecisionOf. (.@) :: (HasPrecision t, HasPrecision s, NaturalNumber p) => t p -> s p -> t p -- | A class for types with variable precision. Minimal complete -- definition: (all). class HasPrecision t => VariablePrecision t adjustPrecision :: (VariablePrecision t, NaturalNumber p, NaturalNumber q) => t p -> t q -- | Much like adjustPrecision combined with atPrecision. withPrecision :: (VariablePrecision t, NaturalNumber p, NaturalNumber q) => t p -> q -> t q -- | Much like withPrecision combined with precisionOf. withPrecisionOf :: (VariablePrecision t, HasPrecision s, NaturalNumber p, NaturalNumber q) => t p -> s q -> t q -- | An alias for withPrecisionOf. (.@~) :: (VariablePrecision t, HasPrecision s, NaturalNumber p, NaturalNumber q) => t p -> s q -> t q -- | Reify from value-level to type-level using Rank2Types. module Numeric.VariablePrecision.Precision.Reify -- | Reify a precision from value-level to type-level. reifyPrecision :: Int -> (forall p. NaturalNumber p => p -> a) -> a -- | Much like reifyPrecision combined with withPrecision. withReifiedPrecision :: (VariablePrecision t, NaturalNumber p) => t p -> Int -> (forall q. NaturalNumber q => t q -> a) -> a -- | An alias for withReifiedPrecision. (.@$) :: (VariablePrecision t, NaturalNumber p) => t p -> Int -> (forall q. NaturalNumber q => t q -> a) -> a -- | Variable precision software floating point based on (Integer, -- Int) as used by decodeFloat. -- -- Accuracy has not been extensively verified, and termination of -- numerical algorithms has not been proven. -- -- floatRange is arbitrarily limited to mitigate the problems that -- occur when enormous integers might be needed during some number type -- conversions (worst case consequence: program abort in gmp). -- -- No support for infinities, NaNs, negative zero or denormalization: -- --
-- flip mapM_ [1..53] $ \p -> let s = show p in -- putStrLn $ "type F" ++ s ++ " = VFloat N" ++ s ++ -- " ; f" ++ s ++ " :: F" ++ s ++ " ; f" ++ s ++ " = 0" ---- -- Along with aliases for recodeFloat with specialized types. -- -- Using this module in ghc-7.0.4 might require -- -fcontext-stack=100. module Numeric.VariablePrecision.Float.Aliases -- | Convert to a Float from the same precision. toFloat :: F24 -> Float -- | Convert from a Float to the same precision. fromFloat :: Float -> F24 -- | Convert to a Double from the same precision. toDouble :: F53 -> Double -- | Convert from a Double to the same precision. fromDouble :: Double -> F53 type F1 = VFloat N1 f1 :: F1 type F2 = VFloat N2 f2 :: F2 type F3 = VFloat N3 f3 :: F3 type F4 = VFloat N4 f4 :: F4 type F5 = VFloat N5 f5 :: F5 type F6 = VFloat N6 f6 :: F6 type F7 = VFloat N7 f7 :: F7 type F8 = VFloat N8 f8 :: F8 type F9 = VFloat N9 f9 :: F9 type F10 = VFloat N10 f10 :: F10 type F11 = VFloat N11 f11 :: F11 type F12 = VFloat N12 f12 :: F12 type F13 = VFloat N13 f13 :: F13 type F14 = VFloat N14 f14 :: F14 type F15 = VFloat N15 f15 :: F15 type F16 = VFloat N16 f16 :: F16 type F17 = VFloat N17 f17 :: F17 type F18 = VFloat N18 f18 :: F18 type F19 = VFloat N19 f19 :: F19 type F20 = VFloat N20 f20 :: F20 type F21 = VFloat N21 f21 :: F21 type F22 = VFloat N22 f22 :: F22 type F23 = VFloat N23 f23 :: F23 type F24 = VFloat N24 f24 :: F24 type F25 = VFloat N25 f25 :: F25 type F26 = VFloat N26 f26 :: F26 type F27 = VFloat N27 f27 :: F27 type F28 = VFloat N28 f28 :: F28 type F29 = VFloat N29 f29 :: F29 type F30 = VFloat N30 f30 :: F30 type F31 = VFloat N31 f31 :: F31 type F32 = VFloat N32 f32 :: F32 type F33 = VFloat N33 f33 :: F33 type F34 = VFloat N34 f34 :: F34 type F35 = VFloat N35 f35 :: F35 type F36 = VFloat N36 f36 :: F36 type F37 = VFloat N37 f37 :: F37 type F38 = VFloat N38 f38 :: F38 type F39 = VFloat N39 f39 :: F39 type F40 = VFloat N40 f40 :: F40 type F41 = VFloat N41 f41 :: F41 type F42 = VFloat N42 f42 :: F42 type F43 = VFloat N43 f43 :: F43 type F44 = VFloat N44 f44 :: F44 type F45 = VFloat N45 f45 :: F45 type F46 = VFloat N46 f46 :: F46 type F47 = VFloat N47 f47 :: F47 type F48 = VFloat N48 f48 :: F48 type F49 = VFloat N49 f49 :: F49 type F50 = VFloat N50 f50 :: F50 type F51 = VFloat N51 f51 :: F51 type F52 = VFloat N52 f52 :: F52 type F53 = VFloat N53 f53 :: F53 -- | Newtype wrapper around Complex. When both of Complex and -- this module need to be imported, use qualified imports. module Numeric.VariablePrecision.Complex -- | Newtype wrapper around Complex so that instances can be written -- for HasPrecision and VariablePrecision. newtype VComplex p C :: Complex (VFloat p) -> VComplex p toComplex :: VComplex p -> Complex (VFloat p) -- | Alike to :+, constructs a complex number from a real part and -- an imaginary part. (.+) :: NaturalNumber p => VFloat p -> VFloat p -> VComplex p -- | Convert Complex to VComplex. fromComplex :: Complex (VFloat p) -> VComplex p -- | Lift an operation on Complex to one on VComplex. withComplex :: (Complex (VFloat p) -> Complex (VFloat q)) -> (VComplex p -> VComplex q) -- | Real part. realPart :: NaturalNumber p => VComplex p -> VFloat p -- | Imaginary part. imagPart :: NaturalNumber p => VComplex p -> VFloat p -- | Conjugate. conjugate :: NaturalNumber p => VComplex p -> VComplex p -- | Magnitude. magnitude :: NaturalNumber p => VComplex p -> VFloat p -- | Magnitude squared. magnitude2 :: NaturalNumber p => VComplex p -> VFloat p -- | Phase. phase :: NaturalNumber p => VComplex p -> VFloat p -- | Polar form. polar :: NaturalNumber p => VComplex p -> (VFloat p, VFloat p) -- | Unit at phase. cis :: NaturalNumber p => VFloat p -> VComplex p -- | From polar form. mkPolar :: NaturalNumber p => VFloat p -> VFloat p -> VComplex p instance Typeable1 VComplex instance Eq (VComplex p) instance NaturalNumber p => Num (VComplex p) instance NaturalNumber p => Fractional (VComplex p) instance NaturalNumber p => Floating (VComplex p) instance Data p => Data (VComplex p) instance NaturalNumber p => Read (VComplex p) instance NaturalNumber p => Show (VComplex p) instance VariablePrecision VComplex instance HasPrecision VComplex