1 ## Copyright (C) 1996-2012 John W. Eaton
3 ## This file is part of Octave.
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 3 of the License, or (at
8 ## your option) any later version.
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.
15 ## You should have received a copy of the GNU General Public License
16 ## along with Octave; see the file COPYING. If not, see
17 ## <http://www.gnu.org/licenses/>.
20 ## @deftypefn {Function File} {} sylvester_matrix (@var{k})
21 ## Return the Sylvester matrix of order
29 ## @seealso{toeplitz, hankel}
34 function retval = sylvester_matrix (k)
36 persistent warned = false;
39 warning ("Octave:deprecated-function",
40 "sylvester_matrix is obsolete and will be removed from a future version of Octave; please use hadamard(2^k) instead");
51 tmp = sylvester_matrix (k-1);
52 retval = [tmp, tmp; tmp, -tmp];
55 error ("sylvester_matrix: expecting scalar argument");
60 %!assert((sylvester_matrix (1) == [1, 1; 1, -1]
61 %! && (sylvester_matrix (2)
62 %! == [1, 1, 1, 1; 1, -1, 1, -1; 1, 1, -1, -1; 1, -1, -1, 1])));
64 %!error sylvester_matrix ([1, 2; 3, 4]);
66 %!error sylvester_matrix ();
68 %!error sylvester_matrix (1, 2);