561
|
1 function y = polyvalm(c,x) |
904
|
2 |
|
3 # Evaluate a polynomial in the matrix sense. |
561
|
4 # |
904
|
5 # In octave, a polynomial is represented by it's coefficients (arranged |
|
6 # in descending order). For example a vector c of length n+1 corresponds |
|
7 # to the following nth order polynomial |
561
|
8 # |
904
|
9 # p(x) = c(1) x^n + ... + c(n) x + c(n+1). |
561
|
10 # |
904
|
11 # polyvalm(c,X) will evaluate the polynomial in the matrix sense, i.e. matrix |
|
12 # multiplication is used instead of element by element multiplication as is |
|
13 # used in polyval. |
561
|
14 # |
904
|
15 # X must be a square matrix. |
|
16 # |
|
17 # SEE ALSO: polyval, poly, roots, conv, deconv, residue, filter, |
|
18 # polyderiv, polyinteg |
561
|
19 |
|
20 # Author: |
|
21 # Tony Richardson |
|
22 # amr@mpl.ucsd.edu |
|
23 # June 1994 |
|
24 |
|
25 if(nargin != 2) |
904
|
26 usage ("polyvalm(c,x)"); |
561
|
27 endif |
|
28 |
|
29 if(is_matrix(c)) |
|
30 error("poly: first argument must be a vector."); |
|
31 endif |
|
32 |
|
33 if(!is_square(x)) |
|
34 error("poly: second argument must be a square matrix."); |
|
35 endif |
|
36 |
|
37 [v, d] = eig(x); |
|
38 |
|
39 y = v * diag(polyval(c,diag(d))) * v'; |
|
40 |
|
41 endfunction |