-
galois.FieldArray.row_reduce(ncols: int | None =
None
, eye: 'left' | 'right' ='left'
) Self Performs Gaussian elimination on the matrix to achieve reduced row echelon form (RREF).
Notes¶
The elementary row operations in Gaussian elimination are:
Swap the position of any two rows.
Multiply any row by a non-zero scalar.
Add any row to a scalar multiple of another row.
Examples¶
Perform Gaussian elimination to get the reduced row echelon form of \(\mathbf{A}\).
In [1]: GF = galois.GF(31) In [2]: A = GF([[16, 12, 1, 25], [1, 10, 27, 29], [1, 0, 3, 19]]); A Out[2]: GF([[16, 12, 1, 25], [ 1, 10, 27, 29], [ 1, 0, 3, 19]], order=31) In [3]: A.row_reduce() Out[3]: GF([[ 1, 0, 0, 11], [ 0, 1, 0, 7], [ 0, 0, 1, 13]], order=31) In [4]: np.linalg.matrix_rank(A) Out[4]: np.int64(3)
Perform Gaussian elimination to get an \(\mathbf{I}\) on the right side of \(\mathbf{A}\).
In [5]: A.row_reduce(eye="right") Out[5]: GF([[ 5, 1, 0, 0], [27, 0, 1, 0], [17, 0, 0, 1]], order=31)
Or only perform Gaussian elimination over 2 columns.
In [6]: A.row_reduce(ncols=2) Out[6]: GF([[ 1, 0, 5, 14], [ 0, 1, 27, 17], [ 0, 0, 29, 5]], order=31)