Am Sonntag, den 29.03.2009, 13:10 -0500 schrieb Barton Willis:
> -----drdieterkaiser at web.de wrote: -----
>
> >dbesj does not return the result of the numerical evaluation, but writes
> >the
> result into the array jvals. The entries into the array correspond to the
> >results of bessel_j(0,2.0), bessel_j(1,2.0), bessel_j(2,2.0) and
> >bessel_j(3,2.0):
> >
> >MAXIMA> jvals
> >#(0.22389077914123579 0.57672480775687363 0.35283402861563784
> > 0.12894324947440208)
> >
> >You can compare the entries in the array with a call to $bessel_j:
> >
> >MAXIMA> ($bessel_j 3 2.0)
> >0.12894324947440208
> >MAXIMA> ($bessel_j 2 2.0)
> >0.35283402861563773
> >MAXIMA> ($bessel_j 1 2.0)
> >0.5767248077568734
> >MAXIMA> ($bessel_j 0 2.0)
> >0.22389077914123562
> >
> >So the best would be at first to check if the array jvals after the
> >calculation contains the expected values.
> >
> >Dieter Kaiser
>
>
> Good experiment--As RJF suggested, let's try interperted mode and
> let's initialize each member of jvals to 0.0; here is what happens
> in Clozure:
>
> Maxima 5.17post http://maxima.sourceforge.net
> Using Lisp Clozure Common Lisp Version 1.3-dev-r11537M-trunk
> (WindowsX8632)
> (%i1) to_lisp();
> MAXIMA> (load "bessel.lisp")
> MAXIMA> (setq jvals (make-array 4 :element-type
> 'double-float :initial-element 0.0d0))
>
> #(0.0 0.0 0.0 0.0)
>
> MAXIMA> (slatec:dbesj 2.0 0.0 4 jvals 0)
>
> NIL
> NIL
> NIL
> NIL
> 0
> MAXIMA> jvals
> #(0.0 0.0 0.0 0.0)
>
> Is this a Clozure bug? I still do not understand how calling slatec:dbesj
> has the side-effect of
> modifying the array jvals. But from what I understand, the complex case
> (zbesj) also works by
> side-effects on arrays--that code works at least sometimes with Clozure CL.
A lot of slatec routines do not return the result as a value, but change
the value of an argument to the function.
In the routine dbesj the values of the array jvals are set e.g. in the
following line (y refers to jvals):
(setf (f2cl-lib:fref y (k) ((1 *))) (* tb ak))
fref is a macro defined in f2cl-lib.lisp:
(defmacro fref (arr indices bounds &optional offset)
(if *check-array-bounds*
`(aref ,arr (if ,(check-array-bounds indices bounds)
(the fixnum (+ (the fixnum ,(or offset 0)) ,(col-major-index
indices bounds)))
(error "Out of bounds index for array ~S"
',arr)))
`(aref ,arr (the fixnum (+ (the fixnum ,(or offset
0)) ,(col-major-index indices bounds))))))
The default value of *check-array-bounds* is nil. The routine
col-major-index does the work and is a function in f2cl-lib.lisp.
Dieter Kaiser