Development/GSL: Difference between revisions
Line 24: | Line 24: | ||
<br> |
<br> |
||
= Description = |
= Description = |
||
The '''GNU Scientific Library''' ('''GSL''') is a software library for numerical computations in applied mathematics and science. |
The '''GNU Scientific Library''' ('''GSL''') is a software library for numerical computations in applied mathematics and science. GSL is written in C, but bindings exist for other programming languages as well. The library provides a wide range of mathematical routines such as random number generators, special functions and least-squares fitting. There are over 1000 functions in total with an extensive test suite. |
||
<br> |
|||
The GNU Scientific Library (GSL) is a numerical library for C and C++ programmers. |
|||
<br> |
|||
The library provides a wide range of mathematical routines such as random number generators, special functions and least-squares fitting. There are over 1000 functions in total with an extensive test suite. |
|||
<br> |
<br> |
||
<br> |
<br> |
Revision as of 23:22, 2 June 2021
Description | Content |
---|---|
module load | numlib/gsl |
Availability | bwUniCluster_2.0 | BwForCluster_JUSTUS_2 |
License | GNU General Public License (GPL) |
Citing | M. Galassi et al., GNU Scientific Library Reference Manual (3rd Ed.), ISBN 0954612078. |
Links | Homepage | Documentation |
Graphical Interface | No |
Description
The GNU Scientific Library (GSL) is a software library for numerical computations in applied mathematics and science. GSL is written in C, but bindings exist for other programming languages as well. The library provides a wide range of mathematical routines such as random number generators, special functions and least-squares fitting. There are over 1000 functions in total with an extensive test suite.
The complete range of subject areas covered by the library includes
• Complex Numbers • Roots of Polynomials • Special Functions • Vectors and Matrices • Permutations • Sorting • BLAS Support • Linear Algebra • Eigensystems • Fast Fourier Transforms • Quadrature • Random Numbers • Quasi-Random Sequences • Random Distributions • Statistics • Histograms • N-Tuples • Monte Carlo Integration • Simulated Annealing • Differential Equations • Interpolation • Numerical Differentiation • Chebyshev Approximation • Series Acceleration • Discrete Hankel Transforms • Root-Finding • Minimization • Least-Squares Fitting • Physical Constants • IEEE Floating-Point • Discrete Wavelet Transforms • Basis splines • Running Statistics • Sparse Matrices and Linear Algebra
Availability
GSL is available on selected bwHPC-Clusters. A complete list of versions currently installed on the bwHPC-Clusters can be obtained from the Cluster Information System (CIS).
In order to check which versions of GSL are installed on the compute cluster, run the following command:
$ module avail numlib/gsl
Documentation
Online
Local
- info gsl
- man gsl
- man gsl-config
Usage
Loading the module
You can load the default version of GSL with the following command:
$ module load numlib/gsl
The module will try to load all modules it needs to function (e.g., compiler, mpi, ...). If loading the module fails, check if you have already loaded one of those modules, but not in the version required by GSL.
If you wish to load another (older) version of GSL, you can do so using
$ module load numlib/gsl/<version>
with <version> specifying the desired version.
GSL-Specific Environments
To see a list of all GSL environments set by the 'module load'-command use 'env | grep GSL'.
Or use the command 'module show numlib/gsl'.
$ module show numlib/gsl ----------------------------------------------------------------- /opt/bwhpc/common/modulefiles/numlib/gsl/1.16-intel-13.1: GSL_VERSION = 1.16 GSL_HOME = /opt/bwhpc/common/numlib/gsl/1.16-intel-13.1 GSL_BIN_DIR = /opt/bwhpc/common/numlib/gsl/1.16-intel-13.1/bin GSL_INC_DIR = /opt/bwhpc/common/numlib/gsl/1.16-intel-13.1/include GSL_LIB_DIR = /opt/bwhpc/common/numlib/gsl/1.16-intel-13.1/lib GSL_STA_DIR = /opt/bwhpc/common/numlib/gsl/1.16-intel-13.1/lib GSL_SHA_DIR = /opt/bwhpc/common/numlib/gsl/1.16-intel-13.1/lib GSL_MAN_DIR = /opt/bwhpc/common/numlib/gsl/1.16-intel-13.1/share/man GSL_INF_DIR = /opt/bwhpc/common/numlib/gsl/1.16-intel-13.1/share/info GSL_DOC_DIR = /opt/bwhpc/common/numlib/gsl/1.16-intel-13.1/share/doc GSL_EXA_DIR = /opt/bwhpc/common/numlib/gsl/1.16-intel-13.1/share/doc/examples GSL_WWW http://www.gnu.org/software/gsl/ PATH = /opt/bwhpc/common/numlib/gsl/1.16-intel-13.1/bin:$PATH MANPATH = /opt/bwhpc/common/numlib/gsl/1.16-intel-13.1/share/man:$MANPATH INFOPATH = /opt/bwhpc/common/numlib/gsl/1.16-intel-13.1/share/info:$INFOPATH LD_LIBRARY_PATH = /opt/bwhpc/common/numlib/gsl/1.16-intel-13.1/lib:$LD_LIBRARY_PATH INCLUDE = /opt/bwhpc/common/numlib/gsl/1.16-intel-13.1/include:$INCLUDE [...]
How To Use the Library
Includes
Your source code should contain preprocessor include statements with a gsl/ prefix, such as
#include <gsl/gsl_math.h>
Compile
A typical compilation command for a source file example.c with the Intel C compiler icc is
$ icc -Wall -I$GSL_INC_DIR -c example.c
The $GSL_INC_DIR environment variable points to location of
the include path for the gsl header files.
Link
The following command can be used to link the application with the gsl libraries.
$ icc -L$GSL_LIB_DIR -o example example.o -lgsl -lgslcblas -lm
The $GSL_LIB_DIR environment variable points to the location
of the gsl libraries.
Also make sure to have the GSL-module loaded before running applications build
with this library.
Example C-Source Code
Create source code file 'intro.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;
}
Compile and Link
Load the GSL module for the Intel compiler, compile, link and run the program
$ module load numlib/gsl/1.16-intel-13.1 Loading module dependency 'compiler/intel/13.1'. $ icc -Wall -I$GSL_INC_DIR -c intro.c $ icc -L$GSL_LIB_DIR -o intro intro.o -lgsl -lgslcblas -lm $ ./intro J0(5) = -1.775967713143382642e-01