Mercurial > hg > octave-nkf
diff scripts/polynomial/mpoles.m @ 9360:df42106beec8
mpoles.m: Fix infinite loop for a multiplicity of poles at zero. Test added.
author | Ben Abbott <bpabbott@mac.com> |
---|---|
date | Thu, 18 Jun 2009 07:51:03 -0400 |
parents | 16f53d29049f |
children | f6e0404421f4 |
line wrap: on
line diff
--- 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]) +