JavaCompilerCore/test/javFiles/Matrix.jav
2017-05-19 17:40:47 +02:00

43 lines
1.1 KiB
Java

class Matrix extends Menge<Menge<Integer>> {
Matrix mul_rec(Matrix m) {
v1;
v1 = new Menge<Integer>();
v2;
v2 = new Menge<Integer>();
i;
i = 0;
while(i < m.size()) {
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 Menge<Integer>());
i++;
}
}
i = 0;
while (i < this.size()) {
int erg = 0;
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;
}
}