-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathTest.java
49 lines (46 loc) · 1.39 KB
/
Test.java
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
/*
* Filiz Eryilmaz - 215220908
* June Yu - 214300479
*/
public class Test{
public static void main(String[] args)throws Exception
{
int testPart = Integer.parseInt(args[0]);
Assignment1 a1 = new Assignment1();
int n = 8;
int[][] matrix;
if(testPart==1){
matrix=a1.initMatrix(n);
a1.printMatrix(n, matrix);
}
else if(testPart==2){
matrix=a1.readMatrix("matrix1.txt",n);
a1.printMatrix(n,matrix);
}
else if(testPart==3){
int nextPart = Integer.parseInt(args[1]);
if(nextPart==1){
int[][] matrix1=a1.readMatrix("matrix1.txt",n);
int[][] matrix2=a1.readMatrix("matrix2.txt",n);
int[][] sumMatrix = a1.sum(matrix1, matrix2, 1, 1, 0, 1, 3);
a1.printMatrix(n,matrix1);
a1.printMatrix(n,matrix2);
a1.printMatrix(3,sumMatrix);
}
else{
int[][] matrix1=a1.readMatrix("matrix1.txt",n);
int[][] matrix2=a1.readMatrix("matrix2.txt",n);
int[][] sumMatrix = a1.sub(matrix1, matrix2, 1, 1, 0, 1, 3);
a1.printMatrix(n,matrix1);
a1.printMatrix(n,matrix2);
a1.printMatrix(3,sumMatrix);
}
}
else{
int[][] matrix1=a1.readMatrix("matrix1.txt",n);
int[][] matrix2=a1.readMatrix("matrix2.txt",n);
int[][] resultingMatrix=a1.denseMatrixMult(matrix1, matrix2, n);
a1.printMatrix(n,resultingMatrix);
}
}
}