The GNU Scientific Library (or GSL) is a software library for numerical computations in applied mathematics and science. The GSL is written in C; wrappers are available for other programming languages. The GSL is part of the GNU Project and is distributed under the GNU General Public License.
Project history
The GSL project was initiated in 1996 by physicists Mark Galassi and James Theiler of Los Alamos National Laboratory. They aimed at writing a modern replacement for widely used but somewhat outdated Fortran libraries such as Netlib. They carried out the overall design and wrote early modules; with that ready they recruited other scientists to contribute.
The "overall development of the library and the design and implementation of the major modules" was carried out by Brian Gough and Gerard Jungman.
<syntaxhighlight lang="c">
- include <stdio.h>
- include <gsl/gsl_sf_bessel.h>
int main(void)
{
double x = 5.0;
double y = gsl_sf_bessel_J0(x);
printf("J0(%g) = %.18e\n", x, y);
return 0;
}
</syntaxhighlight>
The example program has to be linked to the GSL library
upon compilation:
<syntaxhighlight lang="console">
$ gcc $(gsl-config --cflags) example.c $(gsl-config --libs)
</syntaxhighlight>
The output is shown below and should be correct to double-precision accuracy:
<syntaxhighlight lang="output">
J0(5) = -1.775967713143382920e-01
</syntaxhighlight>
Features
The software library provides facilities for:
Programming-language bindings
Since the GSL is written in C, it is straightforward to provide wrappers for other programming languages. Such wrappers currently exist for
- AMPL
- C++
- Fortran
- Haskell
- Java
- Julia
- Common Lisp
- Nim
- OCaml
- Octave
- Perl Data Language
- Python
- R
- Ruby
- Rust
C++ support
The GSL can be used in C++ classes, but not using pointers to member functions, because the type of pointer to member function is different from pointer to function. Instead, pointers to static functions have to be used. Another common workaround is using a functor.
C++ wrappers for GSL are available. that allow C++ users to use the Gnu Scientific Library with wrapper features.
See also
- List of numerical-analysis software
- List of numerical libraries
- List of open-source mathematical libraries
- Netlib
- Numerical Recipes
Notes
References
External links
- GSL Design Document
- The gsl package for R (programming language), an R wrapper for the special functions and quasi random number generators.
- FLOSS FOR SCIENCE interview with Mark Galassi on the history of GSL.
