rowSpace method

Matrix rowSpace()

Returns the row space of the matrix.

The row space is the linear space formed by the linearly independent rows of the matrix.

Example:

Matrix A = Matrix.fromList([
  [1, 2, 3],
  [0, 1, 1],
  [0, 0, 0]
]);
print(A.rowSpace());
// Output:
// 1  2  3
// 0  1  1

Implementation

Matrix rowSpace() {
  Matrix rref = reducedRowEchelonForm();
  List<List<dynamic>> rowSpace = [];

  for (int i = 0; i < rref.rowCount; i++) {
    bool isZeroRow = true;

    for (int j = 0; j < rref.columnCount; j++) {
      if (rref[i][j] != 0) {
        isZeroRow = false;
        break;
      }
    }

    if (!isZeroRow) {
      rowSpace.add(this[i]);
    }
  }

  return Matrix.fromList(rowSpace);
}