annotate scripts/deprecated/sylvester_matrix.m @ 14182:f8d99761244c stable

test: Expand %!testif functionality to multiple conditions * test.m: Add testing for multiple conditions in %!testif statement. * svds.m, eigs.cc: Test for ARPACK and other libraries before running some tests.
author Rik <octave@nomad.inbox5.com>
date Mon, 09 Jan 2012 13:32:44 -0800
parents 72c96de7a403
children 1c89599167a6
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
14138
72c96de7a403 maint: update copyright notices for 2012
John W. Eaton <jwe@octave.org>
parents: 12644
diff changeset
1 ## Copyright (C) 1996-2012 John W. Eaton
3140
990ea337e950 [project @ 1998-02-03 08:07:51 by jwe]
jwe
parents:
diff changeset
2 ##
990ea337e950 [project @ 1998-02-03 08:07:51 by jwe]
jwe
parents:
diff changeset
3 ## This file is part of Octave.
990ea337e950 [project @ 1998-02-03 08:07:51 by jwe]
jwe
parents:
diff changeset
4 ##
990ea337e950 [project @ 1998-02-03 08:07:51 by jwe]
jwe
parents:
diff changeset
5 ## Octave is free software; you can redistribute it and/or modify it
990ea337e950 [project @ 1998-02-03 08:07:51 by jwe]
jwe
parents:
diff changeset
6 ## under the terms of the GNU General Public License as published by
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6046
diff changeset
7 ## the Free Software Foundation; either version 3 of the License, or (at
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6046
diff changeset
8 ## your option) any later version.
3140
990ea337e950 [project @ 1998-02-03 08:07:51 by jwe]
jwe
parents:
diff changeset
9 ##
990ea337e950 [project @ 1998-02-03 08:07:51 by jwe]
jwe
parents:
diff changeset
10 ## Octave is distributed in the hope that it will be useful, but
990ea337e950 [project @ 1998-02-03 08:07:51 by jwe]
jwe
parents:
diff changeset
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of
990ea337e950 [project @ 1998-02-03 08:07:51 by jwe]
jwe
parents:
diff changeset
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
990ea337e950 [project @ 1998-02-03 08:07:51 by jwe]
jwe
parents:
diff changeset
13 ## General Public License for more details.
990ea337e950 [project @ 1998-02-03 08:07:51 by jwe]
jwe
parents:
diff changeset
14 ##
990ea337e950 [project @ 1998-02-03 08:07:51 by jwe]
jwe
parents:
diff changeset
15 ## You should have received a copy of the GNU General Public License
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6046
diff changeset
16 ## along with Octave; see the file COPYING. If not, see
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6046
diff changeset
17 ## <http://www.gnu.org/licenses/>.
3140
990ea337e950 [project @ 1998-02-03 08:07:51 by jwe]
jwe
parents:
diff changeset
18
3369
f37ca3017116 [project @ 1999-11-21 16:26:02 by jwe]
jwe
parents: 3140
diff changeset
19 ## -*- texinfo -*-
f37ca3017116 [project @ 1999-11-21 16:26:02 by jwe]
jwe
parents: 3140
diff changeset
20 ## @deftypefn {Function File} {} sylvester_matrix (@var{k})
f37ca3017116 [project @ 1999-11-21 16:26:02 by jwe]
jwe
parents: 3140
diff changeset
21 ## Return the Sylvester matrix of order
f37ca3017116 [project @ 1999-11-21 16:26:02 by jwe]
jwe
parents: 3140
diff changeset
22 ## @tex
f37ca3017116 [project @ 1999-11-21 16:26:02 by jwe]
jwe
parents: 3140
diff changeset
23 ## $n = 2^k$.
f37ca3017116 [project @ 1999-11-21 16:26:02 by jwe]
jwe
parents: 3140
diff changeset
24 ## @end tex
8517
81d6ab3ac93c Allow documentation tobe built for other formats than tex and info
sh@sh-laptop
parents: 7411
diff changeset
25 ## @ifnottex
12639
4d777e05d47c doc: Review and update documentation for "Matrix Manipulation" chapter.
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
26 ## n = 2^@var{k}.
8517
81d6ab3ac93c Allow documentation tobe built for other formats than tex and info
sh@sh-laptop
parents: 7411
diff changeset
27 ## @end ifnottex
12639
4d777e05d47c doc: Review and update documentation for "Matrix Manipulation" chapter.
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
28 ##
4d777e05d47c doc: Review and update documentation for "Matrix Manipulation" chapter.
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
29 ## @seealso{toeplitz, hankel}
3369
f37ca3017116 [project @ 1999-11-21 16:26:02 by jwe]
jwe
parents: 3140
diff changeset
30 ## @end deftypefn
3140
990ea337e950 [project @ 1998-02-03 08:07:51 by jwe]
jwe
parents:
diff changeset
31
990ea337e950 [project @ 1998-02-03 08:07:51 by jwe]
jwe
parents:
diff changeset
32 ## Author: jwe
990ea337e950 [project @ 1998-02-03 08:07:51 by jwe]
jwe
parents:
diff changeset
33
990ea337e950 [project @ 1998-02-03 08:07:51 by jwe]
jwe
parents:
diff changeset
34 function retval = sylvester_matrix (k)
990ea337e950 [project @ 1998-02-03 08:07:51 by jwe]
jwe
parents:
diff changeset
35
12644
e205ebe2ba67 Deprecate sylvester_matrix.m function
Rik <octave@nomad.inbox5.com>
parents: 12639
diff changeset
36 persistent warned = false;
e205ebe2ba67 Deprecate sylvester_matrix.m function
Rik <octave@nomad.inbox5.com>
parents: 12639
diff changeset
37 if (! warned)
e205ebe2ba67 Deprecate sylvester_matrix.m function
Rik <octave@nomad.inbox5.com>
parents: 12639
diff changeset
38 warned = true;
e205ebe2ba67 Deprecate sylvester_matrix.m function
Rik <octave@nomad.inbox5.com>
parents: 12639
diff changeset
39 warning ("Octave:deprecated-function",
e205ebe2ba67 Deprecate sylvester_matrix.m function
Rik <octave@nomad.inbox5.com>
parents: 12639
diff changeset
40 "sylvester_matrix is obsolete and will be removed from a future version of Octave; please use hadamard(2^k) instead");
e205ebe2ba67 Deprecate sylvester_matrix.m function
Rik <octave@nomad.inbox5.com>
parents: 12639
diff changeset
41 endif
e205ebe2ba67 Deprecate sylvester_matrix.m function
Rik <octave@nomad.inbox5.com>
parents: 12639
diff changeset
42
3140
990ea337e950 [project @ 1998-02-03 08:07:51 by jwe]
jwe
parents:
diff changeset
43 if (nargin != 1)
6046
34f96dd5441b [project @ 2006-10-10 16:10:25 by jwe]
jwe
parents: 5642
diff changeset
44 print_usage ();
3140
990ea337e950 [project @ 1998-02-03 08:07:51 by jwe]
jwe
parents:
diff changeset
45 endif
990ea337e950 [project @ 1998-02-03 08:07:51 by jwe]
jwe
parents:
diff changeset
46
4030
22bd65326ec1 [project @ 2002-08-09 18:58:13 by jwe]
jwe
parents: 3408
diff changeset
47 if (isscalar (k))
3140
990ea337e950 [project @ 1998-02-03 08:07:51 by jwe]
jwe
parents:
diff changeset
48 if (k < 1)
990ea337e950 [project @ 1998-02-03 08:07:51 by jwe]
jwe
parents:
diff changeset
49 retval = 1;
990ea337e950 [project @ 1998-02-03 08:07:51 by jwe]
jwe
parents:
diff changeset
50 else
990ea337e950 [project @ 1998-02-03 08:07:51 by jwe]
jwe
parents:
diff changeset
51 tmp = sylvester_matrix (k-1);
990ea337e950 [project @ 1998-02-03 08:07:51 by jwe]
jwe
parents:
diff changeset
52 retval = [tmp, tmp; tmp, -tmp];
990ea337e950 [project @ 1998-02-03 08:07:51 by jwe]
jwe
parents:
diff changeset
53 endif
990ea337e950 [project @ 1998-02-03 08:07:51 by jwe]
jwe
parents:
diff changeset
54 else
990ea337e950 [project @ 1998-02-03 08:07:51 by jwe]
jwe
parents:
diff changeset
55 error ("sylvester_matrix: expecting scalar argument");
990ea337e950 [project @ 1998-02-03 08:07:51 by jwe]
jwe
parents:
diff changeset
56 endif
990ea337e950 [project @ 1998-02-03 08:07:51 by jwe]
jwe
parents:
diff changeset
57
990ea337e950 [project @ 1998-02-03 08:07:51 by jwe]
jwe
parents:
diff changeset
58 endfunction
7411
83a8781b529d [project @ 2008-01-22 21:52:25 by jwe]
jwe
parents: 7017
diff changeset
59
83a8781b529d [project @ 2008-01-22 21:52:25 by jwe]
jwe
parents: 7017
diff changeset
60 %!assert((sylvester_matrix (1) == [1, 1; 1, -1]
83a8781b529d [project @ 2008-01-22 21:52:25 by jwe]
jwe
parents: 7017
diff changeset
61 %! && (sylvester_matrix (2)
83a8781b529d [project @ 2008-01-22 21:52:25 by jwe]
jwe
parents: 7017
diff changeset
62 %! == [1, 1, 1, 1; 1, -1, 1, -1; 1, 1, -1, -1; 1, -1, -1, 1])));
83a8781b529d [project @ 2008-01-22 21:52:25 by jwe]
jwe
parents: 7017
diff changeset
63
83a8781b529d [project @ 2008-01-22 21:52:25 by jwe]
jwe
parents: 7017
diff changeset
64 %!error sylvester_matrix ([1, 2; 3, 4]);
83a8781b529d [project @ 2008-01-22 21:52:25 by jwe]
jwe
parents: 7017
diff changeset
65
83a8781b529d [project @ 2008-01-22 21:52:25 by jwe]
jwe
parents: 7017
diff changeset
66 %!error sylvester_matrix ();
83a8781b529d [project @ 2008-01-22 21:52:25 by jwe]
jwe
parents: 7017
diff changeset
67
83a8781b529d [project @ 2008-01-22 21:52:25 by jwe]
jwe
parents: 7017
diff changeset
68 %!error sylvester_matrix (1, 2);
83a8781b529d [project @ 2008-01-22 21:52:25 by jwe]
jwe
parents: 7017
diff changeset
69