The GNU Scientific Library (or GSL) is a
software library for numerical computations in
applied mathematics
Applied mathematics is the application of mathematics, mathematical methods by different fields such as physics, engineering, medicine, biology, finance, business, computer science, and Industrial sector, industry. Thus, applied mathematics is a ...
and
science
Science is a systematic discipline that builds and organises knowledge in the form of testable hypotheses and predictions about the universe. Modern science is typically divided into twoor threemajor branches: the natural sciences, which stu ...
. The GSL is written in
C; wrappers are available for other programming languages. The GSL is part of the
GNU Project
The GNU Project ( ) is a free software, mass collaboration project announced by Richard Stallman on September 27, 1983. Its goal is to give computer users freedom and control in their use of their computers and Computer hardware, computing dev ...
and is distributed under the
GNU General Public License
The GNU General Public Licenses (GNU GPL or simply GPL) are a series of widely used free software licenses, or ''copyleft'' licenses, that guarantee end users the freedom to run, study, share, or modify the software. The GPL was the first ...
.
Project history
The GSL project was initiated in 1996 by physicists Mark Galassi and James Theiler of
Los Alamos National Laboratory.
[GSL homepage](_blank)
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.
Other major contributors were
Jim Davies, Reid Priedhorsky, M. Booth, and F. Rossi.
Version 1.0 was released in 2001. In the following years, the library expanded only slowly; as the documentation stated, the maintainers were more interested in stability than in additional functionality. Major version 1 ended with release 1.16 of July 2013; this was the only public activity in the three years 2012–2014.
Vigorous development resumed with publication of version 2.0 in October 2015, which included user contributed patches. The latest version 2.8 was released in May 2024.
Example
The following example program calculates the value of the
Bessel function of the first kind and order zero for 5:
#include
#include
int main(void)
The example program has to be linked to the GSL library
upon compilation:
$ gcc $(gsl-config --cflags) example.c $(gsl-config --libs)
The output is shown below and should be correct to
double-precision accuracy:
J0(5) = -1.775967713143382920e-01
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
AMPL (A Mathematical Programming Language) is an algebraic modeling language to describe and solve high-complexity problems for large-scale mathematical computing (e.g. large-scale optimization and scheduling-type problems).
It was developed ...
*
C++[ccgsl: a C++ interface for the GNU Scientific Library](_blank)
[GSL-- C++ wrappers for GSL](_blank)
;[GSLwrap: A C++ wrapper class for the GNU Scientific Library](_blank)
[gslcpp: A Header-Only, Modern C++-Library Wrapping the GNU Scientific Library](_blank)
*
Fortran
*
Haskell
Haskell () is a general-purpose, statically typed, purely functional programming language with type inference and lazy evaluation. Designed for teaching, research, and industrial applications, Haskell pioneered several programming language ...
[The hmatrix-special package, an interface to GSL special functions](_blank)
[The hmatrix-gsl package, a purely functional interface to selected numerical computations, internally implemented using GSL](_blank)
*
Java
Java is one of the Greater Sunda Islands in Indonesia. It is bordered by the Indian Ocean to the south and the Java Sea (a part of Pacific Ocean) to the north. With a population of 156.9 million people (including Madura) in mid 2024, proje ...
*
Julia
*
Common Lisp
Common Lisp (CL) is a dialect of the Lisp programming language, published in American National Standards Institute (ANSI) standard document ''ANSI INCITS 226-1994 (S2018)'' (formerly ''X3.226-1994 (R1999)''). The Common Lisp HyperSpec, a hyperli ...
*
OCaml
OCaml ( , formerly Objective Caml) is a General-purpose programming language, general-purpose, High-level programming language, high-level, Comparison of multi-paradigm programming languages, multi-paradigm programming language which extends the ...
*
Octave
In music, an octave (: eighth) or perfect octave (sometimes called the diapason) is an interval between two notes, one having twice the frequency of vibration of the other. The octave relationship is a natural phenomenon that has been referr ...
*
Perl Data Language
*
Python
*
R
*
Ruby
Ruby is a pinkish-red-to-blood-red-colored gemstone, a variety of the mineral corundum ( aluminium oxide). Ruby is one of the most popular traditional jewelry gems and is very durable. Other varieties of gem-quality corundum are called sapph ...
*
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''.
Pointers to member functions
. Instead, pointers to static functions have to be used. Another common workaround is using a functor
In mathematics, specifically category theory, a functor is a Map (mathematics), mapping between Category (mathematics), categories. Functors were first considered in algebraic topology, where algebraic objects (such as the fundamental group) ar ...
.
C++ wrappers for GSL are available. Not all of these are regularly maintained. They do offer access to matrix and vector classes without having to use GSL's interface to malloc and free functions. Some also offer support for also creating workspaces that behave like Smart pointer classes. Finally, there is (limited, as of April 2020) support for allowing the user to create classes to represent a parameterised function as a functor
In mathematics, specifically category theory, a functor is a Map (mathematics), mapping between Category (mathematics), categories. Functors were first considered in algebraic topology, where algebraic objects (such as the fundamental group) ar ...
.
While not strictly wrappers, there are some C++ classes [o2scl Object-oriented Scientific Computing Library](_blank)
[yat](_blank)
that allow C++ users to use the Gnu Scientific Library with wrapper features.
See also
* List of numerical-analysis software
* List of numerical libraries
* Netlib
* '' Numerical Recipes''
Notes
References
External links
*
GSL Design Document
* Th
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.
{{GNU
C (programming language) libraries
Free computer libraries
Free software programmed in C
Scientific Library
Mathematical libraries
Numerical libraries
Numerical software
Articles with example C code
Software using the GNU General Public License