-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.java
More file actions
130 lines (103 loc) · 4.22 KB
/
Copy pathMain.java
File metadata and controls
130 lines (103 loc) · 4.22 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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
import java.util.Arrays;
public class Main
{
public static void main(String[] args)
{
String operation = "";
if( args.length >= 1 )
{
operation = args[0];
}
switch( operation )
{
case "-Add" :
if( args[1].compareTo("-V") == 0 )
{
Vector u = new Vector(args[2]);
Vector v = new Vector(args[3]);
Vector sum = Operation.add(u,v);
sum.print();
}
else if(args[1].compareTo("-M") == 0 )
{
Matrix a = new Matrix(args[2]);
Matrix b = new Matrix(args[3]);
Matrix sum = Operation.add(a,b);
sum.print();
}
break;
case "-SM" :
Double c = Double.parseDouble(args[2]);
if( args[1].compareTo("-V") == 0 )
{
Vector u = new Vector(args[3]);
Vector product = Operation.scalarMultiplication(c,u);
product.print();
}
else if(args[1].compareTo("-M") == 0 )
{
Matrix a = new Matrix(args[3]);
Matrix product = Operation.scalarMultiplication(c,a);
product.print();
}
break;
case "-DP" :
if( args[1].compareTo("-V") == 0 )
{
Vector u = new Vector(args[2]);
Vector v = new Vector(args[3]);
Double dotProduct = Operation.dotProduct(u,v);
System.out.println(dotProduct);
}
else if(args[1].compareTo("-M") == 0 )
{
Matrix a = new Matrix( args[ 2 ] );
Matrix b = new Matrix( args[ 3 ] );
Double dotProduct = Operation.dotProduct(a,b);
System.out.println(dotProduct);
}
break;
case "-CP" :
break;
case "-Det" :
Matrix a = new Matrix( args[ 1 ] );
System.out.println(Operation.determinant(a));
break;
case "-Tran":
a = new Matrix( args[ 1 ] );
Matrix transpose = Operation.transpose(a);
transpose.print();
break;
case "-Inv":
break;
case "-Diag":
break;
case "-Eval":
break;
case "EVect":
break;
case "-h" :
printHelp();
break;
default :
System.out.println("Use the -h option for usage");
break;
}
}
public static void printHelp()
{
System.out.println("Basic syntax java Main -[operation] -[option] [operand1] [operand2] ");
System.out.println("Operation Description options " );
System.out.println("-Add Performs addition on two operands -V(vector operands) ");
System.out.println(" -M(Matrix operands) ");
System.out.println("-SM Performs scalar multiplication on operand -V ");
System.out.println(" -M ");
System.out.println("-DP Performs the dot product on two operands -V ");
System.out.println(" -M ");
System.out.println("-Det Takes the determinant of a matrix ");
System.out.println("-Tran Takes displays the transpose of a matrix ");
System.out.println("Example Usage ");
System.out.println("java Main -Add -V 2,4,5 6,4,3 ");
System.out.println("java Main -Add -M 2,4,5:6,4,3 3,4,5:6,7,8 ");
}
}