Finite fields of characteristic 2#
- class sage.rings.finite_rings.finite_field_ntl_gf2e.FiniteField_ntl_gf2e(q, names='a', modulus=None, repr='poly')[source]#
Bases:
FiniteField
Finite Field of characteristic 2 and order \(2^n\).
INPUT:
q
– \(2^n\) (must be 2 power)names
– variable used for poly_repr (default:'a'
)modulus
– A minimal polynomial to use for reduction.repr
– controls the way elements are printed to the user:(default:
'poly'
)
'poly'
: polynomial representation
OUTPUT:
Finite field with characteristic 2 and cardinality \(2^n\).
EXAMPLES:
sage: k.<a> = GF(2^16) sage: type(k) <class 'sage.rings.finite_rings.finite_field_ntl_gf2e.FiniteField_ntl_gf2e_with_category'> sage: k.<a> = GF(2^1024) sage: k.modulus() x^1024 + x^19 + x^6 + x + 1 sage: set_random_seed(6397) sage: k.<a> = GF(2^17, modulus='random') sage: k.modulus() x^17 + x^16 + x^15 + x^10 + x^8 + x^6 + x^4 + x^3 + x^2 + x + 1 sage: k.modulus().is_irreducible() True sage: k.<a> = GF(2^211, modulus='minimal_weight') sage: k.modulus() x^211 + x^11 + x^10 + x^8 + 1 sage: k.<a> = GF(2^211, modulus='conway') sage: k.modulus() x^211 + x^9 + x^6 + x^5 + x^3 + x + 1 sage: k.<a> = GF(2^23, modulus='conway') sage: a.multiplicative_order() == k.order() - 1 True
>>> from sage.all import * >>> k = GF(Integer(2)**Integer(16), names=('a',)); (a,) = k._first_ngens(1) >>> type(k) <class 'sage.rings.finite_rings.finite_field_ntl_gf2e.FiniteField_ntl_gf2e_with_category'> >>> k = GF(Integer(2)**Integer(1024), names=('a',)); (a,) = k._first_ngens(1) >>> k.modulus() x^1024 + x^19 + x^6 + x + 1 >>> set_random_seed(Integer(6397)) >>> k = GF(Integer(2)**Integer(17), modulus='random', names=('a',)); (a,) = k._first_ngens(1) >>> k.modulus() x^17 + x^16 + x^15 + x^10 + x^8 + x^6 + x^4 + x^3 + x^2 + x + 1 >>> k.modulus().is_irreducible() True >>> k = GF(Integer(2)**Integer(211), modulus='minimal_weight', names=('a',)); (a,) = k._first_ngens(1) >>> k.modulus() x^211 + x^11 + x^10 + x^8 + 1 >>> k = GF(Integer(2)**Integer(211), modulus='conway', names=('a',)); (a,) = k._first_ngens(1) >>> k.modulus() x^211 + x^9 + x^6 + x^5 + x^3 + x + 1 >>> k = GF(Integer(2)**Integer(23), modulus='conway', names=('a',)); (a,) = k._first_ngens(1) >>> a.multiplicative_order() == k.order() - Integer(1) True
- characteristic()[source]#
Return the characteristic of
self
which is 2.EXAMPLES:
sage: k.<a> = GF(2^16,modulus='random') sage: k.characteristic() 2
>>> from sage.all import * >>> k = GF(Integer(2)**Integer(16),modulus='random', names=('a',)); (a,) = k._first_ngens(1) >>> k.characteristic() 2
- degree()[source]#
If this field has cardinality \(2^n\) this method returns \(n\).
EXAMPLES:
sage: k.<a> = GF(2^64) sage: k.degree() 64
>>> from sage.all import * >>> k = GF(Integer(2)**Integer(64), names=('a',)); (a,) = k._first_ngens(1) >>> k.degree() 64
- fetch_int(*args, **kwds)[source]#
Deprecated: Use
from_integer()
instead. See Issue #33941 for details.
- from_integer(number)[source]#
Given an integer \(n\) less than
cardinality()
with base \(2\) representation \(a_0 + 2 \cdot a_1 + \cdots + 2^k a_k\), returns \(a_0 + a_1 \cdot x + \cdots + a_k x^k\), where \(x\) is the generator of this finite field.INPUT:
number
– an integer
EXAMPLES:
sage: k.<a> = GF(2^48) sage: k.from_integer(2^43 + 2^15 + 1) a^43 + a^15 + 1 sage: k.from_integer(33793) a^15 + a^10 + 1 sage: 33793.digits(2) # little endian [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]
>>> from sage.all import * >>> k = GF(Integer(2)**Integer(48), names=('a',)); (a,) = k._first_ngens(1) >>> k.from_integer(Integer(2)**Integer(43) + Integer(2)**Integer(15) + Integer(1)) a^43 + a^15 + 1 >>> k.from_integer(Integer(33793)) a^15 + a^10 + 1 >>> Integer(33793).digits(Integer(2)) # little endian [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]
- gen(n=0)[source]#
Return a generator of
self
over its prime field, which is a root ofself.modulus()
.INPUT:
n
– must be 0
OUTPUT:
An element \(a\) of
self
such thatself.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 themodulus="primitive"
option when constructing the field.EXAMPLES:
sage: k.<a> = GF(2^19) sage: k.gen() == a True sage: a a
>>> from sage.all import * >>> k = GF(Integer(2)**Integer(19), names=('a',)); (a,) = k._first_ngens(1) >>> k.gen() == a True >>> a a
- order()[source]#
Return the cardinality of this field.
EXAMPLES:
sage: k.<a> = GF(2^64) sage: k.order() 18446744073709551616
>>> from sage.all import * >>> k = GF(Integer(2)**Integer(64), names=('a',)); (a,) = k._first_ngens(1) >>> k.order() 18446744073709551616
- prime_subfield()[source]#
Return the prime subfield \(\GF{p}\) of
self
ifself
is \(\GF{p^n}\).EXAMPLES:
sage: F.<a> = GF(2^16) sage: F.prime_subfield() Finite Field of size 2
>>> from sage.all import * >>> F = GF(Integer(2)**Integer(16), names=('a',)); (a,) = F._first_ngens(1) >>> F.prime_subfield() Finite Field of size 2
- sage.rings.finite_rings.finite_field_ntl_gf2e.late_import()[source]#
Imports various modules after startup.
EXAMPLES:
sage: sage.rings.finite_rings.finite_field_ntl_gf2e.late_import() sage: sage.rings.finite_rings.finite_field_ntl_gf2e.GF2 is None # indirect doctest False
>>> from sage.all import * >>> sage.rings.finite_rings.finite_field_ntl_gf2e.late_import() >>> sage.rings.finite_rings.finite_field_ntl_gf2e.GF2 is None # indirect doctest False