Commit 60f252ea authored by liam's avatar liam
Browse files

Fix bug in defun-gsl that caused #'polynomial-solve to not return

anything.


git-svn-id: svn+ssh://pop/opt/space/mathematics/gsl/trunk@3275 a3d8a0fb-c1db-0310-ace7-a616afeb9e30
parent e803849a
;; Macros to interface GSL functions. ;; Macros to interface GSL functions.
;; Liam Healy ;; Liam Healy
;; Time-stamp: <2008-01-19 19:54:09EST interface.lisp> ;; Time-stamp: <2008-01-26 21:33:48EST interface.lisp>
;; $Id: $ ;; $Id: $
(in-package :gsl) (in-package :gsl)
...@@ -185,7 +185,7 @@ ...@@ -185,7 +185,7 @@
(mapcar (mapcar
(lambda (s) (find s cargs :key #'st-symbol)) (lambda (s) (find s cargs :key #'st-symbol))
allocated)) allocated))
(clret (or (substitute cret-name :c-return return) (clret (or (substitute cret-name :c-return return) ; better as a symbol macro
(mapcan #'cl-convert-form allocated-decl) (mapcan #'cl-convert-form allocated-decl)
invalidate invalidate
(unless (eq c-return :void) (unless (eq c-return :void)
...@@ -251,7 +251,8 @@ ...@@ -251,7 +251,8 @@
(t (unless (t (unless
(or (or
(and (eq c-return :error-code) (and (eq c-return :error-code)
(not allocated)) (not allocated)
(not return-supplied-p))
(and (null return) return-supplied-p)) (and (null return) return-supplied-p))
clret))))))) clret)))))))
,@(when index `((map-name ',(if (eql index t) name index) ,gsl-name))) ,@(when index `((map-name ',(if (eql index t) name index) ,gsl-name)))
......
...@@ -130,26 +130,19 @@ ...@@ -130,26 +130,19 @@
;;;; General Polynomial Equations ;;;; General Polynomial Equations
;;;;**************************************************************************** ;;;;****************************************************************************
(defun-gsl complex-workspace-alloc (n) (set-asf complex-workspace allocate-complex-workspace free-complex-workspace)
(defun-gsl allocate-complex-workspace (n)
"gsl_poly_complex_workspace_alloc" ((n :size)) "gsl_poly_complex_workspace_alloc" ((n :size))
:c-return :pointer :c-return :pointer
:export nil :export nil
:index with-poly-complex-workspace) :index (with-gsl-object complex-workspace))
(defun-gsl complex-workspace-free (ws) (defun-gsl free-complex-workspace (ws)
"gsl_poly_complex_workspace_free" ((ws :pointer)) "gsl_poly_complex_workspace_free" ((ws :pointer))
:c-return :void :c-return :void
:export nil :export nil
:index with-poly-complex-workspace) :index (with-gsl-object complex-workspace))
(export '(with-poly-complex-workspace))
(defmacro with-poly-complex-workspace ((workspace size) &body body)
"Macro to create and cleanup workspace for polynomial root solver."
`(let ((,workspace (complex-workspace-alloc ,size)))
(unwind-protect
(progn ,@body)
(complex-workspace-free ,workspace))))
(defun polynomial-solve (coefficients) (defun polynomial-solve (coefficients)
"The roots of the general polynomial "The roots of the general polynomial
...@@ -164,7 +157,7 @@ ...@@ -164,7 +157,7 @@
(with-data (coef vector-double len) (with-data (coef vector-double len)
(setf (data coef) coefficients) (setf (data coef) coefficients)
(with-data (answer vector-double ((* 2 (1- len)))) (with-data (answer vector-double ((* 2 (1- len))))
(with-poly-complex-workspace (ws len) (with-gsl-objects ((complex-workspace ws len))
(values-list (polynomial-solve-ws coef ws answer))))))) (values-list (polynomial-solve-ws coef ws answer)))))))
(defun-gsl polynomial-solve-ws (coefficients workspace answer-pd) (defun-gsl polynomial-solve-ws (coefficients workspace answer-pd)
......
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