GSL-OCaml - GSL-Bindings for OCaml
GSL-OCaml is an interface to the GSL (GNU scientific library) for the OCaml-language. The currently latest GSL-version known to be compatible is 2.0.
The platform must not align doubles on double-word addresses, i.e. the C-macro
ARCH_ALIGN_DOUBLE must be undefined in the OCaml C-configuration header in
Configuring alternative BLAS-libraries
The underlying GSL-library depends on a C-implementation of the BLAS-library
(Basic Linear Algebra Subroutines). It comes with its own implementation,
gslcblas, which GSL will link with by default.
This implementation is usually considerably slower than alternatives like OpenBLAS or ATLAS (Automatically Tuned Linear Algebra Software) or miscellaneous platform-specific vendor implementations.
If you want GSL-OCaml to link with another BLAS-implementation by default, you
will need to set an environment variable before starting the build process (e.g.
$ export GSL_CBLAS_LIB=-lopenblas
Note that on Mac OS X GSL-OCaml requires the Apple-specific, highly optimized
vecLib, which is part of the Accelerate-framework, and will
automatically link with it (unless overridden with
Read the GSL manual to learn more about the GNU Scientific Library, and also the GSL-OCaml API.
Vectors and Matrices
There are several data types for handling vectors and matrices.
Gsl.Vector_complex.Single, and the corresponding matrix modules use bigarrays with single or double precision and real or complex values.
Gsl.Vector_complex_flat, and the corresponding matrix modules use a record wrapping a regular OCaml float array. This is the equivalent of the
gsl_matrixstructs in GSL.
Gsl.Vectmatdefines a sum type with polymorphic variants that regroups these two representations. For instance:
Gsl.Vectmat.v_add (`V v1) (`VF v2)
adds a vector in an OCaml array to a bigarray.
Gsl.Blas_genprovide a (quite incomplete) interface to CBLAS for these types.
Errors in GSL functions are reported as exceptions:
Gsl.Error.Gsl_exn (errno, msg)
You have to call
Gsl.Error.init () to initialize error reporting. Otherwise,
the default GSL error handler is used and aborts the program, leaving a core
dump (not so helpful with OCaml).
If a callback (for minimizers, solvers, etc.) raises an exception, GSL-OCaml
NaN to GSL depending on the type of callback.
In either case the original OCaml exception is not propagated. The GSL function
will either return normally (but probably with values containing
somewhere) or raise a
Contact Information and Contributing
Please submit bugs reports, feature requests, contributions and similar to the GitHub issue tracker.
Up-to-date information is available at: https://mmottl.github.io/gsl-ocaml