changeset 12001:21f9ff16c49a release-3-2-x

mpoles.m: Fix infinite loop for a multiplicity of poles at zero. Test added.
author Ben Abbott <bpabbott@mac.com>
date Mon, 22 Jun 2009 07:56:24 +0200
parents a9d20c890190
children 59fb9a2d9aca
files scripts/ChangeLog scripts/polynomial/mpoles.m
diffstat 2 files changed, 13 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/scripts/ChangeLog	Thu Jun 18 09:31:47 2009 +0200
+++ b/scripts/ChangeLog	Mon Jun 22 07:56:24 2009 +0200
@@ -1,3 +1,8 @@
+2009-06-18  Daniel Gualberto <daniel@alacer.com.br>
+
+	* polynomial/mpoles.m: Fix infinite loop for a multiplicity of
+	poles at zero. Test added.
+
 2009-06-17  Bertrand Roessli <bertrand.roessli@psi.ch>
 
 	* plot/axis.m: Fix bug for 'axis tight' with multiple surface plots,
--- a/scripts/polynomial/mpoles.m	Thu Jun 18 09:31:47 2009 +0200
+++ b/scripts/polynomial/mpoles.m	Mon Jun 22 07:56:24 2009 +0200
@@ -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])
+