Commit fccb266c authored by liam's avatar liam
Browse files

Define the Jacobian function and struct for the system.


git-svn-id: svn+ssh://pop/opt/space/mathematics/gsl/trunk@3228 a3d8a0fb-c1db-0310-ace7-a616afeb9e30
parent d5250819
......@@ -3,18 +3,22 @@
; description: ODE initial value problems
; date: Sun Apr 15 2007 - 14:19
; author: Liam Healy
; modified: Sat Sep 15 2007 - 19:24
; modified: Sun Sep 23 2007 - 18:26
;********************************************************
;;; $Id: $
(in-package :gsl)
(defun-gsl
"gsl_odeiv_system"
(cffi:defcstruct ode-system ; gsl_odeiv_system
;; See /usr/include/gsl/gsl_odeiv.h
"The definition of an ordinary differential equation system for GSL."
(function :pointer)
(jacobian :pointer)
(dimension :size)
(parameters :pointer))
)
(export 'def-ode-function 'def-jacobian-function)
(export 'def-ode-function)
(defmacro def-ode-function (name time dependent derivatives &body body)
"Define a function that will evaluate the right-hand sides (derivatives)
defining a set of ordinary differential equations (ODE).
......@@ -27,8 +31,8 @@
using a lexical closure."
`(cffi:defcallback ,name :int
((,time :double)
(,dependent :pointer) ; This needs to be a C array
(,derivatives :pointer) ; This needs to be a C array
(,dependent :pointer)
(,derivatives :pointer)
(params :pointer))
(declare (ignore params) (ignorable ,time))
,@body
......@@ -41,3 +45,26 @@
(setf (double-to-cl dydt 0) (- (double-to-cl y 1))
(double-to-cl dydt 1) (double-to-cl y 0)))
|#
(defmacro def-jacobian-function (name time dependent dfdy dfdt &body body)
"Define a function that will evaluate the Jacobian (partial derivative)
of the set of ordinary differential equations (ODE).
The function should take as input the time (a double-float) and
dependent variables (a vector of double-floats) and fill the
dfdy matrix and dfdt vector with double-floats.
It may refer to elements
of these vectors (arrays) using the macro double-to-cl.
This function may be passed to the GSL ODE integrators.
Parameters (non integration variables) may be passed by
using a lexical closure."
`(cffi:defcallback ,name :int
((,time :double)
(,dependent :pointer)
(,dfdy :pointer) ; This is a vector but should be CL array
(,dfdt :pointer)
(params :pointer))
(declare (ignore params) (ignorable ,time))
,@body
;; Any errors or warnings should be signalled on the CL side;
;; if the function completes, we will always return success.
(cffi:foreign-enum-value 'gsl-errorno :SUCCESS)))
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