galois.FieldArray.row_reduce(ncols: int | None = None) FieldArray

Performs Gaussian elimination on the matrix to achieve reduced row echelon form (RREF).

Parameters
ncols: int | None = None

The number of columns to perform Gaussian elimination over. The default is None which represents the number of columns of the matrix.

Returns

The reduced row echelon form of the input matrix.

Notes

The elementary row operations in Gaussian elimination are:

  1. Swap the position of any two rows.

  2. Multiply any row by a non-zero scalar.

  3. 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]: 3

Or only perform Gaussian elimination over 2 columns.

In [5]: A.row_reduce(ncols=2)
Out[5]: 
GF([[ 1,  0,  5, 14],
    [ 0,  1, 27, 17],
    [ 0,  0, 29,  5]], order=31)

Last update: Jul 28, 2022