Haskell bindings to L-BFGS-B

More information can be found at Hackage. Since the package probably fails to build there, due to the L-BFGS-B library missing, the Haddock documentation might not exist. The missing Haddock documentation can be viewed here instead.

Version can also be downloaded from here.

Building L-BFGS-B as a shared library

The bindings expect to find L-BFGS-B 3.0 as a shared library liblbfgsb.so.0 built by a relatively recent version of GFortran. L-BFGS-B can be downloaded from its author's webpage, but the included makefile does not build shared libraries.

To do so, unpack the tarball and build with:

gfortran -O2 -shared -Wl,-soname,liblbfgsb.so.0 -o liblbfgsb.so.0 -fPIC lbfgsb.f linpack.f timer.f -lblas

If you prefer to use the included (subset of) BLAS instead of linking to libblas, omit -lblas and add blas.f.

Place liblbfgsb.so.0 anywhere in GHC's linker search path, or use the -L flag.

Alternatively, Debian/Ubuntu packages with the shared library can be found in this PPA. The Haskell bindings are packaged here.

Patching L-BFGS-B

The L-BFGS-B library is supposed to be quiet when the iprint argument is negative. There are, however, two places in the code where this is ignored. Since the Haskell bindings wrap FFI calls to L-BFGS-B in unsafePerformIO, we really don't want L-BFSG-B to print anything. This patch silences L-BFGS-B.

The L-BFGS-B library uses an internal copy of LINPACK for some linear algebra computations. LAPACK supersedes LINPACK, and this patch makes L-BFGS-B use it instead. If this patch is used, liblbfgsb0.so.0 must be dynamically linked against LAPACK. To this end, remove linpack.f from the above compilation command, and add instead -llapack.

The Debian/Ubuntu package in this PPA has both patches.