From 0ca58836c611a007d48aea97d5eab44c1c00449b Mon Sep 17 00:00:00 2001 From: Liam Healy <liam@thinkpad.local> Date: Sat, 2 May 2009 22:48:02 -0400 Subject: [PATCH] Call GSL functions with complex scalars With improved fsbv:foreign-funcall that does the conversion of values between Lisp and C, the function foreign-funcall-indirect has been eliminated in favor of using fsbv:foreign-funcall directly. Spot checks on various functions that use complex scalars like #'evaluate polynomials at a complex point, or set-all on complex marrays, or the functions in complex.lisp, show that these all work. Everything compiles/loads and the usual tests pass in SBCL. --- init/body-expand.lisp | 31 ++----------------------------- polynomial.lisp | 3 +-- 2 files changed, 3 insertions(+), 31 deletions(-) diff --git a/init/body-expand.lisp b/init/body-expand.lisp index 0b53ddb4..d1b69cf7 100644 --- a/init/body-expand.lisp +++ b/init/body-expand.lisp @@ -1,6 +1,6 @@ ;; Expand the body of a defmfun ;; Liam Healy 2009-04-13 22:07:13EDT body-expand.lisp -;; Time-stamp: <2009-04-25 23:42:34EDT body-expand.lisp> +;; Time-stamp: <2009-05-02 21:43:36EDT body-expand.lisp> ;; $Id: $ (in-package :gsl) @@ -42,33 +42,6 @@ :test 'st-symbol)) finally (return answer))) -(defmacro foreign-funcall-indirect (name-and-options &rest arguments) - "Call the foreign function through FSBV, after setting one more level of indirection." - (let* ((arguments-symbol-type - (loop for (type form) on (butlast arguments) by #'cddr - collect - (list (if (symbolp form) - (make-symbol (string form)) - (gensym "FORMARG")) - type))) - (clargs (loop for (nil form) on (butlast arguments) by #'cddr - collect form)) - (ptrlist (mapcar - (lambda (st) - (make-st (st-symbol st) - (st-type st))) - arguments-symbol-type))) - ;; Here allocate the foreign objects - `(fsbv:with-foreign-objects - ,(mapcar (lambda (st cl) - (append (make-st (st-symbol st) `',(st-type st)) - (list cl))) - ptrlist - clargs) - (fsbv:foreign-funcall - ,name-and-options - ,@(append (mappend 'reverse ptrlist) (last arguments)))))) - (defun body-expand (name arglist gsl-name c-arguments key-args) "Expand the body (computational part) of the defmfun." (with-defmfun-key-args key-args @@ -113,7 +86,7 @@ cbinfo callback-dynamic-variables callback-dynamic) (let ((,(st-symbol creturn-st) (,(if (some 'identity pbv) - 'foreign-funcall-indirect + 'fsbv:foreign-funcall 'cffi:foreign-funcall) ,gsl-name ,@(mappend diff --git a/polynomial.lisp b/polynomial.lisp index d6511efe..8adc4df5 100644 --- a/polynomial.lisp +++ b/polynomial.lisp @@ -1,6 +1,6 @@ ;; Polynomials ;; Liam Healy, Tue Mar 21 2006 - 18:33 -;; Time-stamp: <2009-04-29 22:34:47EDT polynomial.lisp> +;; Time-stamp: <2009-04-30 22:57:18EDT polynomial.lisp> ;; $Id$ (in-package :gsl) @@ -26,7 +26,6 @@ :documentation ; FDL "Evaluate the polyonomial with coefficients at the point x.") -;;; These won't work until we can take returned complex (structs). (defmfun evaluate ((coefficients vector-double-float) (x complex) &key) -- GitLab