Skip to content
Snippets Groups Projects
Commit 84b5a165 authored by Liam Healy's avatar Liam Healy
Browse files

Chebyshev ported to callbacks-included and example/test fixed

Chebyshev object now built on callbacks-included.  The example/test
was generating an error because the calls in integral-chebyshev and
derivative-chebyshev did not have a needed #'mpointer call.  This has
been fixed and the test results match the previous result given in
8d9ce4e8.
parent ea176adc
No related branches found
No related tags found
No related merge requests found
;; Chebyshev Approximations ;; Chebyshev Approximations
;; Liam Healy Sat Nov 17 2007 - 20:36 ;; Liam Healy Sat Nov 17 2007 - 20:36
;; Time-stamp: <2009-01-28 19:05:30EST chebyshev.lisp> ;; Time-stamp: <2009-02-15 10:44:23EST chebyshev.lisp>
;; $Id$ ;; $Id$
(in-package :gsl) (in-package :gsl)
...@@ -16,9 +16,19 @@ ...@@ -16,9 +16,19 @@
"Chebyshev series" "Chebyshev series"
:documentation ; FDL :documentation ; FDL
"Make a Chebyshev series of specified order." "Make a Chebyshev series of specified order."
:superclasses (callback-included)
:ci-class-slots (gsl-function nil (function))
:initialize-suffix "init" :initialize-suffix "init"
:initialize-args :initialize-args
((function :pointer) (lower-limit :double) (upper-limit :double))) ((callback :pointer) (lower-limit :double) (upper-limit :double))
:singular (function))
(def-make-callbacks chebyshev (function)
`(defmcallback ,function
:double :double
nil
t
,function))
;;;;**************************************************************************** ;;;;****************************************************************************
;;;; Chebyshev series evaluation ;;;; Chebyshev series evaluation
...@@ -55,7 +65,7 @@ ...@@ -55,7 +65,7 @@
(defmfun derivative-chebyshev (derivative chebyshev) (defmfun derivative-chebyshev (derivative chebyshev)
"gsl_cheb_calc_deriv" "gsl_cheb_calc_deriv"
((derivative :pointer) ((mpointer chebyshev) :pointer)) (((mpointer derivative) :pointer) ((mpointer chebyshev) :pointer))
:documentation ; FDL :documentation ; FDL
"Compute the derivative of the Chebyshev series, storing "Compute the derivative of the Chebyshev series, storing
the derivative coefficients in the previously allocated series. the derivative coefficients in the previously allocated series.
...@@ -63,7 +73,7 @@ ...@@ -63,7 +73,7 @@
(defmfun integral-chebyshev (integral chebyshev) (defmfun integral-chebyshev (integral chebyshev)
"gsl_cheb_calc_integ" "gsl_cheb_calc_integ"
((integral :pointer) ((mpointer chebyshev) :pointer)) (((mpointer integral) :pointer) ((mpointer chebyshev) :pointer))
:documentation ; FDL :documentation ; FDL
"Compute the integral of the Chebyshev series, storing "Compute the integral of the Chebyshev series, storing
the integral coefficients in the previously allocated series. the integral coefficients in the previously allocated series.
...@@ -80,11 +90,11 @@ ...@@ -80,11 +90,11 @@
(defun chebyshev-step (x) (if (< x 0.5d0) 0.25d0 0.75d0)) (defun chebyshev-step (x) (if (< x 0.5d0) 0.25d0 0.75d0))
(make-callbacks chebyshev chebyshev-step)
(defun chebyshev-table-example () (defun chebyshev-table-example ()
(let ((steps 100)) (let ((steps 100))
(let ((cheb (let ((cheb (make-chebyshev 40 'chebyshev-step 0.0d0 1.0d0)))
(make-chebyshev
40 (make-single-function chebyshev-step) 0.0d0 1.0d0)))
(dotimes (i steps) (dotimes (i steps)
(let ((x (coerce (/ i steps) 'double-float))) (let ((x (coerce (/ i steps) 'double-float)))
(format t "~&~a ~a ~a ~a" (format t "~&~a ~a ~a ~a"
...@@ -95,8 +105,7 @@ ...@@ -95,8 +105,7 @@
(defun chebyshev-point-example (x) (defun chebyshev-point-example (x)
(check-type x double-float) (check-type x double-float)
(let ((cheb (make-chebyshev (let ((cheb (make-chebyshev 40 'chebyshev-step 0.0d0 1.0d0))
40 (make-single-function chebyshev-step) 0.0d0 1.0d0))
(deriv (make-chebyshev 40)) (deriv (make-chebyshev 40))
(integ (make-chebyshev 40))) (integ (make-chebyshev 40)))
(derivative-chebyshev deriv cheb) (derivative-chebyshev deriv cheb)
......
;; Foreign callback functions. ;; Foreign callback functions.
;; Liam Healy ;; Liam Healy
;; Time-stamp: <2009-02-14 19:22:53EST callback.lisp> ;; Time-stamp: <2009-02-15 10:43:05EST callback.lisp>
;; $Id$ ;; $Id$
(in-package :gsl) (in-package :gsl)
...@@ -372,7 +372,9 @@ ...@@ -372,7 +372,9 @@
(defmethod print-object ((object callback-included) stream) (defmethod print-object ((object callback-included) stream)
(print-unreadable-object (object stream :type t :identity t) (print-unreadable-object (object stream :type t :identity t)
(princ "for " stream) (when (slot-boundp object 'functions)
(princ (first (functions object)) stream) (princ "for " stream)
(princ ", dimensions " stream) (princ (first (functions object)) stream)
(princ "," stream))
(princ "dimensions " stream)
(princ (dimensions object) stream))) (princ (dimensions object) stream)))
;; Univariate minimization ;; Univariate minimization
;; Liam Healy Tue Jan 8 2008 - 21:02 ;; Liam Healy Tue Jan 8 2008 - 21:02
;; Time-stamp: <2009-02-10 21:47:41EST minimization-one.lisp> ;; Time-stamp: <2009-02-15 10:14:09EST minimization-one.lisp>
;; $Id$ ;; $Id$
(in-package :gsl) (in-package :gsl)
...@@ -192,9 +192,6 @@ ...@@ -192,9 +192,6 @@
(make-callbacks one-dimensional-minimizer minimization-one-fn) (make-callbacks one-dimensional-minimizer minimization-one-fn)
#+callback-toplevel-only
(defparameter *minone-cb* (make-single-function minimization-one-fn))
(defun minimization-one-example (defun minimization-one-example
(&optional (minimizer-type *brent-fminimizer*) (print-steps t)) (&optional (minimizer-type *brent-fminimizer*) (print-steps t))
"Solving a minimum, the example given in Sec. 33.8 of the GSL manual." "Solving a minimum, the example given in Sec. 33.8 of the GSL manual."
......
...@@ -3,7 +3,9 @@ ...@@ -3,7 +3,9 @@
(in-package :gsl) (in-package :gsl)
(LISP-UNIT:DEFINE-TEST CHEBYSHEV (LISP-UNIT:DEFINE-TEST CHEBYSHEV
(LISP-UNIT:ASSERT-ERROR 'TYPE-ERROR (LISP-UNIT::ASSERT-NUMERICAL-EQUAL
(CHEBYSHEV-POINT-EXAMPLE (LIST
0.55d0))) (LIST 0.7159209901689866d0 -1.5019966658054353d0
0.17239719403979925d0))
(MULTIPLE-VALUE-LIST (CHEBYSHEV-POINT-EXAMPLE 0.55d0))))
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment