BAEL3236 Fixing test cases and updating the missed version in pom.xml

This commit is contained in:
Chirag Dewan
2019-10-26 18:46:18 +05:30
parent db85c8f275
commit f52e3c9e60
20349 changed files with 1637694 additions and 0 deletions
@@ -0,0 +1,23 @@
package com.baeldung.matrices;
public class HomemadeMatrix {
public static double[][] multiplyMatrices(double[][] firstMatrix, double[][] secondMatrix) {
double[][] result = new double[firstMatrix.length][secondMatrix[0].length];
for (int row = 0; row < result.length; row++) {
for (int col = 0; col < result[row].length; col++) {
result[row][col] = multiplyMatricesCell(firstMatrix, secondMatrix, row, col);
}
}
return result;
}
private static double multiplyMatricesCell(double[][] firstMatrix, double[][] secondMatrix, int row, int col) {
double cell = 0;
for (int i = 0; i < secondMatrix.length; i++) {
cell += firstMatrix[row][i] * secondMatrix[i][col];
}
return cell;
}
}