public Matrix<T, A> multiply(Matrix<T, A> right) throws MatrixException {
Matrix<T, A> temp = new Matrix<T, A>(arithmetics, rowSize, columnSize);
if (rowSize != right.columnSize)
throw new MatrixException(
"Cannot multiply matrices of different sizes");
for (int i = 0; i < rowSize; i++) {
for (int j = 0; j < right.columnSize ; j++)
for(int k = 0; k < right.rowSize ; k++)
temp.matrix[i][j] = arithmetics.add(temp.matrix[i][j],
(arithmetics.multiply(matrix[i][k], right.matrix[k][j])));
return temp;
}}
好吧,所以我正在尝试将 2 个矩阵相乘,但是
Matrix1
0 0 1
1 1 1
Matrix5
1 2
2 4
3 6
我得到一个答案
Matrix1 multiply Matrix5
3 6 0
6 12 0
但应该是
3 6
6 12
因为它矩阵乘法