Commit eb1420b4 authored by Liam Healy's avatar Liam Healy

Standardized names of GSL function structs

All defcstruct definitions for functions are in the new file
init/callback-struct.lisp.  They all have standard name format
beginning with "fnstruct" and have been consolidated where there were
redundant definitions.
parent 3987beef
;; Monte Carlo Integration
;; Liam Healy Sat Feb 3 2007 - 17:42
;; Time-stamp: <2009-04-01 21:25:08EDT monte-carlo.lisp>
;; Time-stamp: <2009-04-04 22:34:29EDT monte-carlo.lisp>
;; $Id$
(in-package :gsl)
......@@ -10,15 +10,6 @@
;;; /usr/include/gsl/gsl_monte_miser.h
;;; /usr/include/gsl/gsl_monte_vegas.h
;;;;****************************************************************************
;;;; Callback definition
;;;;****************************************************************************
(cffi:defcstruct monte-function
(function :pointer)
(dimensions sizet)
(parameters :pointer))
;;;;****************************************************************************
;;;; PLAIN Monte Carlo
;;;;****************************************************************************
......@@ -28,7 +19,7 @@
((dim sizet))
"plain Monte Carlo integration"
:documentation ; FDL
"Make and initialize a workspace for Monte Carlo integration in dim dimensions."
"Make and initialize a workspace for Monte Carlo integration in dimension dim."
:initialize-suffix "init"
:initialize-args nil)
......@@ -56,7 +47,7 @@
(result :double) (abserr :double))
:inputs (lower-limits upper-limits)
:callbacks
(callback monte-function (dimensions)
(callback fnstruct-dimension (dimension)
(function :double (:input :double :cvector dim0) :slug))
:callback-dynamic (((dim0 lower-limits)) (function scalars))
:documentation ; FDL
......@@ -85,7 +76,7 @@
"miser Monte Carlo integration"
:documentation ; FDL
"Make and initialize a workspace for Monte Carlo integration in
dim dimensions. The workspace is used to maintain
dimension dim. The workspace is used to maintain
the state of the integration."
:initialize-suffix "init"
:initialize-args nil)
......@@ -142,7 +133,7 @@
(result :double) (abserr :double))
:inputs (lower-limits upper-limits)
:callbacks
(callback monte-function (dimensions)
(callback fnstruct-dimension (dimension)
(function :double (:input :double :cvector dim0) :slug))
:callback-dynamic (((dim0 lower-limits)) (function scalars))
:documentation ; FDL
......@@ -171,7 +162,7 @@
"vegas Monte Carlo integration"
:documentation ; FDL
"Make and initialize a workspace for Monte Carlo integration in
dim dimensions. The workspace is used to maintain
dimension dim. The workspace is used to maintain
the state of the integration. Returns a pointer to vegas-state."
:initialize-suffix "init"
:initialize-args nil)
......@@ -238,7 +229,7 @@
(result :double) (abserr :double))
:inputs (lower-limits upper-limits)
:callbacks
(callback monte-function (dimensions)
(callback fnstruct-dimension (dimension)
(function :double (:input :double :cvector dim0) :slug))
:callback-dynamic (((dim0 lower-limits)) (function scalars))
:documentation ; FDL
......
;; Numerical differentiation.
;; Liam Healy Mon Nov 12 2007 - 22:07
;; Time-stamp: <2009-03-31 22:08:34EDT numerical-differentiation.lisp>
;; Time-stamp: <2009-04-04 22:24:31EDT numerical-differentiation.lisp>
;; $Id$
(in-package :gsl)
......@@ -15,7 +15,7 @@
((callback :pointer) (x :double) (step :double)
(result :double) (abserr :double))
:callbacks
(callback gsl-function nil (function :double (:input :double) :slug))
(callback fnstruct nil (function :double (:input :double) :slug))
:callback-dynamic (nil (function))
:documentation ; FDL
"Compute the numerical derivative of the function
......@@ -38,7 +38,7 @@
((callback :pointer) (x :double) (step :double)
(result :double) (abserr :double))
:callbacks
(callback gsl-function nil (function :double (:input :double) :slug))
(callback fnstruct nil (function :double (:input :double) :slug))
:callback-dynamic (nil (function))
:documentation ; FDL
"Compute the numerical derivative of the function
......@@ -63,7 +63,7 @@
((callback :pointer) (x :double) (step :double)
(result :double) (abserr :double))
:callbacks
(callback gsl-function nil (function :double (:input :double) :slug))
(callback fnstruct nil (function :double (:input :double) :slug))
:callback-dynamic (nil (function))
:documentation ; FDL
"Compute the numerical derivative of the function at the point x
......
;; Numerical integration techniques that require tables
;; Liam Healy 2009-04-04 15:24:05EDT
;; Time-stamp: <2009-04-04 18:09:47EDT numerical-integration-with-tables.lisp>
;; Time-stamp: <2009-04-04 22:27:18EDT numerical-integration-with-tables.lisp>
;; $Id: $
(in-package :gsl)
......@@ -50,7 +50,7 @@
(limit sizet) ((mpointer workspace) :pointer)
(result :double) (abserr :double))
:callbacks
(callback gsl-function nil (function :double (:input :double) :slug))
(callback fnstruct nil (function :double (:input :double) :slug))
:callback-dynamic (nil (function))
:documentation ; FDL
"Compute the integral of the function f(x) over the interval (a,b)
......@@ -111,7 +111,7 @@
((mpointer table) :pointer)
(result :double) (abserr :double))
:callbacks
(callback gsl-function nil (function :double (:input :double) :slug))
(callback fnstruct nil (function :double (:input :double) :slug))
:callback-dynamic (nil (function))
:documentation ; FDL
"Use an adaptive algorithm to compute the integral of f over (a,b)
......@@ -155,7 +155,7 @@
((mpointer table) :pointer)
(result :double) (abserr :double))
:callbacks
(callback gsl-function nil (function :double (:input :double) :slug))
(callback fnstruct nil (function :double (:input :double) :slug))
:callback-dynamic (nil (function))
:documentation ; FDL
"This function attempts to compute a Fourier integral of the
......
;; Numerical integration
;; Liam Healy, Wed Jul 5 2006 - 23:14
;; Time-stamp: <2009-04-04 21:30:01EDT numerical-integration.lisp>
;; Time-stamp: <2009-04-04 22:25:57EDT numerical-integration.lisp>
;; $Id$
(in-package :gsl)
......@@ -36,7 +36,7 @@
(absolute-error :double) (relative-error :double)
(result :double) (abserr :double) (neval sizet))
:callbacks
(callback gsl-function nil (function :double (:input :double) :slug))
(callback fnstruct nil (function :double (:input :double) :slug))
:callback-dynamic (nil (function))
:documentation ; FDL
"Apply the Gauss-Kronrod 10-point, 21-point, 43-point and
......@@ -80,7 +80,7 @@
(limit sizet) (method integrate-method) ((mpointer workspace) :pointer)
(result :double) (abserr :double))
:callbacks
(callback gsl-function nil (function :double (:input :double) :slug))
(callback fnstruct nil (function :double (:input :double) :slug))
:callback-dynamic (nil (function))
:documentation ; FDL
"Apply an integration rule adaptively until an estimate
......@@ -116,7 +116,7 @@
(absolute-error :double) (relative-error :double) (limit sizet)
((mpointer workspace) :pointer) (result :double) (abserr :double))
:callbacks
(callback gsl-function nil (function :double (:input :double) :slug))
(callback fnstruct nil (function :double (:input :double) :slug))
:callback-dynamic (nil (function))
:documentation ; FDL
"Apply the Gauss-Kronrod 21-point integration rule
......@@ -149,7 +149,7 @@
((mpointer workspace) :pointer) (result :double) (abserr :double))
:inputs (points)
:callbacks
(callback gsl-function nil (function :double (:input :double) :slug))
(callback fnstruct nil (function :double (:input :double) :slug))
:callback-dynamic (nil (function))
:documentation ; FDL
"Apply the adaptive integration algorithm QAGS taking
......@@ -178,7 +178,7 @@
(absolute-error :double) (relative-error :double) (limit sizet)
((mpointer workspace) :pointer) (result :double) (abserr :double))
:callbacks
(callback gsl-function nil (function :double (:input :double) :slug))
(callback fnstruct nil (function :double (:input :double) :slug))
:callback-dynamic (nil (function))
:documentation ; FDL
"Compute the integral of the function f over the
......@@ -202,7 +202,7 @@
(absolute-error :double) (relative-error :double) (limit sizet)
((mpointer workspace) :pointer) (result :double) (abserr :double))
:callbacks
(callback gsl-function nil (function :double (:input :double) :slug))
(callback fnstruct nil (function :double (:input :double) :slug))
:callback-dynamic (nil (function))
:documentation ; FDL
"Compute the integral of the function f over the
......@@ -222,7 +222,7 @@
(absolute-error :double) (relative-error :double) (limit sizet)
((mpointer workspace) :pointer) (result :double) (abserr :double))
:callbacks
(callback gsl-function nil (function :double (:input :double) :slug))
(callback fnstruct nil (function :double (:input :double) :slug))
:callback-dynamic (nil (function))
:documentation ; FDL
"Compute the integral of the function f over the
......@@ -247,7 +247,7 @@
(absolute-error :double) (relative-error :double) (limit sizet)
((mpointer workspace) :pointer) (result :double) (abserr :double))
:callbacks
(callback gsl-function nil (function :double (:input :double) :slug))
(callback fnstruct nil (function :double (:input :double) :slug))
:callback-dynamic (nil (function))
:documentation ; FDL
"Compute the Cauchy principal value of the integral of
......
;; Chebyshev Approximations
;; Liam Healy Sat Nov 17 2007 - 20:36
;; Time-stamp: <2009-03-29 11:44:09EDT chebyshev.lisp>
;; Time-stamp: <2009-04-04 22:27:16EDT chebyshev.lisp>
;; $Id$
(in-package :gsl)
......@@ -17,7 +17,7 @@
:documentation ; FDL
"Make a Chebyshev series of specified order."
:callbacks
(callback gsl-function nil (function :double (:input :double) :slug))
(callback fnstruct nil (function :double (:input :double) :slug))
:initialize-suffix "init"
:initialize-args
((callback :pointer) (lower-limit :double) (upper-limit :double))
......
;; Definition of GSLL system
;; Liam Healy
;; Time-stamp: <2009-04-04 17:56:17EDT gsll.asd>
;; Time-stamp: <2009-04-04 22:32:18EDT gsll.asd>
;; $Id$
(asdf:defsystem "gsll"
......@@ -23,8 +23,9 @@
(:file "callback-included" :depends-on (mobject))
(:file "callback"
:depends-on (init utility forms number-conversion callback-included))
(:file "funcallable" :depends-on (utility))
(:file "types" :depends-on (init))
(:file "callback-struct" :depends-on (types))
(:file "funcallable" :depends-on (utility))
(:file "complex-types" :depends-on (types))
(:file "element-types" :depends-on (init complex-types))
(:file "interface"
......
;; Definitions for macro expansion
;; Liam Healy 2009-03-15 14:50:28EDT callback-compile-defs.lisp
;; Time-stamp: <2009-04-04 21:40:57EDT callback-compile-defs.lisp>
;; Time-stamp: <2009-04-04 22:44:05EDT callback-compile-defs.lisp>
;; $Id: $
(in-package :gsl)
......@@ -23,7 +23,7 @@
(let ((cbs (get-callbacks-for-class class)))
(unless cbs (error "Class ~a not defined." class))
`(make-cbstruct
',(parse-callback-static cbs 'callback-structure-type)
',(parse-callback-static cbs 'callback-fnstruct)
(when (dimension-names object)
(mappend 'list (dimension-names object) (dimensions object)))
,@(mappend
......
;; GSL structures for holding functions
;; Liam Healy 2009-04-04 22:15:56EDT callback-struct.lisp
;; Time-stamp: <2009-04-04 22:34:29EDT callback-struct.lisp>
;; $Id: $
(in-package :gsl)
;;; Only the function
(cffi:defcstruct fnstruct
"Passing functions to GSL."
;; see /usr/include/gsl/gsl_math.h
(function :pointer)
(parameters :pointer))
;;; The function and its derivative(s)
(cffi:defcstruct fnstruct-fdf
;; See /usr/include/gsl/gsl_math.h
"The definition of a function and its derivative for root finding in GSL."
(function :pointer)
(df :pointer)
(fdf :pointer)
(parameters :pointer))
;;; The function and a dimension
(cffi:defcstruct fnstruct-dimension
;; See /usr/include/gsl/gsl_multiroots.h
;; or /usr/include/gsl/gsl_monte.h
(function :pointer)
(dimension sizet)
(parameters :pointer))
;;; The function, dimension, and derivatives
(cffi:defcstruct fnstruct-dimension-fdf
;; See /usr/include/gsl/gsl_multiroots.h
(function :pointer)
(df :pointer)
(fdf :pointer)
(dimension sizet)
(parameters :pointer))
;;; The function and two dimensions (for nonlinear fit).
(cffi:defcstruct fnstruct-fit
;; See gsl_multifit_function in /usr/include/gsl/gsl_multifit_nlin.h
(function :pointer)
(number-of-observations sizet)
(number-of-parameters sizet)
(parameters :pointer))
;;; The function, two dimensions, and derivatives (for nonlinear fit)
(cffi:defcstruct fnstruct-fit-fdf
(function :pointer)
(df :pointer)
(fdf :pointer)
(number-of-observations sizet)
(number-of-parameters sizet)
(parameters :pointer))
;; Foreign callback functions.
;; Liam Healy
;; Time-stamp: <2009-04-04 21:58:32EDT callback.lisp>
;; Time-stamp: <2009-04-04 22:44:06EDT callback.lisp>
;; $Id$
(in-package :gsl)
......@@ -53,16 +53,6 @@
(set-structure-slot foreign-structure structure-name
'parameters (cffi:null-pointer)))
;;;;****************************************************************************
;;;; The GSL struct for holding callbacks
;;;;****************************************************************************
(cffi:defcstruct gsl-function
"Passing functions to GSL."
;; see /usr/include/gsl/gsl_math.h
(function :pointer)
(parameters :pointer))
;;;;****************************************************************************
;;;; Definitions for making cbstruct
;;;;****************************************************************************
......@@ -88,7 +78,7 @@
;;;;****************************************************************************
;;; The :callbacks (cbinfo) argument is a list of the form:
;;; (foreign-argument callback-structure-type dimension-names function ...)
;;; (foreign-argument callback-fnstruct dimension-names function ...)
;;; where each function is of the form
;;; (structure-slot-name
;;; &optional (return-spec 'double-float) (argument-spec 'double-float)
......@@ -100,7 +90,7 @@
"Get the information component from the callbacks list."
(case component
(foreign-argument (first cbinfo))
(callback-structure-type (second cbinfo))
(callback-fnstruct (second cbinfo))
(dimension-names (third cbinfo))
(functions (nthcdr 3 cbinfo))))
......@@ -181,7 +171,7 @@
(when cbinfo
`((set-cbstruct
,(parse-callback-static cbinfo 'foreign-argument)
',(parse-callback-static cbinfo 'callback-structure-type)
',(parse-callback-static cbinfo 'callback-fnstruct)
,(when (parse-callback-static cbinfo 'dimension-names)
(cons 'list
(loop
......
;; Macros to interface GSL functions, including definitions necessary for defmfun.
;; Liam Healy
;; Time-stamp: <2009-04-04 21:42:32EDT interface.lisp>
;; Time-stamp: <2009-04-04 22:44:06EDT interface.lisp>
;; $Id$
(in-package :gsl)
......@@ -65,7 +65,7 @@
`(',(st-eltype d) ,(st-dim d))
(if (eq (st-symbol d)
(parse-callback-static cbinfo 'foreign-argument))
`(',(parse-callback-static cbinfo 'callback-structure-type))
`(',(parse-callback-static cbinfo 'callback-fnstruct))
`(',(st-type d))))))
;;;;****************************************************************************
......
;; Generic functions for optimization
;; Liam Healy 2009-01-03 12:59:07EST generic.lisp
;; Time-stamp: <2009-03-21 23:52:17EDT generic.lisp>
;; Time-stamp: <2009-04-04 22:20:38EDT generic.lisp>
;; $Id: $
(in-package :gsl)
......@@ -26,37 +26,4 @@
(:documentation ; FDL
"The last step dx taken by the solver."))
;;;;****************************************************************************
;;;; Structures and macros for function definition
;;;;****************************************************************************
(cffi:defcstruct gsl-mfunction
;; See /usr/include/gsl/gsl_multiroots.h
"The definition of a function for multiroot finding in GSL."
(function :pointer)
(dimension sizet)
(parameters :pointer))
(cffi:defcstruct gsl-mfunction-fdf
;; See /usr/include/gsl/gsl_multiroots.h
"The definition of a function and its derivatives for multiroot
finding in GSL."
(function :pointer)
(df :pointer)
(fdf :pointer)
(dimension sizet)
(parameters :pointer))
;;;;****************************************************************************
;;;; Function definition
;;;;****************************************************************************
;;; Solvers that require the function and its derivative use the
;;; following structure.
(cffi:defcstruct gsl-function-fdf
;; See /usr/include/gsl/gsl_math.h
"The definition of a function and its derivative for root finding in GSL."
(function :pointer)
(df :pointer)
(fdf :pointer)
(parameters :pointer))
;; Multivariate minimization.
;; Liam Healy <Tue Jan 8 2008 - 21:28>
;; Time-stamp: <2009-03-29 12:43:30EDT minimization-multi.lisp>
;; Time-stamp: <2009-04-04 22:29:11EDT minimization-multi.lisp>
;; $Id$
(in-package :gsl)
......@@ -14,7 +14,7 @@
;;; is easy enough to eliminate this, but then mfdfminimizer-gradient
;;; would not be useful to a CL user.
;;; The structures gsl-mfunction and gsl-mfunction-fdf are, from the
;;; The structures fnstruct-dimension and fnstruct-dimension-fdf are, from the
;;; CFFI point of view, equally valid for gsl_multimin_function and
;;; gsl_multimin_function_fdf defined in
;;; /usr/include/gsl/gsl_multimin.h as they are for
......@@ -38,7 +38,7 @@
initial trial steps is given in vector step-size. The precise
meaning of this parameter depends on the method used."
:callbacks
(callback gsl-mfunction (dimension)
(callback fnstruct-dimension (dimension)
(function :double (:input :double :marray dim0) :slug))
:initialize-suffix "set"
:initialize-args ;; Could have one fewer argument: dimension=(dim0 initial)
......@@ -62,7 +62,7 @@
direction p to a relative accuracy of tolerance, where dot(p,g) <
tol |p| |g|."
:callbacks
(callback gsl-mfunction-fdf (dimension)
(callback fnstruct-dimension-fdf (dimension)
(function :double (:input :double :marray dim0) :slug)
(df :void
(:input :double :marray dim0) :slug
......
;; Univariate minimization
;; Liam Healy Tue Jan 8 2008 - 21:02
;; Time-stamp: <2009-03-29 12:13:30EDT minimization-one.lisp>
;; Time-stamp: <2009-04-04 22:27:15EDT minimization-one.lisp>
;; $Id$
(in-package :gsl)
......@@ -21,7 +21,7 @@
set to use the function and the initial search interval [lower,
upper], with a guess for the location of the minimum."
:callbacks
(callback gsl-function nil (function :double (:input :double) :slug))
(callback fnstruct nil (function :double (:input :double) :slug))
:initialize-suffix "set" ; should use set_with_values?
:initialize-args
((callback :pointer) (minimum :double) (lower :double) (upper :double))
......
;; Nonlinear least squares fitting.
;; Liam Healy, 2008-02-09 12:59:16EST nonlinear-least-squares.lisp
;; Time-stamp: <2009-03-29 12:42:59EDT nonlinear-least-squares.lisp>
;; Time-stamp: <2009-04-04 22:30:04EDT nonlinear-least-squares.lisp>
;; $Id$
(in-package :gsl)
......@@ -22,7 +22,7 @@
:documentation ; FDL
"The number of observations must be greater than or equal to parameters."
:callbacks
(callback gsl-ffit-function
(callback fnstruct-fit
(number-of-observations number-of-parameters)
(function
:success-failure
......@@ -32,14 +32,6 @@
:initialize-args ((callback :pointer) ((mpointer initial-guess) :pointer))
:singular (function))
(cffi:defcstruct gsl-ffit-function
"The definition of a function for nonlinear least squares fitting in GSL."
;; See gsl_multifit_function in /usr/include/gsl/gsl_multifit_nlin.h
(function :pointer)
(number-of-observations sizet)
(number-of-parameters sizet)
(parameters :pointer))
(defmfun name ((solver nonlinear-ffit))
"gsl_multifit_fsolver_name"
(((mpointer solver) :pointer))
......@@ -61,7 +53,7 @@
"The number of observations must be greater than or
equal to parameters."
:callbacks
(callback gsl-fdffit-function
(callback fnstruct-fit-fdf
(number-of-observations number-of-parameters)
(function :success-failure
(:input :double :marray dim1)
......@@ -91,16 +83,6 @@
(dx :pointer)
(state :pointer))
(cffi:defcstruct gsl-fdffit-function
"The definition of a function and its derivatives for nonlinear
least squares fitting in GSL."
(function :pointer)
(df :pointer)
(fdf :pointer)
(number-of-observations sizet)
(number-of-parameters sizet)
(parameters :pointer))
(defmfun name ((solver nonlinear-fdffit))
"gsl_multifit_fdfsolver_name"
(((mpointer solver) :pointer))
......
;;; Multivariate roots.
;;; Liam Healy 2008-01-12 12:49:08
;;; Time-stamp: <2009-03-31 22:51:42EDT roots-multi.lisp>
;;; Time-stamp: <2009-04-04 22:29:12EDT roots-multi.lisp>
;;; $Id$
(in-package :gsl)
......@@ -29,7 +29,7 @@
:initialize-suffix "set"
:initialize-args ((callback :pointer) ((mpointer initial) :pointer))
:callbacks
(callback gsl-mfunction (dimension)
(callback fnstruct-dimension (dimension)
(function
:success-failure
(:input :double :marray dim0) :slug
......@@ -56,7 +56,7 @@
:initialize-suffix "set"
:initialize-args ((callback :pointer) ((mpointer initial) :pointer))
:callbacks
(callback gsl-mfunction-fdf (dimension)
(callback fnstruct-dimension-fdf (dimension)
(function :success-failure
(:input :double :marray dim0)
:slug
......
;; One-dimensional root solver.
;; Liam Healy
;; Time-stamp: <2009-03-29 11:50:01EDT roots-one.lisp>
;; Time-stamp: <2009-04-04 22:27:16EDT roots-one.lisp>
;; $Id$
(in-package :gsl)
......@@ -17,7 +17,7 @@
:initialize-suffix "set"
:initialize-args ((callback :pointer) (lower :double) (upper :double))
:callbacks
(callback gsl-function nil (function :double (:input :double) :slug))
(callback fnstruct nil (function :double (:input :double) :slug))
:singular (function))
(defmobject one-dimensional-root-solver-fdf "gsl_root_fdfsolver"
......@@ -26,7 +26,7 @@
:initialize-suffix "set"
:initialize-args ((callback :pointer) (root-guess :double))
:callbacks
(callback gsl-function-fdf nil
(callback fnstruct-fdf nil
(function :double (:input :double) :slug)
(df :double (:input :double) :slug)
(fdf :void (:input :double) :slug
......
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