Commit 84b5a165 authored by Liam Healy's avatar Liam Healy

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
parent ea176adc
;; Chebyshev Approximations
;; 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$
(in-package :gsl)
......@@ -16,9 +16,19 @@
"Chebyshev series"
:documentation ; FDL
"Make a Chebyshev series of specified order."
:superclasses (callback-included)
:ci-class-slots (gsl-function nil (function))
:initialize-suffix "init"
((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
;;;; Chebyshev series evaluation
......@@ -55,7 +65,7 @@
(defmfun derivative-chebyshev (derivative chebyshev)
((derivative :pointer) ((mpointer chebyshev) :pointer))
(((mpointer derivative) :pointer) ((mpointer chebyshev) :pointer))
:documentation ; FDL
"Compute the derivative of the Chebyshev series, storing
the derivative coefficients in the previously allocated series.
......@@ -63,7 +73,7 @@
(defmfun integral-chebyshev (integral chebyshev)
((integral :pointer) ((mpointer chebyshev) :pointer))
(((mpointer integral) :pointer) ((mpointer chebyshev) :pointer))
:documentation ; FDL
"Compute the integral of the Chebyshev series, storing
the integral coefficients in the previously allocated series.
......@@ -80,11 +90,11 @@
(defun chebyshev-step (x) (if (< x 0.5d0) 0.25d0 0.75d0))
(make-callbacks chebyshev chebyshev-step)
(defun chebyshev-table-example ()
(let ((steps 100))
(let ((cheb
40 (make-single-function chebyshev-step) 0.0d0 1.0d0)))
(let ((cheb (make-chebyshev 40 'chebyshev-step 0.0d0 1.0d0)))
(dotimes (i steps)
(let ((x (coerce (/ i steps) 'double-float)))
(format t "~&~a ~a ~a ~a"
......@@ -95,8 +105,7 @@
(defun chebyshev-point-example (x)
(check-type x double-float)
(let ((cheb (make-chebyshev
40 (make-single-function chebyshev-step) 0.0d0 1.0d0))
(let ((cheb (make-chebyshev 40 'chebyshev-step 0.0d0 1.0d0))
(deriv (make-chebyshev 40))
(integ (make-chebyshev 40)))
(derivative-chebyshev deriv cheb)
;; Foreign callback functions.
;; Liam Healy
;; Time-stamp: <2009-02-14 19:22:53EST callback.lisp>
;; Time-stamp: <2009-02-15 10:43:05EST callback.lisp>
;; $Id$
(in-package :gsl)
......@@ -372,7 +372,9 @@
(defmethod print-object ((object callback-included) stream)
(print-unreadable-object (object stream :type t :identity t)
(princ "for " stream)
(princ (first (functions object)) stream)
(princ ", dimensions " stream)
(when (slot-boundp object 'functions)
(princ "for " stream)
(princ (first (functions object)) stream)
(princ "," stream))
(princ "dimensions " stream)
(princ (dimensions object) stream)))
;; Univariate minimization
;; 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$
(in-package :gsl)
......@@ -192,9 +192,6 @@
(make-callbacks one-dimensional-minimizer minimization-one-fn)
(defparameter *minone-cb* (make-single-function minimization-one-fn))
(defun minimization-one-example
(&optional (minimizer-type *brent-fminimizer*) (print-steps t))
"Solving a minimum, the example given in Sec. 33.8 of the GSL manual."
......@@ -3,7 +3,9 @@
(in-package :gsl)
(LIST 0.7159209901689866d0 -1.5019966658054353d0
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