From 8c0e6eb70aed9d3fc8c7ab72c881217e6c3b01d6 Mon Sep 17 00:00:00 2001 From: Liam Healy <liam@thinkpad.local> Date: Sat, 6 Jun 2009 17:14:56 -0400 Subject: [PATCH] Define C structures using CFFI-grovel Almost all GSL structures are now defined using CFFI-grovel, which makes the code more robust should there be changes in GSL. The exceptions are complex-float-c, complex-double-c, and simulated-annealing-parameters; because these structures are used by value, they need to be defined with fsbv:defcstruct at the present. --- calculus/monte-carlo-structs.lisp | 65 +++++++++++++++ calculus/monte-carlo.lisp | 66 +-------------- data/array-structs.lisp | 46 +++++++++++ data/combination.lisp | 9 +-- data/marray.lisp | 7 +- data/matrix.lisp | 14 +--- data/permutation.lisp | 8 +- data/vector.lisp | 13 +-- documentation/index.html | 6 +- eigensystems/eigen-struct.lisp | 13 +++ eigensystems/symmetric-hermitian.lisp | 11 +-- gsll.asd | 34 +++++--- init/callback-struct.lisp | 81 ++++++++++--------- .../ode-struct.lisp | 16 ++++ ordinary-differential-equations/stepping.lisp | 10 +-- series-acceleration.lisp | 14 +--- series-struct.lisp | 14 ++++ .../nonlinear-least-squares.lisp | 14 +--- solve-minimize-fit/roots-multi.lisp | 10 +-- solve-minimize-fit/solver-struct.lisp | 25 ++++++ special-functions/return-structures.lisp | 17 +--- special-functions/sf-result.lisp | 24 ++++++ 22 files changed, 290 insertions(+), 227 deletions(-) create mode 100644 calculus/monte-carlo-structs.lisp create mode 100644 data/array-structs.lisp create mode 100644 eigensystems/eigen-struct.lisp create mode 100644 ordinary-differential-equations/ode-struct.lisp create mode 100644 series-struct.lisp create mode 100644 solve-minimize-fit/solver-struct.lisp create mode 100644 special-functions/sf-result.lisp diff --git a/calculus/monte-carlo-structs.lisp b/calculus/monte-carlo-structs.lisp new file mode 100644 index 00000000..bb2d7b28 --- /dev/null +++ b/calculus/monte-carlo-structs.lisp @@ -0,0 +1,65 @@ +;; CFFI-Grovel definitions for unix systems. +;; Liam Healy 2009-06-06 09:32:30EDT monte-carlo-structs.lisp +;; Time-stamp: <2009-06-06 09:36:24EDT monte-carlo-structs.lisp> + +#+linux +(define "_GNU_SOURCE") + +(in-package :gsl) + +(include "gsl/gsl_monte_plain.h") + +(cstruct plain-state "gsl_monte_plain_state" + (dim "dim" :type sizet) + (x "x" :type :pointer)) + +(include "gsl/gsl_monte_miser.h") + +(cstruct miser-state "gsl_monte_miser_state" + (min-calls "min_calls" :type sizet) + (min-calls-per-bisection "min_calls_per_bisection" :type sizet) + (dither "dither" :type :double) + (estimate-frac "estimate_frac" :type :double) + (alpha "alpha" :type :double) + (dim "dim" :type sizet) + (estimate-style "estimate_style" :type :int) + (depth "depth" :type :int) + (verbose "verbose" :type :int) + (x "x" :type :pointer) + (xmid "xmid" :type :pointer) + (sigma-l "sigma_l" :type :pointer) + (sigma-r "sigma_r" :type :pointer) + (fmax-l "fmax_l" :type :pointer) + (fmax-r "fmax_r" :type :pointer) + (fmin-l "fmin_l" :type :pointer) + (fmin-r "fmin_r" :type :pointer) + (fsum-l "fsum_l" :type :pointer) + (fsum-r "fsum_r" :type :pointer) + (fsum2-l "fsum2_l" :type :pointer) + (fsum2-r "fsum2_r" :type :pointer) + (hits-l "hits_l" :type :pointer) + (hits-r "hits_r" :type :pointer)) + +(include "gsl/gsl_monte_vegas.h") + +(cstruct vegas-state "gsl_monte_vegas_state" + ;; grid + (dim "dim" :type sizet) + (bins-max "bins_max" :type sizet) + (bins "bins" :type :uint) ; uint + (boxes "boxes" :type :uint) ; these are both counted along the axes + (xi "xi" :type :pointer) + (xin "xin" :type :pointer) + (delx "delx" :type :pointer) + (weight "weight" :type :pointer) + (vol "vol" :type :double) + (x "x" :type :pointer) + (bin "bin" :type :pointer) + (box "box" :type :pointer) + (d "d" :type :pointer) ; distribution + ;; control variables + (alpha "alpha" :type :double) + (mode "mode" :type :int) + (verbose "verbose" :type :int) + (iterations "iterations" :type :uint) + (stage "stage" :type :int)) diff --git a/calculus/monte-carlo.lisp b/calculus/monte-carlo.lisp index e88f4b81..32fbfd93 100644 --- a/calculus/monte-carlo.lisp +++ b/calculus/monte-carlo.lisp @@ -1,6 +1,6 @@ ;; Monte Carlo Integration ;; Liam Healy Sat Feb 3 2007 - 17:42 -;; Time-stamp: <2009-04-26 23:21:18EDT monte-carlo.lisp> +;; Time-stamp: <2009-06-06 09:27:29EDT monte-carlo.lisp> ;; $Id$ (in-package :gsl) @@ -23,10 +23,6 @@ :initialize-suffix "init" :initialize-args nil) -(cffi:defcstruct plain-state - (dim sizet) - (x :pointer)) - (defparameter *monte-carlo-default-samples-per-dimension* 150000) (defmfun monte-carlo-integrate-plain @@ -81,31 +77,6 @@ :initialize-suffix "init" :initialize-args nil) -(cffi:defcstruct miser-state - (min-calls sizet) - (min-calls-per-bisection sizet) - (dither :double) - (estimate-frac :double) - (alpha :double) - (dim sizet) - (estimate-style :int) - (depth :int) - (verbose :int) - (x :pointer) - (xmid :pointer) - (sigma-l :pointer) - (sigma-r :pointer) - (fmax-l :pointer) - (fmax-r :pointer) - (fmin-l :pointer) - (fmin-r :pointer) - (fsum-l :pointer) - (fsum-r :pointer) - (fsum2-l :pointer) - (fsum2-r :pointer) - (hits-l :pointer) - (hits-r :pointer)) - (export 'miser-parameter) (defmacro miser-parameter (workspace parameter) ;; FDL @@ -167,41 +138,6 @@ :initialize-suffix "init" :initialize-args nil) -(cffi:defcstruct vegas-state - ;; grid - (dim sizet) - (bins-max sizet) - (bins :uint) ; uint - (boxes :uint) ; these are both counted along the axes - (xi :pointer) - (xin :pointer) - (delx :pointer) - (weight :pointer) - (vol :double) - (x :pointer) - (bin :pointer) - (box :pointer) - (d :pointer) ; distribution - ;; control variables - (alpha :double) - (mode :int) - (verbose :int) - (iterations :uint) - (stage :int) - ;; scratch variables preserved between calls to vegas1/2/3 - (jac :double) - (wtd-int-sum :double) - (sum-wgts :double) - (chi-sum :double) - (chisq :double) - (result :double) - (sigma :double) - (it-start :uint) - (it-num :uint) - (samples :uint) - (calls-per-box :uint) - (ostream :pointer)) - (export 'vegas-parameter) (defmacro vegas-parameter (workspace parameter) ;; FDL diff --git a/data/array-structs.lisp b/data/array-structs.lisp new file mode 100644 index 00000000..28ad5dc5 --- /dev/null +++ b/data/array-structs.lisp @@ -0,0 +1,46 @@ +;; CFFI-Grovel definitions for unix systems. +;; Liam Healy 2009-06-06 09:36:29EDT array-structs.lisp +;; Time-stamp: <2009-06-06 10:16:51EDT array-structs.lisp> + +#+linux +(define "_GNU_SOURCE") + +(in-package :gsl) + +(include "gsl/gsl_block_double.h") + +(cstruct gsl-block-c "gsl_block" + (size "size" :type sizet) + (data "data" :type :pointer)) + +(include "gsl/gsl_vector_double.h") + +(cstruct gsl-vector-c "gsl_vector" + (size "size" :type sizet) + (stride "stride" :type sizet) + (data "data" :type :pointer) + (block "block" :type :pointer) + (owner "owner" :type :int)) + +(include "gsl/gsl_matrix_double.h") + +(cstruct gsl-matrix-c "gsl_matrix" + (size0 "size1" :type sizet) + (size1 "size2" :type sizet) + (tda "tda" :type sizet) + (data "data" :type :pointer) + (block "block" :type :pointer) + (owner "owner" :type :int)) + +(include "gsl/gsl_permutation.h") + +(cstruct gsl-permutation-c "gsl_permutation" + (size "size" :type sizet) + (data "data" :type :pointer)) + +(include "gsl/gsl_combination.h") + +(cstruct gsl-combination-c "gsl_combination" + (choice-of "n" :type sizet) + (size "k" :type sizet) + (data "data" :type :pointer)) diff --git a/data/combination.lisp b/data/combination.lisp index a369739e..9de51372 100644 --- a/data/combination.lisp +++ b/data/combination.lisp @@ -1,10 +1,12 @@ ;; Combinations ;; Liam Healy, Sun Mar 26 2006 - 11:51 -;; Time-stamp: <2009-05-25 10:04:32EDT combination.lisp> +;; Time-stamp: <2009-06-06 09:53:02EDT combination.lisp> ;; $Id$ (in-package :gsl) +;;; /usr/include/gsl/gsl_combination.h + ;;;;**************************************************************************** ;;;; Combination structure and CL object ;;;;**************************************************************************** @@ -19,11 +21,6 @@ :documentation "Maximum possible value; n in the (n k) notation.")) (:documentation "GSL combinations.")) -(cffi:defcstruct gsl-combination-c ; The GSL struct - (choice-of sizet) ; n - (size sizet) ; k - (data :pointer)) - (defmethod initialize-instance :after ((object combination) &key choice-of dimensions &allow-other-keys) (let ((mptr (cffi:foreign-alloc 'gsl-combination-c))) diff --git a/data/marray.lisp b/data/marray.lisp index 117540cf..4844b7c5 100644 --- a/data/marray.lisp +++ b/data/marray.lisp @@ -1,7 +1,6 @@ ;; A "marray" is an array in both GSL and CL ;; Liam Healy 2008-04-06 21:23:41EDT -;; Time-stamp: <2009-06-05 08:45:44EDT marray.lisp> -;; $Id$ +;; Time-stamp: <2009-06-06 09:58:56EDT marray.lisp> (in-package :gsl) @@ -15,10 +14,6 @@ (:documentation "A superclass for arrays represented in GSL and CL.")) -(cffi:defcstruct gsl-block-c ; The GSL struct - (size sizet) - (data :pointer)) - ;;; We don't allocate or free the C array data, because that is ;;; handled by foreign-array. We can use the GSL functions ;;; *_alloc_from_block because they will allocate only the structure, diff --git a/data/matrix.lisp b/data/matrix.lisp index 7ae31863..4056d188 100644 --- a/data/matrix.lisp +++ b/data/matrix.lisp @@ -1,10 +1,11 @@ ;; Matrices ;; Liam Healy 2008-04-15 21:57:52EDT matrix.lisp -;; Time-stamp: <2009-06-02 22:51:24EDT matrix.lisp> -;; $Id$ +;; Time-stamp: <2009-06-06 10:07:26EDT matrix.lisp> (in-package :gsl) +;;; /usr/include/gsl/gsl_matrix_double.h + ;;;;**************************************************************************** ;;;; Matrix structure and CL object ;;;;**************************************************************************** @@ -14,15 +15,6 @@ () (:documentation "GSL matrices.")) -;;; GSL-matrix definition -(cffi:defcstruct gsl-matrix-c - (size0 sizet) - (size1 sizet) - (tda sizet) - (data :pointer) - (block :pointer) - (owner :int)) - ;;; Define all supported matrix subclasses #.(data-defclass 'matrix 'matrix) diff --git a/data/permutation.lisp b/data/permutation.lisp index edec762b..b336d170 100644 --- a/data/permutation.lisp +++ b/data/permutation.lisp @@ -1,10 +1,12 @@ ;; Permutations ;; Liam Healy, Sun Mar 26 2006 - 11:51 -;; Time-stamp: <2009-05-25 09:47:14EDT permutation.lisp> +;; Time-stamp: <2009-06-06 09:49:18EDT permutation.lisp> ;; $Id$ (in-package :gsl) +;;; /usr/include/gsl/gsl_permutation.h + ;;;;**************************************************************************** ;;;; Permutation structure and CL object ;;;;**************************************************************************** @@ -17,10 +19,6 @@ :reader element-type :allocation :class)) (:documentation "GSL permutations.")) -(cffi:defcstruct gsl-permutation-c ; The GSL struct - (size sizet) - (data :pointer)) - (defmethod initialize-instance :after ((object permutation) &key dimensions &allow-other-keys) (let ((mptr (cffi:foreign-alloc 'gsl-permutation-c))) diff --git a/data/vector.lisp b/data/vector.lisp index a6a17b3c..6682c3c2 100644 --- a/data/vector.lisp +++ b/data/vector.lisp @@ -1,10 +1,11 @@ ;; Vectors ;; Liam Healy 2008-04-13 09:39:02EDT vector.lisp -;; Time-stamp: <2009-06-02 22:51:23EDT vector.lisp> -;; $Id$ +;; Time-stamp: <2009-06-06 10:04:13EDT vector.lisp> (in-package :gsl) +;;; /usr/include/gsl/gsl_vector_double.h + ;;;;**************************************************************************** ;;;; Vector structure, CL object, and allocation ;;;;**************************************************************************** @@ -14,14 +15,6 @@ () (:documentation "GSL vectors.")) -;;; GSL-vector definition -(cffi:defcstruct gsl-vector-c - (size sizet) - (stride sizet) - (data :pointer) - (block :pointer) - (owner :int)) - ;;; Define all supported mvector subclasses #.(data-defclass 'vector 'mvector) diff --git a/documentation/index.html b/documentation/index.html index 593fbd32..3287e6ae 100644 --- a/documentation/index.html +++ b/documentation/index.html @@ -327,6 +327,10 @@ area of memory.</p> e.g. solving, minimizing or fitting) that need to set a GSL vector or matrix, because one can simply copy into the passed-in pointer. </p> +<p>There are two functions provided to extract the dimensions of a + vector or array: <code>dim0</code> and <code>dim1</code>; the latter + is applicable only for matrices. +</p> <p>If you use <a href="http://common-lisp.net/project/iterate/">iterate</a>, there are extensions defined that make it easier to iterate over @@ -423,7 +427,7 @@ and arrays used internally or for function return. <!-- Created: Feb 25 2005 --> <!-- hhmts start --> <small> -Time-stamp: <2009-06-05 09:13:55EDT index.html> +Time-stamp: <2009-06-06 10:09:01EDT index.html> </small> <!-- hhmts end --> </div> diff --git a/eigensystems/eigen-struct.lisp b/eigensystems/eigen-struct.lisp new file mode 100644 index 00000000..433e6cf4 --- /dev/null +++ b/eigensystems/eigen-struct.lisp @@ -0,0 +1,13 @@ +;; CFFI-Grovel definitions. +;; Liam Healy +;; Time-stamp: <2009-06-06 11:01:18EDT eigen-struct.lisp> + +#+linux +(define "_GNU_SOURCE") + +(in-package :gsl) + +(include "gsl/gsl_eigen.h") + +(cstruct gsl-nonsymm-ws "gsl_eigen_nonsymm_workspace" + (n-evals "n_evals" :type sizet)) ; number of eigenvalues found diff --git a/eigensystems/symmetric-hermitian.lisp b/eigensystems/symmetric-hermitian.lisp index 610edb1f..1f391d66 100644 --- a/eigensystems/symmetric-hermitian.lisp +++ b/eigensystems/symmetric-hermitian.lisp @@ -1,6 +1,6 @@ ;; Eigenvectors and eigenvalues ;; Liam Healy, Sun May 21 2006 - 19:52 -;; Time-stamp: <2009-06-04 23:10:16EDT symmetric-hermitian.lisp> +;; Time-stamp: <2009-06-06 11:01:44EDT symmetric-hermitian.lisp> ;; $Id$ (in-package :gsl) @@ -23,15 +23,6 @@ n-by-n real symmetric matrices. The size of the workspace is O(2n).") -(cffi:defcstruct gsl-nonsymm-ws - (size sizet) ; size of matrices - (diag :pointer) ; diagonal matrix elements from balancing - (tau :pointer) ; Householder coefficients - (Z :pointer) ; pointer to Z matrix - (balancep :int) ; perform balancing transformation? - (n-evals sizet) ; number of eigenvalues found - (francis-ws :pointer)) - (defmobject eigen-symmv "gsl_eigen_symmv" ((n sizet)) "symmetric eigensystem workspace" diff --git a/gsll.asd b/gsll.asd index ecc2d4e2..8f82dadd 100644 --- a/gsll.asd +++ b/gsll.asd @@ -1,6 +1,6 @@ ;; Definition of GSLL system ;; Liam Healy -;; Time-stamp: <2009-06-04 22:58:44EDT gsll.asd> +;; Time-stamp: <2009-06-06 17:05:47EDT gsll.asd> ;; $Id$ (when (asdf:find-system :fsbv nil) @@ -28,7 +28,7 @@ (:file "callback" :depends-on (init utility forms number-conversion callback-included)) (:file "types" :depends-on (init)) - (:file "callback-struct" :depends-on (types)) + (cffi-grovel:grovel-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)) @@ -55,20 +55,22 @@ :components ((:file "foreign-friendly") (:file "foreign-array" :depends-on (foreign-friendly)) - (:file "marray" :depends-on (foreign-array)) - (:file "vector" :depends-on (marray)) - (:file "matrix" :depends-on (marray vector)) + (cffi-grovel:grovel-file "array-structs") + (:file "marray" :depends-on (foreign-array array-structs)) + (:file "vector" :depends-on (marray array-structs)) + (:file "matrix" :depends-on (marray vector array-structs)) (:file "maref" :depends-on (marray vector matrix)) (:file "both" :depends-on (marray vector matrix)) (:file "copy-cl") (:file "array-tests" :depends-on (both)) - (:file "permutation" :depends-on (marray)) - (:file "combination" :depends-on (marray)))) + (:file "permutation" :depends-on (marray array-structs)) + (:file "combination" :depends-on (marray array-structs)))) (:file "polynomial" :depends-on (init data)) (:module special-functions :depends-on (init) :components - ((:file "return-structures") + ((cffi-grovel:grovel-file "sf-result") + (:file "return-structures" :depends-on (sf-result)) (:file "airy" :depends-on (return-structures)) (:file "bessel" :depends-on (return-structures)) (:file "clausen" :depends-on (return-structures)) @@ -117,7 +119,8 @@ :depends-on (init data) :components ((:file "symmetric-hermitian") - (:file "nonsymmetric") + (cffi-grovel:grovel-file "eigen-struct") + (:file "nonsymmetric" :depends-on (eigen-struct)) (:file "generalized") (:file "nonsymmetric-generalized"))) ;; Skip fft for now, I'm not sure how it works in C @@ -187,13 +190,15 @@ ((:file "numerical-integration") (:file "numerical-integration-with-tables" :depends-on (numerical-integration)) + (cffi-grovel:grovel-file "monte-carlo-structs") (:file "monte-carlo") (:file "numerical-differentiation"))) (:module ordinary-differential-equations :depends-on (init) :components ((:file "ode-system") - (:file "stepping") + (cffi-grovel:grovel-file "ode-struct") + (:file "stepping" :depends-on (ode-struct)) (:file "control") (:file "evolution") (:file "ode-example" :depends-on (ode-system stepping)))) @@ -206,19 +211,22 @@ (:file "evaluation") (:file "spline-example" :depends-on (types)))) (:file "chebyshev" :depends-on (init)) - (:file "series-acceleration" :depends-on (init)) + (cffi-grovel:grovel-file "series-struct") + (:file "series-acceleration" :depends-on (init series-struct)) (:file "wavelet" :depends-on (init data)) (:file "hankel" :depends-on (init data)) (:module solve-minimize-fit :depends-on (init data random) :components ((:file "generic") + (cffi-grovel:grovel-file "solver-struct") (:file "roots-one" :depends-on (generic)) (:file "minimization-one" :depends-on (generic)) - (:file "roots-multi" :depends-on (roots-one generic)) + (:file "roots-multi" :depends-on (roots-one generic solver-struct)) (:file "minimization-multi" :depends-on (generic)) (:file "linear-least-squares") - (:file "nonlinear-least-squares" :depends-on (generic)) + (:file "nonlinear-least-squares" + :depends-on (generic solver-struct)) #+fsbv (:file "simulated-annealing"))) (:file "basis-splines" :depends-on (init data random)))) diff --git a/init/callback-struct.lisp b/init/callback-struct.lisp index 30cb1485..ac0ab39b 100644 --- a/init/callback-struct.lisp +++ b/init/callback-struct.lisp @@ -1,56 +1,57 @@ ;; 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: $ +;; Time-stamp: <2009-06-06 10:50:41EDT callback-struct.lisp> + +#+linux +(define "_GNU_SOURCE") (in-package :gsl) +(include "gsl/gsl_math.h") + ;;; Only the function -(cffi:defcstruct fnstruct - "Passing functions to GSL." - ;; see /usr/include/gsl/gsl_math.h - (function :pointer) - (parameters :pointer)) +(cstruct fnstruct "gsl_function" + (function "function" :type :pointer) + (parameters "params" :type :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)) +(cstruct fnstruct-fdf "gsl_function_fdf" + (function "f" :type :pointer) + (df "df" :type :pointer) + (fdf "fdf" :type :pointer) + (parameters "params" :type :pointer)) + +(include "gsl/gsl_multiroots.h") ;;; 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)) +;;; also defined in /usr/include/gsl/gsl_monte.h +(cstruct fnstruct-dimension "gsl_multiroot_function" + (function "f" :type :pointer) + (dimension "n" :type sizet) + (parameters "params" :type :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)) +(cstruct fnstruct-dimension-fdf "gsl_multiroot_function_fdf" + (function "f" :type :pointer) + (df "df" :type :pointer) + (fdf "fdf" :type :pointer) + (dimension "n" :type sizet) + (parameters "params" :type :pointer)) + +(include "gsl/gsl_multifit_nlin.h") ;;; 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)) +(cstruct fnstruct-fit "gsl_multifit_function" + (function "f" :type :pointer) + (number-of-observations "n" :type sizet) + (number-of-parameters "p" :type sizet) + (parameters "params" :type :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)) +(cstruct fnstruct-fit-fdf "gsl_multifit_function_fdf" + (function "f" :type :pointer) + (df "df" :type :pointer) + (fdf "fdf" :type :pointer) + (number-of-observations "n" :type sizet) + (number-of-parameters "p" :type sizet) + (parameters "params" :type :pointer)) diff --git a/ordinary-differential-equations/ode-struct.lisp b/ordinary-differential-equations/ode-struct.lisp new file mode 100644 index 00000000..b42a61c0 --- /dev/null +++ b/ordinary-differential-equations/ode-struct.lisp @@ -0,0 +1,16 @@ +;; Define the structure for ODEs +;; Liam Healy 2009-06-06 16:42:29EDT ode-struct.lisp +;; Time-stamp: <2009-06-06 17:08:02EDT ode-struct.lisp> + +#+linux +(define "_GNU_SOURCE") + +(in-package :gsl) + +(include "gsl/gsl_odeiv.h") + +(cstruct ode-system "gsl_odeiv_system" + (function "function" :type :pointer) + (jacobian "jacobian" :type :pointer) + (dimension "dimension" :type sizet) + (parameters "params" :type :pointer)) diff --git a/ordinary-differential-equations/stepping.lisp b/ordinary-differential-equations/stepping.lisp index ad863726..250be3fe 100644 --- a/ordinary-differential-equations/stepping.lisp +++ b/ordinary-differential-equations/stepping.lisp @@ -1,6 +1,6 @@ ;; Stepping functions for ODE systems. ;; Liam Healy, Mon Sep 24 2007 - 21:33 -;; Time-stamp: <2009-03-31 22:33:39EDT stepping.lisp> +;; Time-stamp: <2009-06-06 16:44:42EDT stepping.lisp> ;; $Id$ ;; /usr/include/gsl/gsl_odeiv.h @@ -39,14 +39,6 @@ (:type type :dimensions (list dimension)) (:functions (list function jacobian) :scalarsp scalarsp)))) -(cffi:defcstruct ode-system ; gsl_odeiv_system - "The definition of an ordinary differential equation system for GSL." - (function :pointer) - (jacobian :pointer) - (dimension sizet) - (parameters :pointer)) - - #| This description applies when scalars=t: diff --git a/series-acceleration.lisp b/series-acceleration.lisp index dd4dcd18..49eb4726 100644 --- a/series-acceleration.lisp +++ b/series-acceleration.lisp @@ -1,6 +1,6 @@ ;; Series acceleration. ;; Liam Healy, Wed Nov 21 2007 - 18:41 -;; Time-stamp: <2009-04-26 23:27:40EDT series-acceleration.lisp> +;; Time-stamp: <2009-06-06 11:12:37EDT series-acceleration.lisp> ;; $Id$ (in-package :gsl) @@ -11,18 +11,6 @@ ;;;; Creation and calculation of Levin series acceleration ;;;;**************************************************************************** -(cffi:defcstruct levin-c - "The definition of Levin series acceleration for GSL." - (size sizet) - (position-in-array sizet) - (terms-used sizet) - (sum-plain :double) - (q-num :pointer) - (q-den :pointer) - (dq-num :pointer) - (dq-den :pointer) - (dsum :pointer)) - (defun levin-value (levin slot) (cffi:foreign-slot-value (mpointer levin) 'levin-c slot)) diff --git a/series-struct.lisp b/series-struct.lisp new file mode 100644 index 00000000..e85c33fd --- /dev/null +++ b/series-struct.lisp @@ -0,0 +1,14 @@ +;; Define the structure for series +;; Liam Healy 2009-06-06 11:08:11EDT series-struct.lisp +;; Time-stamp: <2009-06-06 16:44:41EDT series-struct.lisp> + +#+linux +(define "_GNU_SOURCE") + +(in-package :gsl) + +(include "gsl/gsl_sum.h") + +(cstruct levin-c "gsl_sum_levin_u_workspace" + (terms-used "terms_used" :type sizet) + (sum-plain "sum_plain" :type :double)) diff --git a/solve-minimize-fit/nonlinear-least-squares.lisp b/solve-minimize-fit/nonlinear-least-squares.lisp index 6e41da22..39f19388 100644 --- a/solve-minimize-fit/nonlinear-least-squares.lisp +++ b/solve-minimize-fit/nonlinear-least-squares.lisp @@ -1,6 +1,6 @@ ;; Nonlinear least squares fitting. ;; Liam Healy, 2008-02-09 12:59:16EST nonlinear-least-squares.lisp -;; Time-stamp: <2009-05-24 22:56:35EDT nonlinear-least-squares.lisp> +;; Time-stamp: <2009-06-06 16:47:47EDT nonlinear-least-squares.lisp> ;; $Id$ (in-package :gsl) @@ -71,18 +71,6 @@ :initialize-suffix "set" :initialize-args ((callback :pointer) ((mpointer initial-guess) :pointer))) -(cffi:defcstruct gsl-fdffit-solver - ;; See /usr/include/gsl/gsl_multifit_nlin.h - "The definition of a solver instance and state - for nonlinear least squares fitting in GSL." - (type :pointer) - (fdf :pointer) - (x :pointer) - (f :pointer) - (jacobian :pointer) - (dx :pointer) - (state :pointer)) - (defmfun name ((solver nonlinear-fdffit)) "gsl_multifit_fdfsolver_name" (((mpointer solver) :pointer)) diff --git a/solve-minimize-fit/roots-multi.lisp b/solve-minimize-fit/roots-multi.lisp index 79d87a20..982d216c 100644 --- a/solve-minimize-fit/roots-multi.lisp +++ b/solve-minimize-fit/roots-multi.lisp @@ -1,6 +1,6 @@ ;;; Multivariate roots. ;;; Liam Healy 2008-01-12 12:49:08 -;;; Time-stamp: <2009-04-04 22:29:12EDT roots-multi.lisp> +;;; Time-stamp: <2009-06-06 16:53:34EDT roots-multi.lisp> ;;; $Id$ (in-package :gsl) @@ -189,14 +189,6 @@ ;;; The only place we need to pick apart the gsl_multiroot_fsolver ;;; struct is here. We could use last-step etc., but then we'd have ;;; to discriminate on mfsolver vs. mfdfsolver. -(cffi:defcstruct gsl-multiroot-fsolver - ;; See /usr/include/gsl/gsl_multiroots.h - (type :pointer) - (function :pointer) - (x :pointer) - (f :pointer) - (dx :pointer) - (state :pointer)) (defun multiroot-slot (solver slot) (cffi:foreign-slot-value (mpointer solver) 'gsl-multiroot-fsolver slot)) diff --git a/solve-minimize-fit/solver-struct.lisp b/solve-minimize-fit/solver-struct.lisp new file mode 100644 index 00000000..115bdb7a --- /dev/null +++ b/solve-minimize-fit/solver-struct.lisp @@ -0,0 +1,25 @@ +;; Define the structures for solvers +;; Liam Healy 2009-06-06 16:46:38EDT solver-struct.lisp +;; Time-stamp: <2009-06-06 17:09:33EDT solver-struct.lisp> + +#+linux +(define "_GNU_SOURCE") + +(in-package :gsl) + +(include "gsl/gsl_multifit_nlin.h") + +;; The definition of a solver instance and state +;; for nonlinear least squares fitting in GSL." + +(cstruct gsl-fdffit-solver "gsl_multifit_fdfsolver" + (f "f" :type :pointer) + (jacobian "J" :type :pointer) + (dx "dx" :type :pointer)) + +(include "gsl/gsl_multiroots.h") + +(cstruct gsl-multiroot-fsolver "gsl_multiroot_fsolver" + (x "x" :type :pointer) + (f "f" :type :pointer) + (dx "dx" :type :pointer)) diff --git a/special-functions/return-structures.lisp b/special-functions/return-structures.lisp index e8f805e4..8e123415 100644 --- a/special-functions/return-structures.lisp +++ b/special-functions/return-structures.lisp @@ -1,7 +1,6 @@ ;; Structures returned by special functions. ;; Liam Healy, Mon Jan 1 2007 - 11:35 -;; Time-stamp: <2009-05-25 14:43:47EDT return-structures.lisp> -;; $Id$ +;; Time-stamp: <2009-06-06 10:32:44EDT return-structures.lisp> (in-package :gsl) @@ -9,20 +8,6 @@ ;;;; Result from special functions ;;;;**************************************************************************** -(cffi:defcstruct sf-result - "Results from special functions with value and error estimate." - ;; file:///usr/share/doc/gsl-ref-html/gsl-ref_7.html#SEC61 - (val :double) - (err :double)) - -(cffi:defcstruct sf-result-e10 - "Results from special functions with value, error estimate - and a scaling exponent e10, such that the value is val*10^e10." - ;; file:///usr/share/doc/gsl-ref-html/gsl-ref_7.html#SEC61 - (val :double) - (err :double) - (e10 :int)) - (defun val (sf-result &optional (type 'sf-result)) (cffi:foreign-slot-value sf-result type 'val)) diff --git a/special-functions/sf-result.lisp b/special-functions/sf-result.lisp new file mode 100644 index 00000000..ab714150 --- /dev/null +++ b/special-functions/sf-result.lisp @@ -0,0 +1,24 @@ +;; CFFI-Grovel definitions for unix systems. +;; Liam Healy +;; Time-stamp: <2009-06-06 10:54:09EDT sf-result.lisp> + +#+linux +(define "_GNU_SOURCE") + +(in-package :gsl) + +(include "gsl/gsl_sf_result.h") + +;;; Results from special functions with value and error estimate. +;;; file:///usr/share/doc/gsl-ref-html/gsl-ref_7.html#SEC61 +(cstruct sf-result "gsl_sf_result" + (val "val" :type :double) + (err "err" :type :double)) + +;;; Results from special functions with value, error estimate +;;; and a scaling exponent e10, such that the value is val*10^e10. +;;; file:///usr/share/doc/gsl-ref-html/gsl-ref_7.html#SEC61 +(cstruct sf-result-e10 "gsl_sf_result_e10" + (val "val" :type :double) + (err "err" :type :double) + (e10 "e10" :type :int)) -- GitLab