How to generate a set of N mutually orthogonal (N being a power of 2) N-dimensional binary vectors [+1,-1]?
10 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
For instance:
with N=2 we could have [1 1; 1 -1]
with N=4, we could have [1 1 1 1; 1 1 -1 -1; 1 -1 1 -1; 1 -1 -1 1]
How to efficiently generate N mutually orthogonal binary vectors for larger N (8,16,32,64,...,4096,...)?
0 commentaires
Réponse acceptée
Matt J
le 8 Mar 2021
Modifié(e) : Matt J
le 8 Mar 2021
N=4096;
[C,C0]=deal([1 1;1 -1]);
tic;
for i=1:log2(N/2)
C=kron(C0,C);
end
toc
isOrthogonal=isequal(C*C.', N*speye(N))
C
3 commentaires
Matt J
le 30 Avr 2023
This line was used above to verify mutual orthogonality:
isOrthogonal=isequal(C*C.', N*speye(N))
Plus de réponses (2)
Steven Lord
le 8 Mar 2021
See the hadamard function.
1 commentaire
Matt J
le 8 Mar 2021
For some reason, I find this a fair bit slower than the kron-based solution
N=4096;
tic;
[C,C0]=deal([1 1;1 -1]);
for i=1:log2(N/2)
C=kron(C0,C);
end
toc
tic; hadamard(N); toc
Voir également
Catégories
En savoir plus sur Logical dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!