Main Content

gfrank

R2026b

Compute rank of matrix over Galois field

Description

rk = gfrank(A,) calculates the rank of matrix A for GF(2).

example

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

example

Examples

collapse all

Define a 3-by-3 matrix A.

A = [1 0 1;
    2 1 0;
    0 1 1];

Define the prime number or the GF(p).

p = 3;

Compute the ordinary determinant of matrix A.

det_a = det(A);  

Take the determinant modulo p or determinant in GF(3).

detmodp = rem(det(A),p);

Compute the rank of matrix A over GF(3) using modulo arithmetic.

rankp = gfrank(A,p);

Display the results.

disp(['Determinant = ',num2str(det_a)])
Determinant = 3
disp(['Determinant mod p is ',num2str(detmodp)])
Determinant mod p is 0
disp(['Rank over GF(p) is ',num2str(rankp)])
Rank over GF(p) is 2

Input Arguments

collapse all

Input matrix, specified as a matrix of integers.

Data Types: double

Prime number, specified as a scalar. Each entry in a and b represents an element of GF(p). The entries of a and b are integers in the range [0, (p – 1)].

Data Types: double

Output Arguments

collapse all

Rank of the matrix A, returned as a positive integer.

Data Types: double

Tips

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

Algorithms

gfrank uses an algorithm similar to Gaussian elimination.

Version History

Introduced before R2006a