help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: found a small bug in residue corection


From: Ben Abbott
Subject: Re: found a small bug in residue corection
Date: Mon, 26 Nov 2007 12:26:07 -0800

On Monday, November 26, 2007, at 01:30PM, "John W. Eaton" <address@hidden> 
wrote:
>On 26-Nov-2007, Ben Abbott wrote:
>
>| On Nov 26, 2007, at 10:49 AM, Doug Stewart <address@hidden> wrote:
>| 
>| > I an using qtoctave on windows xp
>| > octave version 2.9.15
>| >
>| > example that produces the problem:
>| >
>| > residue([1],[ 1 10 25])
>| >
>| > to fix the problem goto line 314 in residue
>| > pnum = pnum + prepad (pn, N+1, 0);
>| >
>| > and change it to
>| >
>| > pnum = pnum + prepad (pn, N+1, 0,2);
>| >
>| >
>| > This only shows up when it was trying to prepad a scaler and it  
>| > padded it in the wrong direction.
>| > By adding the 2 as the 4th parameter we tell it to pad in the right  
>| > direction.
>| >
>| >
>| > Sorry for the double posting but I saw that the line number was  
>| > wrong because I still had my debugging lines in the code.
>| >
>| > Doug Stewart
>| 
>| Recently a significant rewrite of residue was submitted. If memory  
>| serves it was first present in 2.9.16.
>| 
>| That version depends upon a new function mpoles.
>| 
>| I'm not at my computer, but when I am I'll try your example on 2.9.17.
>
>I see the following:
>
>It seems to be fixed by the following change.
>
>Thanks,
>
>jwe
>
>
>scripts/ChangeLog:
>
>2007-11-26  John W. Eaton  <address@hidden>
>
>       * polynomial/residue.m: Prepad along second dimension.
>       From Doug Stewart <address@hidden>.
>
>
>Index: scripts/polynomial/residue.m
>===================================================================
>RCS file: /cvs/octave/scripts/polynomial/residue.m,v
>retrieving revision 1.33
>diff -u -u -r1.33 residue.m
>--- scripts/polynomial/residue.m       12 Oct 2007 21:27:25 -0000      1.33
>+++ scripts/polynomial/residue.m       26 Nov 2007 18:28:20 -0000
>@@ -311,7 +311,7 @@
>     endfor
>     pn = deconv (pden, pm);
>     pn = r(n) * pn;
>-    pnum = pnum + prepad (pn, N+1, 0);
>+    pnum = pnum + prepad (pn, N+1, 0, 2);
>   endfor
> 
>   ## Add the direct term.
>
>

John, I'm not sitting at my usual machine with the cvs setup. When I try "test 
residue", I get a failure.

test residue
  ***** test
 b = [1, 1, 1];
 a = [1, -5, 8, -4];
 [r, p, k, e] = residue (b, a);
 assert (abs (r - [-2; 7; 3]) < 1e-5
   && abs (p - [2; 2; 1]) < 1e-7
   && isempty (k)
   && e == [1; 2; 1]);
 k = [1 0];
 b = conv (k, a) + prepad (b, numel (k) + numel (a) - 1, 0);
 a = a;
 [br, ar] = residue (r, p, k);
 assert ((abs (br - b) < 1e-12
   && abs (ar - a) < 1e-12));
 [br, ar] = residue (r, p, k, e);
 assert ((abs (br - b) < 1e-12
   && abs (ar - a) < 1e-12));
!!!!! test failed
error: assert ((abs (br - b) < 1e-12 && abs (ar - a) < 1e-12)) failed

Can you verify the problem exists for the cvs as well?

I was originally thinking of adding an additional test to the residue function 
to verify the functionality handled Doug's case correctly.
In the event you or someone else looks into this error before I, it may also be 
prudent to add that test as well.

%!test
%! b = [1];
%! a = [1, 10, 25];
%! [r, p, k, e] = residue(b, a);
%! r1 = [0; 1];
%! p1 = [-5; -5];
%! assert (abs (r - r1) < 1e-7 && abs (p - p1) < 1e-7
%!   && isempty (k)
%!   && e == [1; 2]);
%! [br, ar] = residue (r, p, k);
%! assert ((abs (br - b) < 1e-12
%!   && abs (ar - a) < 1e-12));

Ben



reply via email to

[Prev in Thread] Current Thread [Next in Thread]