This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.


Compute rank of matrix over Galois field


rk = gfrank(A,p)



This function performs computations in GF(p) where p is prime. If you are working in GF(2m), use the rank function with Galois arrays. For details, see Computing Ranks.

rk = gfrank(A,p) calculates the rank of the matrix A in GF(p), where p is a prime number.


In the code below, gfrank says that the matrix A has less than full rank. This conclusion makes sense because the determinant of A is zero mod p.

A = [1 0 1;
   2 1 0;
   0 1 1];
p = 3;
det_a = det(A); % Ordinary determinant of A
detmodp = rem(det(A),p); % Determinant mod p
rankp = gfrank(A,p);
disp(['Determinant = ',num2str(det_a)])
disp(['Determinant mod p is ',num2str(detmodp)])
disp(['Rank over GF(p) is ',num2str(rankp)])

The output is below.

Determinant = 3
Determinant mod p is 0
Rank over GF(p) is 2


gfrank uses an algorithm similar to Gaussian elimination.

Introduced before R2006a