matrixInsert function

Matrix matrixInsert(
  1. Matrix src,
  2. Matrix dest,
  3. int startRow,
  4. int startColumn,
)

Implementation

Matrix matrixInsert(Matrix src, Matrix dest, int startRow, int startColumn) {
  assert(!startRow.isNegative && !startColumn.isNegative,
      'Indexes cannot be less than 0');
  assert(
      dest.rowsNum - startRow >= src.rowsNum &&
          dest.columnsNum - startColumn >= src.columnsNum,
      'dest Matrix needs to fit into src Matrix at the given row and column');
  List<List<double>> tmp = fromIterable(dest.toList());

  for (int i = 0; i < src.rowsNum; i++) {
    for (int j = 0; j < src.columnsNum; j++) {
      tmp[startRow + i][startColumn + j] = src[i][j];
    }
  }

  return Matrix.fromList(tmp);
}