packages feed

hsignal 0.2.3.1 → 0.2.3.3

raw patch · 8 files changed

+178/−163 lines, 8 filessetup-changed

Files

CHANGES view
@@ -98,3 +98,11 @@  0.2.3.1: 		added cross spectrum+		added cum_sum++0.2.3.2:+		copied Config.hs from hmatrix++0.2.3.3:+		updated for ghc 7.2+		
+ Config.hs view
@@ -0,0 +1,141 @@+{-+    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.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 --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, [])+
Setup.lhs view
@@ -1,5 +1,18 @@ #! /usr/bin/env runhaskell  > import Distribution.Simple+> import Distribution.Simple.Setup+> import Distribution.PackageDescription+> import Distribution.Simple.LocalBuildInfo -> main = defaultMainWithHooks autoconfUserHooks+> import System.Process(system)+> import Config(config)++> main = defaultMainWithHooks simpleUserHooks { confHook = c }++> c x y = do+>     binfo <- confHook simpleUserHooks x y+>     pbi <- config binfo+>     let pkg_descr = localPkgDescr binfo+>     return $ binfo { localPkgDescr = updatePackageDescription pbi pkg_descr }+
− configure
@@ -1,3 +0,0 @@-#! /bin/sh--runhaskell configure.hs $*
− configure.hs
@@ -1,142 +0,0 @@-#! /usr/bin/env runhaskell-{- configure.hs for hsignal, copied from hmatrix-   --------------------------    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,...---}--import System-import System.Directory(createDirectoryIfMissing,getCurrentDirectory)-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--main = do-    dir <- getCurrentDirectory-    putStrLn $ "Current directory: " ++ dir--    putStr "Checking foreign libraries..."--    args <- getArgs-    Just bInfo <- maybeGetPersistBuildConfig "dist"--    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 hsignal.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 hsignal --configure-option=link:lib1,lib2,lib3,etc."-            writeFile "hsignal.buildinfo" ("buildable: False\n")-        Just ops -> do-            putStrLn " OK"-            g <- checkCommand $ gsl112 bInfo buildInfo-            writeFile "hsignal.buildinfo" $ "extra-libraries: " ++-                ops ++ "\n" ++-                if g-                    then ""-                    else "cc-options: -DGSL110\n"
hsignal.cabal view
@@ -1,5 +1,5 @@ Name:               hsignal-Version:            0.2.3.1+Version:            0.2.3.3 License:            BSD3 License-file:       LICENSE Copyright:          (c) A.V.H. McPhail 2010, 2011@@ -18,13 +18,13 @@      .      Feature requests, suggestions, and bug fixes welcome. Category:           Math-tested-with:        GHC ==7.0.1+tested-with:        GHC ==7.0.3  cabal-version:      >=1.8  build-type:         Custom -extra-source-files: configure configure.hs README INSTALL CHANGES+extra-source-files: Config.hs README INSTALL CHANGES extra-tmp-files:    hsignal.buildinfo  flag mkl
lib/Numeric/Signal.hs view
@@ -30,11 +30,11 @@                        cross_covariance,cross_correlation,cross_spectrum,                        auto_covariance,auto_correlation,                        -- * Preprocessing-                       cumulative_sum,                        detrend,                        resize,                        downsample,                        deriv,+                       cumulative_sum                 ) where  -----------------------------------------------------------------------------@@ -295,14 +295,6 @@  ----------------------------------------------------------------------------- --- | cumulative sum of a series-cumulative_sum :: S.Filterable a =>-                 Vector a -               -> Vector a-cumulative_sum = S.cumulative_sum_-------------------------------------------------------------------------------- -- | coefficients of a Hamming window hamming :: S.Filterable a =>           Int           -- ^ length@@ -317,7 +309,13 @@ deriv :: S.Filterable a => Vector a -> Vector a deriv = S.deriv_ --- | unwrap the phase of signal (input expected to be within (-pi,pi)+-- | cumulative sum of a series+cumulative_sum :: S.Filterable a =>+                 Vector a +               -> Vector a+cumulative_sum = S.cumulative_sum_++-- | unwrap the phase of signal (input expected to be within (-pi,pi)) unwrap :: S.Filterable a => Vector a -> Vector a unwrap = S.unwrap_ 
lib/Numeric/Signal/Multichannel.hs view
@@ -124,7 +124,7 @@           l <- get           de <- get           f <- get-          (d :: I.Array Int (a,a,Vector Word64)) <- get+          (d :: I.Array Int (Double,Double,Vector Word64)) <- get           return $! (MC s p c l de f (seq d (fmap convert) d))               where convert (mi,ma,v) = mapVector (\x -> ((fromIntegral x)) / (fromIntegral (maxBound :: Word64)) * (ma - mi) + mi) v @@ -148,7 +148,7 @@           l <- get           de <- get           f <- get-          (d :: I.Array Int (a,a,Vector Word32)) <- get+          (d :: I.Array Int (Float,Float,Vector Word32)) <- get           return $! (MC s p c l de f (seq d (fmap convert) d))               where convert (mi,ma,v) = mapVector (\x -> ((fromIntegral x)) / (fromIntegral (maxBound :: Word32)) * (ma - mi) + mi) v @@ -172,7 +172,7 @@           l <- get           de <- get           f <- get-          (d :: I.Array Int ((a,a,Vector Word64),(a,a,Vector Word64))) <- get+          (d :: I.Array Int ((Double,Double,Vector Word64),(Double,Double,Vector Word64))) <- get           return $! (MC s p c l de f (seq d (fmap (\(r,i) -> toComplex (convert r,convert i)) d)))               where convert (mi,ma,v) = mapVector (\x -> ((fromIntegral x)) / (fromIntegral (maxBound :: Word64)) * (ma - mi) + mi) v @@ -198,7 +198,7 @@           l <- get           de <- get           f <- get-          (d :: I.Array Int ((a,a,Vector Word32),(a,a,Vector Word32))) <- get+          (d :: I.Array Int ((Float,Float,Vector Word32),(Float,Float,Vector Word32))) <- get           return $! (MC s p c l de f (seq d (fmap (\(r,i) -> toComplex (convert r,convert i)) d)))               where convert (mi,ma,v) = mapVector (\x -> ((fromIntegral x)) / (fromIntegral (maxBound :: Word32)) * (ma - mi) + mi) v