求大神指点!!!怎么用算法求矩阵的reduced echelon form(行阶梯矩阵形式)?

以下是一个没有完善的提示 (Ri代表矩阵的第i行)

INPUT matrix A

OUTPUT reduced echelon form of matrix A

SET m TO number of rows of A

SET n TO number of columns of A

SET p TO 1

SET q TO 1

WHILE p ≤ m AND q ≤ n

Find the smallest j ≥ q with Ak,j = 0 for some k ≥ p

IF k = p

Replace Rp by Rp/Ak,j

ELSE

Replace Rp by Rp + Rk/Ak,j

IF there are other rows with non-zero entries in the j th column

Replace Ri by Ri - Ai,j*Rp

SET p TO p + 1

SET q TO j + 1

RETURN A