Commit 9f0886b5 authored by liam's avatar liam

Multivariate root solution, which needs definitions

make-data-from-pointer, gsl-array-p, generalize def-scalar-function.
Derivative-free solution works.


git-svn-id: svn+ssh://pop/opt/space/mathematics/gsl/trunk@3263 a3d8a0fb-c1db-0310-ace7-a616afeb9e30
parent 4423b911
......@@ -3,7 +3,7 @@
; description: Using GSL storage.
; date: Sun Mar 26 2006 - 16:32
; author: Liam M. Healy
; modified: Sun Dec 31 2006 - 17:34
; modified: Sun Jan 13 2008 - 22:49
;********************************************************
;;; $Id: $
......@@ -234,6 +234,14 @@
(progn ,@body)
(free ,symbol))))
(defun make-data-from-pointer (pointer &optional (class 'gsl-vector-double) size)
"Given a C pointer to a GSL data type, make the CL object."
(make-instance
class
:pointer pointer
:storage-size
(or size (cffi:foreign-slot-value pointer 'gsl-vector-c 'size))))
;;;;****************************************************************************
;;;; Getting values into CL
;;;;****************************************************************************
......
......@@ -3,7 +3,7 @@
; description: Vectors
; date: Sun Mar 26 2006 - 11:51
; author: Liam M. Healy
; modified: Mon Nov 26 2007 - 23:30
; modified: Sun Jan 13 2008 - 22:40
;********************************************************
;;; $Id: $
......@@ -79,6 +79,11 @@ deallocated with the vector.
(defmethod gsl-array ((object gsl-vector))
(cffi:foreign-slot-value (pointer object) 'gsl-vector-c 'data))
(defun gsl-array-p (pointer)
"A pointer to the GSL array with the data contents, from the
sruct pointer."
(cffi:foreign-slot-value pointer 'gsl-vector-c 'data))
;;;;****************************************************************************
;;;; Getting values
;;;;****************************************************************************
......
......@@ -3,7 +3,7 @@
; description: Foreign callback functions.
; date: Sun Dec 9 2007 - 22:08
; author: Liam Healy
; modified: Sun Jan 6 2008 - 12:46
; modified: Sun Jan 13 2008 - 13:26
;********************************************************
;;; $Id: $
......@@ -74,16 +74,23 @@
(name
&optional (return-type :double) (argument-type :double)
(structure 'gsl-function)
additional-slots)
"Define the variable given by name
as a foreign gsl-function that contains the callback
of a CL function of the same name."
additional-slots
additional-arguments)
"Define a callback and optionally a related C struct used by GSL.
This struct is bound to a CL special with the specified name.
This macro can be used whenever a callback is defined and
placed in a struct that has no other functions defined."
(let ((argument (gensym "CB")))
`(progn
(cffi:defcallback ,name ,return-type
((,argument ,argument-type) (params :pointer))
(cffi:defcallback ,name
,(if (eq return-type :success-failure) :int return-type)
((,argument ,argument-type) (params :pointer) ,@additional-arguments)
(declare (ignore params))
(,name ,argument))
(,name ,argument ,@(mapcar #'first additional-arguments))
,@(when (eq return-type :success-failure)
;; We always return success, because if there was a
;; problem, a CL error would be signalled.
'((cffi:foreign-enum-value 'gsl-errorno :SUCCESS))))
,@(when
structure
;; Assume that defcallback does not bind the variable 'name.
......
This diff is collapsed.
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