summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--INSTALL58
-rw-r--r--README128
-rw-r--r--examples/benchmarks.hs13
3 files changed, 70 insertions, 129 deletions
diff --git a/INSTALL b/INSTALL
new file mode 100644
index 0000000..e4c7e12
--- /dev/null
+++ b/INSTALL
@@ -0,0 +1,58 @@
1-----------------------------------------
2 A simple scientific library for Haskell
3-----------------------------------------
4
5INSTALLATION
6
7Recommended method:
8 $ sudo apt-get install libgsl0-dev refblas3-dev lapack3-dev atlas3-[your arch]-dev
9 $ cabal install hmatrix
10
11Detailed installation instructions:
12 http://www.hmatrix.googlepages.com/installation
13
14INSTALLATION ON WINDOWS ----------------------------------------
15
161) Download the developer files gsl-1.8-lib.zip from
17 http://gnuwin32.sourceforge.net/packages/gsl.htm
18 and copy the gsl headers folder (under include) to:
19 C:\ghc\ghc.6.x.1\include
20 These headers are also available from:
21 http://perception.inf.um.es/~aruiz/darcs/hmatrix/gsl.zip
22
232) Copy libgsl.dll, libcblas.dll (from the binaries package gsl-1.8.bin.zip)
24 and liblapack.dll (borrowed from the R system) to the ghc folder, e.g.:
25 C:\ghc\ghc-6.x.x.
26 Rename libcblas.dll to libblas.dll.
27 They are needed to compile programs.
28 These three dlls are available from:
29 http://perception.inf.um.es/~aruiz/darcs/hmatrix/dll1.zip
30
312.5) Remove the following functions from the export list of
32 lib/Numeric/GSL/Special/Ellint.hs:
33 ellint_Pcomp_e, ellint_Pcomp, ellint_Dcomp_e, ellint_Dcomp
34
353) Install the package as usual:
36 runhaskell Setup.lhs configure
37 runhaskell Setup.lhs build
38 runhaskell Setup.lhs install
39
403.5) If configure cannot find ld please see:
41 http://article.gmane.org/gmane.comp.lang.haskell.cafe/32025
42
434) Copy the dlls available from:
44 http://perception.inf.um.es/~aruiz/darcs/hmatrix/dll2.zip
45 to the working directory or C:\windows\system
46 They are required to run the programs and ghci.
47
485) run the tests
49
50Unfortunately the lapack dll supplied by the R system does not include
51zgels_, zgelss_, and zgees_, so the functions depending on them
52(linearSolveLS, linearSolveSVD, and schur for complex data)
53will produce a "non supported in this OS" runtime error.
54
55If you find an alternative free and complete lapack.dll which works well
56for this system please let me know.
57
58The examples using graphics do not yet work in windows.
diff --git a/README b/README
index c034e2c..77d384e 100644
--- a/README
+++ b/README
@@ -2,63 +2,16 @@
2 A simple scientific library for Haskell 2 A simple scientific library for Haskell
3----------------------------------------- 3-----------------------------------------
4 4
5REQUIREMENTS ---------------------------- 5INSTALLATION
6
71) GNU Scientific Library (http://www.gnu.org/software/gsl).
8 In Ubuntu we need the package "libgsl0-dev".
9
102) BLAS/LAPACK (http://www.netlib.org/lapack).
11 An optimized implementation is recommended. I have tested:
12
13 - ATLAS (http://math-atlas.sourceforge.net).
14 In Ubuntu the required packages are "refblas3-dev", "lapack3-dev",
15 and "atlas3-base-dev" (or a version tuned for your machine).
16
17 - Intel's MKL (http://www.intel.com/cd/software/products).
18 There is a free noncommercial download of MKL for Linux.
19
20For ghc-6.8.x you may also need:
21
22- libgmp3-dev.
23
24The following packages are used for simple graphics:
25
26- gnuplot
27- imagemagick
28
29GNU-Octave can be used to check if the results
30obtained by this library are correct.
31
32INSTALLATION --------------------------------------
33
34Automatic (using cabal-install and HackageDB):
35 6
7Recommended method (ok in Ubuntu/Debian systems):
8 $ sudo apt-get install libgsl0-dev refblas3-dev lapack3-dev atlas3-[your_arch]-dev
36 $ cabal install hmatrix 9 $ cabal install hmatrix
37 10
38Manual: 11Detailed installation instructions:
39 12 http://www.hmatrix.googlepages.com/installation
40 Install storable-complex from HackageDB and then
41
42 $ runhaskell Setup.lhs configure --prefix=$HOME --user
43 $ runhaskell Setup.lhs build
44 $ runhaskell Setup.lhs haddock
45 $ runhaskell Setup.lhs install
46
47Using Intel's MKL:
48 13
49 - add/modify environment variables (e.g. in your .bashrc): 14For installation in Windows see the companion INSTALL file.
50 export LD_LIBRARY_PATH=/path/to/mkl/lib/arch
51 export LIBRARY_PATH=/path/to/mkl/lib/arch
52 where arch = "32" or "em64t"
53
54 - add the "-fmkl" flag in the cabal configuration command:
55 $ runhaskell Setup.lhs configure --prefix=$HOME --user -fmkl
56 $ runhaskell Setup.lhs build
57 $ runhaskell Setup.lhs install
58
59More information: http://www.hmatrix.googlepages.com/installation
60
61See below for installation on Windows.
62 15
63TESTS --------------------------------------------- 16TESTS ---------------------------------------------
64 17
@@ -110,75 +63,6 @@ KNOWN PROBLEMS / BUGS -------------------------------
110- On distributions with old GSL versions you should comment out a couple of functions 63- On distributions with old GSL versions you should comment out a couple of functions
111 in the export lists of Ellint.hs and Debye.hs 64 in the export lists of Ellint.hs and Debye.hs
112 65
113CHANGES ---------------------------------------------------------
114
115This is a new version of the library previously known as GSLHaskell.
116It has been renamed to "hmatrix" because only a small part of GSL is actually
117available, and most linear algebra is based on LAPACK.
118
119The code has been extensively refactored. There is a new internal representation
120which admits both C and Fortran matrices and avoids many transposes.
121
122There are only minor API changes:
123
124- The matrix product operator (<>) is now overloaded only for matrix-matrix,
125 matrix-vector and vector-matrix, with the same base type. Dot product and scaling
126 of vectors or matrices is now denoted by `dot` or (<.>) and `scale` or (.*).
127 Conversions from real to complex objects must now be explicit.
128
129- Most linear algebra functions admit both real and complex objects. Utilities such as
130 ident or constant are now polymorphic.
131
132- Runtime errors produced by GSL or LAPACK can be handled using Control.Exeception.catch.
133
134Old GSLHaskell code will work with small modifications.
135
136INSTALLATION ON WINDOWS ----------------------------------------
137
1381) Download the developer files gsl-1.8-lib.zip from
139 http://gnuwin32.sourceforge.net/packages/gsl.htm
140 and copy the gsl headers folder (under include) to:
141 C:\ghc\ghc.6.x.1\include
142 These headers are also available from:
143 http://perception.inf.um.es/~aruiz/darcs/hmatrix/gsl.zip
144
1452) Copy libgsl.dll, libcblas.dll (from the binaries package gsl-1.8.bin.zip)
146 and liblapack.dll (borrowed from the R system) to the ghc folder, e.g.:
147 C:\ghc\ghc-6.x.x.
148 Rename libcblas.dll to libblas.dll.
149 They are needed to compile programs.
150 These three dlls are available from:
151 http://perception.inf.um.es/~aruiz/darcs/hmatrix/dll1.zip
152
1532.5) Remove the following functions from the export list of
154 lib/Numeric/GSL/Special/Ellint.hs:
155 ellint_Pcomp_e, ellint_Pcomp, ellint_Dcomp_e, ellint_Dcomp
156
1573) Install the package as usual:
158 runhaskell Setup.lhs configure
159 runhaskell Setup.lhs build
160 runhaskell Setup.lhs install
161
1623.5) If configure cannot find ld please see:
163 http://article.gmane.org/gmane.comp.lang.haskell.cafe/32025
164
1654) Copy the dlls available from:
166 http://perception.inf.um.es/~aruiz/darcs/hmatrix/dll2.zip
167 to the working directory or C:\windows\system
168 They are required to run the programs and ghci.
169
1705) run the tests
171
172Unfortunately the lapack dll supplied by the R system does not include
173zgels_, zgelss_, and zgees_, so the functions depending on them
174(linearSolveLS, linearSolveSVD, and schur for complex data)
175will produce a "non supported in this OS" runtime error.
176
177If you find an alternative free and complete lapack.dll which works well
178for this system please let me know.
179
180The examples using graphics do not yet work in windows.
181
182ACKNOWLEDGEMENTS ----------------------------------------------------- 66ACKNOWLEDGEMENTS -----------------------------------------------------
183 67
184I thank Don Stewart, Henning Thielemann, Bulat Ziganshin and all the people 68I thank Don Stewart, Henning Thielemann, Bulat Ziganshin and all the people
diff --git a/examples/benchmarks.hs b/examples/benchmarks.hs
index 517d402..78c1e5f 100644
--- a/examples/benchmarks.hs
+++ b/examples/benchmarks.hs
@@ -1,8 +1,7 @@
1{-# LANGUAGE BangPatterns #-} 1{-# LANGUAGE BangPatterns #-}
2 2
3-- compile as: 3-- $ ghc --make -O2 benchmarks.hs
4-- ghc --make -O2 -optc-O2 -fvia-C benchmarks.hs 4
5-- ghc --make -O benchmarks.hs
6 5
7import Numeric.LinearAlgebra 6import Numeric.LinearAlgebra
8import System.Time 7import System.Time
@@ -22,11 +21,11 @@ time act = do
22main = sequence_ [bench1,bench2,bench3,bench4] 21main = sequence_ [bench1,bench2,bench3,bench4]
23 22
24w :: Vector Double 23w :: Vector Double
25w = constant 1 30000000 24w = constant 1 5000000
26w2 = 1 * w 25w2 = 1 * w
27 26
28bench1 = do 27bench1 = do
29 putStrLn "Sum of a vector with 30M doubles:" 28 putStrLn "Sum of a vector with 5M doubles:"
30 print$ vectorMax (w+w2) -- evaluate it 29 print$ vectorMax (w+w2) -- evaluate it
31 time $ printf " BLAS: %.2f: " $ sumVB w 30 time $ printf " BLAS: %.2f: " $ sumVB w
32 time $ printf " Haskell: %.2f: " $ sumVH w 31 time $ printf " Haskell: %.2f: " $ sumVH w
@@ -91,7 +90,7 @@ bench3 = do
91 let v = flatten $ ident 500 :: Vector Double 90 let v = flatten $ ident 500 :: Vector Double
92 print $ vectorMax v -- evaluate it 91 print $ vectorMax v -- evaluate it
93 92
94 putStrLn "sum, dim=30M:" 93 putStrLn "sum, dim=5M:"
95 -- time $ print $ foldLoop (\k s -> w@>k + s) 0.0 (dim w) 94 -- time $ print $ foldLoop (\k s -> w@>k + s) 0.0 (dim w)
96 time $ print $ sumVector w 95 time $ print $ sumVector w
97 96
@@ -114,7 +113,7 @@ foldVector f s v = foldLoop g s (dim v)
114 113
115sumVector = foldVector (\k v s -> v k + s) 0.0 114sumVector = foldVector (\k v s -> v k + s) 0.0
116 115
117-- foldVector is slower if it is used in two places unles we use the above INLINE 116-- foldVector is slower if used in two places unless we use the above INLINE
118-- this does not happen with foldLoop 117-- this does not happen with foldLoop
119-------------------------------------------------------------------------------- 118--------------------------------------------------------------------------------
120 119