WARNING: some of these instructions are now very out of date. However, there is a CI script which shows what does work; you are advised to look at that and emulate its installation steps.
This package requires GHC 7.8, cabal-install (available in the Haskell Platform), and the development packages for BLAS/LAPACK and GSL.
Ubuntu/Debian:
$ sudo apt-get install libgsl0-dev liblapack-dev libatlas-base-dev
$ cabal update
$ cabal install hmatrix-tests
Other distributions may require additional libraries. They can be given in a --configure-option.
Adrian Victor Crisciu has developed an installation method for systems which don't provide shared lapack libraries.
GSL must be installed via Homebrew or MacPorts.
Via Homebrew:
$ brew install gsl
$ cabal install hmatrix
Via MacPorts:
$ sudo port install gsl +universal
$ cabal install hmatrix
(Contributed by Heinrich Apfelmus, Torsten Kemps-Benedix and Ted Fujimoto).
-
Install the Haskell Tool Stack tool (
stack
). How to do that is explained here. -
Get, and link to the import library of, the OpenBLAS library. There are various ways to do that. Perhaps the easiest is to use MSYS2 to get it, which is explained in the steps under subheading 2(a) below.
-
stack
comes with a version of MSYS2. It is located in a subfolder of the folder returned by thestack path --programs
command. At the time of writing (28 July 2020), that subfolder ismsys2-20180531
. Change directory to that folder. In PowerShell:> stack path --programs | cd > cd msys2-20180531
-
Open a MSYS2 terminal window, with the
msys2_shell.cmd
command. In PowerShell:> .\msys2_shell.cmd
-
In principle, MSYS2 itself can be updated with the
pacman -Syu
command. At the time of writing, that may be complicated by keyring issues (see here to overcome such issues). In MSYS2:$ pacman -Syu
-
Use MSYS2 to install the OpenBLAS package (and its dependencies). In MSYS2:
$ pacman -S mingw-w64-x86_64-openblas
MSYS2 will put the import libraries in subfolder
\ming64\lib
. Thestack
enviroment will automatically add that folder to the list of library folders (see, back in PowerShell, the result of commandstack path --extra-library-dirs
). -
hmatrix
depends on OpenBLAS.hmatrix-gsl
depends on GSL (the GNU Scientific Library) andhmatrix-glpk
depends on GLPK (the GNU Linear Programming Kit). You can use MSYS2 to install GSL and GLPK packages too. In MSYS2:$ pacman -S mingw-w64-x86_64-gsl $ pacman -S mingw-w64-x86_64-glpk
Again, MSYS2 will put the import libraries in subfolder
\ming64\lib
. -
In
hmatrix.cabal
, ensure that theextra-libraries
specifiesopenblas
(only). (This is incorrect inhmatrix-0.20.0.0
.) That is, the extract should read:if os(windows) if flag(openblas) extra-libraries: openblas else extra-libraries: blas lapack
-
Similarly, in
hmatrix-gsl.cabal
, ensure that theextra-libraries
specifiesgsl
(only). (This is incorrect inhmatrix-gsl-0.19.0.1
.) That is, the extract should read:if os(windows) extra-libraries: gsl
-
stack ghci
can be invoked in the repository root folder (hmatrix
) with an appropriateresolver
and setting the flagopenblas
for packagehmatrix
. At the time of writing,resolver nightly-2020-07-28
works with GHC 8.10.1. In PowerShell:> stack --resolver nightly-2020-07-28 ghci --flag hmatrix:openblas
(At the time of writing, GHC 8.8.3 does not work with Windows 10 version 2004. To use GHC 8.10.1, the upper bound of
base
inexamples.cabal
must be set to be at least 4.14.) -
In GHCi, test the
Numeric.LinearAlbebra
module with the following (the successful output has many lines and so is shortened below):> Numeric.LinearAlgebra.Tests.runTests 20 ------ index +++ OK, passed 100 tests. +++ OK, passed 100 tests. ... +++ OK, passed 100 tests. ------ some unit tests Cases: 52 Tried: 52 Errors: 0 Failures: 0
WARNING: these alternative instructions may be out of date.
-
Download and unzip somewhere OpenBLAS http://www.openblas.net/
-
In MSYS2 console of Stack, i.e.: C:\Users{User}\AppData\Local\Programs\stack\x86_64-windows\msys2-{version}\msys2_shell.bat
$ cd /.../OpenBLAS $ pacman -Sy $ pacman -S make perl gcc-fortran $ make clean $ make $ make install
-
Then in normal Windows console for building hmatrix base lib (fill in user name, versions and check if paths are different on your machine):
> stack install --flag hmatrix:openblas --extra-include-dirs=C:\Users\{User}\AppData\Local\Programs\stack\x86_64-windows\msys2-20150512\opt\OpenBLAS\include --extra-lib-dirs=C:\Users\{User}\AppData\Local\Programs\stack\x86_64-windows\msys2-20150512\opt\OpenBLAS\bin --extra-lib-dirs=C:\Users\{User}\AppData\Local\Programs\stack\x86_64-windows\msys2-20150512\usr\lib\gcc\x86_64-pc-msys\6.3.0\
-
(Not tested). It should be possible to install the new package hmatrix >= 0.16 using the dlls contributed by Gilberto Camara available in gsl-lapack-windows.zip.
-
cabal update
-
Download and unzip gsl-lapack-windows.zip into a stable folder %GSL%
3.a) In a msys shell:
$ cabal install hmatrix-0.13.1.0 --extra-lib-dir=${GSL} --extra-include-dirs=${GSL}
3.b) In a normal windows cmd:
> cabal install --extra-lib-dir=%GSL% --extra-include-dirs=%GSL%
It may be necessary to put the dlls in the search path.
It is expected that a future version of the new hmatrix-gsl package can also be installed using this method.
> cabal update
-
Download and unzip somewhere OpenBLAS http://www.openblas.net/
-
In a normal Windows cmd:
cabal install --flags=openblas --extra-lib-dirs=C:...\OpenBLAS\lib --extra-include-dirs=C:...\OpenBLAS\include
After installation we can verify that the library works as expected:
$ cabal install hmatrix-tests
$ ghci
> Numeric.LinearAlgebra.Tests.runTests 20
+++ OK, passed 100 tests.
+++ OK, passed 100 tests.
... etc...
+++ OK, passed 100 tests.
------ some unit tests
Cases: 71 Tried: 71 Errors: 0 Failures: 0