scaleRow method

void scaleRow(
  1. int rowIndex,
  2. dynamic scaleFactor
)

Scales the elements of the specified row by a given factor.

This function multiplies all the elements in the row with the specified rowIndex by the given scaleFactor.

Example:

Matrix A = Matrix.fromList([
  [1, 2, 3],
  [4, 5, 6],
  [7, 8, 9]
]);
A.scaleRow(1, 2);
print(A);

Output:

1 2 3
8 10 12
7 8 9

Validation: Throws RangeError if rowIndex is not a valid row index in the matrix.

Implementation

void scaleRow(int rowIndex, dynamic scaleFactor) {
  RangeError.checkValidIndex(rowIndex, this, "rowIndex", rowCount);

  for (int j = 0; j < columnCount; j++) {
    this[rowIndex][j] *=
        (scaleFactor is num) ? Complex(scaleFactor) : scaleFactor;
  }
}