Skip to content
DeepForgeby svx
All problems
HardLinear Algebrala-045

Reduced Row Echelon Form

Problem

Transform matrix A into reduced row echelon form (RREF) using Gauss-Jordan elimination.

Each pivot is normalized to 1 and is the only nonzero entry in its column. Treat entries smaller than 1e-12 as zero. Return the result as a matrix of floats.

Hint

Normalize the pivot row, then clear the pivot column in every other row.

Test cases

case 1
in: [[[1,2],[3,4]]]
expected: [[1,0],[0,1]]
case 2
in: [[[1,2],[2,4]]]
expected: [[1,2],[0,0]]
case 3
in: [[[1,2,3],[4,5,6],[7,8,9]]]
expected: [[1,0,-1],[0,1,2],[0,0,0]]
case 4
in: [[[0,0],[0,0]]]
expected: [[0,0],[0,0]]
Starter codePython
def rref(A):
    # Your code here
    pass

4 test cases · run your code against them in the editor