hmatrix: Linear algebra and numerical computations

[ bsd3, library, math ] [ Propose Tags ] [ Report a vulnerability ]

A purely functional interface to basic linear algebra computations and other numerical routines, internally implemented using GSL, BLAS and LAPACK.

More information: http://alberrto.googlepages.com/gslhaskell


[Skip to Readme]

Flags

Automatic Flags
NameDescriptionDefault
splitbase

Choose the new smaller, split-up base package.

Enabled

Use -f <flag> to enable a flag, or -f -<flag> to disable that flag. More info

Downloads

Versions [RSS] 0.1.0.0, 0.1.1.0, 0.2.0.0, 0.2.1.0, 0.3.0.0, 0.4.0.0, 0.5.0.1, 0.5.1.1, 0.5.2.0, 0.5.2.1, 0.5.2.2, 0.6.0.0, 0.7.1.0, 0.7.2.1, 0.8.0.0, 0.8.1.0, 0.8.1.1, 0.8.2.0, 0.8.3.1, 0.9.3.0, 0.10.0.0, 0.10.0.1, 0.10.0.2, 0.11.0.0, 0.11.0.1, 0.11.0.3, 0.11.0.4, 0.11.1.0, 0.12.0.0, 0.12.0.1, 0.12.0.2, 0.13.0.0, 0.13.1.0, 0.14.0.0, 0.14.0.1, 0.14.1.0, 0.15.0.0, 0.15.0.1, 0.15.2.0, 0.15.2.1, 0.16.0.2, 0.16.0.3, 0.16.0.4, 0.16.0.5, 0.16.0.6, 0.16.1.0, 0.16.1.1, 0.16.1.2, 0.16.1.3, 0.16.1.4, 0.16.1.5, 0.17.0.1, 0.17.0.2, 0.18.0.0, 0.18.1.0, 0.18.2.0, 0.19.0.0, 0.20.0.0, 0.20.1, 0.20.2
Dependencies array, base, haskell98 [details]
Tested with ghc ==6.6.1, ghc ==6.8.1
License LicenseRef-GPL
Author Alberto Ruiz
Maintainer Alberto Ruiz <aruiz@um.es>
Category Numerical, Math
Home page http://alberrto.googlepages.com/gslhaskell
Uploaded by AlbertoRuiz at 2007-12-03T10:48:52Z
Distributions Debian:0.20.0.0, LTSHaskell:0.20.2, NixOS:0.20.2, Stackage:0.20.2
Reverse Dependencies 125 direct, 54 indirect [details]
Downloads 75292 total (90 in the last 30 days)
Rating 2.5 (votes: 9) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs uploaded by user
Build status unknown [no reports yet]

Readme for hmatrix-0.1.1.0

[back to package description]
A simple scientific library for Haskell
---------------------------------------

REQUIREMENTS

Development packages of:

