GSLL

GNU Scientific Library for Lisp

Introduction

The GNU Scientific Library for Lisp (GSLL) allows you to use the GNU Scientific Library (GSL) from Common Lisp. This library provides a full range of common mathematical operations useful to scientific and engineering applications. The design of the GSLL interface is such that access to most of the GSL library is possible in a Lisp-natural way; the intent is that the user not be hampered by the restrictions of the C language in which GSL has been written. GSLL thus provides interactive use of GSL for getting quick answers, even for someone not intending to program in Lisp.

This code should be considered alpha but it is largely usable now, with some GSL capability not yet available. See Development section below.

This software is distributed under the GPL and FDL. See COPYING.

Examples

The Jacobian elliptic functions sn, cn, and dn are special functions (Chapter 7):

(jacobian-elliptic-functions 0.2d0 0.81d0)
0.19762082367187703d0
0.9802785369736752d0
0.9840560289645665d0
1.828927267118668d-318
1.4821969375237396d-321
2.023692885365746d-320

which returns the three function values in succession, along with the estimated errors of each. The functions are defined only if the second argument m is not greater than 1, so an error is signalled if this parameter is out of range:

(jacobian-elliptic-functions 0.61802d0 1.5d0)
debugger invoked on a GSL-ERROR in thread #:
  Input domain error (EDOM), |m| > 1.0 in elljac.c at line 46

Documentation

There is little separate documentation for GSLL. Instead, the following techniques for using the API are advised:

It is advisable to look at the examples first for calculations that require more complex setup (generally, the later chapters in the GSL manual) because often there are convenience macros defined to make the setup simpler.

Requirements and Platforms

GSLL should work in any Common Lisp implementation and platform combination that has CFFI with callbacks and defcfun support. You will need

In Debian, the following should work:

apt-get install libgsl0 cl-cffi
(asdf is automatically installed with your CL implementation).

Once your CL implementation is running, do

(asdf:operate 'asdf:compile-op :gsll)
      

or, if using Debian with the common-lisp-controller,

(clc:clc-require :gsll)

GSLL has been tested with SBCL on Debian i386 and amd64.

Source downloads [not yet available]

You may browse or download the Subversion repository at svn://common-lisp.net/project/gsll/subversion/trunk. For example,

svn list svn://common-lisp.net/project/gsll/subversion/trunk
svn checkout svn://common-lisp.net/project/gsll/subversion/trunk
.

Project Development

This project has been in development since March 2006. A majority is done, but there is still much work to do. The status is summarized below, by reference to the Chapters in the GSL manual.

It is possible that the library API will change but probably not substantially; most of the remaining work involves added functions. GSLL is written in pure Common Lisp; there is no C "glue" layer. As such, most every function can be defined with the supplied macro defun-gsl, which simplifies the process of porting. The arguments and defaults provide a convenient way of defining new functions; it is likely this will not change as the rest of GSL functionality is added to GSLL. Where functions in the GSL library do input and output to files, the remainder of the necessary file-related operations must also be performed in C; no CL interface is yet provided.

A Trac web page will soon be set up for those interested in development, and for reporting bugs. In the meantime, send email to me at this address: lhealy -at- common-lisp -dot- net.

In addition to the chapters below, it would be nice if the following were done

The following is not part of the plan for the GSLL interface:

The following is the status of the project by GSL manual chapter. When marked "Done" it means that all or a substantial portion that is planned that GSLL will cover has been defined and some of those definitions have been tested. Improvements may still be desirable.

ChapterStatus
Mathematical Functions Done
Complex NumbersUnneeded
PolynomialsDone
Special Functions Done
Vectors and Matrices Done for integer, real, double, complex; subvectors don't work
Permutations Done
Combinations Done
Sorting Done
BLAS Done?
Linear Algebra Done
Eigensystems Done
FFTs Not started (needs knowledge of C usage)
Numerical Integration Done
Random Number Generation Done
Quasi-Random Sequences Done
Random Number Distributions Done
Statistics Done
Histograms Done
N-Tuples Done
Monte Carlo Integration Done
Simulated Annealing Done but broken
Ordinary Differential Equations Done
Interpolation Done
Numerical Differentiation Done
Chebyshev Approximations Done
Series Acceleration Done
Wavelet Transforms Done but example disagrees with C
Discrete Hankel Transforms Done but untested (no example available)
One-dimensional Root Finding Done
One-dimensional Minimization Done
Multidimensional Root Finding Done
Multidimensional Minimization Done
Least Squares Fitting Done
Nonlinear Least Squares Fitting Done
Basis Splines Not started

Regression Tests

Regression tests using lisp-unit (provided) are given for many of the functions defined. These also serve as examples. The judgement of floating point numbers as equivalent is a hack, and needs to be replaced; I am looking for good ideas. Note that most of the result have not been verified with an independent source; the values given are from previous tests. To run the tests,

(lisp-unit:run-tests)
and expect a few failures on amd64 (four), none? on i386. Often, the failures aren't really failures, just floating point numbers that aren't close enough to pass.

Related projects from others

A partial automatically-generated interface to GSL is provided in cl-gsl. A matlab-like array syntax and plotting is provided by NLISP which might work well with GSLL. Some math functions implemented natively in CL are provided in cl-numlib.