cmath 0.1 → 0.2
raw patch · 3 files changed
+144/−4 lines, 3 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
+ Foreign.C.Math.Double: c_erf :: CDouble -> CDouble
+ Foreign.C.Math.Double: c_erfc :: CDouble -> CDouble
+ Foreign.C.Math.Double: c_finite :: CDouble -> CInt
+ Foreign.C.Math.Double: c_gamma :: CDouble -> CDouble
+ Foreign.C.Math.Double: c_hypot :: CDouble -> CDouble -> CDouble
+ Foreign.C.Math.Double: c_isinf :: CDouble -> CInt
+ Foreign.C.Math.Double: c_isnan :: CDouble -> CInt
+ Foreign.C.Math.Double: c_j0 :: CDouble -> CDouble
+ Foreign.C.Math.Double: c_j1 :: CDouble -> CDouble
+ Foreign.C.Math.Double: c_lgamma :: CDouble -> CDouble
+ Foreign.C.Math.Double: c_y0 :: CDouble -> CDouble
+ Foreign.C.Math.Double: c_y1 :: CDouble -> CDouble
+ Foreign.C.Math.Double: c_yn :: CInt -> CDouble -> CDouble
+ Foreign.C.Math.Double: erf :: Double -> Double
+ Foreign.C.Math.Double: erfc :: Double -> Double
+ Foreign.C.Math.Double: finite :: Double -> Int
+ Foreign.C.Math.Double: gamma :: Double -> Double
+ Foreign.C.Math.Double: hypot :: Double -> Double -> Double
+ Foreign.C.Math.Double: isinf :: Double -> Int
+ Foreign.C.Math.Double: isnan :: Double -> Int
+ Foreign.C.Math.Double: j0 :: Double -> Double
+ Foreign.C.Math.Double: j1 :: Double -> Double
+ Foreign.C.Math.Double: lgamma :: Double -> Double
+ Foreign.C.Math.Double: y0 :: Double -> Double
+ Foreign.C.Math.Double: y1 :: Double -> Double
+ Foreign.C.Math.Double: yn :: Int -> Double -> Double
Files
- Foreign/C/Math/Double.hsc +137/−0
- cmath.cabal +4/−4
- tests/QC.hs +3/−0
Foreign/C/Math/Double.hsc view
@@ -267,3 +267,140 @@ foreign import ccall unsafe "math.h trunc" c_trunc :: CDouble -> CDouble++-- | The erf calculates the error function of x. The error function is defined as:+--+-- > erf(x) = 2/sqrt(pi)*integral from 0 to x of exp(-t*t) dt.+--+erf :: Double -> Double+erf x = realToFrac (c_erf (realToFrac x))+{-# INLINE erf #-}++foreign import ccall unsafe "math.h erf"+ c_erf :: CDouble -> CDouble++-- | The erfc function calculates the complementary error function of x;+-- that is erfc() subtracts the result of the error function erf(x) from+-- 1.0. This is useful, since for large x places disappear.+--+erfc :: Double -> Double+erfc x = realToFrac (c_erfc (realToFrac x))+{-# INLINE erfc #-}++foreign import ccall unsafe "math.h erfc"+ c_erfc :: CDouble -> CDouble++-- | The gamma function.+--+gamma :: Double -> Double+gamma x = realToFrac (c_gamma (realToFrac x))+{-# INLINE gamma #-}++foreign import ccall unsafe "math.h gamma"+ c_gamma :: CDouble -> CDouble++-- | The hypot function function computes the sqrt(x*x+y*y) in such a way that+-- underflow will not happen, and overflow occurs only if the final result+-- deserves it. +-- +-- > hypot(Infinity, v) = hypot(v, Infinity) = +Infinity for all v, including NaN.+--+hypot :: Double -> Double -> Double+hypot x y = realToFrac (c_hypot (realToFrac x) (realToFrac y))+{-# INLINE hypot #-}++foreign import ccall unsafe "math.h hypot"+ c_hypot :: CDouble -> CDouble -> CDouble++-- | The isinf function returns 1 if the number n is Infinity, otherwise 0.+--+isinf :: Double -> Int+isinf x = fromIntegral (c_isinf (realToFrac x))+{-# INLINE isinf #-}++foreign import ccall unsafe "math.h isinf"+ c_isinf :: CDouble -> CInt++-- | The isnan function returns 1 if the number n is ``not-a-number'',+-- otherwise 0.+--+isnan :: Double -> Int+isnan x = fromIntegral (c_isnan (realToFrac x))+{-# INLINE isnan #-}++foreign import ccall unsafe "math.h isnan"+ c_isnan :: CDouble -> CInt++-- | finite returns the value 1 just when -Infinity < x < +Infinity; otherwise+-- a zero is returned (when |x| = Infinity or x is NaN.+--+finite :: Double -> Int+finite x = fromIntegral (c_finite (realToFrac x))+{-# INLINE finite #-}++foreign import ccall unsafe "math.h finite"+ c_finite :: CDouble -> CInt++-- | The functions j0() and j1() compute the Bessel function of the+-- first kind of the order 0 and the order 1, respectively, for the real+-- value x+--+j0 :: Double -> Double+j0 x = realToFrac (c_j0 (realToFrac x))+{-# INLINE j0 #-}++foreign import ccall unsafe "math.h j0"+ c_j0 :: CDouble -> CDouble++-- | The functions j0() and j1() compute the Bessel function of the+-- first kind of the order 0 and the order 1, respectively, for the real+-- value x+--+j1 :: Double -> Double+j1 x = realToFrac (c_j1 (realToFrac x))+{-# INLINE j1 #-}++foreign import ccall unsafe "math.h j1"+ c_j1 :: CDouble -> CDouble++-- | The functions y0() and y1() compute the linearly independent Bessel+-- function of the second kind of the order 0 and the order 1,+-- respectively, for the positive integer value x (expressed as a double)+--+y0 :: Double -> Double+y0 x = realToFrac (c_y0 (realToFrac x))+{-# INLINE y0 #-}++foreign import ccall unsafe "math.h y0"+ c_y0 :: CDouble -> CDouble++-- | The functions y0() and y1() compute the linearly independent Bessel+-- function of the second kind of the order 0 and the order 1,+-- respectively, for the positive integer value x (expressed as a double)+--+y1 :: Double -> Double+y1 x = realToFrac (c_y1 (realToFrac x))+{-# INLINE y1 #-}++foreign import ccall unsafe "math.h y1"+ c_y1 :: CDouble -> CDouble++-- | yn() computes the Bessel function of the second kind for the+-- integer Bessel0 n for the positive integer value x (expressed as a+-- double).+--+yn :: Int -> Double -> Double+yn x y = realToFrac (c_yn (fromIntegral x) (realToFrac y))+{-# INLINE yn #-}++foreign import ccall unsafe "math.h yn"+ c_yn :: CInt -> CDouble -> CDouble++-- | lgamma(x) returns ln|| (x)|.+--+lgamma :: Double -> Double+lgamma x = realToFrac (c_lgamma (realToFrac x))+{-# INLINE lgamma #-}++foreign import ccall unsafe "math.h lgamma"+ c_lgamma :: CDouble -> CDouble
cmath.cabal view
@@ -1,8 +1,8 @@ name: cmath-version: 0.1+version: 0.2 homepage: http://code.haskell.org/~dons/code/cmath-synopsis: A small binding to the standard C math library-description: A small binding to the standard C math library+synopsis: A binding to the standard C math library+description: A binding to the standard C math library category: Math license: BSD3 license-file: LICENSE@@ -14,7 +14,7 @@ exposed-modules: Foreign.C.Math.Double extensions: CPP, ForeignFunctionInterface ghc-options: -Wall -fvia-C -optc-std=c99-cc-options: -optc-std=c99+cc-options: -std=c99 build-depends: base extra-libraries: m
tests/QC.hs view
@@ -22,4 +22,7 @@ , quickCheck $ \x y -> x >= 0 ==> C.pow x y == x ** y , quickCheck $ \x -> x >= 0 ==> C.sqrt x == sqrt x ++ , quickCheck $ \x -> C.log10 x == (log x / log 10 )+ ]