Mercurial > hg > octave-avbm
changeset 2716:2b5c27299cde
[project @ 1997-02-22 08:40:55 by jwe]
line wrap: on
line diff
--- a/scripts/ChangeLog +++ b/scripts/ChangeLog @@ -1,3 +1,18 @@ +Sat Feb 22 01:06:22 1997 John W. Eaton <jwe@bevo.che.wisc.edu> + + * polynomial/conv.m: Check inputs with is_vector(), not is_matrix(). + * polynomial/deconv.m: Likewise. + * polynomial/polyderiv.m: Likewise. + * polynomial/polyinteg.m: Likewise. + * polynomial/polyreduce.m: Likewise. + * polynomial/polyval.m: Likewise. + * polynomial/polyvalm.m: Likewise. + * general/postpad.m: Likewise. + * general/prepad.m: Likewise. + + * polynomial/compan.m: Check input with is_vector(), not + is_matrix(). Handle scalar case. + Fri Feb 21 13:36:58 1997 John W. Eaton <jwe@bevo.che.wisc.edu> * plot/contour.m: Order data so that it is consistent with
--- a/scripts/general/postpad.m +++ b/scripts/general/postpad.m @@ -38,7 +38,7 @@ usage ("postpad (x, l) or postpad (x, l, c)"); endif - if (is_matrix (x)) + if (! is_vector (x)) error ("first argument must be a vector"); elseif (! is_scalar (l)) error ("second argument must be a scaler");
--- a/scripts/general/prepad.m +++ b/scripts/general/prepad.m @@ -38,7 +38,7 @@ usage ("prepad (x, l) or prepad (x, l, c)"); endif - if (is_matrix (x)) + if (! is_vector (x)) error ("first argument must be a vector"); elseif (! is_scalar (l)) error ("second argument must be a scaler");
--- a/scripts/polynomial/compan.m +++ b/scripts/polynomial/compan.m @@ -52,18 +52,23 @@ usage ("compan (vector)"); endif - if(is_matrix (c)) + if (! is_vector (c)) error("compan: expecting a vector argument."); endif ## Ensure that c is a row vector. - if(rows(c) > 1) + if (rows (c) > 1) c = c.'; endif n = length (c); - A = diag (ones (n-2, 1), -1); - A (1, :) = -c (2:n) /c (1); + + if (n == 1) + A = []; + else + A = diag (ones (n-2, 1), -1); + A(1,:) = -c(2:n) / c(1); + endif endfunction
--- a/scripts/polynomial/conv.m +++ b/scripts/polynomial/conv.m @@ -39,7 +39,7 @@ usage ("conv(a, b)"); endif - if (is_matrix (a) || is_matrix (b)) + if (! (is_vector (a) && is_vector (b))) error("conv: both arguments must be vectors"); endif
--- a/scripts/polynomial/deconv.m +++ b/scripts/polynomial/deconv.m @@ -41,7 +41,7 @@ usage ("deconv (y, a)"); endif - if (is_matrix (y) || is_matrix (a)) + if (! (is_vector (y) && is_vector (a))) error("conv: both arguments must be vectors"); endif
--- a/scripts/polynomial/polyderiv.m +++ b/scripts/polynomial/polyderiv.m @@ -35,7 +35,7 @@ usage ("polyderiv (vector)"); endif - if (is_matrix (p)) + if (! is_vector (p)) error ("argument must be a vector"); endif
--- a/scripts/polynomial/polyinteg.m +++ b/scripts/polynomial/polyinteg.m @@ -37,7 +37,7 @@ usage ("polyinteg (vector)"); endif - if (is_matrix (p)) + if (! (is_vector (p) || isempty (p))) error ("argument must be a vector"); endif
--- a/scripts/polynomial/polyreduce.m +++ b/scripts/polynomial/polyreduce.m @@ -31,20 +31,32 @@ function p = polyreduce (p) - index = find (p == 0); + if (nargin != 1) + usage ("polyreduce (p)"); + endif - if (length (index) != 0) + if (! (is_vector (p) || isempty (p))) + error ("polyreduce: argument must be a vector"); + endif - index = find (index == 1:length (index)); + if (! isempty (p)) + + index = find (p == 0); if (length (index) != 0) - if (length (p) > 1) - p = p (index (length (index))+1:length (p)); - endif + index = find (index == 1:length (index)); + + if (length (index) != 0) - if (length (p) == 0) - p = 0; + if (length (p) > 1) + p = p (index (length (index))+1:length (p)); + endif + + if (length (p) == 0) + p = 0; + endif + endif endif
--- a/scripts/polynomial/polyval.m +++ b/scripts/polynomial/polyval.m @@ -45,10 +45,15 @@ usage ("polyval (c, x)"); endif - if(is_matrix (c)) + if (! (is_vector (c) || isempty (c))) error ("poly: first argument must be a vector."); endif + if (isempty (x)) + y = []; + return; + endif + if (length (c) == 0) y = c; return;
--- a/scripts/polynomial/polyvalm.m +++ b/scripts/polynomial/polyvalm.m @@ -46,7 +46,7 @@ usage ("polyvalm (c, x)"); endif - if (is_matrix (c)) + if (! (is_vector (c) || isempty (c))) error("poly: first argument must be a vector."); endif @@ -54,7 +54,12 @@ error("poly: second argument must be a square matrix."); endif - [v, d] = eig(x); + if (isempty (c)) + y = []; + return; + endif + + [v, d] = eig (x); y = v * diag (polyval (c, diag (d))) * v';
--- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,5 +1,8 @@ Fri Feb 21 15:35:18 1997 John W. Eaton <jwe@bevo.che.wisc.edu> + * lex.l: Require flex 2.5 or later (we really want 2.5.4 or later, + but there seems to be no good way to check the patchlevel). + * oct-stream.cc (octave_base_stream::oscanf): Instead of returning an error, just quit processing after a conversion fails.
--- a/src/lex.l +++ b/src/lex.l @@ -63,6 +63,12 @@ #include <y.tab.h> #include <oct-gperf.h> +#if ! (defined (FLEX_SCANNER) \ + && defined (YY_FLEX_MAJOR_VERSION) && YY_FLEX_MAJOR_VERSION >= 2 \ + && defined (YY_FLEX_MINOR_VERSION) && YY_FLEX_MINOR_VERSION >= 5) +#error lex.l requires flex version 2.5.4 or later +#endif + // Flags that need to be shared between the lexer and parser. lexical_feedback lexer_flags;
new file mode 100644 --- /dev/null +++ b/test/octave.test/poly/compan-1.m @@ -0,0 +1,1 @@ +all (all (compan ([1, 2, 3]) == [-2, -3; 1, 0]))
new file mode 100644 --- /dev/null +++ b/test/octave.test/poly/compan-2.m @@ -0,0 +1,1 @@ +all (all (compan ([1; 2; 3]) == [-2, -3; 1, 0]))
new file mode 100644 --- /dev/null +++ b/test/octave.test/poly/compan-3.m @@ -0,0 +1,1 @@ +isempty (compan (4))
new file mode 100644 --- /dev/null +++ b/test/octave.test/poly/compan-4.m @@ -0,0 +1,1 @@ +all (all (compan ([3, 2, 1]) == [-2/3, -1/3; 1, 0]))
new file mode 100644 --- /dev/null +++ b/test/octave.test/poly/compan-5.m @@ -0,0 +1,1 @@ +compan ([1,2;3,4])
new file mode 100644 --- /dev/null +++ b/test/octave.test/poly/compan-6.m @@ -0,0 +1,1 @@ +compan ([])
new file mode 100644 --- /dev/null +++ b/test/octave.test/poly/conv-1.m @@ -0,0 +1,1 @@ +all (all (conv (ones (3, 1), ones (3, 1)) == [1, 2, 3, 2, 1]))
new file mode 100644 --- /dev/null +++ b/test/octave.test/poly/conv-2.m @@ -0,0 +1,1 @@ +all (all (conv (ones (1, 3), ones (3, 1)) == [1, 2, 3, 2, 1]))
new file mode 100644 --- /dev/null +++ b/test/octave.test/poly/conv-3.m @@ -0,0 +1,1 @@ +all (all (conv (3, [1, 2, 3]) == [3, 6, 9]))
new file mode 100644 --- /dev/null +++ b/test/octave.test/poly/conv-4.m @@ -0,0 +1,1 @@ +conv ([1, 2; 3, 4], 3)
new file mode 100644 --- /dev/null +++ b/test/octave.test/poly/conv-5.m @@ -0,0 +1,1 @@ +conv (2, 3)
new file mode 100644 --- /dev/null +++ b/test/octave.test/poly/conv-6.m @@ -0,0 +1,1 @@ +conv (2, [])
new file mode 100644 --- /dev/null +++ b/test/octave.test/poly/deconv-1.m @@ -0,0 +1,2 @@ +[b, r] = deconv ([3, 6, 9, 9], [1, 2, 3]); +all (all (b == [3, 0])) && r == 9
new file mode 100644 --- /dev/null +++ b/test/octave.test/poly/deconv-2.m @@ -0,0 +1,2 @@ +[b, r] = deconv ([3, 6], [1, 2, 3]); +b == 0 && all (all (r == [3, 6]))
new file mode 100644 --- /dev/null +++ b/test/octave.test/poly/deconv-3.m @@ -0,0 +1,2 @@ +[b, r] = deconv ([3, 6], [1; 2; 3]); +b == 0 && all (all (r == [3, 6]))
new file mode 100644 --- /dev/null +++ b/test/octave.test/poly/deconv-4.m @@ -0,0 +1,1 @@ +[b, r] = deconv ([3, 6], [1, 2; 3, 4]);
new file mode 100644 --- /dev/null +++ b/test/octave.test/poly/deconv-5.m @@ -0,0 +1,2 @@ +[b, r] = deconv ([3; 6], [1, 2, 3]); +b == 0 && all (all (r == [3, 6]))
new file mode 100644 --- /dev/null +++ b/test/octave.test/poly/poly-1.m @@ -0,0 +1,1 @@ +all (all (poly ([1, 2, 3]) == [1, -6, 11, -6]))
new file mode 100644 --- /dev/null +++ b/test/octave.test/poly/poly-2.m @@ -0,0 +1,1 @@ +all (all (poly ([1, 2; 3, 4]) - [1, -5, -2] < 2 * eps))
new file mode 100644 --- /dev/null +++ b/test/octave.test/poly/poly-3.m @@ -0,0 +1,1 @@ +poly ([1, 2, 3; 4, 5, 6])
new file mode 100644 --- /dev/null +++ b/test/octave.test/poly/poly.exp @@ -0,0 +1,203 @@ +set test compan-1 +set prog_output "ans = 1" +do_test compan-1.m + +set test compan-2 +set prog_output "ans = 1" +do_test compan-2.m + +set test compan-3 +set prog_output "ans = 1" +do_test compan-3.m + +set test compan-4 +set prog_output "ans = 1" +do_test compan-4.m + +set test compan-5 +set prog_output "error:.*" +do_test compan-5.m + +set test compan-6 +set prog_output "error:.*" +do_test compan-6.m + +set test conv-1 +set prog_output "ans = 1" +do_test conv-1.m + +set test conv-2 +set prog_output "ans = 1" +do_test conv-2.m + +set test conv-3 +set prog_output "ans = 1" +do_test conv-3.m + +set test conv-4 +set prog_output "error:.*" +do_test conv-4.m + +set test conv-5 +set prog_output "ans = 6" +do_test conv-5.m + +set test conv-6 +set prog_output "error:.*" +do_test conv-6.m + +set test deconv-1 +set prog_output "ans = 1" +do_test deconv-1.m + +set test deconv-2 +set prog_output "ans = 1" +do_test deconv-2.m + +set test deconv-3 +set prog_output "ans = 1" +do_test deconv-3.m + +set test deconv-4 +set prog_output "error:.*" +do_test deconv-4.m + +set test deconv-5 +set prog_output "error:.*" +do_test deconv-5.m + +set test poly-1 +set prog_output "ans = 1" +do_test poly-1.m + +set test poly-2 +set prog_output "ans = 1" +do_test poly-2.m + +set test poly-3 +set prog_output "error:.*" +do_test poly-3.m + +set test poly-4 +set prog_output "ans = 1" +do_test poly-4.m + +set test polyderiv-1 +set prog_output "ans = 1" +do_test polyderiv-1.m + +set test polyderiv-2 +set prog_output "ans = 1" +do_test polyderiv-2.m + +set test polyderiv-3 +set prog_output "error:.*" +do_test polyderiv-3.m + +set test polyderiv-4 +set prog_output "error:.*" +do_test polyderiv-4.m + +set test polyfit-1 +set prog_output "ans = 1" +do_test polyfit-1.m + +set test polyfit-2 +set prog_output "ans = 1" +do_test polyfit-2.m + +set test polyfit-3 +set prog_output "error:.*" +do_test polyfit-3.m + +set test polyfit-4 +set prog_output "error:.*" +do_test polyfit-4.m + +set test polyfit-5 +set prog_output "error:.*" +do_test polyfit-5.m + +set test polyinteg-1 +set prog_output "ans = 1" +do_test polyinteg-1.m + +set test polyinteg-2 +set prog_output "ans = 1" +do_test polyinteg-2.m + +set test polyinteg-3 +set prog_output "ans = 1" +do_test polyinteg-3.m + +set test polyinteg-4 +set prog_output "error:.*" +do_test polyinteg-4.m + +set test polyreduce-1 +set prog_output "ans = 1" +do_test polyreduce-1.m + +set test polyreduce-2 +set prog_output "ans = 1" +do_test polyreduce-2.m + +set test polyreduce-3 +set prog_output "ans = 1" +do_test polyreduce-3.m + +set test polyreduce-4 +set prog_output "ans = 1" +do_test polyreduce-4.m + +set test polyreduce-5 +set prog_output "error:.*" +do_test polyreduce-5.m + +set test polyval-1 +set prog_output "ans = 1" +do_test polyval-1.m + +set test polyval-2 +set prog_output "ans = 1" +do_test polyval-2.m + +set test polyval-3 +set prog_output "ans = 1" +do_test polyval-3.m + +set test polyval-4 +set prog_output "ans = 1" +do_test polyval-4.m + +set test polyval-5 +set prog_output "error:.*" +do_test polyval-5.m + +set test polyval-6 +set prog_output "ans = 1" +do_test polyval-6.m + +set test polyvalm-1 +set prog_output "ans = 1" +do_test polyvalm-1.m + +set test polyvalm-2 +set prog_output "error:.*" +do_test polyvalm-2.m + +set test residue-1 +set prog_output "ans = 1" +do_test residue-1.m + +set test roots-1 +set prog_output "ans = 1" +do_test roots-1.m + +set test roots-2 +set prog_output "ans = 1" +do_test roots-2.m + +set test roots-3 +set prog_output "error:.*" +do_test roots-3.m
new file mode 100644 --- /dev/null +++ b/test/octave.test/poly/polyderiv-1.m @@ -0,0 +1,1 @@ +all (all (polyderiv ([1, 2, 3]) == [2, 2])) \ No newline at end of file
new file mode 100644 --- /dev/null +++ b/test/octave.test/poly/polyderiv-2.m @@ -0,0 +1,1 @@ +polyderiv (13) == 0
new file mode 100644 --- /dev/null +++ b/test/octave.test/poly/polyderiv-3.m @@ -0,0 +1,1 @@ +polyderiv ([])
new file mode 100644 --- /dev/null +++ b/test/octave.test/poly/polyderiv-4.m @@ -0,0 +1,1 @@ +polyderiv ([1, 2; 3, 4])
new file mode 100644 --- /dev/null +++ b/test/octave.test/poly/polyfit-1.m @@ -0,0 +1,2 @@ +x = [-2, -1, 0, 1, 2]; +all (all (polyfit (x, x.^2+x+1, 2) - [1; 1; 1] < 4*eps))
new file mode 100644 --- /dev/null +++ b/test/octave.test/poly/polyfit-2.m @@ -0,0 +1,2 @@ +x = [-2, -1, 0, 1, 2]; +all (all (polyfit (x, x.^2+x+1, 3) - [0; 1; 1; 1] < 8*eps))
new file mode 100644 --- /dev/null +++ b/test/octave.test/poly/polyfit-3.m @@ -0,0 +1,1 @@ +polyfit ([1, 2; 3, 4], [1, 2; 3, 4], 4)
new file mode 100644 --- /dev/null +++ b/test/octave.test/poly/polyfit-4.m @@ -0,0 +1,2 @@ +x = [-2, -1, 0, 1, 2]; +polyfit (x, x.^2+x+1)
new file mode 100644 --- /dev/null +++ b/test/octave.test/poly/polyfit-5.m @@ -0,0 +1,2 @@ +x = [-2, -1, 0, 1, 2]; +polyfit (x, x.^2+x+1, [])
new file mode 100644 --- /dev/null +++ b/test/octave.test/poly/polyinteg-1.m @@ -0,0 +1,1 @@ +all (all (polyinteg ([2, 2]) == [1, 2, 0]))
new file mode 100644 --- /dev/null +++ b/test/octave.test/poly/polyinteg-2.m @@ -0,0 +1,1 @@ +isempty (polyinteg ([]))
new file mode 100644 --- /dev/null +++ b/test/octave.test/poly/polyinteg-3.m @@ -0,0 +1,1 @@ +all (all (polyinteg (3) == [3, 0]))
new file mode 100644 --- /dev/null +++ b/test/octave.test/poly/polyinteg-4.m @@ -0,0 +1,1 @@ +polyinteg ([1, 2; 3, 4])
new file mode 100644 --- /dev/null +++ b/test/octave.test/poly/polyreduce-1.m @@ -0,0 +1,1 @@ +all (all (polyreduce ([0, 0, 1, 2, 3]) == [1, 2, 3]))
new file mode 100644 --- /dev/null +++ b/test/octave.test/poly/polyreduce-2.m @@ -0,0 +1,1 @@ +all (all (polyreduce ([1, 2, 3, 0, 0]) == [1, 2, 3, 0, 0]))
new file mode 100644 --- /dev/null +++ b/test/octave.test/poly/polyreduce-3.m @@ -0,0 +1,1 @@ +all (all (polyreduce ([1, 0, 3]) == [1, 0, 3]))
new file mode 100644 --- /dev/null +++ b/test/octave.test/poly/polyreduce-4.m @@ -0,0 +1,1 @@ +isempty (polyreduce ([]))
new file mode 100644 --- /dev/null +++ b/test/octave.test/poly/polyreduce-5.m @@ -0,0 +1,1 @@ +polyreduce ([1, 2; 3, 4])
new file mode 100644 --- /dev/null +++ b/test/octave.test/poly/polyval-1.m @@ -0,0 +1,1 @@ +polyval ([1, 1, 1], 2) == 7
new file mode 100644 --- /dev/null +++ b/test/octave.test/poly/polyval-2.m @@ -0,0 +1,1 @@ +all (all (polyval ([1, 1, 1], [0; 1; 2]) == [1; 3; 7]))
new file mode 100644 --- /dev/null +++ b/test/octave.test/poly/polyval-3.m @@ -0,0 +1,1 @@ +isempty (polyval ([1, 1, 1], []))
new file mode 100644 --- /dev/null +++ b/test/octave.test/poly/polyval-4.m @@ -0,0 +1,1 @@ +all (all (polyval ([1, 1, 1], [-1, 0; 1, 2]) == [1, 1; 3, 7]))
new file mode 100644 --- /dev/null +++ b/test/octave.test/poly/polyval-5.m @@ -0,0 +1,1 @@ +polyval ([1, 2; 3, 4], [-1, 0; 1, 2])
new file mode 100644 --- /dev/null +++ b/test/octave.test/poly/polyval-6.m @@ -0,0 +1,1 @@ +isempty (polyval ([], [-1, 0; 1, 2]))
new file mode 100644 --- /dev/null +++ b/test/octave.test/poly/polyvalm-1.m @@ -0,0 +1,1 @@ +isempty (polyvalm ([], [1, 2; 3, 4]))
new file mode 100644 --- /dev/null +++ b/test/octave.test/poly/polyvalm-2.m @@ -0,0 +1,1 @@ +polyvalm ([1, 1, 1], [1, 2; 3, 4; 5, 6])
new file mode 100644 --- /dev/null +++ b/test/octave.test/poly/residue-1.m @@ -0,0 +1,7 @@ +b = [1, 1, 1]; +a = [1, -5, 8, -4]; +[r, p, k, e] = residue (b, a); +(abs (r - [-2; 7; 3]) < sqrt (eps) + && abs (p - [2; 2; 1]) < sqrt (eps) + && isempty (k) + && e == [1; 2; 1])
new file mode 100644 --- /dev/null +++ b/test/octave.test/poly/roots-1.m @@ -0,0 +1,1 @@ +all (all (abs (roots ([1, -6, 11, -6]) - [3; 2; 1]) < sqrt (eps)))