1) GNU Scientific Library (http://www.gnu.org/software/gsl)

2) BLAS and LAPACK (http://www.netlib.org/lapack)

3) ATLAS (recommended) (http://math-atlas.sourceforge.net/)

For example, in Ubuntu Linux we need:

- libgsl0-dev
- refblas3-dev
- lapack3-dev
- atlas3-base-dev

You can also install an atlas version specifically tuned
for your machine (but see the TESTS section below).

The following packages are used for simple graphics:

- gnuplot
- imagemagick

GNU-Octave can be used to check if the results
obtained by this library are correct.

INSTALLATION

$ runhaskell Setup.lhs configure --prefix=$HOME
$ runhaskell Setup.lhs build
$ runhaskell Setup.lhs haddock
$ runhaskell Setup.lhs install --user

See below for installation on Windows.

For undetermined reasons compilation with -O in Linux requires -fvia-C.

TESTS

$ runhaskell examples/tests

Additional tests with big matrices (taking a few minutes):

$ runhaskell examples/tests --big

NOTE: On Ubuntu 6.06 LTS (Dapper) atlas3-sse2-dev (3.6.0-20)
produces segmentation faults when working with big matrices 
on compiled programs. To expose the problem:

$ cd examples
$ ghc --make -O -fvia-C tests.hs
$ ./tests --big

If this crashes, just uninstall atlas3-sse2 and use atlas3-base-dev instead.
Fortunately, atlas3-sse2-dev seems to work well on Ubuntu 7.10 Gutsy.
A similar problem was reported at:
    http://article.gmane.org/gmane.linux.debian.devel.bugs.general/323065

EXAMPLES

$ ghci
Prelude> :m + Numeric.GSL
Prelude Numeric.GSL> let quad = integrateQNG 1E-10
Prelude Numeric.GSL> quad (^2) 0 1
(0.3333333333333333,3.700743415417188e-15)

Prelude Numeric.GSL> :m + Numeric.LinearAlgebra
Prelude Numeric.LinearAlgebra> let m = (2><3)[1,2,3,4,5,6::Double]
Prelude Numeric.LinearAlgebra> let (u,d,v) = full svd m
Prelude Numeric.LinearAlgebra> d
(2><3)
 [ 9.508032000695724,                0.0, 0.0
 ,               0.0, 0.7728696356734838, 0.0 ]
Prelude Numeric.LinearAlgebra> u <> d <> trans v
(2><3)
 [ 1.0000000000000004,               2.0, 3.0
 , 3.9999999999999996, 5.000000000000001, 6.0 ]
Prelude Numeric.GSL> :q
Leaving GHCi.

A number of illustrative programs are included in the examples folder.

CHANGES

This is a new version of the library previously known as GSLHaskell.
It has been renamed to "hmatrix" because only a small part of GSL is actually
available, and most linear algebra is based on LAPACK.

The code has been extensively refactored. There is a new internal representation
which admits both C and Fortran matrices and avoids many transposes.

There are only minor API changes:

- The matrix product operator (<>) is now overloaded only for matrix-matrix,
  matrix-vector and vector-matrix, with the same base type. Dot product and scaling
  of vectors or matrices is now denoted by `dot` or (<.>) and `scale` or (.*).
  Conversions from real to complex objects must now be explicit.

- Most linear algebra functions admit both real and complex objects. Utilities such as
  ident or constant are now polymorphic.

- Runtime errors produced by GSL or LAPACK can be handled using Control.Exeception.catch.

Old GSLHaskell code will work with small modifications.

INSTALLATION ON WINDOWS

1) Download the developer files gsl-1.8-lib.zip from
   http://gnuwin32.sourceforge.net/packages/gsl.htm
   and copy the gsl headers folder (under include) to:
       C:\ghc\ghc.6.x.1\include
   These headers are also available from:
       http://perception.inf.um.es/~aruiz/darcs/hmatrix/gsl.zip

2) 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:
       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
   They are required to run the programs and ghci.

5) run the tests

Unfortunately the lapack dll supplied by the R system does not include
zgels_, zgelss_, and zgees_, so the functions depending on them
(linearSolveLS, linearSolveSVD, and schur for complex data)
will produce a "non supported in this OS" runtime error.

If you find an alternative free and complete lapack.dll which works well
for this system please let me know.

The examples using graphics do not yet work in windows.

ACKNOWLEDGEMENTS

I thank Henning Thielemann and all the people in the Haskell mailing lists for their help.

- Nico Mahlo discovered a bug in the eigendecomposition wrapper.

- Frederik Eaton discovered a bug in the design of the wrappers.

- Eric Kidd has created a wiki page explaining the installation on MacOS X:
  http://www.haskell.org/haskellwiki/GSLHaskell_on_MacOS_X

- Fawzi Mohamed discovered a portability bug in the lapack wrappers.

- Pedro E. López de Teruel fixed the interface to lapack.

- Antti Siira discovered a bug in the plotting functions.

- Paulo Tanimoto helped to fix the configuration of the required libraries.