From octave-maintainers-request at bevo dot che dot wisc dot edu Thu Dec 2 12:36:47 1999 Subject: Re: polyvalm.m From: "Ross A. Lippert" To: "octave-maintainers at bevo dot che dot wisc dot edu" Date: Thu, 02 Dec 1999 11:36:15 -0700 Forgot a semi-colon. ## usage: polyvalm (c, x) ## ## Evaluate a polynomial in the matrix sense. ## ## In octave, a polynomial is represented by it's coefficients (arranged ## in descending order). For example a vector c of length n+1 corresponds ## to the following nth order polynomial ## ## p(x) = c(1) x^n + ... + c(n) x + c(n+1). ## ## polyvalm(c,X) will evaluate the polynomial in the matrix sense, i.e. matrix ## multiplication is used instead of element by element multiplication as is ## used in polyval. ## ## X must be a square matrix. ## ## SEE ALSO: polyval, poly, roots, conv, deconv, residue, filter, ## polyderiv, polyinteg ## Author: Tony Richardson ## Created: June 1994 ## Adapted-By: jwe ## Changed-By: Ross Lippert function y = polyvalm (c, x) if (nargin != 2) usage ("polyvalm (c, x)"); endif if (! (is_vector (c) || isempty (c))) error ("polyvalm: first argument must be a vector."); endif if (! is_square (x)) error("polyvalm: second argument must be a square matrix."); endif if (isempty (c)) y = []; return; endif n = length(c); I = eye(rows(x),columns(x)); y = c(1) * I; for index = 2:n, y = c(index)*I + x*y; endfor if (is_symmetric (x)) y = (y+y')/2; endif endfunction