Skip to content
Snippets Groups Projects
Commit 84352788 authored by liam's avatar liam
Browse files

Solvers returning complex values also have value counts. Export and

map symbols that are hand-rolled (not going through defun-sf).



git-svn-id: svn+ssh://pop/opt/space/mathematics/gsl/trunk@2992 a3d8a0fb-c1db-0310-ace7-a616afeb9e30
parent 6438e06d
Branches
Tags
No related merge requests found
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
; description: Polynomials ; description: Polynomials
; date: Tue Mar 21 2006 - 18:33 ; date: Tue Mar 21 2006 - 18:33
; author: Liam M. Healy ; author: Liam M. Healy
; modified: Wed Mar 22 2006 - 10:06 ; modified: Wed Mar 22 2006 - 10:23
;******************************************************** ;********************************************************
;;; $Id: $ ;;; $Id: $
...@@ -18,8 +18,7 @@ ...@@ -18,8 +18,7 @@
;;;; Polynomial Evaluation ;;;; Polynomial Evaluation
;;;;**************************************************************************** ;;;;****************************************************************************
(export 'polynomial-eval) (defunx-map polynomial-eval "gsl_poly_eval" (coefficients x)
(defun polynomial-eval (coefficients x)
"Evaluate the polyonomial with coefficients at the point x." "Evaluate the polyonomial with coefficients at the point x."
(let ((len (length coefficients))) (let ((len (length coefficients)))
(cffi::with-foreign-array (coef coefficients :double (list len)) (cffi::with-foreign-array (coef coefficients :double (list len))
...@@ -39,10 +38,7 @@ ...@@ -39,10 +38,7 @@
;;; get-divided-difference, eval-divided-difference or taylor-divided-difference ;;; get-divided-difference, eval-divided-difference or taylor-divided-difference
;;; in the body. ;;; in the body.
(export (export '(with-divided-difference))
'(with-divided-difference get-divided-difference
eval-divided-difference taylor-divided-difference))
(defmacro with-divided-difference ((dd xa ya) &body body) (defmacro with-divided-difference ((dd xa ya) &body body)
"Compute the divided difference and bind dd to it. "Compute the divided difference and bind dd to it.
This variable may then be passed to divided-difference This variable may then be passed to divided-difference
...@@ -71,14 +67,15 @@ ...@@ -71,14 +67,15 @@
:int)) :int))
(list dd xac size))) (list dd xac size)))
(defun get-divided-difference (dd) (defunx get-divided-difference (dd)
"Convert the divided difference into an array." "Convert the divided difference into an array."
(cffi::foreign-array-to-lisp (cffi::foreign-array-to-lisp
(first dd) :double (list (third dd)))) (first dd) :double (list (third dd))))
(defun eval-divided-difference (dd x) (defunx-map eval-divided-difference "gsl_poly_dd_eval" (dd x)
"Evaluate the polynomial stored in divided-difference form "Evaluate the polynomial stored in divided-difference form
at the point @var{x}." at the point @var{x}. Call only within a
with-divided-difference form."
(cffi:foreign-funcall (cffi:foreign-funcall
"gsl_poly_dd_eval" "gsl_poly_dd_eval"
:pointer (first dd) :pointer (first dd)
...@@ -87,9 +84,10 @@ ...@@ -87,9 +84,10 @@
:double x :double x
:double)) :double))
(defun taylor-divided-difference (dd xp) (defunx-map taylor-divided-difference "gsl_poly_dd_taylor" (dd xp)
"Convert the divided-difference representation of a polynomial "Convert the divided-difference representation of a polynomial
to a Taylor expansion about the point xp." to a Taylor expansion about the point xp. Call only within a
with-divided-difference form."
(let ((cc (foreign-alloc :double :count (third dd))) (let ((cc (foreign-alloc :double :count (third dd)))
(workspace (foreign-alloc :double :count (third dd)))) (workspace (foreign-alloc :double :count (third dd))))
(unwind-protect (unwind-protect
...@@ -125,8 +123,11 @@ ...@@ -125,8 +123,11 @@
(defun-sf solve-quadratic-complex ((a :double) (b :double) (c :double)) (defun-sf solve-quadratic-complex ((a :double) (b :double) (c :double))
"gsl_poly_complex_solve_quadratic" "gsl_poly_complex_solve_quadratic"
:documentation :documentation
"The complex roots of the quadratic equation a x^2 + b x + c = 0." "The complex roots of the quadratic equation a x^2 + b x + c = 0.
:return (gsl-complex gsl-complex)) Two values are always returned; if a root does not exist, the
value returned will be NIL."
:return (gsl-complex gsl-complex)
:return-code :number-of-answers)
;;;;**************************************************************************** ;;;;****************************************************************************
;;;; Cubic Equations ;;;; Cubic Equations
...@@ -148,7 +149,7 @@ ...@@ -148,7 +149,7 @@
"Find the real roots of the cubic equation, x^3 + a x^2 + b x + c = 0 "Find the real roots of the cubic equation, x^3 + a x^2 + b x + c = 0
with a leading coefficient of unity. The roots are given with a leading coefficient of unity. The roots are given
in ascending order. Three values are always returned; in ascending order. Three values are always returned;
if a roots is not real, the value returned for it will be NIL." if a root is not real, the value returned for it will be NIL."
:return (:double :double :double) :return (:double :double :double)
:return-code :number-of-answers) :return-code :number-of-answers)
...@@ -156,6 +157,7 @@ ...@@ -156,6 +157,7 @@
"gsl_poly_complex_solve_cubic" "gsl_poly_complex_solve_cubic"
:documentation :documentation
"Find the complex roots of the cubic equation, x^3 + a x^2 + b x + c = 0 "Find the complex roots of the cubic equation, x^3 + a x^2 + b x + c = 0
with a leading coefficient of unity. The real roots are returned. with a leading coefficient of unity. Three values are always returned;
No special indication is given if there is only one real root." if a root does not exist, the value returned for it will be NIL."
:return (gsl-complex gsl-complex gsl-complex)) :return (gsl-complex gsl-complex gsl-complex)
:return-code :number-of-answers)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment