Communications Toolbox | ![]() ![]() |
Compute the rank of a matrix over a Galois field
Syntax
rk = gfrank(A); rk = gfrank(A,p);
Description
rk = gfrank(A)
calculates the rank of the matrix A
in GF(2).
rk = gfrank(A,p)
calculates the rank of the matrix A
in GF(p
), where p
is a prime number.
Algorithm
gfrank
uses an algorithm similar to Gaussian elimination.
Examples
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 2.
A=[1 0 1; 1 1 0; 0 1 1]; det_a = det(A); % Ordinary determinant of A detmod2 = rem(det(A),2); % Determinant mod 2 rank2 = gfrank(A); disp(['determinant = ',num2str(det_a)]) disp(['determinant mod 2 is ',num2str(detmod2)]) disp(['rank over GF(2) is ',num2str(rank2)])
determinant = 2 determinant mod 2 is 0 rank over GF(2) is 2
Notice that gflineq
finds only the trivial solution to the equation A
x = 0, even though the output above implies that there are infinitely many other solutions.
sol = gflineq(A,[0;0;0])' sol = 0 0 0
See Also
gflineq
![]() | gfprimfd | gfrepcov | ![]() |