GNU Scientific Library Interface

Achim Gaedke Achim.Gaedke at zpr.uni-koeln.de
Mon Jan 8 08:00:42 EST 2001


My attempt to access several mathematical functions has grown to a
interface for gsl (GNU Scientific Library:
http://sources.redhat.com/gsl/ ).

You may  obtain it here: http://www.zaik.uni-koeln.de/~achim/gsl/

It gives access to 200 special functions, 31
probability-density-functions, about 20 random number generators.

These functions come with the gsl library, just look at:
http://sources.redhat.com/gsl/ref/gsl-ref_toc.html
The actual status of gsl is 0.7 (alpha-version). In my opinion, the
major part of this library is quite stable.

First you will have to install gsl, then get the gsl-interface and
unpack it. Python-2.0 is necessary for easy installation.
Installation can be done as usual:

python ./setup.py install

I'd like to extend this interface together with other people. So far all
wrapper functions are written in plain C, in order to avoid trouble
while porting.
Just contact me, if you would like to help: Achim.Gaedke --at--
zpr.uni-koeln.de.

Here is a short example:

# import special functions
import gsl.sf

# returns a tuple (result, error of result)
print gsl.sf.gamma(1.0)

#the full list of implemented functions, just refer to gsl-ref for
details
print dir(gsl.sf)

#import random number generator and probability densities
import gsl.rng

#gives you the initialised mt19937 random number generator
r=gsl.rng.gsl_rng_mt19937()

#returns the next long int random value
print r.get()

# returns a float value with gaussian probability (sigma=2,mu=0)
print r.gaussian(2)

# displays all implemented rngs
print filter(lambda e:e[:7]=='gsl_rng',dir(gsl.rng))

# displays all implemented densities:
print filter(lambda e:e[-3:]=='pdf',dir(gsl.rng))

--
Achim Gaedke, ZPR
Weyertal 80, 50931 Köln
Tel: +49 221 470 6021






More information about the Python-list mailing list