bessel-j-integral-2



On 12/03/2011 8:29 PM, David Billinghurst wrote:
> On 12/03/2011 6:43 PM, Andreas Eder wrote:
>> Hi,
>>
>> when looking at compiler messages I found something in bessel.lisp
>> that might be a bug, or I just don't understand it :-)
>>
>> The code in bessel-j-integral-2 looks like:
>>
>>       '((mtimes) ((rat) 1 2) z
>>         ((mplus)
>>     ((mtimes) $%pi
>>      ((%bessel_j) 1 z)
>>      ((%struve_h) 0 z))
>>     ((mtimes)
>>      ((%bessel_j) 0 z)
>>      ((mplus) 2 ((mtimes) -1 $%pi ((%struve_h) 1 z)))))))
>>
>> where z is one of the functions arguments.
>> Shouldn't that be using a backtick and comma like:
>>
>>       `((mtimes) ((rat) 1 2) ,z
>>
>> I don't know the code, but as it is i looks very suspicious to me.
>>
>> Someone in the know wants to comment?
>>
>> 'Andreas
> A good question.
>
> OK.  I wrote this.  It is correct (or at least gives the correct 
> answer), but arguably poor style.
>
> The argument z is unused, which is presumably the source of the 
> compiler warning.  The code returns an expression containing the 
> symbol z that is used in the calling function.  I think you would get 
> an equivalent expression if you used a backtick and a comma to 
> substitute the value of argument z into the expression here.
>
> I will think about the cleanest way to clarify the code in question.  
> Perhaps just declare that argument z is unused to kill the warning.  
> There is similar usage in a couple of other integrals.
>
>     David
>
I had already fixed the other Bessel functions, but missed bessel_j. 
Fixed thusly.

--- bessel.lisp 25 Jan 2011 08:14:19 -0000      1.86
+++ bessel.lisp 12 Mar 2011 14:32:39 -0000
@@ -95,7 +95,8 @@
    grad)

  ;; Integral of the Bessel function wrt z
-(defun bessel-j-integral-2 (v z)
+(defun bessel-j-integral-2 (v unused)
+  (declare (ignore unused))
    (case v
      (0
       ;; integrate(bessel_j(0,z)