comparison scripts/polynomial/mpoles.m @ 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 16f53d29049f
children f6e0404421f4
comparison
equal deleted inserted replaced
12000:a9d20c890190 12001:21f9ff16c49a
90 indx = []; 90 indx = [];
91 n = find (multp == 0, 1); 91 n = find (multp == 0, 1);
92 while (n) 92 while (n)
93 dp = abs (p-p(n)); 93 dp = abs (p-p(n));
94 if (p(n) == 0.0) 94 if (p(n) == 0.0)
95 p0 = mean (abs (p(find (abs (p) > 0)))); 95 if (any (abs (p) > 0 & isfinite (p)))
96 if (isempty (p0)) 96 p0 = mean (abs (p(abs (p) > 0 & isfinite (p))));
97 else
97 p0 = 1; 98 p0 = 1;
98 endif 99 endif
99 else 100 else
100 p0 = abs (p(n)); 101 p0 = abs (p(n));
101 endif 102 endif
111 endwhile 112 endwhile
112 multp = multp(indx); 113 multp = multp(indx);
113 indx = ordr(indx); 114 indx = ordr(indx);
114 115
115 endfunction 116 endfunction
117
118 %!test
119 %! [mp, n] = mpoles ([0 0], 0.01);
120 %! assert (mp, [1; 2])
121