diff liboctave/lo-specfun.cc @ 8278:ab0674a8b345

fix scaling factor for negative alpha in zbesi,cbesi add bessel function tests add all scaling factors to bessel documentation
author Brian Gough <bjg@gnu.org>
date Tue, 28 Oct 2008 10:47:26 -0400
parents e998e81224b5
children b3734f1cb592
line wrap: on
line diff
--- a/liboctave/lo-specfun.cc
+++ b/liboctave/lo-specfun.cc
@@ -819,8 +819,16 @@
 
       if (ierr == 0 || ierr == 3)
 	{
-	  tmp += (2.0 / M_PI) * sin (M_PI * alpha)
+	  Complex tmp2 = (2.0 / M_PI) * sin (M_PI * alpha)
 	    * zbesk (z, alpha, kode, ierr);
+	
+	  if (kode == 2) 
+	    {
+	      // Compensate for different scaling factor of besk.
+	      tmp2 *= exp(-z - std::abs(z.real()));
+	    }
+	  
+	  tmp += tmp2;
 
 	  retval = bessel_return_value (tmp, ierr);
 	}
@@ -1438,8 +1446,16 @@
 
       if (ierr == 0 || ierr == 3)
 	{
-	  tmp += static_cast<float> (2.0 / M_PI) * sinf (static_cast<float> (M_PI) * alpha)
+	  FloatComplex tmp2 = static_cast<float> (2.0 / M_PI) * sinf (static_cast<float> (M_PI) * alpha)
 	    * cbesk (z, alpha, kode, ierr);
+	  
+	  if (kode == 2) 
+	    {
+	      // Compensate for different scaling factor of besk.
+	      tmp2 *= exp(-z - std::abs(z.real()));
+	    }
+
+	  tmp += tmp2;
 
 	  retval = bessel_return_value (tmp, ierr);
 	}