Commit d161d049 authored by liam's avatar liam

Rename macros to be more descriptive

def-scalar-function -> def-single-function
defun-scalar -> defun-single


git-svn-id: svn+ssh://pop/opt/space/mathematics/gsl/trunk@3271 a3d8a0fb-c1db-0310-ace7-a616afeb9e30
parent 19496d61
;********************************************************
; 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))
......
;; 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
......
;********************************************************
; 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))
......@@ -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>
......
;; 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 ()
......
;********************************************************
; 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))))
;;;;****************************************************************************
......
;********************************************************
; 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
......
;********************************************************
; 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
......
;;; 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)
......
;; 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)
......
;********************************************************
; 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
......
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