Mercurial > hg > octave-lyh
diff scripts/polynomial/roots.m @ 904:3470f1e25a79
[project @ 1994-11-09 21:22:15 by jwe]
author | jwe |
---|---|
date | Wed, 09 Nov 1994 21:22:15 +0000 |
parents | c5d35bb139b6 |
children | 2e954ce5263f |
line wrap: on
line diff
--- a/scripts/polynomial/roots.m +++ b/scripts/polynomial/roots.m @@ -1,21 +1,22 @@ function r = roots (v) - # - # For a vector v with n components, return the roots of the - # polynomial v(1) * z^(n-1) + ... + v(n-1) * z + v(n). + +# For a vector v with n components, return the roots of the +# polynomial v(1) * z^(n-1) + ... + v(n-1) * z + v(n). - # Written by KH (Kurt.Hornik@neuro.tuwien.ac.at) on Dec 24, 1993 - # Copyright Dept of Probability Theory and Statistics TU Wien +# Written by KH (Kurt.Hornik@neuro.tuwien.ac.at) on Dec 24, 1993 +# Copyright Dept of Probability Theory and Statistics TU Wien [nr, nc] = size(v); if !((nr == 1 && nc > 1) || (nc == 1 && nr > 1)) - error ("usage: roots (v), where v is a nonzero vector"); + usage ("roots (v), where v is a nonzero vector"); endif n = nr + nc - 1; v = reshape (v, 1, n); - # If v = [ 0 ... 0 v(k+1) ... v(k+l) 0 ... 0 ], we can remove the - # leading k zeros and n - k - l roots of the polynomial are zero. +# If v = [ 0 ... 0 v(k+1) ... v(k+l) 0 ... 0 ], we can remove the +# leading k zeros and n - k - l roots of the polynomial are zero. + f = find (v); m = max (size (f)); if (m > 0) @@ -32,7 +33,7 @@ r = zeros (n - f(m), 1); endif else - error ("usage: roots(v), where v is a nonzero vector"); + usage ("roots (v), where v is a nonzero vector"); endif endfunction