From bug-octave-request at bevo dot che dot wisc dot edu Thu Mar 29 15:01:54 2001 Subject: Incorrect parameters passed to besselh functions From: "John W. Eaton" To: Thomas Stuart Cc: bug-octave at bevo dot che dot wisc dot edu Date: Thu, 29 Mar 2001 15:01:36 -0600 On 29-Mar-2001, Thomas Stuart wrote: | I found this bug, and I think I fixed it, but I didn't understand | most of the code, so please don't take my word for it. Any comments | would be appreciated! Here is the change I made: Index: besselj.cc =================================================================== RCS file: /usr/local/cvsroot/octave/src/DLD-FUNCTIONS/besselj.cc,v retrieving revision 1.10 diff -u -r1.10 besselj.cc --- besselj.cc 2000/02/03 10:21:55 1.10 +++ besselj.cc 2001/03/29 20:49:34 at @ -332,17 +332,15 @@ int nargin = args.length (); - int kind = 1; - if (nargin == 2) { retval = do_bessel (BESSEL_H1, "besselh", args, nargout); } else if (nargin == 3 || nargin == 4) { - double d_kind = args(1).double_value (); + int kind = args(1).int_value (); - if (! error_state && D_NINT (d_kind) == d_kind) + if (! error_state) { octave_value_list tmp_args; Originally, I think the intent was to convert d_kind to an int before using it. The int_value method is relatively new, which is probably why it was not used originally. | >>besselh(0,2,1) | | | ans = 0.765198 + 0.088257i | >> %The correct answer (from MATLAB) | | ans = | 0.44005 + 0.78121i Are you sure this is correct? With the change, I see octave:1> besselh(0,1,1) ans = 0.765198 + 0.088257i octave:2> besselh(0,2,1) ans = 0.765198 - 0.088257i I think the answer from Matlab that you show above is actually for besselh (1, 2, 1). jwe ------------------------------------------------------------- Octave is freely available under the terms of the GNU GPL. Octave's home on the web: http://www.octave.org How to fund new projects: http://www.octave.org/funding.html Subscription information: http://www.octave.org/archive.html -------------------------------------------------------------