# HG changeset patch # User Ben Abbott # Date 1245325863 14400 # Node ID df42106beec886806402c20eefcde3bae8f4cde0 # Parent be6867ba810469f35ac25473ff43bff0a9cb2347 mpoles.m: Fix infinite loop for a multiplicity of poles at zero. Test added. diff --git a/scripts/ChangeLog b/scripts/ChangeLog --- a/scripts/ChangeLog +++ b/scripts/ChangeLog @@ -1,3 +1,8 @@ +2009-06-18 Daniel Gualberto + + * polynomial/mpoles.m: Fix infinite loop for a multiplicity of + poles at zero. Test added. + 2009-06-17 Bertrand Roessli * plot/axis.m: Fix bug for 'axis tight' with multiple surface plots, diff --git a/scripts/polynomial/mpoles.m b/scripts/polynomial/mpoles.m --- a/scripts/polynomial/mpoles.m +++ b/scripts/polynomial/mpoles.m @@ -92,8 +92,9 @@ while (n) dp = abs (p-p(n)); if (p(n) == 0.0) - p0 = mean (abs (p(find (abs (p) > 0)))); - if (isempty (p0)) + if (any (abs (p) > 0 & isfinite (p))) + p0 = mean (abs (p(abs (p) > 0 & isfinite (p)))); + else p0 = 1; endif else @@ -113,3 +114,8 @@ indx = ordr(indx); endfunction + +%!test +%! [mp, n] = mpoles ([0 0], 0.01); +%! assert (mp, [1; 2]) +