annotate scripts/special-matrix/hadamard.m @ 15536:2e8eb9ac43a5 stable rc-3-6-4-0

3.6.4-rc0 release candidate * configure.ac (AC_INIT): Version is now 3.6.2-rc0. (OCTAVE_RELEASE_DATE): Now 2012-05-11.
author John W. Eaton <jwe@octave.org>
date Wed, 17 Oct 2012 10:05:44 -0400
parents 72c96de7a403
children f3d52523cde1
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: 13913
diff changeset
1 ## Copyright (C) 1993-2012 Paul Kienzle
5827
1fe78adb91bc [project @ 2006-05-22 06:25:14 by jwe]
jwe
parents:
diff changeset
2 ##
1fe78adb91bc [project @ 2006-05-22 06:25:14 by jwe]
jwe
parents:
diff changeset
3 ## This file is part of Octave.
1fe78adb91bc [project @ 2006-05-22 06:25:14 by jwe]
jwe
parents:
diff changeset
4 ##
1fe78adb91bc [project @ 2006-05-22 06:25:14 by jwe]
jwe
parents:
diff changeset
5 ## Octave is free software; you can redistribute it and/or modify it
1fe78adb91bc [project @ 2006-05-22 06:25:14 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: 6516
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: 6516
diff changeset
8 ## your option) any later version.
5827
1fe78adb91bc [project @ 2006-05-22 06:25:14 by jwe]
jwe
parents:
diff changeset
9 ##
1fe78adb91bc [project @ 2006-05-22 06:25:14 by jwe]
jwe
parents:
diff changeset
10 ## Octave is distributed in the hope that it will be useful, but
1fe78adb91bc [project @ 2006-05-22 06:25:14 by jwe]
jwe
parents:
diff changeset
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of
1fe78adb91bc [project @ 2006-05-22 06:25:14 by jwe]
jwe
parents:
diff changeset
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1fe78adb91bc [project @ 2006-05-22 06:25:14 by jwe]
jwe
parents:
diff changeset
13 ## General Public License for more details.
1fe78adb91bc [project @ 2006-05-22 06:25:14 by jwe]
jwe
parents:
diff changeset
14 ##
1fe78adb91bc [project @ 2006-05-22 06:25:14 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: 6516
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: 6516
diff changeset
17 ## <http://www.gnu.org/licenses/>.
5827
1fe78adb91bc [project @ 2006-05-22 06:25:14 by jwe]
jwe
parents:
diff changeset
18 ##
1fe78adb91bc [project @ 2006-05-22 06:25:14 by jwe]
jwe
parents:
diff changeset
19 ## Original version by Paul Kienzle distributed as free software in the
1fe78adb91bc [project @ 2006-05-22 06:25:14 by jwe]
jwe
parents:
diff changeset
20 ## public domain.
1fe78adb91bc [project @ 2006-05-22 06:25:14 by jwe]
jwe
parents:
diff changeset
21
1fe78adb91bc [project @ 2006-05-22 06:25:14 by jwe]
jwe
parents:
diff changeset
22 ## -*- texinfo -*-
1fe78adb91bc [project @ 2006-05-22 06:25:14 by jwe]
jwe
parents:
diff changeset
23 ## @deftypefn {Function File} {} hadamard (@var{n})
12639
4d777e05d47c doc: Review and update documentation for "Matrix Manipulation" chapter.
Rik <octave@nomad.inbox5.com>
parents: 11587
diff changeset
24 ## Construct a Hadamard matrix (@nospell{Hn}) of size @var{n}-by-@var{n}. The
4d777e05d47c doc: Review and update documentation for "Matrix Manipulation" chapter.
Rik <octave@nomad.inbox5.com>
parents: 11587
diff changeset
25 ## size @var{n} must be of the form @math{2^k * p} in which
4d777e05d47c doc: Review and update documentation for "Matrix Manipulation" chapter.
Rik <octave@nomad.inbox5.com>
parents: 11587
diff changeset
26 ## p is one of 1, 12, 20 or 28. The returned matrix is normalized,
4d777e05d47c doc: Review and update documentation for "Matrix Manipulation" chapter.
Rik <octave@nomad.inbox5.com>
parents: 11587
diff changeset
27 ## meaning @w{@code{Hn(:,1) == 1}} and @w{@code{Hn(1,:) == 1}}.
5827
1fe78adb91bc [project @ 2006-05-22 06:25:14 by jwe]
jwe
parents:
diff changeset
28 ##
1fe78adb91bc [project @ 2006-05-22 06:25:14 by jwe]
jwe
parents:
diff changeset
29 ## Some of the properties of Hadamard matrices are:
1fe78adb91bc [project @ 2006-05-22 06:25:14 by jwe]
jwe
parents:
diff changeset
30 ##
1fe78adb91bc [project @ 2006-05-22 06:25:14 by jwe]
jwe
parents:
diff changeset
31 ## @itemize @bullet
1fe78adb91bc [project @ 2006-05-22 06:25:14 by jwe]
jwe
parents:
diff changeset
32 ## @item
12639
4d777e05d47c doc: Review and update documentation for "Matrix Manipulation" chapter.
Rik <octave@nomad.inbox5.com>
parents: 11587
diff changeset
33 ## @code{kron (Hm, Hn)} is a Hadamard matrix of size @var{m}-by-@var{n}.
10821
693e22af08ae Grammarcheck documentation of m-files
Rik <octave@nomad.inbox5.com>
parents: 10791
diff changeset
34 ##
5827
1fe78adb91bc [project @ 2006-05-22 06:25:14 by jwe]
jwe
parents:
diff changeset
35 ## @item
12639
4d777e05d47c doc: Review and update documentation for "Matrix Manipulation" chapter.
Rik <octave@nomad.inbox5.com>
parents: 11587
diff changeset
36 ## @code{Hn * Hn' = @var{n} * eye (@var{n})}.
4d777e05d47c doc: Review and update documentation for "Matrix Manipulation" chapter.
Rik <octave@nomad.inbox5.com>
parents: 11587
diff changeset
37 ##
4d777e05d47c doc: Review and update documentation for "Matrix Manipulation" chapter.
Rik <octave@nomad.inbox5.com>
parents: 11587
diff changeset
38 ## @item
4d777e05d47c doc: Review and update documentation for "Matrix Manipulation" chapter.
Rik <octave@nomad.inbox5.com>
parents: 11587
diff changeset
39 ## The rows of @nospell{Hn} are orthogonal.
10821
693e22af08ae Grammarcheck documentation of m-files
Rik <octave@nomad.inbox5.com>
parents: 10791
diff changeset
40 ##
5827
1fe78adb91bc [project @ 2006-05-22 06:25:14 by jwe]
jwe
parents:
diff changeset
41 ## @item
12639
4d777e05d47c doc: Review and update documentation for "Matrix Manipulation" chapter.
Rik <octave@nomad.inbox5.com>
parents: 11587
diff changeset
42 ## @code{det (@var{A}) <= abs (det (Hn))} for all @var{A} with
4d777e05d47c doc: Review and update documentation for "Matrix Manipulation" chapter.
Rik <octave@nomad.inbox5.com>
parents: 11587
diff changeset
43 ## @w{@code{abs (@var{A}(i, j)) <= 1}}.
10821
693e22af08ae Grammarcheck documentation of m-files
Rik <octave@nomad.inbox5.com>
parents: 10791
diff changeset
44 ##
5827
1fe78adb91bc [project @ 2006-05-22 06:25:14 by jwe]
jwe
parents:
diff changeset
45 ## @item
12639
4d777e05d47c doc: Review and update documentation for "Matrix Manipulation" chapter.
Rik <octave@nomad.inbox5.com>
parents: 11587
diff changeset
46 ## Multiplying any row or column by -1 and the matrix will remain a Hadamard
4d777e05d47c doc: Review and update documentation for "Matrix Manipulation" chapter.
Rik <octave@nomad.inbox5.com>
parents: 11587
diff changeset
47 ## matrix.
5827
1fe78adb91bc [project @ 2006-05-22 06:25:14 by jwe]
jwe
parents:
diff changeset
48 ## @end itemize
12639
4d777e05d47c doc: Review and update documentation for "Matrix Manipulation" chapter.
Rik <octave@nomad.inbox5.com>
parents: 11587
diff changeset
49 ## @seealso{compan, hankel, toeplitz}
5827
1fe78adb91bc [project @ 2006-05-22 06:25:14 by jwe]
jwe
parents:
diff changeset
50 ## @end deftypefn
1fe78adb91bc [project @ 2006-05-22 06:25:14 by jwe]
jwe
parents:
diff changeset
51
11587
c792872f8942 all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
52
5827
1fe78adb91bc [project @ 2006-05-22 06:25:14 by jwe]
jwe
parents:
diff changeset
53 ## Reference [1] contains a list of Hadamard matrices up to n=256.
1fe78adb91bc [project @ 2006-05-22 06:25:14 by jwe]
jwe
parents:
diff changeset
54 ## See code for h28 in hadamard.m for an example of how to extend
1fe78adb91bc [project @ 2006-05-22 06:25:14 by jwe]
jwe
parents:
diff changeset
55 ## this function for additional p.
1fe78adb91bc [project @ 2006-05-22 06:25:14 by jwe]
jwe
parents:
diff changeset
56 ##
1fe78adb91bc [project @ 2006-05-22 06:25:14 by jwe]
jwe
parents:
diff changeset
57 ## References:
11587
c792872f8942 all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
58 ## [1] A Library of Hadamard Matrices, N. J. A. Sloane
5827
1fe78adb91bc [project @ 2006-05-22 06:25:14 by jwe]
jwe
parents:
diff changeset
59 ## http://www.research.att.com/~njas/hadamard/
1fe78adb91bc [project @ 2006-05-22 06:25:14 by jwe]
jwe
parents:
diff changeset
60
1fe78adb91bc [project @ 2006-05-22 06:25:14 by jwe]
jwe
parents:
diff changeset
61 function h = hadamard (n)
11587
c792872f8942 all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
62
5827
1fe78adb91bc [project @ 2006-05-22 06:25:14 by jwe]
jwe
parents:
diff changeset
63 if (nargin != 1)
1fe78adb91bc [project @ 2006-05-22 06:25:14 by jwe]
jwe
parents:
diff changeset
64 print_usage ();
1fe78adb91bc [project @ 2006-05-22 06:25:14 by jwe]
jwe
parents:
diff changeset
65 endif
1fe78adb91bc [project @ 2006-05-22 06:25:14 by jwe]
jwe
parents:
diff changeset
66
8507
cadc73247d65 style fixes
John W. Eaton <jwe@octave.org>
parents: 7017
diff changeset
67 ## Find k if n = 2^k*p.
5827
1fe78adb91bc [project @ 2006-05-22 06:25:14 by jwe]
jwe
parents:
diff changeset
68 k = 0;
13893
5b1ddcf5ede1 hadamard.m: Embed hadamard28 matrix as constant rather than computed value.
Rik <octave@nomad.inbox5.com>
parents: 12639
diff changeset
69 while (n > 1 && fix (n/2) == n/2)
11587
c792872f8942 all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
70 k++;
13893
5b1ddcf5ede1 hadamard.m: Embed hadamard28 matrix as constant rather than computed value.
Rik <octave@nomad.inbox5.com>
parents: 12639
diff changeset
71 n /= 2;
5827
1fe78adb91bc [project @ 2006-05-22 06:25:14 by jwe]
jwe
parents:
diff changeset
72 endwhile
11587
c792872f8942 all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
73
8507
cadc73247d65 style fixes
John W. Eaton <jwe@octave.org>
parents: 7017
diff changeset
74 ## Find base hadamard.
cadc73247d65 style fixes
John W. Eaton <jwe@octave.org>
parents: 7017
diff changeset
75 ## Except for n=2^k, need a multiple of 4.
5827
1fe78adb91bc [project @ 2006-05-22 06:25:14 by jwe]
jwe
parents:
diff changeset
76 if (n != 1)
11587
c792872f8942 all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
77 k -= 2;
5827
1fe78adb91bc [project @ 2006-05-22 06:25:14 by jwe]
jwe
parents:
diff changeset
78 endif
1fe78adb91bc [project @ 2006-05-22 06:25:14 by jwe]
jwe
parents:
diff changeset
79
8507
cadc73247d65 style fixes
John W. Eaton <jwe@octave.org>
parents: 7017
diff changeset
80 ## Trigger error if not a multiple of 4.
5827
1fe78adb91bc [project @ 2006-05-22 06:25:14 by jwe]
jwe
parents:
diff changeset
81 if (k < 0)
1fe78adb91bc [project @ 2006-05-22 06:25:14 by jwe]
jwe
parents:
diff changeset
82 n =- 1;
1fe78adb91bc [project @ 2006-05-22 06:25:14 by jwe]
jwe
parents:
diff changeset
83 endif
1fe78adb91bc [project @ 2006-05-22 06:25:14 by jwe]
jwe
parents:
diff changeset
84
1fe78adb91bc [project @ 2006-05-22 06:25:14 by jwe]
jwe
parents:
diff changeset
85 switch (n)
1fe78adb91bc [project @ 2006-05-22 06:25:14 by jwe]
jwe
parents:
diff changeset
86 case 1
1fe78adb91bc [project @ 2006-05-22 06:25:14 by jwe]
jwe
parents:
diff changeset
87 h = 1;
1fe78adb91bc [project @ 2006-05-22 06:25:14 by jwe]
jwe
parents:
diff changeset
88 case 3
1fe78adb91bc [project @ 2006-05-22 06:25:14 by jwe]
jwe
parents:
diff changeset
89 h = h12 ();
1fe78adb91bc [project @ 2006-05-22 06:25:14 by jwe]
jwe
parents:
diff changeset
90 case 5
1fe78adb91bc [project @ 2006-05-22 06:25:14 by jwe]
jwe
parents:
diff changeset
91 h = h20 ();
1fe78adb91bc [project @ 2006-05-22 06:25:14 by jwe]
jwe
parents:
diff changeset
92 case 7
13913
521adfd775be hadamard.m: Fix failing %!tests
Rik <octave@nomad.inbox5.com>
parents: 13893
diff changeset
93 h = h28 ();
5827
1fe78adb91bc [project @ 2006-05-22 06:25:14 by jwe]
jwe
parents:
diff changeset
94 otherwise
11472
1740012184f9 Use uppercase for variable names in error() strings to match Info documentation. Only m-files done.
Rik <octave@nomad.inbox5.com>
parents: 10821
diff changeset
95 error ("hadamard: N must be 2^k*p, for p = 1, 12, 20 or 28");
5827
1fe78adb91bc [project @ 2006-05-22 06:25:14 by jwe]
jwe
parents:
diff changeset
96 endswitch
1fe78adb91bc [project @ 2006-05-22 06:25:14 by jwe]
jwe
parents:
diff changeset
97
8507
cadc73247d65 style fixes
John W. Eaton <jwe@octave.org>
parents: 7017
diff changeset
98 ## Build H(2^k*n) from kron(H(2^k),H(n)).
5827
1fe78adb91bc [project @ 2006-05-22 06:25:14 by jwe]
jwe
parents:
diff changeset
99 h2 = [1,1;1,-1];
1fe78adb91bc [project @ 2006-05-22 06:25:14 by jwe]
jwe
parents:
diff changeset
100 while (true)
13893
5b1ddcf5ede1 hadamard.m: Embed hadamard28 matrix as constant rather than computed value.
Rik <octave@nomad.inbox5.com>
parents: 12639
diff changeset
101 if (fix (k/2) != k/2)
11587
c792872f8942 all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
102 h = kron (h2, h);
5827
1fe78adb91bc [project @ 2006-05-22 06:25:14 by jwe]
jwe
parents:
diff changeset
103 endif
13893
5b1ddcf5ede1 hadamard.m: Embed hadamard28 matrix as constant rather than computed value.
Rik <octave@nomad.inbox5.com>
parents: 12639
diff changeset
104 k = fix (k/2);
11587
c792872f8942 all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
105 if (k == 0)
c792872f8942 all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
106 break;
5827
1fe78adb91bc [project @ 2006-05-22 06:25:14 by jwe]
jwe
parents:
diff changeset
107 endif
1fe78adb91bc [project @ 2006-05-22 06:25:14 by jwe]
jwe
parents:
diff changeset
108 h2 = kron (h2, h2);
1fe78adb91bc [project @ 2006-05-22 06:25:14 by jwe]
jwe
parents:
diff changeset
109 endwhile
13893
5b1ddcf5ede1 hadamard.m: Embed hadamard28 matrix as constant rather than computed value.
Rik <octave@nomad.inbox5.com>
parents: 12639
diff changeset
110
5827
1fe78adb91bc [project @ 2006-05-22 06:25:14 by jwe]
jwe
parents:
diff changeset
111 endfunction
1fe78adb91bc [project @ 2006-05-22 06:25:14 by jwe]
jwe
parents:
diff changeset
112
1fe78adb91bc [project @ 2006-05-22 06:25:14 by jwe]
jwe
parents:
diff changeset
113 function h = h12 ()
8507
cadc73247d65 style fixes
John W. Eaton <jwe@octave.org>
parents: 7017
diff changeset
114 tu = [-1,+1,-1,+1,+1,+1,-1,-1,-1,+1,-1];
cadc73247d65 style fixes
John W. Eaton <jwe@octave.org>
parents: 7017
diff changeset
115 tl = [-1,-1,+1,-1,-1,-1,+1,+1,+1,-1,+1];
cadc73247d65 style fixes
John W. Eaton <jwe@octave.org>
parents: 7017
diff changeset
116 ## Note: assert (tu(2:end), tl(end:-1:2)).
5827
1fe78adb91bc [project @ 2006-05-22 06:25:14 by jwe]
jwe
parents:
diff changeset
117 h = ones (12);
1fe78adb91bc [project @ 2006-05-22 06:25:14 by jwe]
jwe
parents:
diff changeset
118 h(2:end,2:end) = toeplitz (tu, tl);
1fe78adb91bc [project @ 2006-05-22 06:25:14 by jwe]
jwe
parents:
diff changeset
119 endfunction
1fe78adb91bc [project @ 2006-05-22 06:25:14 by jwe]
jwe
parents:
diff changeset
120
1fe78adb91bc [project @ 2006-05-22 06:25:14 by jwe]
jwe
parents:
diff changeset
121 function h = h20 ()
8507
cadc73247d65 style fixes
John W. Eaton <jwe@octave.org>
parents: 7017
diff changeset
122 tu = [+1,-1,-1,+1,+1,+1,+1,-1,+1,-1,+1,-1,-1,-1,-1,+1,+1,-1,-1];
cadc73247d65 style fixes
John W. Eaton <jwe@octave.org>
parents: 7017
diff changeset
123 tl = [+1,-1,-1,+1,+1,-1,-1,-1,-1,+1,-1,+1,-1,+1,+1,+1,+1,-1,-1];
cadc73247d65 style fixes
John W. Eaton <jwe@octave.org>
parents: 7017
diff changeset
124 ## Note: assert (tu(2:end), tl(end:-1:2)).
5827
1fe78adb91bc [project @ 2006-05-22 06:25:14 by jwe]
jwe
parents:
diff changeset
125 h = ones (20);
1fe78adb91bc [project @ 2006-05-22 06:25:14 by jwe]
jwe
parents:
diff changeset
126 h(2:end,2:end) = fliplr (toeplitz (tu, tl));
1fe78adb91bc [project @ 2006-05-22 06:25:14 by jwe]
jwe
parents:
diff changeset
127 endfunction
1fe78adb91bc [project @ 2006-05-22 06:25:14 by jwe]
jwe
parents:
diff changeset
128
1fe78adb91bc [project @ 2006-05-22 06:25:14 by jwe]
jwe
parents:
diff changeset
129 function h = h28 ()
1fe78adb91bc [project @ 2006-05-22 06:25:14 by jwe]
jwe
parents:
diff changeset
130 ## Williamson matrix construction from
1fe78adb91bc [project @ 2006-05-22 06:25:14 by jwe]
jwe
parents:
diff changeset
131 ## http://www.research.att.com/~njas/hadamard/had.28.will.txt
13893
5b1ddcf5ede1 hadamard.m: Embed hadamard28 matrix as constant rather than computed value.
Rik <octave@nomad.inbox5.com>
parents: 12639
diff changeset
132 ## Normalized so that each row and column starts with +1
5b1ddcf5ede1 hadamard.m: Embed hadamard28 matrix as constant rather than computed value.
Rik <octave@nomad.inbox5.com>
parents: 12639
diff changeset
133 h = [1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
5b1ddcf5ede1 hadamard.m: Embed hadamard28 matrix as constant rather than computed value.
Rik <octave@nomad.inbox5.com>
parents: 12639
diff changeset
134 1 1 -1 -1 -1 -1 -1 -1 -1 1 -1 -1 -1 1 1 1 1 1 -1 1 1 1 1 -1 1 -1 1 -1
5b1ddcf5ede1 hadamard.m: Embed hadamard28 matrix as constant rather than computed value.
Rik <octave@nomad.inbox5.com>
parents: 12639
diff changeset
135 1 -1 1 -1 -1 -1 -1 1 -1 1 1 -1 -1 1 -1 -1 -1 -1 1 1 -1 1 -1 1 1 1 1 1
5b1ddcf5ede1 hadamard.m: Embed hadamard28 matrix as constant rather than computed value.
Rik <octave@nomad.inbox5.com>
parents: 12639
diff changeset
136 1 -1 -1 1 -1 -1 -1 1 1 1 1 1 -1 1 1 1 1 1 -1 -1 -1 -1 -1 -1 -1 1 -1 1
5b1ddcf5ede1 hadamard.m: Embed hadamard28 matrix as constant rather than computed value.
Rik <octave@nomad.inbox5.com>
parents: 12639
diff changeset
137 1 -1 -1 -1 1 -1 -1 1 1 -1 1 1 1 1 1 -1 -1 -1 1 1 1 -1 1 -1 1 -1 -1 -1
5b1ddcf5ede1 hadamard.m: Embed hadamard28 matrix as constant rather than computed value.
Rik <octave@nomad.inbox5.com>
parents: 12639
diff changeset
138 1 -1 -1 -1 -1 1 -1 1 1 -1 -1 1 1 -1 -1 -1 1 1 -1 -1 -1 1 1 1 1 1 1 -1
5b1ddcf5ede1 hadamard.m: Embed hadamard28 matrix as constant rather than computed value.
Rik <octave@nomad.inbox5.com>
parents: 12639
diff changeset
139 1 -1 -1 -1 -1 -1 1 -1 1 -1 -1 -1 1 -1 1 1 1 -1 1 1 1 1 -1 1 -1 1 -1 1
5b1ddcf5ede1 hadamard.m: Embed hadamard28 matrix as constant rather than computed value.
Rik <octave@nomad.inbox5.com>
parents: 12639
diff changeset
140 1 -1 1 1 1 1 -1 -1 1 -1 -1 -1 -1 1 1 1 -1 -1 -1 -1 1 -1 -1 1 1 1 1 -1
5b1ddcf5ede1 hadamard.m: Embed hadamard28 matrix as constant rather than computed value.
Rik <octave@nomad.inbox5.com>
parents: 12639
diff changeset
141 1 -1 -1 1 1 1 1 1 -1 -1 -1 -1 -1 1 -1 -1 -1 1 -1 1 1 1 1 -1 -1 1 -1 1
5b1ddcf5ede1 hadamard.m: Embed hadamard28 matrix as constant rather than computed value.
Rik <octave@nomad.inbox5.com>
parents: 12639
diff changeset
142 1 1 1 1 -1 -1 -1 -1 -1 -1 1 1 1 -1 1 -1 -1 -1 -1 -1 1 1 1 -1 -1 1 1 1
5b1ddcf5ede1 hadamard.m: Embed hadamard28 matrix as constant rather than computed value.
Rik <octave@nomad.inbox5.com>
parents: 12639
diff changeset
143 1 -1 1 1 1 -1 -1 -1 -1 1 -1 1 1 -1 -1 -1 1 1 -1 1 1 -1 -1 1 1 -1 -1 1
5b1ddcf5ede1 hadamard.m: Embed hadamard28 matrix as constant rather than computed value.
Rik <octave@nomad.inbox5.com>
parents: 12639
diff changeset
144 1 -1 -1 1 1 1 -1 -1 -1 1 1 -1 1 -1 -1 1 1 -1 1 1 -1 -1 1 -1 -1 1 1 -1
5b1ddcf5ede1 hadamard.m: Embed hadamard28 matrix as constant rather than computed value.
Rik <octave@nomad.inbox5.com>
parents: 12639
diff changeset
145 1 -1 -1 -1 1 1 1 -1 -1 1 1 1 -1 -1 1 1 -1 -1 -1 -1 -1 1 1 1 1 -1 -1 1
5b1ddcf5ede1 hadamard.m: Embed hadamard28 matrix as constant rather than computed value.
Rik <octave@nomad.inbox5.com>
parents: 12639
diff changeset
146 1 1 1 1 1 -1 -1 1 1 -1 -1 -1 -1 -1 -1 1 1 -1 1 -1 -1 1 1 -1 1 -1 -1 1
5b1ddcf5ede1 hadamard.m: Embed hadamard28 matrix as constant rather than computed value.
Rik <octave@nomad.inbox5.com>
parents: 12639
diff changeset
147 1 1 -1 1 1 -1 1 -1 1 -1 1 1 -1 1 -1 -1 1 -1 -1 1 -1 1 -1 1 -1 -1 1 -1
5b1ddcf5ede1 hadamard.m: Embed hadamard28 matrix as constant rather than computed value.
Rik <octave@nomad.inbox5.com>
parents: 12639
diff changeset
148 1 1 -1 1 -1 -1 1 -1 1 1 1 -1 -1 -1 -1 -1 -1 1 1 -1 1 -1 1 1 1 1 -1 -1
5b1ddcf5ede1 hadamard.m: Embed hadamard28 matrix as constant rather than computed value.
Rik <octave@nomad.inbox5.com>
parents: 12639
diff changeset
149 1 1 -1 1 -1 1 1 1 1 1 -1 -1 1 -1 1 -1 -1 -1 -1 1 -1 -1 -1 -1 1 -1 1 1
5b1ddcf5ede1 hadamard.m: Embed hadamard28 matrix as constant rather than computed value.
Rik <octave@nomad.inbox5.com>
parents: 12639
diff changeset
150 1 1 -1 1 -1 1 -1 1 -1 1 -1 1 1 1 -1 1 -1 -1 1 -1 1 1 -1 1 -1 -1 -1 -1
5b1ddcf5ede1 hadamard.m: Embed hadamard28 matrix as constant rather than computed value.
Rik <octave@nomad.inbox5.com>
parents: 12639
diff changeset
151 1 -1 1 -1 1 -1 1 1 1 1 1 -1 1 -1 -1 1 -1 1 -1 -1 1 1 -1 -1 -1 -1 1 -1
5b1ddcf5ede1 hadamard.m: Embed hadamard28 matrix as constant rather than computed value.
Rik <octave@nomad.inbox5.com>
parents: 12639
diff changeset
152 1 1 1 -1 1 -1 1 1 -1 1 -1 -1 1 1 1 -1 1 -1 -1 -1 -1 -1 1 1 -1 1 -1 -1
5b1ddcf5ede1 hadamard.m: Embed hadamard28 matrix as constant rather than computed value.
Rik <octave@nomad.inbox5.com>
parents: 12639
diff changeset
153 1 1 -1 -1 1 -1 1 -1 -1 -1 -1 1 1 1 -1 1 -1 1 1 -1 -1 -1 -1 -1 1 1 1 1
5b1ddcf5ede1 hadamard.m: Embed hadamard28 matrix as constant rather than computed value.
Rik <octave@nomad.inbox5.com>
parents: 12639
diff changeset
154 1 1 1 -1 -1 1 1 1 -1 -1 1 1 -1 -1 -1 1 1 -1 -1 1 1 -1 -1 -1 1 1 -1 -1
5b1ddcf5ede1 hadamard.m: Embed hadamard28 matrix as constant rather than computed value.
Rik <octave@nomad.inbox5.com>
parents: 12639
diff changeset
155 1 1 -1 -1 1 1 -1 1 -1 -1 1 -1 -1 -1 1 -1 1 1 1 -1 1 -1 -1 1 -1 -1 1 1
5b1ddcf5ede1 hadamard.m: Embed hadamard28 matrix as constant rather than computed value.
Rik <octave@nomad.inbox5.com>
parents: 12639
diff changeset
156 1 -1 1 -1 -1 1 1 -1 1 1 -1 1 -1 1 -1 -1 1 -1 1 -1 1 -1 1 -1 -1 -1 1 1
5b1ddcf5ede1 hadamard.m: Embed hadamard28 matrix as constant rather than computed value.
Rik <octave@nomad.inbox5.com>
parents: 12639
diff changeset
157 1 1 1 -1 1 1 -1 -1 1 1 -1 1 -1 -1 1 -1 -1 1 1 1 -1 1 -1 -1 -1 1 -1 -1
5b1ddcf5ede1 hadamard.m: Embed hadamard28 matrix as constant rather than computed value.
Rik <octave@nomad.inbox5.com>
parents: 12639
diff changeset
158 1 -1 1 1 -1 1 1 -1 -1 -1 1 -1 1 1 1 -1 1 1 1 -1 -1 1 -1 -1 1 -1 -1 -1
5b1ddcf5ede1 hadamard.m: Embed hadamard28 matrix as constant rather than computed value.
Rik <octave@nomad.inbox5.com>
parents: 12639
diff changeset
159 1 1 1 -1 -1 1 -1 -1 1 -1 1 -1 1 1 -1 1 -1 1 -1 1 -1 -1 1 1 -1 -1 -1 1
5b1ddcf5ede1 hadamard.m: Embed hadamard28 matrix as constant rather than computed value.
Rik <octave@nomad.inbox5.com>
parents: 12639
diff changeset
160 1 -1 1 1 -1 -1 1 1 -1 -1 -1 1 -1 -1 1 1 -1 1 1 1 -1 -1 1 1 -1 -1 1 -1];
5827
1fe78adb91bc [project @ 2006-05-22 06:25:14 by jwe]
jwe
parents:
diff changeset
161 endfunction
1fe78adb91bc [project @ 2006-05-22 06:25:14 by jwe]
jwe
parents:
diff changeset
162
13893
5b1ddcf5ede1 hadamard.m: Embed hadamard28 matrix as constant rather than computed value.
Rik <octave@nomad.inbox5.com>
parents: 12639
diff changeset
163
5b1ddcf5ede1 hadamard.m: Embed hadamard28 matrix as constant rather than computed value.
Rik <octave@nomad.inbox5.com>
parents: 12639
diff changeset
164 %!assert (hadamard (1), 1)
5b1ddcf5ede1 hadamard.m: Embed hadamard28 matrix as constant rather than computed value.
Rik <octave@nomad.inbox5.com>
parents: 12639
diff changeset
165 %!assert (hadamard (2), [1,1;1,-1])
5827
1fe78adb91bc [project @ 2006-05-22 06:25:14 by jwe]
jwe
parents:
diff changeset
166 %!test
13893
5b1ddcf5ede1 hadamard.m: Embed hadamard28 matrix as constant rather than computed value.
Rik <octave@nomad.inbox5.com>
parents: 12639
diff changeset
167 %! for n = [1,2,4,8,12,24,48,20,28,2^9]
5b1ddcf5ede1 hadamard.m: Embed hadamard28 matrix as constant rather than computed value.
Rik <octave@nomad.inbox5.com>
parents: 12639
diff changeset
168 %! h = hadamard(n);
13913
521adfd775be hadamard.m: Fix failing %!tests
Rik <octave@nomad.inbox5.com>
parents: 13893
diff changeset
169 %! assert (norm (h*h' - n*eye (n)), 0);
13893
5b1ddcf5ede1 hadamard.m: Embed hadamard28 matrix as constant rather than computed value.
Rik <octave@nomad.inbox5.com>
parents: 12639
diff changeset
170 %! endfor
5b1ddcf5ede1 hadamard.m: Embed hadamard28 matrix as constant rather than computed value.
Rik <octave@nomad.inbox5.com>
parents: 12639
diff changeset
171
5b1ddcf5ede1 hadamard.m: Embed hadamard28 matrix as constant rather than computed value.
Rik <octave@nomad.inbox5.com>
parents: 12639
diff changeset
172 %!error hadamard ()
5b1ddcf5ede1 hadamard.m: Embed hadamard28 matrix as constant rather than computed value.
Rik <octave@nomad.inbox5.com>
parents: 12639
diff changeset
173 %!error hadamard (1,2)
13913
521adfd775be hadamard.m: Fix failing %!tests
Rik <octave@nomad.inbox5.com>
parents: 13893
diff changeset
174 %!error <N must be 2\^k\*p> hadamard (5)
13893
5b1ddcf5ede1 hadamard.m: Embed hadamard28 matrix as constant rather than computed value.
Rik <octave@nomad.inbox5.com>
parents: 12639
diff changeset
175