forked from Harvard-Westlake/SourceCodeTest
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMatrixExampleTester.java
More file actions
54 lines (48 loc) · 1.73 KB
/
MatrixExampleTester.java
File metadata and controls
54 lines (48 loc) · 1.73 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
public class MatrixExampleTester {
public static void main(String[] args) {
MatrixExample m = new MatrixExample();
int[][] matrix = {
{ 1, 2, 3, 4, 5, 6 },
{ 4, 5, 6, 3, 7, 2 },
{ 27, 8, 9, 5, 3, 21 },
{ 73, 2, 19, 5, 1, 8 },
{ 47, 9, 9, 5, 0, 22 },
{ 78, 86, 1, 4, 1, 21 },
{ 73, 18, 2, 2, 5, 11 }
};
// int[][] matrix2 = {
// { 1, 2, 3, 4, 5, 6 },
// { 4, 5, 6, 3, 7, 2 },
// { 27, 7, 9, 5, 3, 21 },
// { 73, 2, 19, 5, 1, 8 },
// { 47, 9, 9, 5, 0, 22 },
// { 78, 86, 1, 4, 1, 21 },
// };
// int[][] matrix3 = {
// { 1, 2, 3, 4, 5, 6 },
// { 4, 5, 6, 3, 7, 2 },
// { 73, 2, 19, 5, 1, 8 },
// { 47, 9, 9, 5, 0, 22 },
// { 78, 86, 1, 4, 1, 21 },
// };
// int[][] matrix4 = {
// { 1, 2, 3, 4, 5,},
// { 4, 5, 6, 3, 7,},
// { 27, 7, 9, 5, 3},
// { 73, 2, 19, 5, 1},
// { 47, 9, 9, 5, 0},
// { 78, 86, 1, 4, 1},
// };
int numRows = 7;
int numCols = 6;
int[][] matrix2 = m.generateRandomMatrix(numCols, 20);
int[][] result = m.multiplyMatrices(matrix, matrix2);
System.out.println("result length: " + result.length + " x " + result[0].length);
for (int i = 0; i < result.length; i++) {
for (int j = 0; j < result[i].length; j++) {
System.out.print(result[i][j] + " ");
}
System.out.println();
}
}
}