7017
|
1 ## Copyright (C) 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2002, |
|
2 ## 2004, 2005, 2006, 2007 John W. Eaton |
2313
|
3 ## |
|
4 ## This file is part of Octave. |
|
5 ## |
|
6 ## Octave is free software; you can redistribute it and/or modify it |
|
7 ## under the terms of the GNU General Public License as published by |
7016
|
8 ## the Free Software Foundation; either version 3 of the License, or (at |
|
9 ## your option) any later version. |
2313
|
10 ## |
|
11 ## Octave is distributed in the hope that it will be useful, but |
|
12 ## WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
14 ## General Public License for more details. |
|
15 ## |
|
16 ## You should have received a copy of the GNU General Public License |
7016
|
17 ## along with Octave; see the file COPYING. If not, see |
|
18 ## <http://www.gnu.org/licenses/>. |
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 |