Loading the problem
Reduce a matrix to row echelon form by Gaussian elimination.
A matrix is in row echelon form when every all-zero row sits at the bottom, and the leading non-zero entry of each row (its pivot) is strictly to the right of the pivot in the row above.
Use this convention so the answer is unique:
1e-12), move to the
next column without advancing the pivot row.1.Do not modify the caller's array.
def row_echelon_form(A):
Input
row_echelon_form(np.array([[1.0, 2.0], [2.0, 4.0]]))
Output
array([[1., 2.],
[0., 0.]])
Reasoning
Partial pivoting picks 2 as the first pivot, so the rows swap and the pivot row becomes [1, 2]. Subtracting it from [1, 2] leaves a zero row. The second column has no pivot left.
1.Check runs the visible cases against a fresh kernel. Submit runs the hidden ones too.
⇧↵run cell