insertRow method

Matrix insertRow(
  1. int rowIndex,
  2. List newValues
)

Inserts a new row at the specified position in the matrix with the values provided in new Values.

rowIndex: The row index to insert into the matrix newValues: The new values

Return a new matrix with the inserted row in the matrix

Example:

var matrix = Matrix.fromList([[1, 2], [3, 4]]);
matrix.insertRow(1, [5, 6]);
print(matrix);
// Output:
// Matrix: 3x2
// ┌ 1 2 ┐
// | 5 6 |
// └ 3 4 ┘

Implementation

Matrix insertRow(int rowIndex, List<dynamic> newValues) {
  var newData = _data;
  newData.insert(rowIndex, newValues);
  return Matrix(newData);
}