Setting Up GNU Scientific Library (GSL)

Introduction

I have a few scientific computing projects that I would like to do which will require a good numerical methods library. I am going to try to use GSL.

Getting the Library

Getting the library install was easy enough, just needed to use apt-get

sudo apt-get install libgsl-dev

To check that the installation succeeded:

ldconfig -p | grep gsl 

Which resulted in:

First Example

To test the library I grabbed a basic example from the documentation:

#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;
}

and compiled it with the following:

g++ main.cpp -lgsl -o test

running the binary yields:

 

which I guess is the value of the first Bessel Function at 5?


 

Comments

Popular posts from this blog

Passwordless SSH