Hallo zusammen,
1 Matrix (m) ist bereits im Code vorhanden, und ist funktionsfähig.
Ich möchte die Matrix "m" mit der neuen Matrix "other" multiplizieren.
Leider bekomme ich keinen Output im Tester File.
Ist dieser Code richtig?
Wenn ja, wird die Methode im TesterFile richtig aufgerufen?
ich habe versucht, die Methode wie unten angegeben, aufzurufen.
Ich bekomme keine Ausgabe. Hat jemand einen Tipp?
VG
Natalia
1 Matrix (m) ist bereits im Code vorhanden, und ist funktionsfähig.
Ich möchte die Matrix "m" mit der neuen Matrix "other" multiplizieren.
Leider bekomme ich keinen Output im Tester File.
Ist dieser Code richtig?
Wenn ja, wird die Methode im TesterFile richtig aufgerufen?
Java:
public double[][] multiply (double[][] other) {
double C[][];
int mRows = m.length;
int mCols = m[0].length;
int otherRows = other.length;
int otherCols = other[0].length;
C = new double[mRows][otherCols];
for (int i = 0; i < mRows; i++) {
for (int j = 0; j < otherCols; i++) {
C[i][j] = 0.0;
}
}
for (int i = 0; i < mRows; i++) {
for (int j = 0; j < otherCols; j++) {
for (int k = 0; k < mCols; k++) {
C[i][j] = C[i][j] + m[i][k] * other[k][j];
}
}
}
return C;
}
ich habe versucht, die Methode wie unten angegeben, aufzurufen.
Ich bekomme keine Ausgabe. Hat jemand einen Tipp?
Java:
double other[][] = {
{1, 2, 3},
{5, 6, 7},
{9, 10, 11} };
double[][] C = m.multiply(other);
Arrays.deepToString(C);
VG
Natalia