np.linalg.matrix_rank

np.linalg.matrix_rank(x)

Returns the rank of a Galois field matrix.

References

Examples

In [1]: GF = galois.GF(31)

In [2]: A = GF.Identity(4); A
Out[2]: 
GF([[1, 0, 0, 0],
    [0, 1, 0, 0],
    [0, 0, 1, 0],
    [0, 0, 0, 1]], order=31)

In [3]: np.linalg.matrix_rank(A)
Out[3]: 4

One column is a linear combination of another.

In [4]: GF = galois.GF(31)

In [5]: A = GF.Random((4,4)); A
Out[5]: 
GF([[ 3,  2,  5, 15],
    [ 0, 13, 13,  8],
    [20,  3, 29,  8],
    [19,  2,  8, 10]], order=31)

In [6]: A[:,2] = A[:,1] * GF(17); A
Out[6]: 
GF([[ 3,  2,  3, 15],
    [ 0, 13,  4,  8],
    [20,  3, 20,  8],
    [19,  2,  3, 10]], order=31)

In [7]: np.linalg.matrix_rank(A)
Out[7]: 3

One row is a linear combination of another.

In [8]: GF = galois.GF(31)

In [9]: A = GF.Random((4,4)); A
Out[9]: 
GF([[16, 24, 25,  8],
    [28,  1,  6,  3],
    [ 1,  9, 27,  8],
    [12, 11,  8,  7]], order=31)

In [10]: A[3,:] = A[2,:] * GF(8); A
Out[10]: 
GF([[16, 24, 25,  8],
    [28,  1,  6,  3],
    [ 1,  9, 27,  8],
    [ 8, 10, 30,  2]], order=31)

In [11]: np.linalg.matrix_rank(A)
Out[11]: 3