package gsl

  1. Overview
  2. Docs
GSL - Bindings to the GNU Scientific Library

Install

Dune Dependency

Authors

Maintainers

Sources

gsl-1.25.1.tbz
sha256=837b2869aa001b1d9c72cc70ac02cc603ff93632f0c67936dacb3bda91c58d60
sha512=dc6f745738d8f2ad6da221c32634c072bb3de397613b76312d46f59ea66459aee8884019ddd88f3ef2d00ccbd015b63a37265dc5dded4d0207e954ae3fa9ec8f

Description

gsl-ocaml interfaces the GSL (GNU Scientific Library), providing many of the most frequently used functions for scientific computation including algorithms for optimization, differential equations, statistics, random number generation, linear algebra, etc.

Published: 26 Nov 2024

README

GSL-OCaml - GSL-Bindings for OCaml

GSL-OCaml is an interface to the GSL (GNU scientific library) for the OCaml-language. The latest GSL-version known to be compatible is 2.0.

Requirements

The platform must not align doubles on double-word addresses, i.e. it should not define the C-macro ARCH_ALIGN_DOUBLE in the OCaml C-configuration header in <caml/config.h>.

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 typically 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. before opam install):

export GSL_CBLAS_LIB=-lopenblas

Note that on Mac OS X GSL-OCaml requires the Apple-specific, highly optimized vendor library vecLib, which is part of the Accelerate-framework, and will automatically link with it. If you do not wish to use Accelerate you can override it; for a Homebrew-installed OpenBlas in the usual place you then need to

export GSL_CBLAS_LIB="-L/usr/local/opt/openblas/lib/ -lopenblas"

Documentation

Read the GSL manual to learn more about the GNU Scientific Library, and also the GSL-OCaml API.

Usage Hints

Vectors and Matrices

Data types for handling vectors and matrices:

  • Modules Gsl.Vector, Gsl.Vector.Single, Gsl.Vector_complex, Gsl.Vector_complex.Single, and the corresponding matrix modules use bigarrays with single or double precision and real or complex values.

  • Modules Gsl.Vector_flat, Gsl.Vector_complex_flat, and the corresponding matrix modules use a record wrapping a regular OCaml float array. This approach mirrors the gsl_vector and gsl_matrix structs in GSL.

  • Module Gsl.Vectmat defines 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.

  • Modules Gsl.Blas Gsl.Blas_flat and Gsl.Blas_gen provide an incomplete interface to CBLAS for these types.

ERROR HANDLING

Errors in GSL functions raise exceptions:

Gsl.Error.Gsl_exn (errno, msg)

You have to call Gsl.Error.init () to initialize error reporting. Otherwise, the default GSL error handler aborts the program, leaving a core dump (rather unhelpful with OCaml).

If a callback (for minimizers, solvers, etc.) raises an exception, GSL-OCaml either returns GSL_FAILURE or NaN to GSL depending on the callback. In either case the original OCaml exception is not propagated. The GSL function will either return succesfully (but probably with values containing NaNs somewhere) or raise a Gsl_exn exception.

Contact Information and Contributing

Please submit bugs reports, feature requests, contributions to the GitHub issue tracker.

Up-to-date information is available at: https://mmottl.github.io/gsl-ocaml

Dependencies (5)

  1. conf-pkg-config build
  2. conf-gsl build
  3. dune-configurator
  4. ocaml >= "4.12"
  5. dune >= "2.7"

Dev Dependencies (1)

  1. odoc with-doc

Used by (10)

  1. biotk >= "0.2.0"
  2. curve-sampling >= "0.2"
  3. gpr
  4. libsvm = "0.9.0"
  5. orpie
  6. owl >= "0.2.9" & < "0.3.7"
  7. pareto
  8. phylogenetics
  9. prbnmcn-dagger-gsl < "0.0.3"
  10. prc

Conflicts

None

OCaml

Innovation. Community. Security.