Mercurial > hg > octave-nkf
comparison scripts/special-matrix/vander.m @ 4:b4df021f796c
[project @ 1993-08-08 01:26:08 by jwe]
Initial revision
author | jwe |
---|---|
date | Sun, 08 Aug 1993 01:26:08 +0000 |
parents | |
children | 16a24e76d6e0 |
comparison
equal
deleted
inserted
replaced
3:9a4c07481e61 | 4:b4df021f796c |
---|---|
1 function retval = vander (c) | |
2 | |
3 # usage: vander (c) | |
4 # | |
5 # Return the Vandermonde matrix whose next to last column is c. | |
6 # | |
7 # See also: hankel, hadamard, hilb, invhilb, toeplitz | |
8 | |
9 if (nargin != 1) | |
10 error ("usage: vander (c)"); | |
11 endif | |
12 | |
13 nr = rows (c); | |
14 nc = columns (c); | |
15 if (nr == 1 && nc == 1) | |
16 retval = 1; | |
17 elseif (nr == 1 || nc == 1) | |
18 n = length (c); | |
19 if (n > 0) | |
20 retval = zeros (n, n); | |
21 for i = 1:n | |
22 tmp = c(i); | |
23 for j = 1:n | |
24 retval (i, j) = tmp ^ (n - j); | |
25 endfor | |
26 endfor | |
27 endif | |
28 else | |
29 error ("vander: argument must be a vector"); | |
30 endif | |
31 | |
32 endfunction |