Finite fields that are implemented using Zech logs and the
cardinality must be less than . By default, conway polynomials are
used as minimal polynomial.
TESTS:
Test backwards compatibility:
sage: from sage.rings.finite_rings.finite_field_givaro import FiniteField_givaro
sage: FiniteField_givaro(9, 'a')
doctest:...: DeprecationWarning: constructing a FiniteField_givaro without giving a polynomial as modulus is deprecated, use the more general FiniteField constructor instead
See http://trac.sagemath.org/16930 for details.
Finite Field in a of size 3^2
Bases: sage.rings.finite_rings.finite_field_base.FiniteField
Finite field implemented using Zech logs and the cardinality must be
less than . By default, conway polynomials are used as minimal
polynomials.
INPUT:
OUTPUT:
Givaro finite field with characteristic and cardinality
.
EXAMPLES:
By default conway polynomials are used for extension fields:
sage: k.<a> = GF(2**8)
sage: -a ^ k.degree()
a^4 + a^3 + a^2 + 1
sage: f = k.modulus(); f
x^8 + x^4 + x^3 + x^2 + 1
You may enforce a modulus:
sage: P.<x> = PolynomialRing(GF(2))
sage: f = x^8 + x^4 + x^3 + x + 1 # Rijndael Polynomial
sage: k.<a> = GF(2^8, modulus=f)
sage: k.modulus()
x^8 + x^4 + x^3 + x + 1
sage: a^(2^8)
a
You may enforce a random modulus:
sage: k = GF(3**5, 'a', modulus='random')
sage: k.modulus() # random polynomial
x^5 + 2*x^4 + 2*x^3 + x^2 + 2
Three different representations are possible:
sage: FiniteField(9, 'a', impl='givaro', repr='poly').gen()
a
sage: FiniteField(9, 'a', impl='givaro', repr='int').gen()
3
sage: FiniteField(9, 'a', impl='givaro', repr='log').gen()
1
For prime fields, the default modulus is the polynomial ,
but you can ask for a different modulus:
sage: GF(1009, impl='givaro').modulus()
x + 1008
sage: GF(1009, impl='givaro', modulus='conway').modulus()
x + 998
Return a*b - c.
INPUT:
EXAMPLES:
sage: k.<a> = GF(3**3)
sage: k.a_times_b_minus_c(a,a,k(1))
a^2 + 2
Return a*b + c. This is faster than multiplying a and b first and adding c to the result.
INPUT:
EXAMPLES:
sage: k.<a> = GF(2**8)
sage: k.a_times_b_plus_c(a,a,k(1))
a^2 + 1
Return c - a*b.
INPUT:
EXAMPLES:
sage: k.<a> = GF(3**3)
sage: k.c_minus_a_times_b(a,a,k(1))
2*a^2 + 1
Return the characteristic of this field.
EXAMPLES:
sage: p = GF(19^5,'a').characteristic(); p
19
sage: type(p)
<type 'sage.rings.integer.Integer'>
If the cardinality of self is , then this returns
.
OUTPUT:
Integer – the degree
EXAMPLES:
sage: GF(3^4,'a').degree()
4
Given an integer return a finite field element in self
which equals
under the condition that gen() is set to
characteristic().
EXAMPLES:
sage: k.<a> = GF(2^8)
sage: k.fetch_int(8)
a^3
sage: e = k.fetch_int(151); e
a^7 + a^4 + a^2 + a + 1
sage: 2^7 + 2^4 + 2^2 + 2 + 1
151
INPUT:
OUTPUT:
The -th power of the absolute arithmetic Frobenius
endomorphism on this finite field.
EXAMPLES:
sage: k.<t> = GF(3^5)
sage: Frob = k.frobenius_endomorphism(); Frob
Frobenius endomorphism t |--> t^3 on Finite Field in t of size 3^5
sage: a = k.random_element()
sage: Frob(a) == a^3
True
We can specify a power:
sage: k.frobenius_endomorphism(2)
Frobenius endomorphism t |--> t^(3^2) on Finite Field in t of size 3^5
The result is simplified if possible:
sage: k.frobenius_endomorphism(6)
Frobenius endomorphism t |--> t^3 on Finite Field in t of size 3^5
sage: k.frobenius_endomorphism(5)
Identity endomorphism of Finite Field in t of size 3^5
Comparisons work:
sage: k.frobenius_endomorphism(6) == Frob
True
sage: from sage.categories.morphism import IdentityMorphism
sage: k.frobenius_endomorphism(5) == IdentityMorphism(k)
True
AUTHOR:
Return a generator of self over its prime field, which is a root of self.modulus().
INPUT:
OUTPUT:
An element of self such that self.modulus()(a) == 0.
Warning
This generator is not guaranteed to be a generator for the multiplicative group. To obtain the latter, use multiplicative_generator() or use the modulus="primitive" option when constructing the field.
EXAMPLES:
sage: k = GF(3^4, 'b'); k.gen()
b
sage: k.gen(1)
Traceback (most recent call last):
...
IndexError: only one generator
sage: F = FiniteField(31, impl='givaro')
sage: F.gen()
1
Given an integer this method returns
where
satisfies
where
is the generator and
is the
characteristic of self.
INPUT:
OUTPUT:
log representation of n
EXAMPLES:
sage: k = GF(7**3, 'a')
sage: k.int_to_log(4)
228
sage: k.int_to_log(3)
57
sage: k.gen()^57
3
Given an integer this method returns i where i
satisfies
where
is the generator of self; the
result is interpreted as an integer.
INPUT:
OUTPUT:
integer representation of a finite field element.
EXAMPLES:
sage: k = GF(2**8, 'a')
sage: k.log_to_int(4)
16
sage: k.log_to_int(20)
180
Return the cardinality of this field.
OUTPUT:
Integer – the number of elements in self.
EXAMPLES:
sage: n = GF(19^5,'a').order(); n
2476099
sage: type(n)
<type 'sage.rings.integer.Integer'>
Return the prime subfield of self if self is
.
EXAMPLES:
sage: GF(3^4, 'b').prime_subfield()
Finite Field of size 3
sage: S.<b> = GF(5^2); S
Finite Field in b of size 5^2
sage: S.prime_subfield()
Finite Field of size 5
sage: type(S.prime_subfield())
<class 'sage.rings.finite_rings.finite_field_prime_modn.FiniteField_prime_modn_with_category'>
Return a random element of self.
EXAMPLES:
sage: k = GF(23**3, 'a')
sage: e = k.random_element(); e
2*a^2 + 14*a + 21
sage: type(e)
<type 'sage.rings.finite_rings.element_givaro.FiniteField_givaroElement'>
sage: P.<x> = PowerSeriesRing(GF(3^3, 'a'))
sage: P.random_element(5)
2*a + 2 + (a^2 + a + 2)*x + (2*a + 1)*x^2 + (2*a^2 + a)*x^3 + 2*a^2*x^4 + O(x^5)