Difference between revisions of "GNU Scientific Library (GSL)"

From bwHPC Wiki
Jump to: navigation, search
(Created page with " The '''GNU Scientific Library''' (or '''GSL''') is a software library for numerical computations in applied mathematics and science. The GSL is written in the C programming lang…")
 
(Redirected page to GSL)
(Tag: New redirect)
 
(10 intermediate revisions by 2 users not shown)
Line 1: Line 1:
  +
#REDIRECT[[GSL]]
 
The '''GNU Scientific Library''' (or '''GSL''') is a software library for numerical computations in applied mathematics and science. The GSL is written in the C programming language, but bindings exist for other languages as well.
 
 
'''Online-Documentation:''' http://www.gnu.org/software/gsl/
 
 
'''Local-Documentation:'''
 
 
See 'info gsl', 'man gsl' and 'man gsl-config'.
 
 
'''Tips for compiling and linking:'''
 
 
Load the gsl module. After having loaded the gsl environment module, you can use several
 
environment variables to compile and link your application with the gsl library.
 
 
Your source code should contain preprocessor include statements with a gsl/ prefix, such as
 
 
<pre> #include <gsl/gsl_math.h></pre>
 
 
A typical compilation command for a source file example.c with the
 
Intel C compiler icc is
 
 
<pre> $ icc -Wall -I$GSL_INC_DIR -c example.c </pre>
 
 
The $GSL_INC_DIR environment variable points to location of
 
the include path for the gsl header files.
 
 
The following command can be used to link the application with the
 
gsl libraries,
 
 
<pre> $ icc -L$GSL_LIB_DIR -o example example.o -lgsl -lgslcblas -lm </pre>
 
 
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'''
 
 
Create source code file 'intro.c':
 
 
{| style="width: 100%; border:1px solid #d0cfcc; background:#f2f7ff;border-spacing: 2px;"
 
| style="width:280px; text-align:center; white-space:nowrap; color:#000;" |
 
<source 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;
 
}
 
</source>
 
|}
 
 
Load the gsl module for the Intel compiler, compile, link and run the program:
 
 
<pre>
 
$ 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
 
</pre>
 
[[Category: Numerical libraries]]
 

Latest revision as of 22:25, 4 February 2022

Redirect to: