multiplyMatrices method

List<int> multiplyMatrices(
  1. List<int> firstMatrix,
  2. List secondMatrix,
  3. int c1,
  4. int c2,
)

Implementation

List<int> multiplyMatrices(
    List<int> firstMatrix, List<dynamic> secondMatrix, int c1, int c2) {
  var product = List<int>.generate(c2, (index) => 0, growable: false);

  int sums = 0;
  for (int i = 0; i < c2; i++) {
    for (int j = 0; j < c1; j++) {
      sums = (sums + (secondMatrix[j][i] * firstMatrix[j])).toInt();
    }

    product[i] = sums;
    sums = 0;
  }

  return product;
}