Main Content


Check whether polynomial over Galois field is primitive


ck = gfprimck(a)
ck = gfprimck(a,p)



This function performs computations in GF(pm), where p is prime. If you are working in GF(2m), use the isprimitive function. For details, see Finding Primitive Polynomials in Primitive Polynomials and Element Representations.

ck = gfprimck(a) checks whether the degree-m GF(2) polynomial a is a primitive polynomial for GF(2m), where m = length(a) - 1. The output ck is as follows:

  • -1 if a is not an irreducible polynomial

  • 0 if a is irreducible but not a primitive polynomial for GF(pm)

  • 1 if a is a primitive polynomial for GF(pm)

ck = gfprimck(a,p) checks whether the degree-m GF(P) polynomial a is a primitive polynomial for GF(pm). p is a prime number.

a is either a polynomial character vector or a row vector representing the polynomial by listing its coefficients in ascending order. For example, in GF(5), '4 + 3x + 2x^3' and [4 3 0 2] are equivalent.

This function considers the zero polynomial to be “not irreducible” and considers all polynomials of degree zero or one to be primitive.


Characterization of Polynomials contains examples.


An irreducible polynomial over GF(p) of degree at least 2 is primitive if and only if it does not divide -1 + xk for any positive integer k smaller than pm-1.


[1] Clark, George C. Jr., and J. Bibb Cain, Error-Correction Coding for Digital Communications, New York, Plenum, 1981.

[2] Krogsgaard, K., and T., Karp, Fast Identification of Primitive Polynomials over Galois Fields: Results from a Course Project, ICASSP 2005, Philadelphia, PA, 2004.

Version History

Introduced before R2006a