3140
|
1 ## Copyright (C) 1996, 1997 John W. Eaton |
|
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. |
3140
|
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/>. |
3140
|
18 |
3369
|
19 ## -*- texinfo -*- |
|
20 ## @deftypefn {Function File} {} sylvester_matrix (@var{k}) |
|
21 ## Return the Sylvester matrix of order |
|
22 ## @iftex |
|
23 ## @tex |
|
24 ## $n = 2^k$. |
|
25 ## @end tex |
|
26 ## @end iftex |
|
27 ## @ifinfo |
|
28 ## n = 2^k. |
|
29 ## @end ifinfo |
5642
|
30 ## @seealso{hankel, vander, hilb, invhilb, toeplitz} |
3369
|
31 ## @end deftypefn |
3140
|
32 |
|
33 ## Author: jwe |
|
34 |
|
35 function retval = sylvester_matrix (k) |
|
36 |
|
37 if (nargin != 1) |
6046
|
38 print_usage (); |
3140
|
39 endif |
|
40 |
4030
|
41 if (isscalar (k)) |
3140
|
42 if (k < 1) |
|
43 retval = 1; |
|
44 else |
|
45 tmp = sylvester_matrix (k-1); |
|
46 retval = [tmp, tmp; tmp, -tmp]; |
|
47 endif |
|
48 else |
|
49 error ("sylvester_matrix: expecting scalar argument"); |
|
50 endif |
|
51 |
|
52 endfunction |