diff --git a/chebyshev.lisp b/chebyshev.lisp index 3b8e82f8ddbcaa3535ac29b659573e4788c306e2..0dcce83bffdd1bafbcf4b0cc7165602b59acd0ab 100644 --- a/chebyshev.lisp +++ b/chebyshev.lisp @@ -1,11 +1,7 @@ -;******************************************************** -; file: chebyshev.lisp -; description: Chebyshev Approximations -; date: Sat Nov 17 2007 - 20:36 -; author: Liam Healy -; modified: Sun Dec 30 2007 - 16:05 -;******************************************************** -;;; $Id: $ +;; Chebyshev Approximations +;; Liam Healy Sat Nov 17 2007 - 20:36 +;; Time-stamp: <2008-01-20 22:37:14EST chebyshev.lisp> +;; $Id: $ (in-package :gsl) @@ -119,7 +115,7 @@ ;;; From Chap. 28.5, except I have set steps = 100 instead of 10000 ;;; to keep things sane. -(defun-scalar chebyshev-step (x) (if (< x 0.5d0) 0.25d0 0.75d0)) +(defun-single chebyshev-step (x) (if (< x 0.5d0) 0.25d0 0.75d0)) (defun chebyshev-table-example () (let ((cheb (allocate-chebyshev 40)) diff --git a/general/functions.lisp b/general/functions.lisp index 973ca634fab9f6bf6526c53db8eae897729b62dd..6eb850749430f685f02ac0f1a4f4d0f2e7625c75 100644 --- a/general/functions.lisp +++ b/general/functions.lisp @@ -1,6 +1,6 @@ ;; Foreign callback functions. ;; Liam Healy -;; Time-stamp: <2008-01-20 18:12:42EST functions.lisp> +;; Time-stamp: <2008-01-20 22:34:41EST functions.lisp> ;; $Id: $ (in-package :gsl) @@ -14,7 +14,7 @@ ;;; numerical-integration, numerical-differentiation, chebyshev and ;;; definitions to aid in creating and using them are provided here. ;;; The idea behind the definitions is that the boundary between the CL -;;; and C functions is a narrow as possible; #'defun-scalar is +;;; and C functions is a narrow as possible; #'defun-single is ;;; macro that allows one to define a function in Lisp and make ;;; use it in these GSL tasks. @@ -29,7 +29,7 @@ ;;; #'with-c-double is provided to give named access to the elements. (export - '(def-scalar-function undef-scalar-function defun-scalar + '(def-single-function undef-cbstruct defun-single with-c-double with-c-doubles)) ;;;;**************************************************************************** @@ -135,7 +135,14 @@ `(set-structure-slot ,name ',structure ',(first slot) ,(second slot)))))) -(defmacro def-scalar-function +(defun undef-cbstruct (name) + "Free foreign callback function. It is not necessary to do this; think + of the memory taken by an unused foreign function as much + less than that used by an unused defun." + (cffi:foreign-free (symbol-value name)) + (makunbound name)) + +(defmacro def-single-function (name &optional (return-type :double) (argument-type :double) (structure 'gsl-function) @@ -151,20 +158,13 @@ structure `((defcbstruct ,name ,structure ,additional-slots))))) -(defun undef-scalar-function (name) - "Free foreign callback function. It is not necessary to do this; think - of the memory taken by an unused foreign function as much - less than that used by an unused defun." - (cffi:foreign-free (symbol-value name)) - (makunbound name)) - -;;; Combine a defun and def-scalar-function in one: -(defmacro defun-scalar (name arglist &body body) +;;; Combine a defun and def-single-function in one: +(defmacro defun-single (name arglist &body body) "Define a function of a scalar double-float argument returning a double-float in CL and C." `(progn (defun ,name ,arglist ,@body) - (def-scalar-function ,name))) + (def-single-function ,name))) ;;;;**************************************************************************** ;;;; Vector of doubles diff --git a/histogram/ntuple.lisp b/histogram/ntuple.lisp index 337541c0839dc19e37cbb41a2f2ee54e3816d128..7723ce1d56e293d76b9d9ab3e2e688bff8bda8d8 100644 --- a/histogram/ntuple.lisp +++ b/histogram/ntuple.lisp @@ -1,11 +1,7 @@ -;******************************************************** -; file: ntuple.lisp -; description: N-tuples -; date: Sat Feb 3 2007 - 12:53 -; author: Liam Healy -; modified: Sun Dec 30 2007 - 16:33 -;******************************************************** -;;; $Id: $ +;; N-tuples +;; Liam Healy Sat Feb 3 2007 - 12:53 +;; Time-stamp: <2008-01-20 22:37:47EST ntuple.lisp> +;; $Id: $ (in-package :gsl) @@ -90,10 +86,10 @@ for histogramming. The struct component function should return a non-zero value for each ntuple row that is to be included in the histogram. " - `(def-scalar-function ,name ,arg :int :pointer)) + `(def-single-function ,name ,arg :int :pointer)) (defmacro def-ntuple-value-function (name arg) "The value function computes scalar values for those ntuple rows selected by the selection function which should return the value to be added to the histogram." - `(def-scalar-function ,name ,arg :double :pointer)) + `(def-single-function ,name ,arg :double :pointer)) diff --git a/index.html b/index.html index c7de1b2deaee0862459f411976b59a2996b665fd..0fc2c055d9cd63c90289554072016130a3391880 100644 --- a/index.html +++ b/index.html @@ -70,7 +70,7 @@ debugger invoked on a GSL-ERROR in thread #<THREAD "initial thread" {10032258C1} <li>Find the appropriate function(s) in the <a href="http://www.gnu.org/software/gsl/manual/">GSL documentation</a>.</li> - <li>Use the GSLL function gsl-lookup + <li>Use the GSLL function <code>gsl-lookup</code> to find the equivalent GSLL function, for example <pre> (gsl-lookup "gsl_sf_elljac_e") @@ -91,6 +91,10 @@ to find that the Lisp function name is <code>#'jacobian-elliptic-functions</code in a <code>lisp-unit:define-test</code> form, and therefore show the answer expected.</li> </ul> + 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. </div> <h3>Requirements and Platforms</h3> @@ -370,7 +374,7 @@ and expect a few failures on amd64 (four), none? on i386. Often, the <!-- Created: Feb 25 2005 --> <!-- hhmts start --> <small> - Time-stamp: <2008-01-20 21:01:45EST index.html> + Time-stamp: <2008-01-20 21:29:20EST index.html> </small> <!-- hhmts end --> </div> diff --git a/minimization-one.lisp b/minimization-one.lisp index 7faaef55335925b10b78c9f2f829254fbbd1883e..83b7089fd34d1c79dae188f4dbda5d328bb537e2 100644 --- a/minimization-one.lisp +++ b/minimization-one.lisp @@ -1,6 +1,6 @@ ;; Univariate minimization ;; Liam Healy Tue Jan 8 2008 - 21:02 -;; Time-stamp: <2008-01-20 17:02:12EST minimization-one.lisp> +;; Time-stamp: <2008-01-20 22:40:18EST minimization-one.lisp> ;; $Id: $ (in-package :gsl) @@ -193,7 +193,7 @@ ;;; This is the example given in Sec. 33.8. The results are different ;;; than given there. -(defun-scalar minimization-one-fn (x) +(defun-single minimization-one-fn (x) (1+ (cos x))) (defun minimization-one-example () diff --git a/monte-carlo.lisp b/monte-carlo.lisp index 1293080c15ca647f07fd1d0e9f936205b94733d5..8814367683df186b5f731e4d56eac9d2b8bb8547 100644 --- a/monte-carlo.lisp +++ b/monte-carlo.lisp @@ -1,11 +1,7 @@ -;******************************************************** -; file: monte-carlo.lisp -; description: Monte Carlo Integration -; date: Sat Feb 3 2007 - 17:42 -; author: Liam Healy -; modified: Sat Jan 5 2008 - 21:20 -;******************************************************** -;;; $Id: $ +;; Monte Carlo Integration +;; Liam Healy Sat Feb 3 2007 - 17:42 +;; Time-stamp: <2008-01-20 22:39:10EST monte-carlo.lisp> +;; $Id: $ (in-package :gsl) @@ -298,7 +294,7 @@ (export 'def-mc-function) (defmacro def-mc-function (name dimensions) - `(def-scalar-function ,name :double :pointer monte-function + `(def-single-function ,name :double :pointer monte-function ((dimensions ,dimensions)))) ;;;;**************************************************************************** diff --git a/numerical-differentiation.lisp b/numerical-differentiation.lisp index 1d5ee971c0bf7566b1947ab9fa7cdf0199c42c97..d9230aba939a59ed300ccdae408029edb9e1fae5 100644 --- a/numerical-differentiation.lisp +++ b/numerical-differentiation.lisp @@ -1,11 +1,7 @@ -;******************************************************** -; file: numerical-differentiation.lisp -; description: Numerical differentiation. -; date: Mon Nov 12 2007 - 22:07 -; author: Liam Healy -; modified: Sun Dec 30 2007 - 14:25 -;******************************************************** -;;; $Id: $ +;; Numerical differentiation. +;; Liam Healy Mon Nov 12 2007 - 22:07 +;; Time-stamp: <2008-01-20 22:35:42EST numerical-differentiation.lisp> +;; $Id: $ (in-package :gsl) @@ -74,7 +70,7 @@ ;;;; Examples and unit test ;;; This is the example given in the GSL manual, Sec. 27.2. -(defun-scalar 3/2-power (x) (expt x 3/2)) +(defun-single 3/2-power (x) (expt x 3/2)) ;;; (3/2-power 2.0d0) (lisp-unit:define-test numerical-differentiation diff --git a/numerical-integration.lisp b/numerical-integration.lisp index 6199d4d1473c545045cbbef05739b06255d15119..a75e1d9f984392a5d0247e964a4660cacc7f68c7 100644 --- a/numerical-integration.lisp +++ b/numerical-integration.lisp @@ -1,11 +1,7 @@ -;******************************************************** -; file: numerical-integration.lisp -; description: Numerical integration -; date: Wed Jul 5 2006 - 23:14 -; author: Liam M. Healy -; modified: Sun Dec 30 2007 - 14:19 -;******************************************************** -;;; $Id: $ +;; Numerical integration +;; Liam Healy, Wed Jul 5 2006 - 23:14 +;; Time-stamp: <2008-01-20 22:39:09EST numerical-integration.lisp> +;; $Id: $ ;;; To do: QAWS, QAWO, QAWF, more tests @@ -219,12 +215,11 @@ ;;;; Examples and unit test ;;;;**************************************************************************** -;;; defun-scalar is a combination of defun and def-scalar-function: -(defun-scalar one-sine (x) (sin x)) +(defun-single one-sine (x) (sin x)) ;;; Parameters may be defined through the lexical environment: (let ((mult 2.0d0)) - (defun-scalar two-sine (x) (sin (* mult x)))) + (defun-single two-sine (x) (sin (* mult x)))) (lisp-unit:define-test numerical-integration (lisp-unit:assert-first-fp-equal diff --git a/roots-multi.lisp b/roots-multi.lisp index 962235302095e52416522149c0499ecbd9dd1147..782c30a5e604f727d1663904ba6292f511405a45 100644 --- a/roots-multi.lisp +++ b/roots-multi.lisp @@ -1,6 +1,6 @@ ;;; Multivariate roots. ;;; Liam Healy 2008-01-12 12:49:08 -;;; Time-stamp: <2008-01-20 17:18:39EST roots-multi.lisp> +;;; Time-stamp: <2008-01-20 22:40:18EST roots-multi.lisp> ;;; $Id: $ (in-package :gsl) @@ -25,7 +25,7 @@ (export 'def-mfunction) (defmacro def-mfunction (name dimensions) "Define a function for multivariate root solving." - `(def-scalar-function ,name :success-failure :pointer gsl-mfunction + `(def-single-function ,name :success-failure :pointer gsl-mfunction ((dimensions ,dimensions)) (gsl-vector-c))) @@ -453,7 +453,7 @@ (rosenbrock argument value) (rosenbrock-df argument jacobian)) -;;; Because def-solver-functions and def-scalar-function bind a symbol +;;; Because def-solver-functions and def-single-function bind a symbol ;;; of the same name as the first function, and we want both to run, ;;; we'll make an alias function so we can use both. (eval-when (:load-toplevel :execute) diff --git a/roots-one.lisp b/roots-one.lisp index ebdba67ae878b3def61358a966a9f8784c95a53a..7b4793e48a3d0cd4f3624319ab66474fb8b93c2f 100644 --- a/roots-one.lisp +++ b/roots-one.lisp @@ -1,6 +1,6 @@ ;; One-dimensional root solver. ;; Liam Healy -;; Time-stamp: <2008-01-20 17:24:01EST roots-one.lisp> +;; Time-stamp: <2008-01-20 22:40:19EST roots-one.lisp> ;; $Id: $ (in-package :gsl) @@ -357,7 +357,7 @@ (setf y (+ (* (+ (* a x) b) x) c) dy (+ (* 2 a x) b))))) -(def-scalar-function quadratic) +(def-single-function quadratic) (defun roots-one-example () "Solving a quadratic, the example given in Sec. 32.10 of the GSL manual." @@ -377,7 +377,7 @@ root (- root (sqrt 5.0d0)) (- upper lower)))))) -;;; Because def-solver-functions and def-scalar-function bind a symbol +;;; Because def-solver-functions and def-single-function bind a symbol ;;; of the same name as the first function, and we want both to run, ;;; we'll make an alias function so we can use both. (eval-when (:load-toplevel :execute) diff --git a/simulated-annealing.lisp b/simulated-annealing.lisp index c2aa19e085be4f69a4f322a865c5eb90d765095a..f1cbfb671948d636bff965e94dffb553212dc719 100644 --- a/simulated-annealing.lisp +++ b/simulated-annealing.lisp @@ -1,11 +1,7 @@ -;******************************************************** -; file: simulated-annealing.lisp -; description: Simulated Annealing -; date: Sun Feb 11 2007 - 17:23 -; author: Liam Healy -; modified: Sat Jan 5 2008 - 21:20 -;******************************************************** -;;; $Id: $ +;; Simulated Annealing +;; Liam Healy Sun Feb 11 2007 - 17:23 +;; Time-stamp: <2008-01-20 22:37:12EST simulated-annealing.lisp> +;; $Id: $ (in-package :gsl) @@ -110,7 +106,7 @@ (defmacro def-energy-function (name) "Define an energy or distance fuction for simulated annealing." - `(def-scalar-function ,name :double :pointer nil)) + `(def-single-function ,name :double :pointer nil)) (defmacro def-step-function (name) "Define a step fuction for simulated annealing." @@ -131,7 +127,7 @@ (defmacro def-print-function (name) "Define a print function for simulated annealing." - `(def-scalar-function ,name :int :pointer nil)) + `(def-single-function ,name :int :pointer nil)) ;;;;**************************************************************************** ;;;; Example