copyInto method

Matrix<T> copyInto(
  1. Matrix<T> target
)

Returns the target matrix with all elements of this matrix copied into it.

Implementation

Matrix<T> copyInto(Matrix<T> target) {
  assert(
      rowCount == target.rowCount,
      'Row count of this matrix ($rowCount) and the target matrix '
      '(${target.rowCount}) must match.');
  assert(
      colCount == target.colCount,
      'Column count of this matrix ($colCount) and the target matrix '
      '(${target.colCount}) must match.');
  if (this != target) {
    for (var r = 0; r < rowCount; r++) {
      for (var c = 0; c < colCount; c++) {
        target.setUnchecked(r, c, getUnchecked(r, c));
      }
    }
  }
  return target;
}