# HG changeset patch # User Michele Ginesi # Date 1517415022 -3600 # Node ID bddd9ecfa420f7673c033313a159a70be4b6b6b6 # Parent c6cdacb1794eac21d89ad1ad17eb1d4fb7f5b6ef 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 diff -r c6cdacb1794e -r bddd9ecfa420 scripts/specfun/cosint.m --- 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