hmatrix 0.11.0.1 → 0.11.0.3
raw patch · 8 files changed
+210/−155 lines, 8 filessetup-changedPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
API changes (from Hackage documentation)
- Data.Packed.Vector: foldVectorG :: Storable a => (Int -> (Int -> a) -> t -> t) -> t -> Vector a -> t
+ Data.Packed.Vector: foldVectorG :: Storable t1 => (Int -> (Int -> t1) -> t -> t) -> t -> Vector t1 -> t
- Numeric.Container: (*/) :: Container c a => c a -> a -> c a
+ Numeric.Container: (*/) :: Container c e => c e -> e -> c e
- Numeric.Container: (<->) :: (Element t, Joinable a b) => a t -> b t -> Matrix t
+ Numeric.Container: (<->) :: (Joinable a b, Element t) => a t -> b t -> Matrix t
- Numeric.Container: (<|>) :: (Element t, Joinable a b) => a t -> b t -> Matrix t
+ Numeric.Container: (<|>) :: (Joinable a b, Element t) => a t -> b t -> Matrix t
- Numeric.LinearAlgebra.Algorithms: economy :: (Element t2, Element t, Element t1) => (Matrix t -> (Matrix t1, Vector Double, Matrix t2)) -> Matrix t -> (Matrix t1, Vector Double, Matrix t2)
+ Numeric.LinearAlgebra.Algorithms: economy :: (Element t1, Element t2, Element t) => (Matrix t -> (Matrix t1, Vector Double, Matrix t2)) -> Matrix t -> (Matrix t1, Vector Double, Matrix t2)
- Numeric.LinearAlgebra.Algorithms: full :: (Num a, Storable a) => (Matrix t -> (t1, Vector a, t2)) -> Matrix t -> (t1, Matrix a, t2)
+ Numeric.LinearAlgebra.Algorithms: full :: (Storable t1, Num t1) => (Matrix t -> (t2, Vector t1, t3)) -> Matrix t -> (t2, Matrix t1, t3)
Files
- Config.hs +145/−0
- Setup.lhs +36/−1
- THANKS +9/−0
- configure +0/−3
- configure.hs +0/−145
- hmatrix.cabal +9/−5
- lib/Data/Packed/Internal/Vector.hs +10/−0
- lib/Numeric/LinearAlgebra/Tests.hs +1/−1
+ Config.hs view
@@ -0,0 +1,145 @@+{-+ 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 = do+ info <- maybeGetPersistBuildConfig "dist"+ case info of+ Nothing -> putStrLn "Please run \"cabal clean\" first." >> exitFailure+ Just bInfo -> mainOk bInfo+ +mainOk 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."+ writeFile "hmatrix.buildinfo" ("buildable: False\n")+ Just ops -> do+ putStrLn " OK"+ g <- checkCommand $ gsl112 bInfo buildInfo+ writeFile "hmatrix.buildinfo" $ "extra-libraries: " +++ ops ++ "\n" +++ if g+ then ""+ else "cc-options: -DGSL110\n"+
Setup.lhs view
@@ -2,7 +2,42 @@ > import Distribution.Simple > import System.Process(system)+>+> import Config(config)+>+> import Distribution.Simple.Setup+> import Distribution.PackageDescription+> import Distribution.Simple.LocalBuildInfo+> import Distribution.Simple.Command+> import Distribution.PackageDescription.Parse+> import Distribution.Simple.Utils(info)+> import Distribution.Verbosity -> main = defaultMainWithHooks autoconfUserHooks {runTests = t}+> main = do+> defaultMainWithHooks autoconfUserHooks {+> runTests = t, +> postConf = modifiedPostConf }+> where modifiedPostConf :: Args -> ConfigFlags -> PackageDescription -> LocalBuildInfo -> IO ()+> modifiedPostConf args flags pkg_descr lbi+> = do let verbosity = fromFlag (configVerbosity flags)+> noExtraFlags args+>+> config+>+> pbi <- getHookedBuildInfo verbosity+> let pkg_descr' = updatePackageDescription pbi pkg_descr+> postConf simpleUserHooks args flags pkg_descr' lbi ++> getHookedBuildInfo :: Verbosity -> IO HookedBuildInfo+> getHookedBuildInfo verbosity = do+> maybe_infoFile <- defaultHookedPackageDesc+> case maybe_infoFile of+> Nothing -> return emptyHookedBuildInfo+> Just infoFile -> do+> info verbosity $ "Reading parameters from " ++ infoFile+> readHookedBuildInfo verbosity infoFile++ > t _ _ _ _ = system ( "runhaskell examples/tests.hs") >> return()+
THANKS view
@@ -85,3 +85,12 @@ - Stefan Kersten fixed hmatrix.cabal for 64-bit ghc-7 in OS/X +- Sacha Sokoloski reported an installation problem on Arch Linux and+ helped with the configuration.++- Carter Schonwald helped with the configuration for Homebrew OS X and+ found a tolerance problem in test "1E5 rots".++- Duncan Coutts reported a problem with configure.hs and contributed+ a solution.+
− configure
@@ -1,3 +0,0 @@-#! /bin/sh--runhaskell configure.hs $*
− configure.hs
@@ -1,145 +0,0 @@-#! /usr/bin/env runhaskell-{- configure.hs for 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.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--main = do- info <- maybeGetPersistBuildConfig "dist"- case info of- Nothing -> putStrLn "Please run \"cabal clean\" first." >> exitFailure- Just bInfo -> mainOk bInfo- -mainOk 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."- writeFile "hmatrix.buildinfo" ("buildable: False\n")- Just ops -> do- putStrLn " OK"- g <- checkCommand $ gsl112 bInfo buildInfo- writeFile "hmatrix.buildinfo" $ "extra-libraries: " ++- ops ++ "\n" ++- if g- then ""- else "cc-options: -DGSL110\n"
hmatrix.cabal view
@@ -1,5 +1,5 @@ Name: hmatrix-Version: 0.11.0.1+Version: 0.11.0.3 License: GPL License-file: LICENSE Author: Alberto Ruiz@@ -21,14 +21,14 @@ . - "Numeric.LinearAlgebra": everything + instances of standard Haskell numeric classes Category: Math-tested-with: GHC ==6.10.4, GHC ==6.12.1, GHC ==6.12.3+tested-with: GHC ==6.10.4, GHC ==6.12.1, GHC ==6.12.3, GHC ==7.0.1, GHC==7.0.2 cabal-version: >=1.6 build-type: Custom extra-source-files: lib/Numeric/LinearAlgebra/Tests/quickCheckCompat.h- configure configure.hs THANKS INSTALL CHANGES+ Config.hs THANKS INSTALL CHANGES extra-tmp-files: hmatrix.buildinfo extra-source-files: examples/tests.hs@@ -164,12 +164,14 @@ if impl(ghc < 6.10.2) cpp-options: -DFINIT + if impl(ghc >= 7.0.1)+ cpp-options: -DFINIT+ if flag(finit) cpp-options: -DFINIT if impl(ghc == 7.0.1) cpp-options: -DNONORMVTEST- cpp-options: -DFINIT if flag(mkl) if arch(x86_64)@@ -179,7 +181,9 @@ if os(OSX) extra-lib-dirs: /opt/local/lib/- include-dirs: /opt/local/include+ include-dirs: /opt/local/include/+ extra-lib-dirs: /usr/local/lib/+ include-dirs: /usr/local/include/ extra-libraries: gsl if arch(i386) cc-options: -arch i386
lib/Data/Packed/Internal/Vector.hs view
@@ -201,12 +201,21 @@ subVector = Vector.slice +{-+subVector k l v+ | k<0 || k >= n || k+l > n || l < 0 = error "subVector out of range"+ | otherwise = unsafeFromForeignPtr fp (i+k) l+ where+ (fp, i, n) = unsafeToForeignPtr v+-}+ #else subVector k l v@V{idim = n, ioff = i} | k<0 || k >= n || k+l > n || l < 0 = error "subVector out of range" | otherwise = v {idim = l, ioff = i+k} +{- subVectorCopy k l (v@V {idim=n}) | k<0 || k >= n || k+l > n || l < 0 = error "subVector out of range" | otherwise = unsafePerformIO $ do@@ -214,6 +223,7 @@ let f _ s _ d = copyArray d (advancePtr s k) l >> return 0 app2 f vec v vec r "subVector" return r+-} #endif
lib/Numeric/LinearAlgebra/Tests.hs view
@@ -213,7 +213,7 @@ where c = cos a s = sin a -rotTest = fun (10^5) :~12~: rot 5E4+rotTest = fun (10^5) :~11~: rot 5E4 where fun n = foldl1' (<>) (map rot angles) where angles = toList $ linspace n (0,1)