private void equal_AxB() {
int x = matrix_A.length;
int y = matrix_B[0].length;
matrix_C = new double[x][y];
for(int i = 0; i < x; i++) {
for(int j = 0; j < y; j++) {
for(int k = 0; k < y; k++){
matrix_C[i][j] += matrix_A[i][k]*matrix_B[k][j];
}
}
}
return;
}
matrix_A:
2 3
2 3
2 3
matrix_B:
2 3 4
2 4 3
Two problems I could see:
columns of
Ais equal to number ofrows of
B. If this does not hold you cannot multiply the matrices.kloop should vary from0toNwhereNis number of columns of matrixA, currently you are varying it till number of columns of matrixB.