packages feed

hmatrix-gsl-stats 0.2 → 0.2.1

raw patch · 12 files changed

+47/−177 lines, 12 files

Files

CHANGES view
@@ -70,3 +70,6 @@  0.2: 		add `cmat` to `app` FFI calls for matrices++0.2.1:+		Update build configuration : copied from hmatrix
− Config.hs
@@ -1,141 +0,0 @@-{--    GSL and LAPACK may require auxiliary libraries which depend on OS,-    distribution, and implementation. This script tries to to find out-    the correct link command for your system.-    Suggestions and contributions are welcome.--    By default we try to link -lgsl -llapack. This works in ubuntu/debian,-    both with and without ATLAS.-    If this fails we try different sets of additional libraries which are-    known to work in some systems.--    The desired libraries can also be explicitly given by the user using cabal-    flags (e.g., -fmkl, -faccelerate) or --configure-option=link:lib1,lib2,lib3,...---}--module Config(config) where--import System.Process-import System.Exit-import System.Environment-import System.Directory(createDirectoryIfMissing)-import Data.List(isPrefixOf, intercalate)-import Distribution.Simple.LocalBuildInfo-import Distribution.Simple.Configure-import Distribution.PackageDescription---- possible additional dependencies for the desired libs (by default gsl lapack)--opts = [ ""                              -- Ubuntu/Debian-       , "blas"-       , "blas cblas"-       , "cblas"-       , "gslcblas"-       , "blas gslcblas"-       , "f77blas"-       , "f77blas cblas atlas gcc_s"     -- Arch Linux (older version of atlas-lapack)-       , "blas gslcblas gfortran"        -- Arch Linux with normal blas and lapack-       ]---- compile a simple program with symbols from GSL and LAPACK with the given libs-testprog bInfo buildInfo libs fmks =-    "echo \"#include <gsl/gsl_sf_gamma.h>\nint main(){zgesvd_(); gsl_sf_gamma(5);}\""-                     ++" > " ++ (buildDir bInfo) ++ "/dummy.c; gcc "-                     ++ (join $ ccOptions buildInfo) ++ " "-                     ++ (join $ cppOptions buildInfo) ++ " "-                     ++ (join $ map ("-I"++) $ includeDirs buildInfo) ++ " " -                     ++ (buildDir bInfo) ++ "/dummy.c -o "-                     ++ (buildDir bInfo) ++ "/dummy "-                     ++ (join $ map ("-L"++) $ extraLibDirs buildInfo) ++ " "-                     ++ (prepend "-l" $ libs) ++ " "-                     ++ (prepend "-framework " fmks) ++ " > /dev/null 2> /dev/null"--join = intercalate " "-prepend x = unwords . map (x++) . words--check bInfo buildInfo libs fmks = (ExitSuccess ==) `fmap` system (testprog bInfo buildInfo libs fmks)---- simple test for GSL-gsl bInfo buildInfo = "echo \"#include <gsl/gsl_sf_gamma.h>\nint main(){gsl_sf_gamma(5);}\""-           ++" > " ++ (buildDir bInfo) ++ "/dummy.c; gcc "-           ++ (join $ ccOptions buildInfo) ++ " "-           ++ (join $ cppOptions buildInfo) ++ " "-           ++ (join $ map ("-I"++) $ includeDirs buildInfo) ++ " " -           ++ (buildDir bInfo) ++ "/dummy.c -o "-           ++ (buildDir bInfo) ++ "/dummy "-           ++ (join $ map ("-L"++) $ extraLibDirs buildInfo) ++ " -lgsl -lgslcblas"-           ++ " > /dev/null 2> /dev/null"---- test for gsl >= 1.12-gsl112 bInfo buildInfo =-    "echo \"#include <gsl/gsl_sf_exp.h>\nint main(){gsl_sf_exprel_n_CF_e(1,1,0);}\""-           ++" > " ++ (buildDir bInfo) ++ "/dummy.c; gcc " -           ++ (buildDir bInfo) ++ "/dummy.c "-           ++ (join $ ccOptions buildInfo) ++ " "-           ++ (join $ cppOptions buildInfo) ++ " "-           ++ (join $ map ("-I"++) $ includeDirs buildInfo)-           ++" -o " ++ (buildDir bInfo) ++ "/dummy "-           ++ (join $ map ("-L"++) $ extraLibDirs buildInfo) ++ " -lgsl -lgslcblas"-           ++ " > /dev/null 2> /dev/null"---checkCommand c = (ExitSuccess ==) `fmap` system c---- test different configurations until the first one works-try _ _ _ _ [] = return Nothing-try l i b f (opt:rest) = do-    ok <- check l i (b ++ " " ++ opt) f-    if ok then return (Just opt)-          else try l i b f rest---- read --configure-option=link:lib1,lib2,lib3,etc-linkop = "link:"-getUserLink = concatMap (g . drop (length linkop)) . filter (isPrefixOf linkop)-    where g = map cs-          cs ',' = ' '-          cs x   = x--config :: LocalBuildInfo -> IO HookedBuildInfo-          -config bInfo = do-    putStr "Checking foreign libraries..."-    args <- getArgs--    let Just lib = library . localPkgDescr $ bInfo-        buildInfo = libBuildInfo lib-        base = unwords . extraLibs $ buildInfo-        fwks = unwords . frameworks $ buildInfo-        auxpref = getUserLink args--    -- We extract the desired libs from hmatrix-gsl-stats.cabal (using a cabal flags)-    -- and from a posible --configure-option=link:lib1,lib2,lib3-    -- by default the desired libs are gsl lapack.--    let pref = if null (words (base ++ " " ++ auxpref)) then "gsl lapack" else auxpref-        fullOpts = map ((pref++" ")++) opts--    -- create the build directory (used for tmp files) if necessary-    createDirectoryIfMissing True $ buildDir bInfo-    -    r <- try bInfo buildInfo base fwks fullOpts--    case r of-        Nothing -> do-            putStrLn " FAIL"-            g  <- checkCommand $ gsl bInfo buildInfo-            if g-                then putStrLn " *** Sorry, I can't link LAPACK."-                else putStrLn " *** Sorry, I can't link GSL."-            putStrLn " *** Please make sure that the appropriate -dev packages are installed."-            putStrLn " *** You can also specify the required libraries using"-            putStrLn " *** cabal install hmatrix-gsl-stats --configure-option=link:lib1,lib2,lib3,etc."            -            return (Just emptyBuildInfo { buildable = False }, [])-        Just ops -> do-            putStrLn $ " OK " ++ ops-            g <- checkCommand $ gsl112 bInfo buildInfo-            let hbi = if g-                        then emptyBuildInfo { extraLibs = words ops}-                        else emptyBuildInfo { extraLibs = words ops, ccOptions = ["-DGSL110"]}-            return (Just hbi, [])-
hmatrix-gsl-stats.cabal view
@@ -1,8 +1,8 @@ Name:               hmatrix-gsl-stats-Version:            0.2+Version:            0.2.1 License:            BSD3 License-file:       LICENSE-Copyright:          (c) A.V.H. McPhail 2010, 2011, 2013+Copyright:          (c) A.V.H. McPhail 2010, 2011, 2013, 2015 Author:             Vivian McPhail Maintainer:         haskell.vivian.mcphail <at> gmail <dot> com Stability:          provisional@@ -17,17 +17,17 @@      .      The vector type is Data.Vector.Storable from the 'vector' package. Category:           Math, Statistics, FFI-tested-with:        GHC ==7.4.1+tested-with:        GHC ==7.10.1  cabal-version:      >=1.10.1.0 -build-type:         Custom+build-type:         Simple -extra-source-files: Config.hs README INSTALL CHANGES+extra-source-files: README INSTALL CHANGES extra-tmp-files:    hmatrix-gsl-stats.buildinfo -flag mkl-    description:    Link with Intel's MKL optimized libraries.+flag openblas+    description:    Link with OpenBLAS (https://github.com/xianyi/OpenBLAS) optimized libraries.     default:        False  library@@ -64,26 +64,34 @@                               -fno-warn-orphans                               -fno-warn-unused-binds -    if flag(mkl)-      if arch(x86_64)-        extra-libraries:   gsl mkl_lapack mkl_intel_lp64 mkl_sequential mkl_core-      else-        extra-libraries:   gsl mkl_lapack mkl_intel mkl_sequential mkl_core+    cc-options:         -O4 -msse2 -Wall +    if flag(openblas)+        extra-lib-dirs:     /usr/lib/openblas/lib    +        extra-libraries:    openblas+    else +        extra-libraries:    blas lapack+     if os(OSX)         extra-lib-dirs: /opt/local/lib/         include-dirs: /opt/local/include/-        extra-libraries: gsl+        extra-lib-dirs: /usr/local/lib/+        include-dirs: /usr/local/include/+        if arch(i386)+            cc-options: -arch i386         frameworks: Accelerate -    if os(windows)-        extra-libraries: gsl-0 blas lapack+    if os(freebsd)+       extra-lib-dirs: /usr/local/lib+       include-dirs: /usr/local/include+       extra-libraries: blas lapack gfortran --- The extra-libraries required for GSL--- should now be automatically detected by configure(.hs)+    if os(windows)+        extra-libraries: blas lapack -    extra-libraries:-    extra-lib-dirs:+    if os(linux)+        if arch(x86_64)+            cc-options: -fPIC  source-repository head     type:     git
lib/Numeric/GSL/Distribution/Common.hs view
@@ -2,7 +2,7 @@ -- | -- Module      :  Numeric.GSL.Distribution.Common -- Copyright   :  (c) A. V. H. McPhail 2010--- License     :  GPL-style+-- License     :  BSD3 -- -- Maintainer  :  haskell.vivian.mcphail <at> gmail <dot> com -- Stability   :  provisional
lib/Numeric/GSL/Distribution/Continuous.hs view
@@ -2,7 +2,7 @@ -- | -- Module      :  Numeric.GSL.Distribution.Continuous -- Copyright   :  (c) A. V. H. McPhail 2010--- License     :  GPL-style+-- License     :  BSD3 -- -- Maintainer  :  haskell.vivian.mcphail <at> gmail <dot> com -- Stability   :  provisional@@ -39,7 +39,7 @@  --import Control.Monad(when) -import Foreign hiding(shift,unsafePerformIO)+import Foreign hiding(shift) --import Foreign.ForeignPtr --import Foreign.Marshal.Alloc(alloca) --import Foreign.C.Types(CInt,CChar)
lib/Numeric/GSL/Distribution/Discrete.hs view
@@ -2,7 +2,7 @@ -- | -- Module      :  Numeric.GSL.Distribution.Discrete -- Copyright   :  (c) A. V. H. McPhail 2010--- License     :  GPL-style+-- License     :  BSD3 -- -- Maintainer  :  haskell.vivian.mcphail <at> gmail <dot> com -- Stability   :  provisional@@ -35,7 +35,7 @@  --import Control.Monad(when) -import Foreign hiding(shift,unsafePerformIO)+import Foreign hiding(shift) --import Foreign.ForeignPtr --import Foreign.Marshal.Alloc(alloca) --import Foreign.C.Types(CInt,CUInt,CChar)
lib/Numeric/GSL/Fitting/Linear.hs view
@@ -2,7 +2,7 @@ -- | -- Module      :  Numeric.GSL.Fitting.Linear -- Copyright   :  (c) A. V. H. McPhail 2010--- License     :  GPL-style+-- License     :  BSD3 -- -- Maintainer  :  haskell.vivian.mcphail <at> gmail <dot> com -- Stability   :  provisional@@ -29,7 +29,7 @@  --import Control.Monad(when) -import Foreign hiding (unsafePerformIO)+import Foreign --import Foreign.ForeignPtr --import Foreign.Marshal.Alloc(alloca) import Foreign.C.Types(CInt(..))
lib/Numeric/GSL/Histogram.hs view
@@ -4,7 +4,7 @@ -- | -- Module      :  Numeric.GSL.Histogram -- Copyright   :  (c) A. V. H. McPhail 2010--- License     :  GPL-style+-- License     :  BSD3 -- -- Maintainer  :  haskell.vivian.mcphail <at> gmail <dot> com -- Stability   :  provisional@@ -58,7 +58,7 @@ --import Control.Monad import Data.Binary -import Foreign hiding(shift,unsafePerformIO)+import Foreign hiding(shift) --import Foreign.ForeignPtr --import Foreign.Marshal.Alloc(alloca) import Foreign.C.Types(CInt(..),CChar(..))
lib/Numeric/GSL/Histogram2D.hs view
@@ -4,7 +4,7 @@ -- | -- Module      :  Numeric.GSL.Histogram2D -- Copyright   :  (c) A. V. H. McPhail 2010--- License     :  GPL-style+-- License     :  BSD3 -- -- Maintainer  :  haskell.vivian.mcphail <at> gmail <dot> com -- Stability   :  provisional@@ -63,7 +63,7 @@  import Data.Binary -import Foreign hiding(shift,unsafePerformIO)+import Foreign hiding(shift) --import Foreign.Storable --import Foreign.Ptr --import Foreign.ForeignPtr
lib/Numeric/GSL/Permutation.hs view
@@ -3,7 +3,7 @@ -- | -- Module      :  Numeric.GSL.Permutation -- Copyright   :  (c) A. V. H. McPhail 2010--- License     :  GPL-style+-- License     :  BSD3 -- -- Maintainer  :  haskell.vivian.mcphail <at> gmail <dot> com -- Stability   :  provisional@@ -41,7 +41,7 @@  --import Control.Monad(when) -import Foreign hiding(shift,unsafePerformIO)+import Foreign hiding(shift) --import Foreign.ForeignPtr --import Foreign.Marshal.Alloc(alloca) import Foreign.C.Types(CInt(..),CChar(..))
lib/Numeric/GSL/Sort.hs view
@@ -2,7 +2,7 @@ -- | -- Module      :  Numeric.GSL.Sort -- Copyright   :  (c) A. V. H. McPhail 2010--- License     :  GPL-style+-- License     :  BSD3 -- -- Maintainer  :  haskell.vivian.mcphail <at> gmail <dot> com -- Stability   :  provisional@@ -22,7 +22,7 @@ import Data.Packed.Vector import Data.Packed.Development -import Foreign hiding (unsafePerformIO)+import Foreign import Foreign.C.Types(CInt(..))  import System.IO.Unsafe(unsafePerformIO)
lib/Numeric/GSL/Statistics.hs view
@@ -2,7 +2,7 @@ -- | -- Module      :  Numeric.GSL.Statistics -- Copyright   :  (c) A. V. H. McPhail 2010--- License     :  GPL-style+-- License     :  BSD3 -- -- Maintainer  :  haskell.vivian.mcphail <at> gmail <dot> com -- Stability   :  provisional@@ -49,7 +49,7 @@ --import Numeric.LinearAlgebra.Instances() --import Numeric.LinearAlgebra.Linear(Linear(..)) -import Foreign hiding (unsafePerformIO)+import Foreign import Foreign.C.Types(CInt(..)) --import Foreign.Marshal.Alloc(alloca)