2847
|
1 ## Copyright (C) 1996, 1997 John W. Eaton |
2313
|
2 ## |
|
3 ## This file is part of Octave. |
|
4 ## |
|
5 ## Octave is free software; you can redistribute it and/or modify it |
|
6 ## under the terms of the GNU General Public License as published by |
7016
|
7 ## the Free Software Foundation; either version 3 of the License, or (at |
|
8 ## your option) any later version. |
2313
|
9 ## |
|
10 ## Octave is distributed in the hope that it will be useful, but |
|
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
13 ## General Public License for more details. |
|
14 ## |
|
15 ## You should have received a copy of the GNU General Public License |
7016
|
16 ## along with Octave; see the file COPYING. If not, see |
|
17 ## <http://www.gnu.org/licenses/>. |
245
|
18 |
3369
|
19 ## -*- texinfo -*- |
|
20 ## @deftypefn {Function File} {} vander (@var{c}) |
|
21 ## Return the Vandermonde matrix whose next to last column is @var{c}. |
3426
|
22 ## |
5016
|
23 ## A Vandermonde matrix has the form: |
3369
|
24 ## @iftex |
|
25 ## @tex |
|
26 ## $$ |
5016
|
27 ## \left[\matrix{c_1^{n-1} & \cdots & c_1^2 & c_1 & 1 \cr |
|
28 ## c_2^{n-1} & \cdots & c_2^2 & c_2 & 1 \cr |
|
29 ## \vdots & \ddots & \vdots & \vdots & \vdots \cr |
|
30 ## c_n^{n-1} & \cdots & c_n^2 & c_n & 1 }\right] |
3369
|
31 ## $$ |
|
32 ## @end tex |
|
33 ## @end iftex |
|
34 ## @ifinfo |
3426
|
35 ## |
3369
|
36 ## @example |
|
37 ## @group |
5016
|
38 ## c(1)^(n-1) ... c(1)^2 c(1) 1 |
|
39 ## c(2)^(n-1) ... c(2)^2 c(2) 1 |
|
40 ## . . . . . |
|
41 ## . . . . . |
|
42 ## . . . . . |
|
43 ## c(n)^(n-1) ... c(n)^2 c(n) 1 |
3369
|
44 ## @end group |
|
45 ## @end example |
|
46 ## @end ifinfo |
5642
|
47 ## @seealso{hankel, sylvester_matrix, hilb, invhilb, toeplitz} |
3369
|
48 ## @end deftypefn |
4
|
49 |
2314
|
50 ## Author: jwe |
|
51 |
2311
|
52 function retval = vander (c) |
4
|
53 |
|
54 if (nargin != 1) |
6046
|
55 print_usage (); |
4
|
56 endif |
|
57 |
4030
|
58 if (isvector (c)) |
4
|
59 n = length (c); |
3885
|
60 retval = zeros (n, n); |
|
61 j = 1:n; |
|
62 for i = 1:n |
|
63 retval(i,:) = c(i) .^ (n - j); |
|
64 endfor |
4
|
65 else |
|
66 error ("vander: argument must be a vector"); |
|
67 endif |
|
68 |
|
69 endfunction |