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 |
|
7 ## the Free Software Foundation; either version 2, or (at your option) |
|
8 ## any later version. |
|
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 |
|
16 ## along with Octave; see the file COPYING. If not, write to the Free |
5307
|
17 ## Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
|
18 ## 02110-1301, USA. |
245
|
19 |
3369
|
20 ## -*- texinfo -*- |
|
21 ## @deftypefn {Function File} {} vander (@var{c}) |
|
22 ## Return the Vandermonde matrix whose next to last column is @var{c}. |
3426
|
23 ## |
5016
|
24 ## A Vandermonde matrix has the form: |
3369
|
25 ## @iftex |
|
26 ## @tex |
|
27 ## $$ |
5016
|
28 ## \left[\matrix{c_1^{n-1} & \cdots & c_1^2 & c_1 & 1 \cr |
|
29 ## c_2^{n-1} & \cdots & c_2^2 & c_2 & 1 \cr |
|
30 ## \vdots & \ddots & \vdots & \vdots & \vdots \cr |
|
31 ## c_n^{n-1} & \cdots & c_n^2 & c_n & 1 }\right] |
3369
|
32 ## $$ |
|
33 ## @end tex |
|
34 ## @end iftex |
|
35 ## @ifinfo |
3426
|
36 ## |
3369
|
37 ## @example |
|
38 ## @group |
5016
|
39 ## c(1)^(n-1) ... c(1)^2 c(1) 1 |
|
40 ## c(2)^(n-1) ... c(2)^2 c(2) 1 |
|
41 ## . . . . . |
|
42 ## . . . . . |
|
43 ## . . . . . |
|
44 ## c(n)^(n-1) ... c(n)^2 c(n) 1 |
3369
|
45 ## @end group |
|
46 ## @end example |
|
47 ## @end ifinfo |
5642
|
48 ## @seealso{hankel, sylvester_matrix, hilb, invhilb, toeplitz} |
3369
|
49 ## @end deftypefn |
4
|
50 |
2314
|
51 ## Author: jwe |
|
52 |
2311
|
53 function retval = vander (c) |
4
|
54 |
|
55 if (nargin != 1) |
6046
|
56 print_usage (); |
4
|
57 endif |
|
58 |
4030
|
59 if (isvector (c)) |
4
|
60 n = length (c); |
3885
|
61 retval = zeros (n, n); |
|
62 j = 1:n; |
|
63 for i = 1:n |
|
64 retval(i,:) = c(i) .^ (n - j); |
|
65 endfor |
4
|
66 else |
|
67 error ("vander: argument must be a vector"); |
|
68 endif |
|
69 |
|
70 endfunction |