fq_default – finite fields

class flint.fq_default(val, ctx)
frobenius(self, e=1)

Evaluates the homomorphism \(\Sigma^e\) on self.

>>> gf = fq_default_ctx(163, 3)
>>> a = gf([1,2,3])
>>> a.frobenius()
155*z^2 + 9*z + 4
>>> a.frobenius(2)
5*z^2 + 152*z + 119
>>> a == a.frobenius(3)
True
>>> a.frobenius(2) == a.frobenius(-1)
True
inverse(self)

Computes the inverse of self

>>> gf = fq_default_ctx(163, 3)
>>> a = gf([1,2,3])
>>> b = a.inverse()
>>> b
68*z^2 + 17*z + 116
>>> a*b == gf.one()
True
is_one(self)

Returns true is self is one and false otherwise

>>> gf = fq_default_ctx(163, 3)
>>> gf(-1).is_one()
False
>>> gf(1).is_one()
True
is_square(self)

Returns if the element is a square in the field

>>> gf = fq_default_ctx(163, 3)
>>> a = gf([1,2,3])
>>> a.is_square()
False
>>> (a*a).is_square()
True
is_zero(self)

Returns true is self is zero and false otherwise

>>> gf = fq_default_ctx(163, 3)
>>> gf(0).is_zero()
True
>>> gf(-1).is_zero()
False
norm(self)

Returns the norm of self

>>> gf = fq_default_ctx(163, 3)
>>> a = gf([1,2,3])
>>> a.norm()
116
polynomial(self)

Returns a representative of self as a polynomial in \((Z/pZ)[x] / h(x)\) where \(h(x)\) is the defining polynomial of the finite field.

>>> gf = fq_default_ctx(163, 3)
>>> a = gf([1,2,3])
>>> a.polynomial()
3*x^2 + 2*x + 1
>>> gf(123).polynomial()
123
pth_root(self)

Returns the pth root of the element.

This is computed by raising self to the \(p^(d-1)\) power, \(p\) is the characteristic of the field and \(d\) is the degree of the extension.

>>> gf = fq_default_ctx(163, 3)
>>> a = gf([1,2,3])
>>> a.pth_root()
5*z^2 + 152*z + 119
sqrt(self)

Returns the square root of the element, if not square root exists, throws a ValueError.

>>> gf = fq_default_ctx(163, 3)
>>> a = gf([3,2,1])
>>> a.is_square()
True
>>> b = a.sqrt()
>>> b
95*z^2 + 36*z + 34
>>> b**2 in [a, -a]
True
square(self)

Computes the square of self

>>> gf = fq_default_ctx(163, 3)
>>> a = gf([1,2,3])
>>> a.square() == a*a
True
>>> a.square()
110*z^2 + 101*z + 25
str(self)
to_list(self)

Returns self as a list of fmpz types corresponding to a list of coefficients

>>> gf = fq_default_ctx(163, 3)
>>> gf([-1,2,1]).to_list()
[162, 2, 1]
>>> gf.one().to_list()
[1, 0, 0]
trace(self)

Returns the trace of self

>>> gf = fq_default_ctx(163, 3)
>>> a = gf([1,2,3])
>>> a.trace()
124