hmatrix 0.15.2.0 → 0.15.2.1
raw patch · 10 files changed
+103/−61 lines, 10 filesdep ~arraydep ~basedep ~binary
Dependency ranges changed: array, base, binary, process
Files
- Config.hs +5/−6
- INSTALL.md +9/−2
- THANKS.md +12/−0
- hmatrix.cabal +7/−2
- lib/Data/Packed/Internal/Matrix.hs +1/−1
- lib/Data/Packed/Internal/Vector.hs +3/−7
- lib/Numeric/ContainerBoot.hs +25/−5
- lib/Numeric/GSL/Integration.hs +27/−24
- lib/Numeric/GSL/gsl-aux.c +12/−12
- lib/Numeric/LinearAlgebra/Util.hs +2/−2
Config.hs view
@@ -48,20 +48,20 @@ -- compile, discarding error messages compile cmd = do- let processRecord = (shell $ join cmd) { std_out = CreatePipe+ let processRecord = (shell $ unwords cmd) { std_out = CreatePipe , std_err = CreatePipe } ( _, _, _, h) <- createProcess processRecord waitForProcess h -- command to compile the test program compileCmd bInfo buildInfo = [ "gcc "- , (join $ ccOptions buildInfo) - , (join $ cppOptions buildInfo) - , (join $ map ("-I"++) $ includeDirs buildInfo) + , (unwords $ ccOptions buildInfo) + , (unwords $ cppOptions buildInfo) + , (unwords $ map ("-I"++) $ includeDirs buildInfo) , testProgLoc bInfo , "-o" , testOutLoc bInfo - , (join $ map ("-L"++) $ extraLibDirs buildInfo) + , (unwords $ map ("-L"++) $ extraLibDirs buildInfo) ] -- compile a simple program with symbols from GSL and LAPACK with the given libs@@ -72,7 +72,6 @@ ++ [ (prepend "-l" $ libs) , (prepend "-framework " fmks) ] -join = intercalate " " prepend x = unwords . map (x++) . words check bInfo buildInfo libs fmks = (ExitSuccess ==) `fmap` testprog bInfo buildInfo libs fmks
INSTALL.md view
@@ -21,12 +21,19 @@ ## Mac OS/X ############################################### -GSL must be installed via MacPorts:+GSL must be installed via Homebrew or MacPorts. +Via Homebrew:++ $ brew install gsl+ $ cabal install hmatrix++Via MacPorts:+ $ sudo port install gsl +universal $ cabal install hmatrix -(Contributed by Heinrich Apfelmus and Torsten Kemps-Benedix).+(Contributed by Heinrich Apfelmus, Torsten Kemps-Benedix and Ted Fujimoto). ## Windows ###############################################
THANKS.md view
@@ -141,3 +141,15 @@ - Henning Thielemann reported the pinv inefficient implementation. +- bdoering reported the problem of zero absolute tolerance in the integration functions.++- Alexei Uimanov replaced fromList by Vector.fromList.++- Adam Vogt updated the code for ghc-7.7++- Mike Meyer (mwm) added freeBSD library configuration information.++- tfgit updated the OSX installation instructions via Homebrew+++
hmatrix.cabal view
@@ -1,5 +1,5 @@ Name: hmatrix-Version: 0.15.2.0+Version: 0.15.2.1 License: GPL License-file: LICENSE Author: Alberto Ruiz@@ -21,7 +21,7 @@ . - "Numeric.LinearAlgebra": everything + instances of standard Haskell numeric classes Category: Math-tested-with: GHC ==7.6+tested-with: GHC ==7.8 cabal-version: >=1.8 @@ -185,6 +185,11 @@ if arch(i386) cc-options: -arch i386 frameworks: Accelerate++ if os(freebsd)+ extra-lib-dirs: /usr/local/lib+ include-dirs: /usr/local/include+ extra-libraries: gsl blas lapack if os(windows) extra-libraries: gsl-0 blas lapack
lib/Data/Packed/Internal/Matrix.hs view
@@ -154,7 +154,7 @@ fromRows :: Element t => [Vector t] -> Matrix t fromRows vs = case compatdim (map dim vs) of Nothing -> error "fromRows applied to [] or to vectors with different sizes"- Just c -> reshape c . join . map (adapt c) $ vs+ Just c -> reshape c . Data.Packed.Internal.Vector.join . map (adapt c) $ vs where adapt c v | dim v == c = v | otherwise = constantD (v@>0) c
lib/Data/Packed/Internal/Vector.hs view
@@ -16,7 +16,7 @@ module Data.Packed.Internal.Vector ( Vector, dim, fromList, toList, (|>),- join, (@>), safe, at, at', subVector, takesV,+ Data.Packed.Internal.Vector.join, (@>), safe, at, at', subVector, takesV, mapVector, mapVectorWithIndex, zipVectorWith, unzipVectorWith, mapVectorM, mapVectorM_, mapVectorWithIndexM, mapVectorWithIndexM_, foldVector, foldVectorG, foldLoop, foldVectorWithIndex,@@ -34,7 +34,7 @@ import Data.Packed.Internal.Common import Data.Packed.Internal.Signatures import Foreign.Marshal.Alloc(free)-import Foreign.Marshal.Array(peekArray, pokeArray, copyArray, advancePtr)+import Foreign.Marshal.Array(peekArray, copyArray, advancePtr) import Foreign.ForeignPtr(ForeignPtr, castForeignPtr) import Foreign.Ptr(Ptr) import Foreign.Storable(Storable, peekElemOff, pokeElemOff, sizeOf)@@ -57,6 +57,7 @@ import qualified Data.Vector.Storable as Vector import Data.Vector.Storable(Vector,+ fromList, unsafeToForeignPtr, unsafeFromForeignPtr, unsafeWith)@@ -102,11 +103,6 @@ 4 |> [2.0,3.0,5.0,7.0]@ -}-fromList :: Storable a => [a] -> Vector a-fromList l = unsafePerformIO $ do- v <- createVector (length l)- unsafeWith v $ \ p -> pokeArray p l- return v safeRead v = inlinePerformIO . unsafeWith v {-# INLINE safeRead #-}
lib/Numeric/ContainerBoot.hs view
@@ -510,20 +510,40 @@ class Build f where build' :: BoundsOf f -> f -> ContainerOf f -type family BoundsOf x +#if MIN_VERSION_base(4,7,0)+-- ghc >= 7.7 considers:+--+-- > a -> a+-- > b -> b -> b+--+-- to overlap+type family BoundsOf x where+ BoundsOf (a -> a) = Int+ BoundsOf (a->a->a) = (Int,Int)+type family ContainerOf x where+ ContainerOf (a->a) = Vector a+ ContainerOf (a->a->a) = Matrix a+#else+type family BoundsOf x+type family ContainerOf x type instance BoundsOf (a->a) = Int type instance BoundsOf (a->a->a) = (Int,Int)--type family ContainerOf x- type instance ContainerOf (a->a) = Vector a type instance ContainerOf (a->a->a) = Matrix a+#endif + instance (Element a, Num a) => Build (a->a) where build' = buildV -instance (Element a, Num a) => Build (a->a->a) where+instance (Element a,+#if MIN_VERSION_base(4,7,0)+ BoundsOf (a -> a -> a) ~ (Int,Int),+ ContainerOf (a -> a -> a) ~ Matrix a,+#endif+ Num a)+ => Build (a->a->a) where build' = buildM buildM (rc,cc) f = fromLists [ [f r c | c <- cs] | r <- rs ]
lib/Numeric/GSL/Integration.hs view
@@ -31,6 +31,8 @@ import Data.Packed.Internal(check,(//)) import System.IO.Unsafe(unsafePerformIO) +eps = 1e-12+ {- | conversion of Haskell functions into function pointers that can be used in the C side -} foreign import ccall safe "wrapper" mkfun:: (Double -> Ptr() -> Double) -> IO( FunPtr (Double -> Ptr() -> Double)) @@ -55,7 +57,7 @@ r <- malloc e <- malloc fp <- mkfun (\x _ -> f x) - c_integrate_qags fp a b prec (fromIntegral n) r e // check "integrate_qags"+ c_integrate_qags fp a b eps prec (fromIntegral n) r e // check "integrate_qags" vr <- peek r ve <- peek e let result = (vr,ve)@@ -64,9 +66,9 @@ freeHaskellFunPtr fp return result -foreign import ccall safe "gsl-aux.h integrate_qags" - c_integrate_qags :: FunPtr (Double-> Ptr() -> Double) -> Double -> Double -> Double -> CInt- -> Ptr Double -> Ptr Double -> IO CInt+foreign import ccall safe "integrate_qags" c_integrate_qags+ :: FunPtr (Double-> Ptr() -> Double) -> Double -> Double+ -> Double -> Double -> CInt -> Ptr Double -> Ptr Double -> IO CInt ----------------------------------------------------------------- {- | Numerical integration using /gsl_integration_qng/ (useful for fast integration of smooth functions). For example:@@ -86,7 +88,7 @@ r <- malloc e <- malloc fp <- mkfun (\x _ -> f x) - c_integrate_qng fp a b prec r e // check "integrate_qng"+ c_integrate_qng fp a b eps prec r e // check "integrate_qng" vr <- peek r ve <- peek e let result = (vr,ve)@@ -95,9 +97,9 @@ freeHaskellFunPtr fp return result -foreign import ccall safe "gsl-aux.h integrate_qng" - c_integrate_qng :: FunPtr (Double-> Ptr() -> Double) -> Double -> Double -> Double - -> Ptr Double -> Ptr Double -> IO CInt+foreign import ccall safe "integrate_qng" c_integrate_qng+ :: FunPtr (Double-> Ptr() -> Double) -> Double -> Double+ -> Double -> Double -> Ptr Double -> Ptr Double -> IO CInt -------------------------------------------------------------------- {- | Numerical integration using /gsl_integration_qagi/ (integration over the infinite integral -Inf..Inf using QAGS). @@ -118,7 +120,7 @@ r <- malloc e <- malloc fp <- mkfun (\x _ -> f x) - c_integrate_qagi fp prec (fromIntegral n) r e // check "integrate_qagi"+ c_integrate_qagi fp eps prec (fromIntegral n) r e // check "integrate_qagi" vr <- peek r ve <- peek e let result = (vr,ve)@@ -127,9 +129,9 @@ freeHaskellFunPtr fp return result -foreign import ccall safe "gsl-aux.h integrate_qagi" - c_integrate_qagi :: FunPtr (Double-> Ptr() -> Double) -> Double -> CInt- -> Ptr Double -> Ptr Double -> IO CInt+foreign import ccall safe "integrate_qagi" c_integrate_qagi+ :: FunPtr (Double-> Ptr() -> Double) -> Double -> Double+ -> CInt -> Ptr Double -> Ptr Double -> IO CInt -------------------------------------------------------------------- {- | Numerical integration using /gsl_integration_qagiu/ (integration over the semi-infinite integral a..Inf). @@ -151,7 +153,7 @@ r <- malloc e <- malloc fp <- mkfun (\x _ -> f x) - c_integrate_qagiu fp a prec (fromIntegral n) r e // check "integrate_qagiu"+ c_integrate_qagiu fp a eps prec (fromIntegral n) r e // check "integrate_qagiu" vr <- peek r ve <- peek e let result = (vr,ve)@@ -160,9 +162,9 @@ freeHaskellFunPtr fp return result -foreign import ccall safe "gsl-aux.h integrate_qagiu" - c_integrate_qagiu :: FunPtr (Double-> Ptr() -> Double) -> Double -> Double -> CInt- -> Ptr Double -> Ptr Double -> IO CInt+foreign import ccall safe "integrate_qagiu" c_integrate_qagiu+ :: FunPtr (Double-> Ptr() -> Double) -> Double -> Double+ -> Double -> CInt -> Ptr Double -> Ptr Double -> IO CInt -------------------------------------------------------------------- {- | Numerical integration using /gsl_integration_qagil/ (integration over the semi-infinite integral -Inf..b). @@ -184,7 +186,7 @@ r <- malloc e <- malloc fp <- mkfun (\x _ -> f x) - c_integrate_qagil fp b prec (fromIntegral n) r e // check "integrate_qagil"+ c_integrate_qagil fp b eps prec (fromIntegral n) r e // check "integrate_qagil" vr <- peek r ve <- peek e let result = (vr,ve)@@ -193,9 +195,9 @@ freeHaskellFunPtr fp return result -foreign import ccall safe "gsl-aux.h integrate_qagil" - c_integrate_qagil :: FunPtr (Double-> Ptr() -> Double) -> Double -> Double -> CInt- -> Ptr Double -> Ptr Double -> IO CInt+foreign import ccall safe "gsl-aux.h integrate_qagil" c_integrate_qagil+ :: FunPtr (Double-> Ptr() -> Double) -> Double -> Double+ -> Double -> CInt -> Ptr Double -> Ptr Double -> IO CInt --------------------------------------------------------------------@@ -231,7 +233,7 @@ e <- malloc neval <- malloc fp <- mkfun (\x _ -> f x)- c_integrate_cquad fp a b prec (fromIntegral n) r e neval // check "integrate_cquad"+ c_integrate_cquad fp a b eps prec (fromIntegral n) r e neval // check "integrate_cquad" vr <- peek r ve <- peek e vneval <- peek neval@@ -242,6 +244,7 @@ freeHaskellFunPtr fp return result -foreign import ccall safe "gsl-aux.h integrate_cquad" - c_integrate_cquad :: FunPtr (Double-> Ptr() -> Double) -> Double -> Double -> Double -> CInt- -> Ptr Double -> Ptr Double -> Ptr Int -> IO CInt+foreign import ccall safe "integrate_cquad" c_integrate_cquad+ :: FunPtr (Double-> Ptr() -> Double) -> Double -> Double+ -> Double -> Double -> CInt -> Ptr Double -> Ptr Double -> Ptr Int -> IO CInt+
lib/Numeric/GSL/gsl-aux.c view
@@ -737,80 +737,80 @@ } -int integrate_qng(double f(double, void*), double a, double b, double prec,+int integrate_qng(double f(double, void*), double a, double b, double aprec, double prec, double *result, double*error) { DEBUGMSG("integrate_qng"); gsl_function F; F.function = f; F.params = NULL; size_t neval;- int res = gsl_integration_qng (&F, a,b, 0, prec, result, error, &neval); + int res = gsl_integration_qng (&F, a,b, aprec, prec, result, error, &neval); CHECK(res,res); OK } -int integrate_qags(double f(double,void*), double a, double b, double prec, int w, +int integrate_qags(double f(double,void*), double a, double b, double aprec, double prec, int w, double *result, double* error) { DEBUGMSG("integrate_qags"); gsl_integration_workspace * wk = gsl_integration_workspace_alloc (w); gsl_function F; F.function = f; F.params = NULL;- int res = gsl_integration_qags (&F, a,b, 0, prec, w,wk, result, error); + int res = gsl_integration_qags (&F, a,b, aprec, prec, w,wk, result, error); CHECK(res,res); gsl_integration_workspace_free (wk); OK } -int integrate_qagi(double f(double,void*), double prec, int w, +int integrate_qagi(double f(double,void*), double aprec, double prec, int w, double *result, double* error) { DEBUGMSG("integrate_qagi"); gsl_integration_workspace * wk = gsl_integration_workspace_alloc (w); gsl_function F; F.function = f; F.params = NULL;- int res = gsl_integration_qagi (&F, 0, prec, w,wk, result, error); + int res = gsl_integration_qagi (&F, aprec, prec, w,wk, result, error); CHECK(res,res); gsl_integration_workspace_free (wk); OK } -int integrate_qagiu(double f(double,void*), double a, double prec, int w, +int integrate_qagiu(double f(double,void*), double a, double aprec, double prec, int w, double *result, double* error) { DEBUGMSG("integrate_qagiu"); gsl_integration_workspace * wk = gsl_integration_workspace_alloc (w); gsl_function F; F.function = f; F.params = NULL;- int res = gsl_integration_qagiu (&F, a, 0, prec, w,wk, result, error); + int res = gsl_integration_qagiu (&F, a, aprec, prec, w,wk, result, error); CHECK(res,res); gsl_integration_workspace_free (wk); OK } -int integrate_qagil(double f(double,void*), double b, double prec, int w, +int integrate_qagil(double f(double,void*), double b, double aprec, double prec, int w, double *result, double* error) { DEBUGMSG("integrate_qagil"); gsl_integration_workspace * wk = gsl_integration_workspace_alloc (w); gsl_function F; F.function = f; F.params = NULL;- int res = gsl_integration_qagil (&F, b, 0, prec, w,wk, result, error); + int res = gsl_integration_qagil (&F, b, aprec, prec, w,wk, result, error); CHECK(res,res); gsl_integration_workspace_free (wk); OK } -int integrate_cquad(double f(double,void*), double a, double b, double prec,+int integrate_cquad(double f(double,void*), double a, double b, double aprec, double prec, int w, double *result, double* error, int *neval) { DEBUGMSG("integrate_cquad"); gsl_integration_cquad_workspace * wk = gsl_integration_cquad_workspace_alloc (w); gsl_function F; F.function = f; F.params = NULL;- int res = gsl_integration_cquad (&F, a, b, 0, prec, wk, result, error, neval); + int res = gsl_integration_cquad (&F, a, b, aprec, prec, wk, result, error, neval); CHECK(res,res); gsl_integration_cquad_workspace_free (wk); OK
lib/Numeric/LinearAlgebra/Util.hs view
@@ -97,7 +97,7 @@ -- | concatenation of real vectors infixl 3 & (&) :: Vector Double -> Vector Double -> Vector Double-a & b = join [a,b]+a & b = Numeric.Container.join [a,b] -- | horizontal concatenation of real matrices infixl 3 !@@ -206,7 +206,7 @@ vech :: Element t => Matrix t -> Vector t -- ^ half-vectorization (of the lower triangular part)-vech m = join . zipWith f [0..] . toColumns $ m+vech m = Numeric.Container.join . zipWith f [0..] . toColumns $ m where f k v = subVector k (dim v - k) v