|
Revision 34, 1.0 kB
(checked in by lhealy, 9 months ago)
|
|
The classes/types in the different contexts are now gathered together
in one place, in *type-names* for the types and in *data-class-name*
for data classes, populated by #'add-data-class. Both defdata and
defmfun-all use the table and so mapping between various names is
consistent. The data class names are now different, *-double-float
and *-single-float replaces *-double and *-single. The regression
tests give the same results as before.
|
-
Property svn:keywords set to
Id
|
| Line | |
|---|
| 1 | ;; Example spline |
|---|
| 2 | ;; Liam Healy, Sat Nov 10 2007 - 21:18 |
|---|
| 3 | ;; Time-stamp: <2008-03-09 19:21:47EDT spline-example.lisp> |
|---|
| 4 | ;; $Id$ |
|---|
| 5 | |
|---|
| 6 | (in-package :gsl) |
|---|
| 7 | |
|---|
| 8 | ;;; Possible future improvement: direct double-float vectors. |
|---|
| 9 | |
|---|
| 10 | (defun spline-example-arrays () |
|---|
| 11 | (let ((xarr (make-array '(10) :element-type 'double-float)) |
|---|
| 12 | (yarr (make-array '(10) :element-type 'double-float))) |
|---|
| 13 | (loop for i from 0 below 10 |
|---|
| 14 | do (setf (aref xarr i) (+ i (* 0.5d0 (sin (coerce i 'double-float)))) |
|---|
| 15 | (aref yarr i) (+ i (cos (expt (coerce i 'double-float) 2))))) |
|---|
| 16 | (values xarr yarr))) |
|---|
| 17 | |
|---|
| 18 | (defun spline-example () |
|---|
| 19 | "The first example in Sec. 26.7 of the GSL manual." |
|---|
| 20 | (multiple-value-bind (xarr yarr) |
|---|
| 21 | (spline-example-arrays) |
|---|
| 22 | (letm ((acc (acceleration)) |
|---|
| 23 | (cxarr (vector-double-float xarr)) |
|---|
| 24 | (cyarr (vector-double-float yarr)) |
|---|
| 25 | (spline (spline *cubic-spline-interpolation* cxarr cyarr))) |
|---|
| 26 | (loop for xi from (aref xarr 0) below (aref xarr 9) by 0.01d0 |
|---|
| 27 | collect (list xi (evaluate-spline spline xi acc)))))) |
|---|