hmatrix 0.2.1.0 → 0.3.0.0
raw patch · 7 files changed
+93/−36 lines, 7 files
Files
- README +45/−22
- hmatrix.cabal +16/−9
- lib/Numeric/GSL/Minimization.hs +2/−2
- lib/Numeric/LinearAlgebra/Instances.hs +18/−0
- lib/Numeric/LinearAlgebra/LAPACK/clapack.h +2/−2
- lib/Numeric/LinearAlgebra/Tests.hs +5/−0
- lib/Numeric/LinearAlgebra/Tests/Properties.hs +5/−1
README view
@@ -4,20 +4,21 @@ REQUIREMENTS ---------------------------- -Development packages of:--1) GNU Scientific Library (http://www.gnu.org/software/gsl)--2) BLAS and LAPACK (http://www.netlib.org/lapack)+1) GNU Scientific Library (http://www.gnu.org/software/gsl).+ In Ubuntu we need the package "libgsl0-dev". -3) ATLAS (recommended) (http://math-atlas.sourceforge.net/)+2) BLAS/LAPACK (http://www.netlib.org/lapack).+ An optimized implementation is recommended. I have tested: -For example, in Ubuntu Linux we need:+ - Intel's MKL (http://www.intel.com/cd/software/products).+ There is a free noncommercial download of MKL for Linux. -- libgsl0-dev-- refblas3-dev-- lapack3-dev-- atlas3-base-dev (or a version specifically tuned for your machine)+ - ATLAS (http://math-atlas.sourceforge.net).+ In Ubuntu the required packages are "refblas3-dev", "lapack3-dev",+ and "atlas3-base-dev" (or a version tuned for your machine).+ Please note that ATLAS currently requires compilation -fviaC in 32bit+ machines. Otherwise many functions fail, producing strange NaN's.+ Even with -fvia-C we may get wrong behavior in some cases. For ghc-6.8.x you may also need: @@ -46,6 +47,19 @@ $ runhaskell Setup.lhs haddock $ runhaskell Setup.lhs install +Using Intel's MKL:++ - add/modify environment variables (e.g. in your .bashrc):+ export LD_LIBRARY_PATH=/path/to/mkl/lib/arch+ export LIBRARY_PATH=/path/to/mkl/lib/arch+ where arch = "32" or "em64t"++ - add the "-fmkl" flag in the cabal configuration command:+ $ runhaskell Setup.lhs configure --prefix=$HOME --user -fmkl+ $ runhaskell Setup.lhs build+ $ runhaskell Setup.lhs install++ See below for installation on Windows. TESTS ---------------------------------------------@@ -88,7 +102,7 @@ NaN's results on certain blas/lapack calls. In these machines the library is automatically compiled -fvia-C, which apparently solves the problem.- On 64-bit the default and faster -fasm seems to work well.+ On 64-bit, or using MKL, the default and faster -fasm seems to work well. - On 64-bit machines the example "minimize.hs", when run from ghci, produces a segmentation fault. It happens in the call to@@ -110,6 +124,9 @@ A similar problem was reported at: http://article.gmane.org/gmane.linux.debian.devel.bugs.general/323065 +- On distributions with old GSL versions you should comment out a couple of functions+ in the export lists of Ellint.hs and Debye.hs+ CHANGES --------------------------------------------------------- This is a new version of the library previously known as GSLHaskell.@@ -142,22 +159,26 @@ These headers are also available from: http://perception.inf.um.es/~aruiz/darcs/hmatrix/gsl.zip -2) Install the package as usual:+2) Copy libgsl.dll, libcblas.dll (from the binaries package gsl-1.8.bin.zip)+ and liblapack.dll (borrowed from the R system) to the ghc folder, e.g.:+ C:\ghc\ghc-6.x.x.+ Rename libcblas.dll to libblas.dll.+ They are needed to compile programs.+ These three dlls are available from:+ http://perception.inf.um.es/~aruiz/darcs/hmatrix/dll1.zip++2.5) Remove the following functions from the export list of+ lib/Numeric/GSL/Special/Ellint.hs:+ ellint_Pcomp_e, ellint_Pcomp, ellint_Dcomp_e, ellint_Dcomp++3) Install the package as usual: runhaskell Setup.lhs configure runhaskell Setup.lhs build runhaskell Setup.lhs install -2.5) If configure cannot find ld please see:+3.5) If configure cannot find ld please see: http://article.gmane.org/gmane.comp.lang.haskell.cafe/32025 -3) Copy libgsl.dll, libcblas.dll (from the binaries package gsl-1.8.bin.zip)- and liblapack.dll (borrowed from the R system) to the folder in which- hmatrix has been installed: C:\Program Files\haskell\hmatrix-x.x.x.x\ghc-6.x.x.- Rename libcblas.dll to libblas.dll.- They are needed to compile programs.- These three dlls are available from:- http://perception.inf.um.es/~aruiz/darcs/hmatrix/dll1.zip- 4) Copy the dlls available from: http://perception.inf.um.es/~aruiz/darcs/hmatrix/dll2.zip to the working directory or C:\windows\system@@ -198,3 +219,5 @@ - Xiao-Yong Jin reported a bug on x86_64 caused by the assumptions in f2c.h, which are wrong for this architecture.++- Jason Schroeder reported an error in the documentation.
hmatrix.cabal view
@@ -1,5 +1,5 @@ Name: hmatrix-Version: 0.2.1.0+Version: 0.3.0.0 License: GPL License-file: LICENSE Author: Alberto Ruiz@@ -21,19 +21,19 @@ flag splitBase description: Choose the new smaller, split-up base package. +flag mkl+ description: Link with Intel's MKL optimized libraries.+ default: False+ library if flag(splitBase) build-depends: base >= 3, array, QuickCheck, HUnit, storable-complex else build-depends: base < 3, QuickCheck, HUnit, storable-complex - if os(windows)- ghc-options:- else- if arch(x86_64)- ghc-options:- else- ghc-options: -fvia-C+ if !flag(mkl)+ if !arch(x86_64)+ ghc-options: -fvia-C Build-Depends: haskell98 Extensions: ForeignFunctionInterface@@ -95,6 +95,13 @@ C-sources: lib/Data/Packed/Internal/auxi.c, lib/Numeric/LinearAlgebra/LAPACK/lapack-aux.c, lib/Numeric/GSL/gsl-aux.c- extra-libraries: gsl blas lapack+ 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+ else+ extra-libraries: gsl blas lapack+ cc-options: -O4 ghc-prof-options: -auto-all
lib/Numeric/GSL/Minimization.hs view
@@ -69,7 +69,7 @@ The path to the solution can be graphically shown by means of: -@'GSL.Plot.mplot' $ drop 3 ('toColumns' p)@+@'Graphics.Plot.mplot' $ drop 3 ('toColumns' p)@ -} minimizeNMSimplex :: ([Double] -> Double) -- ^ function to minimize@@ -130,7 +130,7 @@ The path to the solution can be graphically shown by means of: -@'GSL.Plot.mplot' $ drop 2 ('toColumns' p)@+@'Graphics.Plot.mplot' $ drop 2 ('toColumns' p)@ -} minimizeConjugateGradient ::
lib/Numeric/LinearAlgebra/Instances.hs view
@@ -48,6 +48,24 @@ ------------------------------------------------------------------ +instance (Element a, Read a) => Read (Matrix a) where+ readsPrec _ s = [((rows><cols) . read $ listnums, rest)]+ where (thing,rest) = breakAt ']' s+ (dims,listnums) = breakAt ')' thing+ cols = read . init . fst. breakAt ')' . snd . breakAt '<' $ dims+ rows = read . snd . breakAt '(' .init . fst . breakAt '>' $ dims++instance (Element a, Read a) => Read (Vector a) where+ readsPrec _ s = [((d |>) . read $ listnums, rest)]+ where (thing,rest) = breakAt ']' s+ (dims,listnums) = breakAt '>' thing+ d = read . init . fst . breakAt '|' $ dims++breakAt c l = (a++[c],tail b) where+ (a,b) = break (==c) l++------------------------------------------------------------------+ adaptScalar f1 f2 f3 x y | dim x == 1 = f1 (x@>0) y | dim y == 1 = f3 x (y@>0)
lib/Numeric/LinearAlgebra/LAPACK/clapack.h view
@@ -1483,7 +1483,7 @@ doublereal *wi, doublereal *z__, integer *ldz, doublereal *work, integer *lwork, integer *info); -/* Subroutine */ int dlabad_(doublereal *small, doublereal *large);+/* Subroutine */ int dlabad_(doublereal *smalll, doublereal *large); /* !? */ /* Subroutine */ int dlabrd_(integer *m, integer *n, integer *nb, doublereal * a, integer *lda, doublereal *d__, doublereal *e, doublereal *tauq, @@ -2858,7 +2858,7 @@ integer *ihi, real *h__, integer *ldh, real *wr, real *wi, real *z__, integer *ldz, real *work, integer *lwork, integer *info); -/* Subroutine */ int slabad_(real *small, real *large);+/* Subroutine */ int slabad_(real *smalll, real *large); /* !? */ /* Subroutine */ int slabrd_(integer *m, integer *n, integer *nb, real *a, integer *lda, real *d__, real *e, real *tauq, real *taup, real *x,
lib/Numeric/LinearAlgebra/Tests.hs view
@@ -174,6 +174,11 @@ test (\u -> sin u ** 2 + cos u ** 2 |~| (1::RM)) test (\u -> cos u * tan u |~| sin (u::RM)) test (\u -> (cos u * tan u) |~| sin (u::CM))+ putStrLn "------ read . show"+ test (\m -> (m::RM) == read (show m))+ test (\m -> (m::CM) == read (show m))+ test (\m -> toRows (m::RM) == read (show (toRows m)))+ test (\m -> toRows (m::CM) == read (show (toRows m))) putStrLn "------ some unit tests" runTestTT $ TestList [ utest "1E5 rots" rotTest
lib/Numeric/LinearAlgebra/Tests/Properties.hs view
@@ -40,7 +40,10 @@ import Numeric.LinearAlgebra import Numeric.LinearAlgebra.Tests.Instances(Sq(..),Her(..),Rot(..)) import Test.QuickCheck+import Debug.Trace +debug x = trace (show x) x+ -- relative error dist :: (Normed t, Num t) => t -> t -> Double dist a b = r@@ -89,8 +92,9 @@ ----------------------------------------------------- -luProp m = m |~| p <> l <> u && det p == s+luProp m = m |~| p <> l <> u && f (det p) |~| f s where (l,u,p,s) = lu m+ f x = fromList [x] invProp m = m <> inv m |~| ident (rows m)