Skip to content

pedhmendes/gsl

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Gnu Scientific Library

The Library

    A good tool for scientific programmin in C is GNU Scientific Library (GSL). In this page I will leave some codes where some simple functions can be implemented. More informantion can be found in this link.

    If you don't have the library installed, open a terminal and type.

    sudo apt-get update
    sudo apt-get install libgsl-dev

    GSL requires some special flags when compiling, take an example

    gcc programa.c -lgsl -lgslcblas -lm -static

    The last flag is important if you are using some cluster.

Examples

01 - Coupled ODEs

In physics there are some times we find some coupled ODE that we want to solve. Some can be a little bit trick to write an actual algorithm. We can use GSL to solve. In this repo you can find an code where I use the Runge-Kutta-Fehlberg method to solve the SIR epidemiology model. All methods and more info in ODE resolution can be found here.

02 - Random Number Generator

Is not very hard to write linear congruential generator (LCG), but, for cientifical reasons, they can't be taken very serious. GSL library has a list of good RNG that we can use. In this repo you can find an example where I introduce some basic rng functions that GLS has to offer. I choose the Mersenne Twister because it has and period of (219937 - 1) and good proprieties. More options of RNG can be found here.

03 - Numbers Following Distributions

It can be convinient that we generate numbers following some distribution, GSL can do it. This special generators requires and random number as seed, then they return another number following the desired distribution. So we need the RNG, we talked about this above, and we can use one of GSL. We are gonna give the pointer as argument of the function, is not difficult as it sounds. As example there is a code in this repo that uses the Box-Muller method to generate numbers following the Gaussian Distribution. You can check this making and histogram. More information about this generators and more avaiable distributions can be found here.

Releases

No releases published

Packages

No packages published

Languages