Commit 103e85d1 authored by liam's avatar liam
Browse files

Fix minor bugs that were revealed by running tests in amd64. Bug in

sorting still not resolved.  Created a home page.

git-svn-id: svn+ssh://pop/opt/space/mathematics/gsl/trunk@3189 a3d8a0fb-c1db-0310-ace7-a616afeb9e30
parent 8c92fe16
......@@ -3,7 +3,7 @@
; description: Vectors
; date: Sun Mar 26 2006 - 11:51
; author: Liam M. Healy
; modified: Sun Feb 18 2007 - 19:08
; modified: Sun Mar 4 2007 - 09:40
;;; $Id: $
......@@ -52,6 +52,8 @@ deallocated with the vector.
(defdata "vector_float" vector-single single-float gsl-vector)
(defdata "vector_int" vector-fixnum fixnum gsl-vector)
(defdata "vector_complex" vector-complex complex gsl-vector)
;;; (defdata "vector_uint" vector-unsigned-fixnum (unsigned-byte 64) gsl-vector)
;;; doesn't work 2007-03-04.
(defmacro defun-gsl-vdsfc (&rest args)
"A defun-gsl for vectors of double, single, fixnum, and complex."
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "">
<html xmlns="">
<link rel="stylesheet" href="style.css" type="text/css"/>
<title>GSLL, the GNU Scientific Library for Lisp</title>
<div class="body">
<div class="header">
<h2>GNU Scientific Library for Lisp</h2>
<div class="content">
<p>The GNU Scientific Library for Lisp (GSLL) allows you to use
the <a href="">GNU Scientific
Library (GSL)</a> 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.
<p>This code should be considered alpha but it is largely usable
now, with some GSL capability not yet available. See
Development section below.</p>
<p>This software is distributed under the <a
and <a href="">FDL</a>.
??? REally; can't find it in the source code.???
If the GSL docstrings are included, the ??? text ???? must
be included in any distribution, as required by the FDL.
The remainder of the source code is licensed under the GPL.
<div class="content">
<p>The Jacobian elliptic functions <i>sn</i>, <i>cn</i>, and
<i>dn</i> are special functions (Chapter 7):</p>
(jacobian-elliptic-functions 0.2d0 0.81d0)
<p>which returns the three function values in succession, along
with the estimated errors of each. The functions are defined
only if the second argument <i>m</i> is not greater than 1,
so an error is signalled if this parameter is out of range: </p>
(jacobian-elliptic-functions 0.61802d0 1.5d0)
debugger invoked on a GSL-ERROR in thread #<THREAD "initial thread" {10032258C1}>:
Input domain error (EDOM), |m| > 1.0 in elljac.c at line 46
<div class="content">
<p>There is little separate documentation for GSLL. Instead, the
following techniques for using the API are advised:</p>
<li>Find the appropriate function(s) in the <a
<li>Use the GSLL function gsl-lookup
to find the equivalent GSLL function, for example
(gsl-lookup "gsl_sf_elljac_e")
((JACOBIAN-ELLIPTIC-FUNCTIONS . "gsl_sf_elljac_e"))
to find that the Lisp function name is #'JACOBIAN-ELLIPTIC-FUNCTIONS.
<li>Look at the documentation for that Lisp function, e.g.
<pre>(documentation #'jacobian-elliptic-functions 'function)
"The Jacobian elliptic functions @math{sn(u|m)},
@math{cn(u|m)}, @math{dn(u|m)} computed by descending Landen
to get an explanation of the arguments etc.
<li>Look at the end of the Lisp source file for examples.</li>
<h3>Requirements and Platforms</h3>
<div class="content">
<p> GSLL should work in
any Common Lisp implementation and platform combination
that has <a href="">CFFI</a>
with callbacks and defcfun support. You will need
<li><a href="">GSL</a></li>
<li><a href="">CFFI</a></li>
<li><a href="">ASDF</a>
If you are running Debian, the following should work:</p>
<blockquote><pre>apt-get install libgsl0 cl-cffi</pre></blockquote>
(asdf is automatically installed with your CL implementation).
<p>Once your CL implementation is running, do</p>
<blockquote><pre>(asdf:operate 'asdf:compile-op :gsll)
<p>or, if using Debian with the common-lisp-controller,</p>
<blockquote><pre>(clc:clc-require :gsll)</pre></blockquote>
<p>GSLL has been tested with SBCL on Debian i386 and amd64.</p>
<h3>Source downloads [not yet available]</h3>
<div class="content">
<p>You may browse or download the <a
repository at
svn:// For
<pre>svn list svn://
svn checkout svn://</pre>
You can also get a tgz file <a href="gsll.tgz">here</a>.</p>
<h3>Project Development</h3>
<div class="content">
<p>This project has been in development for a year. 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.</p>
<p>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
<code>defun-gsl</code>, 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.</p>
<p>Regression tests using <a
(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 indpendent source; the values given are from previous
<p>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: <code>lhealy</code> -at-
<code>common-lisp</code> -dot- <code>net</code>.</p>
<div class="content">
<h4>In progress</h4>
<div class="content">
Work has been done on the following, but not to completion
<h4>To be done</h4>
<div class="content">
The following should eventually be done
Native vectors
<h4>Won't be done</h4>
<div class="content">
<p>The following is not part of the plan for the GSLL interface:</p>
<li>Anything that is defined solely in C header files and not in the .so
library will not be a part of GSLL, because of the lack of access
through the library. For example, Chapter 38, Physical Constants,
are all defined as C macros.</li>
<li>Anything for which there are two near-equivalent GSL functions
and for which one is already provided. For example, all of the
special functions have two forms, one which provides the answer(s)
with an estimated error as a structure, and one which just provides
the answer as a double. This makes a
difference when C programming, but GSLL always uses the form with the
error estimate and returns the error as a later multiple value so
that it can easily be ignored.</li>
<li>Anything for which there is a Common Lisp
equivalent probably won't be done, unless there is a need to have it
present for some other GSL functionality that isn't present in CL.
<h3>Related projects</h3>
<div class="content">
A partial automatically-generated interface to GSL is provided in <a
A matlab-like array syntax and plotting is provided by
<a href="">NLISP</a> which might work well with
<div class="footer">
<address><a href="mailto:">Liam Healy</a></address>
<!-- Created: Feb 25 2005 -->
<!-- hhmts start -->
Last modified: March 4, 2007
<!-- hhmts end -->
......@@ -3,7 +3,7 @@
; description: Dirichlet distribution
; date: Sun Oct 29 2006
; author: Liam M. Healy
; modified: Sat Nov 11 2006 - 20:57
; modified: Sat Mar 3 2007 - 22:40
;;; $Id: $
......@@ -12,14 +12,14 @@
(defun-gsl dirichlet (generator alpha theta)
(((generator generator) :pointer)
((1- (dim0 alpha)) :size)
((dim0 alpha) :size)
((gsl-array alpha) :pointer)
;; theta had better be at least as long as alpha, or they'll be trouble
((gsl-array theta) :pointer))
:c-return :void
"An array of @var{K} random variates from a Dirichlet
distribution of order @var{K}-1. The distribution function is
"An array of K=(length alpha) random variates from a Dirichlet
distribution of order K-1. The distribution function is
p(\theta_1,\ldots,\theta_K) \, d\theta_1 \cdots d\theta_K =
{1 \over Z} \prod_{i=1}^{K} \theta_i^{\alpha_i - 1}
\; \delta(1 -\sum_{i=1}^K \theta_i) d\theta_1 \cdots d\theta_K
......@@ -61,8 +61,8 @@
;;; Examples and unit test
(lisp-unit:define-test dirichlet
'("0.485599280805d-04" "0.578734200082d+00"
"0.421217239990d+00" "0.200000000000d+00")
'("0.392833324564d-04" "0.468176310887d+00"
"0.340750440311d+00" "0.191033965469d+00")
(rng-set *rng-mt19937* 0)
......@@ -3,7 +3,7 @@
; description: Quasi-random sequences in arbitrary dimensions.
; date: Sun Jul 16 2006 - 15:54
; author: Liam M. Healy
; modified: Sat Feb 17 2007 - 17:45
; modified: Sat Mar 3 2007 - 19:55
;;; $Id: $
......@@ -133,6 +133,7 @@
(let ((gen (make-quasi-random-number-generator 2 *sobol*)))
(init gen)
(loop repeat 5
append (coerce (data (qrng-get gen vec)) 'list))
(loop repeat 5
do (qrng-get gen vec)
append (coerce (data vec) 'list))
(free gen))))))
......@@ -3,7 +3,7 @@
; description: Sorting
; date: Fri Apr 14 2006 - 20:20
; author: Liam M. Healy
; modified: Wed Jun 21 2006 - 23:29
; modified: Sun Mar 4 2007 - 10:06
;;; $Id: $
......@@ -12,6 +12,11 @@
;;; #'heapsort has just a cursory port, use CL's #'sort.
;;; Raw C array functions not ported, not policy.
;;; Errors:
;;; sort-vector-smallest-index and sort-vector-largest-index
;;; do not work on amd64/SBCL, and should be defined in terms of
;;; vector-unsigned-fixnum anyway
;;;; Heapsort, not recommended
......@@ -82,7 +87,8 @@
:c-return :void
:invalidate (dest))
;;; This is not right in that p should be over uint, not int.
;;; p should be gsl-vector-unsigned-fixnum, if that can be made to
;;; work (see vector.lisp).
(defun-gsl-vdsf sort-vector-smallest-index
((p gsl-vector-fixnum) (v gsl-vector))
......@@ -104,7 +110,8 @@
:c-return :void
:invalidate (dest))
;;; This is not right in that p should be over uint, not int.
;;; p should be gsl-vector-unsigned-fixnum, if that can be made to
;;; work (see vector.lisp).
(defun-gsl-vdsf sort-vector-largest-index
((p gsl-vector-fixnum) (v gsl-vector))
......@@ -3,7 +3,7 @@
; description: Coulumb functions
; date: Sat Mar 18 2006 - 23:23
; author: Liam M. Healy
; modified: Sat Oct 7 2006 - 15:21
; modified: Sat Mar 3 2007 - 22:45
;;; $Id:$
......@@ -67,9 +67,8 @@
:invalidate (fc-array)
:return (fc-array (double-to-cl F-exponent)))
;;; gc-array seems to always be zero. Is that right?
(defun-gsl coulomb-wave-FG-array (L-min eta x fc-array gc-array)
((L-min :double) ((1- (dim0 fc-array)) :int) (eta :double) (x :double)
((gsl-array fc-array) :pointer) ((gsl-array gc-array) :pointer)
(F-exponent :double) (G-exponent :double))
......@@ -156,7 +155,7 @@
(coulomb-wave-fg 1.0d0 2.0d0 2.5d0 1))
'("0.350215846039d-01" "0.575250061420d-02" "0.711695560198d-03"
"0.000000000000d+01" "0.800000000000d+01" "0.110000000000d+02")
"0.647172649613d+01" "0.275745747216d+02" "0.170560372931d+03")
(with-data (Farr vector-double 3)
(with-data (Garr vector-double 3)
body {
font-family: sans-serif;
background-color: white;
color: black;
margin: 0;
padding: 0;
.header * {
color: black;
background-color: #cc4422;
margin: 0;
padding: 0.5em;
h1 {
text-align: right;
.info {
text-align: left;
font-weight: bold;
line-height: 1em;
.body {
margin: 2em 1em;
.level {
margin: 1em;
p {
margin: 1em 0em;
padding: 0em;
a {
color: maroon;
ul {
margin: 1em;
padding: 0em;
pre {
margin: 0em;
padding: 1em;
border: 1px solid;
background-color: #eeeeee;
vertical-align: baseline;
img {
border: 0;
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment