annotate scripts/special-matrix/hadamard.m @ 29359:7854d5752dd2

maint: merge stable to default.
author John W. Eaton <jwe@octave.org>
date Wed, 10 Feb 2021 10:10:40 -0500
parents 90fea9cc9caa 0a5b15007766
children 363fb10055df
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
27923
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
1 ########################################################################
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
2 ##
29358
0a5b15007766 update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents: 27984
diff changeset
3 ## Copyright (C) 1993-2021 The Octave Project Developers
27918
b442ec6dda5c use centralized file for copyright info for individual contributors
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
4 ##
27923
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
5 ## See the file COPYRIGHT.md in the top-level directory of this
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
6 ## distribution or <https://octave.org/copyright/>.
5827
1fe78adb91bc [project @ 2006-05-22 06:25:14 by jwe]
jwe
parents:
diff changeset
7 ##
1fe78adb91bc [project @ 2006-05-22 06:25:14 by jwe]
jwe
parents:
diff changeset
8 ## This file is part of Octave.
1fe78adb91bc [project @ 2006-05-22 06:25:14 by jwe]
jwe
parents:
diff changeset
9 ##
24534
194eb4bd202b maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents: 23220
diff changeset
10 ## Octave is free software: you can redistribute it and/or modify it
5827
1fe78adb91bc [project @ 2006-05-22 06:25:14 by jwe]
jwe
parents:
diff changeset
11 ## under the terms of the GNU General Public License as published by
24534
194eb4bd202b maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents: 23220
diff changeset
12 ## the Free Software Foundation, either version 3 of the License, or
22755
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22323
diff changeset
13 ## (at your option) any later version.
5827
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 ## 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
16 ## WITHOUT ANY WARRANTY; without even the implied warranty of
22755
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22323
diff changeset
17 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22323
diff changeset
18 ## GNU General Public License for more details.
5827
1fe78adb91bc [project @ 2006-05-22 06:25:14 by jwe]
jwe
parents:
diff changeset
19 ##
1fe78adb91bc [project @ 2006-05-22 06:25:14 by jwe]
jwe
parents:
diff changeset
20 ## 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
21 ## along with Octave; see the file COPYING. If not, see
24534
194eb4bd202b maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents: 23220
diff changeset
22 ## <https://www.gnu.org/licenses/>.
5827
1fe78adb91bc [project @ 2006-05-22 06:25:14 by jwe]
jwe
parents:
diff changeset
23 ##
27923
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
24 ########################################################################
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
25 ##
5827
1fe78adb91bc [project @ 2006-05-22 06:25:14 by jwe]
jwe
parents:
diff changeset
26 ## 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
27 ## public domain.
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 ## -*- texinfo -*-
20852
516bb87ea72e 2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents: 20735
diff changeset
30 ## @deftypefn {} {} hadamard (@var{n})
20162
2645f9ef8c88 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19697
diff changeset
31 ## Construct a Hadamard matrix (@nospell{Hn}) of size @var{n}-by-@var{n}.
2645f9ef8c88 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19697
diff changeset
32 ##
2645f9ef8c88 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19697
diff changeset
33 ## The size @var{n} must be of the form @math{2^k * p} in which p is one of
2645f9ef8c88 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19697
diff changeset
34 ## 1, 12, 20 or 28. The returned matrix is normalized, meaning
2645f9ef8c88 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19697
diff changeset
35 ## @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
36 ##
1fe78adb91bc [project @ 2006-05-22 06:25:14 by jwe]
jwe
parents:
diff changeset
37 ## Some of the properties of Hadamard matrices are:
1fe78adb91bc [project @ 2006-05-22 06:25:14 by jwe]
jwe
parents:
diff changeset
38 ##
1fe78adb91bc [project @ 2006-05-22 06:25:14 by jwe]
jwe
parents:
diff changeset
39 ## @itemize @bullet
1fe78adb91bc [project @ 2006-05-22 06:25:14 by jwe]
jwe
parents:
diff changeset
40 ## @item
12639
4d777e05d47c doc: Review and update documentation for "Matrix Manipulation" chapter.
Rik <octave@nomad.inbox5.com>
parents: 11587
diff changeset
41 ## @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
42 ##
5827
1fe78adb91bc [project @ 2006-05-22 06:25:14 by jwe]
jwe
parents:
diff changeset
43 ## @item
12639
4d777e05d47c doc: Review and update documentation for "Matrix Manipulation" chapter.
Rik <octave@nomad.inbox5.com>
parents: 11587
diff changeset
44 ## @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
45 ##
4d777e05d47c doc: Review and update documentation for "Matrix Manipulation" chapter.
Rik <octave@nomad.inbox5.com>
parents: 11587
diff changeset
46 ## @item
4d777e05d47c doc: Review and update documentation for "Matrix Manipulation" chapter.
Rik <octave@nomad.inbox5.com>
parents: 11587
diff changeset
47 ## The rows of @nospell{Hn} are orthogonal.
10821
693e22af08ae Grammarcheck documentation of m-files
Rik <octave@nomad.inbox5.com>
parents: 10791
diff changeset
48 ##
5827
1fe78adb91bc [project @ 2006-05-22 06:25:14 by jwe]
jwe
parents:
diff changeset
49 ## @item
12639
4d777e05d47c doc: Review and update documentation for "Matrix Manipulation" chapter.
Rik <octave@nomad.inbox5.com>
parents: 11587
diff changeset
50 ## @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
51 ## @w{@code{abs (@var{A}(i, j)) <= 1}}.
10821
693e22af08ae Grammarcheck documentation of m-files
Rik <octave@nomad.inbox5.com>
parents: 10791
diff changeset
52 ##
5827
1fe78adb91bc [project @ 2006-05-22 06:25:14 by jwe]
jwe
parents:
diff changeset
53 ## @item
12639
4d777e05d47c doc: Review and update documentation for "Matrix Manipulation" chapter.
Rik <octave@nomad.inbox5.com>
parents: 11587
diff changeset
54 ## 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
55 ## matrix.
5827
1fe78adb91bc [project @ 2006-05-22 06:25:14 by jwe]
jwe
parents:
diff changeset
56 ## @end itemize
12639
4d777e05d47c doc: Review and update documentation for "Matrix Manipulation" chapter.
Rik <octave@nomad.inbox5.com>
parents: 11587
diff changeset
57 ## @seealso{compan, hankel, toeplitz}
5827
1fe78adb91bc [project @ 2006-05-22 06:25:14 by jwe]
jwe
parents:
diff changeset
58 ## @end deftypefn
1fe78adb91bc [project @ 2006-05-22 06:25:14 by jwe]
jwe
parents:
diff changeset
59
1fe78adb91bc [project @ 2006-05-22 06:25:14 by jwe]
jwe
parents:
diff changeset
60 ## 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
61 ## 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
62 ## this function for additional p.
1fe78adb91bc [project @ 2006-05-22 06:25:14 by jwe]
jwe
parents:
diff changeset
63 ##
27984
b09432b20a84 maint: Remove special cases of old version control keywords in code base.
Rik <rik@octave.org>
parents: 27923
diff changeset
64 ## Reference:
11587
c792872f8942 all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
65 ## [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
66 ## http://www.research.att.com/~njas/hadamard/
1fe78adb91bc [project @ 2006-05-22 06:25:14 by jwe]
jwe
parents:
diff changeset
67
1fe78adb91bc [project @ 2006-05-22 06:25:14 by jwe]
jwe
parents:
diff changeset
68 function h = hadamard (n)
11587
c792872f8942 all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
69
28891
de5f2f9a64ff maint: Use same coding style when checking for a minimum of 1 input.
Rik <rik@octave.org>
parents: 27984
diff changeset
70 if (nargin < 1)
5827
1fe78adb91bc [project @ 2006-05-22 06:25:14 by jwe]
jwe
parents:
diff changeset
71 print_usage ();
1fe78adb91bc [project @ 2006-05-22 06:25:14 by jwe]
jwe
parents:
diff changeset
72 endif
1fe78adb91bc [project @ 2006-05-22 06:25:14 by jwe]
jwe
parents:
diff changeset
73
8507
cadc73247d65 style fixes
John W. Eaton <jwe@octave.org>
parents: 7017
diff changeset
74 ## Find k if n = 2^k*p.
5827
1fe78adb91bc [project @ 2006-05-22 06:25:14 by jwe]
jwe
parents:
diff changeset
75 k = 0;
13893
5b1ddcf5ede1 hadamard.m: Embed hadamard28 matrix as constant rather than computed value.
Rik <octave@nomad.inbox5.com>
parents: 12639
diff changeset
76 while (n > 1 && fix (n/2) == n/2)
20735
418ae0cb752f Replace ++,-- with in-place operators for performance.
Rik <rik@octave.org>
parents: 20162
diff changeset
77 k += 1;
13893
5b1ddcf5ede1 hadamard.m: Embed hadamard28 matrix as constant rather than computed value.
Rik <octave@nomad.inbox5.com>
parents: 12639
diff changeset
78 n /= 2;
5827
1fe78adb91bc [project @ 2006-05-22 06:25:14 by jwe]
jwe
parents:
diff changeset
79 endwhile
11587
c792872f8942 all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
80
8507
cadc73247d65 style fixes
John W. Eaton <jwe@octave.org>
parents: 7017
diff changeset
81 ## Find base hadamard.
cadc73247d65 style fixes
John W. Eaton <jwe@octave.org>
parents: 7017
diff changeset
82 ## 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
83 if (n != 1)
11587
c792872f8942 all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
84 k -= 2;
5827
1fe78adb91bc [project @ 2006-05-22 06:25:14 by jwe]
jwe
parents:
diff changeset
85 endif
1fe78adb91bc [project @ 2006-05-22 06:25:14 by jwe]
jwe
parents:
diff changeset
86
8507
cadc73247d65 style fixes
John W. Eaton <jwe@octave.org>
parents: 7017
diff changeset
87 ## Trigger error if not a multiple of 4.
5827
1fe78adb91bc [project @ 2006-05-22 06:25:14 by jwe]
jwe
parents:
diff changeset
88 if (k < 0)
1fe78adb91bc [project @ 2006-05-22 06:25:14 by jwe]
jwe
parents:
diff changeset
89 n =- 1;
1fe78adb91bc [project @ 2006-05-22 06:25:14 by jwe]
jwe
parents:
diff changeset
90 endif
1fe78adb91bc [project @ 2006-05-22 06:25:14 by jwe]
jwe
parents:
diff changeset
91
1fe78adb91bc [project @ 2006-05-22 06:25:14 by jwe]
jwe
parents:
diff changeset
92 switch (n)
1fe78adb91bc [project @ 2006-05-22 06:25:14 by jwe]
jwe
parents:
diff changeset
93 case 1
1fe78adb91bc [project @ 2006-05-22 06:25:14 by jwe]
jwe
parents:
diff changeset
94 h = 1;
1fe78adb91bc [project @ 2006-05-22 06:25:14 by jwe]
jwe
parents:
diff changeset
95 case 3
1fe78adb91bc [project @ 2006-05-22 06:25:14 by jwe]
jwe
parents:
diff changeset
96 h = h12 ();
1fe78adb91bc [project @ 2006-05-22 06:25:14 by jwe]
jwe
parents:
diff changeset
97 case 5
1fe78adb91bc [project @ 2006-05-22 06:25:14 by jwe]
jwe
parents:
diff changeset
98 h = h20 ();
1fe78adb91bc [project @ 2006-05-22 06:25:14 by jwe]
jwe
parents:
diff changeset
99 case 7
13913
521adfd775be hadamard.m: Fix failing %!tests
Rik <octave@nomad.inbox5.com>
parents: 13893
diff changeset
100 h = h28 ();
5827
1fe78adb91bc [project @ 2006-05-22 06:25:14 by jwe]
jwe
parents:
diff changeset
101 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
102 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
103 endswitch
1fe78adb91bc [project @ 2006-05-22 06:25:14 by jwe]
jwe
parents:
diff changeset
104
8507
cadc73247d65 style fixes
John W. Eaton <jwe@octave.org>
parents: 7017
diff changeset
105 ## 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
106 h2 = [1,1;1,-1];
1fe78adb91bc [project @ 2006-05-22 06:25:14 by jwe]
jwe
parents:
diff changeset
107 while (true)
13893
5b1ddcf5ede1 hadamard.m: Embed hadamard28 matrix as constant rather than computed value.
Rik <octave@nomad.inbox5.com>
parents: 12639
diff changeset
108 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
109 h = kron (h2, h);
5827
1fe78adb91bc [project @ 2006-05-22 06:25:14 by jwe]
jwe
parents:
diff changeset
110 endif
13893
5b1ddcf5ede1 hadamard.m: Embed hadamard28 matrix as constant rather than computed value.
Rik <octave@nomad.inbox5.com>
parents: 12639
diff changeset
111 k = fix (k/2);
11587
c792872f8942 all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
112 if (k == 0)
c792872f8942 all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
113 break;
5827
1fe78adb91bc [project @ 2006-05-22 06:25:14 by jwe]
jwe
parents:
diff changeset
114 endif
1fe78adb91bc [project @ 2006-05-22 06:25:14 by jwe]
jwe
parents:
diff changeset
115 h2 = kron (h2, h2);
1fe78adb91bc [project @ 2006-05-22 06:25:14 by jwe]
jwe
parents:
diff changeset
116 endwhile
13893
5b1ddcf5ede1 hadamard.m: Embed hadamard28 matrix as constant rather than computed value.
Rik <octave@nomad.inbox5.com>
parents: 12639
diff changeset
117
5827
1fe78adb91bc [project @ 2006-05-22 06:25:14 by jwe]
jwe
parents:
diff changeset
118 endfunction
1fe78adb91bc [project @ 2006-05-22 06:25:14 by jwe]
jwe
parents:
diff changeset
119
1fe78adb91bc [project @ 2006-05-22 06:25:14 by jwe]
jwe
parents:
diff changeset
120 function h = h12 ()
8507
cadc73247d65 style fixes
John W. Eaton <jwe@octave.org>
parents: 7017
diff changeset
121 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
122 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
123 ## Note: assert (tu(2:end), tl(end:-1:2)).
5827
1fe78adb91bc [project @ 2006-05-22 06:25:14 by jwe]
jwe
parents:
diff changeset
124 h = ones (12);
1fe78adb91bc [project @ 2006-05-22 06:25:14 by jwe]
jwe
parents:
diff changeset
125 h(2:end,2:end) = toeplitz (tu, tl);
1fe78adb91bc [project @ 2006-05-22 06:25:14 by jwe]
jwe
parents:
diff changeset
126 endfunction
1fe78adb91bc [project @ 2006-05-22 06:25:14 by jwe]
jwe
parents:
diff changeset
127
1fe78adb91bc [project @ 2006-05-22 06:25:14 by jwe]
jwe
parents:
diff changeset
128 function h = h20 ()
8507
cadc73247d65 style fixes
John W. Eaton <jwe@octave.org>
parents: 7017
diff changeset
129 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
130 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
131 ## Note: assert (tu(2:end), tl(end:-1:2)).
5827
1fe78adb91bc [project @ 2006-05-22 06:25:14 by jwe]
jwe
parents:
diff changeset
132 h = ones (20);
1fe78adb91bc [project @ 2006-05-22 06:25:14 by jwe]
jwe
parents:
diff changeset
133 h(2:end,2:end) = fliplr (toeplitz (tu, tl));
1fe78adb91bc [project @ 2006-05-22 06:25:14 by jwe]
jwe
parents:
diff changeset
134 endfunction
1fe78adb91bc [project @ 2006-05-22 06:25:14 by jwe]
jwe
parents:
diff changeset
135
1fe78adb91bc [project @ 2006-05-22 06:25:14 by jwe]
jwe
parents:
diff changeset
136 function h = h28 ()
1fe78adb91bc [project @ 2006-05-22 06:25:14 by jwe]
jwe
parents:
diff changeset
137 ## Williamson matrix construction from
1fe78adb91bc [project @ 2006-05-22 06:25:14 by jwe]
jwe
parents:
diff changeset
138 ## 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
139 ## 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
140 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
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
5b1ddcf5ede1 hadamard.m: Embed hadamard28 matrix as constant rather than computed value.
Rik <octave@nomad.inbox5.com>
parents: 12639
diff changeset
161 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
162 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
163 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
164 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
165 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
166 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
167 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
168 endfunction
1fe78adb91bc [project @ 2006-05-22 06:25:14 by jwe]
jwe
parents:
diff changeset
169
13893
5b1ddcf5ede1 hadamard.m: Embed hadamard28 matrix as constant rather than computed value.
Rik <octave@nomad.inbox5.com>
parents: 12639
diff changeset
170
5b1ddcf5ede1 hadamard.m: Embed hadamard28 matrix as constant rather than computed value.
Rik <octave@nomad.inbox5.com>
parents: 12639
diff changeset
171 %!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
172 %!assert (hadamard (2), [1,1;1,-1])
5827
1fe78adb91bc [project @ 2006-05-22 06:25:14 by jwe]
jwe
parents:
diff changeset
173 %!test
13893
5b1ddcf5ede1 hadamard.m: Embed hadamard28 matrix as constant rather than computed value.
Rik <octave@nomad.inbox5.com>
parents: 12639
diff changeset
174 %! for n = [1,2,4,8,12,24,48,20,28,2^9]
14363
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
175 %! h = hadamard (n);
13913
521adfd775be hadamard.m: Fix failing %!tests
Rik <octave@nomad.inbox5.com>
parents: 13893
diff changeset
176 %! 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
177 %! endfor
5b1ddcf5ede1 hadamard.m: Embed hadamard28 matrix as constant rather than computed value.
Rik <octave@nomad.inbox5.com>
parents: 12639
diff changeset
178
28896
90fea9cc9caa test: Add expected error message <Invalid call> to BIST tests for nargin.
Rik <rik@octave.org>
parents: 28891
diff changeset
179 %!error <Invalid call> hadamard ()
13893
5b1ddcf5ede1 hadamard.m: Embed hadamard28 matrix as constant rather than computed value.
Rik <octave@nomad.inbox5.com>
parents: 12639
diff changeset
180 %!error hadamard (1,2)
13913
521adfd775be hadamard.m: Fix failing %!tests
Rik <octave@nomad.inbox5.com>
parents: 13893
diff changeset
181 %!error <N must be 2\^k\*p> hadamard (5)