forked from JavaTX/JavaCompilerCore
42 lines
1.1 KiB
Java
42 lines
1.1 KiB
Java
import java.util.Vector;
|
|
|
|
class Matrix extends Vector<Vector<Integer>> {
|
|
|
|
Matrix mul_rec(Matrix m) {
|
|
auto v1 = new Vector<Integer>();
|
|
auto v2 = new Vector<Integer>();
|
|
auto i = 0;
|
|
while(i < m.size()) {
|
|
auto v;
|
|
v = m.elementAt(i);
|
|
v2.addElement(v.remove(v.size()-1));
|
|
i++;
|
|
}
|
|
Matrix ret;
|
|
if (m.elementAt(0).size() > 0) {
|
|
ret = this.mul_rec(m);
|
|
}
|
|
else {
|
|
ret = new Matrix();
|
|
i = 0;
|
|
while (i < this.size()) {
|
|
ret.addElement(new Vector<Integer>());
|
|
i++;
|
|
}
|
|
}
|
|
i = 0;
|
|
while (i < this.size()) {
|
|
int erg = 0;
|
|
auto j;
|
|
j = 0;
|
|
while (j < v2.size()) {
|
|
erg = erg + this.elementAt(i).elementAt(j).intValue()
|
|
* v2.elementAt(j).intValue();
|
|
j++;
|
|
}
|
|
ret.elementAt(i).addElement(erg);
|
|
i++;
|
|
}
|
|
return ret;
|
|
}
|
|
} |