changeset 24916:bddd9ecfa420 stable

Cosint: solved problem with -0i Solved (in a brute force way) the error in the imaginary part of the output when the input has negative real part and imaginary part set to -0. -- changed scripts/specfun/cosint.m
author Michele Ginesi <michele.ginesi@gmail.com>
date Wed, 31 Jan 2018 17:10:22 +0100
parents c6cdacb1794e
children 509e78c26e82
files scripts/specfun/cosint.m
diffstat 1 files changed, 12 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/scripts/specfun/cosint.m	Fri Jan 26 10:43:52 2018 +0100
+++ b/scripts/specfun/cosint.m	Wed Jan 31 17:10:22 2018 +0100
@@ -136,7 +136,9 @@
   endwhile
 
   y(i_miss) = yy;
-
+  flag_neg_zero_imag = ((real(x) < 0) & (imag(x) == 0) & ...
+    (signbit (imag (x))));
+  y(flag_neg_zero_imag) = complex (real (y(flag_neg_zero_imag)), - pi);
   y = reshape (y, sz);
 
 endfunction
@@ -188,7 +190,15 @@
 %!         -0.140981697886930412 + pi*1i];
 %! assert (cosint (x), y_ex, -4*eps);
 
-%!xtest
+%!test
+%! x = complex(-(1:4).', 0);
+%! y_ex = [0.337403922900968135 + pi*1i
+%!         0.422980828774864996 + pi*1i
+%!         0.119629786008000328 + pi*1i
+%!         -0.140981697886930412 + pi*1i];
+%! assert (cosint (x), y_ex, -4*eps);
+
+%!test
 %! x = complex (-(1:4).', -0);
 %! y_ex = [0.337403922900968135 - pi*1i
 %!         0.422980828774864996 - pi*1i