package gsl
Install
Dune Dependency
Authors
Maintainers
Sources
sha256=bac9cf86c46a38c10fad54faa834846bfce40ac628ba6bc612a6b5af3ca8be89
sha512=4e7692426e2f87b3c099f0cb2feed08f3b68cfedaffac131768638d09b84715636bc570f3a806387897df972fa9cdd191f5cc291a0c291fa120e157bce1fb1ed
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: 05 Aug 2020
README
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.
Requirements
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 <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 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. 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
There are several 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 is the equivalent of thegsl_vector
andgsl_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
andGsl.Blas_gen
provide a (quite incomplete) interface to CBLAS for these types.
ERROR HANDLING
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 either returns GSL_FAILURE
or 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 NaN
s somewhere) or raise a Gsl_exn
exception.
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
Dependencies (7)
-
stdio
build
-
base
build
-
conf-pkg-config
build
-
conf-gsl
build
- dune-configurator
-
dune
>= "1.10"
-
ocaml
>= "4.08" & < "5.0"
Dev Dependencies
None
Used by (9)
-
biotk
>= "0.2.0"
-
curve-sampling
>= "0.2"
- gpr
-
libsvm
= "0.9.0"
- orpie
-
owl
>= "0.2.9" & < "0.3.7"
- pareto
- phylogenetics
- prc
Conflicts
None