operator * method

Matrix operator *(
  1. Matrix other
)

Implementation

Matrix operator *(Matrix other) {
  assert(this.ncols == other.nrows,
      "LHS matrix ncols do not match RHS matrix nrows");

  final List<Vector> rowsResult = <Vector>[];
  for (int i = 0; i < nrows; i++) {
    final List<double> row = List.filled(other.ncols, 0.0);
    for (int j = 0; j < other.ncols; j++) {
      for (int k = 0; k < ncols; k++) {
        row[j] += this[i][k] * other[k][j];
      }
    }
    rowsResult.add(Vector.fromList(row));
  }

  return Matrix.fromRows(rowsResult);
}