Mercurial > octave
changeset 22609:dc872d5d74c5
residue.m: Remove code that filters out small return values (bug #34266, bug #49291).
* residue.m (rresidue): Delete code that filters out coefficients that are small relative to the eps of the largest coefficient. Correct BIST tests for new behavior.
Add new BIST test from bug #49291.
author | Rik <rik@octave.org> |
---|---|
date | Mon, 10 Oct 2016 13:00:58 -0700 |
parents | 54332b6ddeb6 |
children | c05377052b50 |
files | scripts/polynomial/residue.m |
diffstat | 1 files changed, 10 insertions(+), 13 deletions(-) [+] |
line wrap: on
line diff
--- a/scripts/polynomial/residue.m Thu Oct 06 12:18:15 2016 -0500 +++ b/scripts/polynomial/residue.m Mon Oct 10 13:00:58 2016 -0700 @@ -333,21 +333,10 @@ endfor ## Add the direct term. - if (numel (k)) pnum += conv (pden, k); endif - ## Check for leading zeros and trim the polynomial coefficients. - if (isa (r, "single") || isa (p, "single") || isa (k, "single")) - small = max ([max(abs(pden)), max(abs(pnum)), 1]) * eps ("single"); - else - small = max ([max(abs(pden)), max(abs(pnum)), 1]) * eps; - endif - - pnum(abs (pnum) < small) = 0; - pden(abs (pden) < small) = 0; - pnum = polyreduce (pnum); pden = polyreduce (pden); @@ -383,7 +372,7 @@ %! assert (isempty (k)); %! assert (e, [1; 2; 1; 2]); %! [br, ar] = residue (r, p, k); -%! assert (br, b, 1e-12); +%! assert (br, [0,b], 1e-12); %! assert (ar, a, 1e-12); %!test @@ -431,6 +420,14 @@ %! b = [1, z1]; %! a = [1, -(p1 + p2), p1*p2, 0, 0]; %! [br, ar] = residue (r, p, k, e); -%! assert (br, b, 1e-8); +%! assert (br, [0,0,b], 1e-7); %! assert (ar, a, 1e-8); +%!test <49291> +%! rf = [1e3, 2e3, 1e3, 2e3]; +%! cf = [316.2e-9, 50e-9, 31.6e-9, 5e-9]; +%! [num, den] = residue (1./cf,-1./(rf.*cf),0); +%! assert (numel (num), 4); +%! assert (numel (den), 5); +%! assert (den(1), 1); +