Created
October 23, 2012 06:40
-
-
Save yao2030/3937264 to your computer and use it in GitHub Desktop.
Hadamard matrix
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Hadamard | |
{ | |
public static void main(String[] args) | |
{ | |
int N = Integer.parseInt(args[0]); | |
boolean[][] H = new boolean[N][N]; | |
H[0][0] = true; | |
for(int n = 1; n < N; n += n) | |
{ | |
for(int i = 0; i < n; i++) | |
for(int j = 0; j < n; j++) | |
{ | |
H[i+n][j] = H[i][j]; | |
H[i][j+n] = H[i][j]; | |
H[i+n][j+n] = !H[i][j]; | |
} | |
} | |
for(int i = 0; i < N; i++) | |
{ | |
for(int j = 0; j < N; j++) | |
{ | |
if(H[i][j]) System.out.print("* "); | |
else System.out.print(". "); | |
} | |
System.out.println(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment