isPrimitive(f) -- Given an element f in a quotient of a polynomial ring R over a finite field Kwhich is itself a finite field, with the ring being finite dimensional over the field, determine if f generates the multiplicative group of this field.
i1 : R = ZZ/5[t]/(t^2+t+1); |
i2 : isPrimitive t |
i3 : isPrimitive (t-1) |
Code:
-- ../../../Macaulay2/m2/galois.m2:47-53 isPrimitive = (g) -> ( g != 0 and unpack(ring g, (R,p,n,f) -> ( q := p^n; all(factor (q-1), v -> 1 != g ^ ((q-1)//v#0)) )))