comparison scripts/polynomial/polygcd.m @ 13045:92cb87addf25

codesprint: Add tests to polygcd * polygcd.m : Add tests.
author Carlo de Falco <kingcrimson@tiscali.it>
date Sat, 03 Sep 2011 17:44:20 +0200
parents fd0a3ac60b0e
children e81ddf9cacd5
comparison
equal deleted inserted replaced
13044:a04e32272ecb 13045:92cb87addf25
79 else 79 else
80 print_usage (); 80 print_usage ();
81 endif 81 endif
82 82
83 endfunction 83 endfunction
84
85
86 %!test
87 %! poly1 = [1 6 11 6]; % (x+1)(x+2)(x+3)
88 %! poly2 = [1 3 2]; % (x+1)(x+2)
89 %! poly3 = polygcd (poly1, poly2);
90 %! assert (poly3, poly2, sqrt (eps))
91
92 %!test
93 %! assert (polygcd (poly(1:8), poly(3:12)), poly(3:8), sqrt (eps))
94
95 %!test
96 %! assert (deconv (poly(1:8), polygcd (poly(1:8), poly(3:12))), poly(1:2), sqrt (eps))
97
98 %!test
99 %! for ii=1:10
100 %! p = (unique (randn (10, 1)) * 10).';
101 %! p1 = p(3:end);
102 %! p2 = p(1:end-2);
103 %! assert (polygcd (poly (-p1), poly (-p2)), poly (- intersect (p1, p2)), sqrt (eps))
104 %! endfor