[Gsll-devel] Correction for integral-evaluate-spline

Mirko Vukovic mirko.vukovic at gmail.com
Tue Jan 27 16:29:22 UTC 2009


Hello,

In order to use integral-evaluate-spline, I had to modify its
definition.  The one below works, but I am not sure if there is a
better way.  Here is the definition:
(defmfun integral-evaluate-spline (spline xa ya low high acceleration)
  "gsl_spline_eval_integ"
  (((mpointer spline) :pointer) ((c-pointer xa) :pointer) ((c-pointer
ya) :pointer) (low :double) (high :double)
   ((mpointer acceleration) :pointer))
  :c-return :double
  :documentation			; FDL
  "Find the numerical integral of an interpolated function over the
   range [low, high], using the spline object spline,
   data arrays xa and ya and the accelerator acceleration.")

I removed a reference to a double-float `x' and added the x&y array
pointers into the arguments, as they are necessary for gsl's
`gsl_interp_eval_integ'.
(I am really not sure what is the purpose of the ..._e functions).

Here is a bit of test code that exercises the defintion by integrating
pi*sin(pi x) between 0 & 0.5 which should equal 1.0:

(let* ((acc (make-acceleration))
       (xarr
	(make-marray
	 'double-float
	 :initial-contents
	 (loop for i from 0.0d0 below 1d0 by 0.2d0
	    collect i)))
       (yarr
	(make-marray
	 'double-float
	 :initial-contents
	 (loop for x across (cl-array xarr)
	    collect (sin (* x pi)))))
       (spline (make-spline *cubic-spline-interpolation* xarr yarr)))
  (* pi (integral-evaluate-spline spline xarr yarr 0d0 0.5d0 acc)))

I wonder if there is a way for `make-spline' to "remember" xarr and
yarr so they don't have to be passed to `integral-evaluate-spline'.

As always, thank for the heavy lifting :-)

Mirko




More information about the gsll-devel mailing list