Finite prime fields - Finite Rings

Skip to content
Back to top
View this page
Edit this page

# Finite prime fields

AUTHORS:

- William Stein: initial version

- Martin Albrecht (2008-01): refactoring

class sage.rings.finite_rings.finite_field_prime_modn.FiniteField_prime_modn(p, check=True, modulus=None)

  Bases: `FiniteField`, `IntegerModRing_generic`

  Finite field of order \(p\) where \(p\) is prime.

  EXAMPLES:

  Sage

      sage: FiniteField(3)
      Finite Field of size 3

      sage: FiniteField(next_prime(1000))                                             # needs sage.rings.finite_rings
      Finite Field of size 1009

  Python

      >>> from sage.all import *
      >>> FiniteField(Integer(3))
      Finite Field of size 3

      >>> FiniteField(next_prime(Integer(1000)))                                             # needs sage.rings.finite_rings
      Finite Field of size 1009

  characteristic()

    Return the characteristic of code{self}.

    EXAMPLES:

    Sage

        sage: k = GF(7)
        sage: k.characteristic()
        7

    Python

        >>> from sage.all import *
        >>> k = GF(Integer(7))
        >>> k.characteristic()
        7

  construction()

    Return the construction of this finite field (for use by `sage.categories.pushout`).

    EXAMPLES:

    Sage

        sage: GF(3).construction()
        (QuotientFunctor, Integer Ring)

    Python

        >>> from sage.all import *
        >>> GF(Integer(3)).construction()
        (QuotientFunctor, Integer Ring)

  degree()

    Return the degree of `self` over its prime field.

    This always returns 1.

    EXAMPLES:

    Sage

        sage: FiniteField(3).degree()
        1

    Python

        >>> from sage.all import *
        >>> FiniteField(Integer(3)).degree()
        1

    See also

    `absolute_degree()`

  gen(n=0)

    Return a generator of `self` over its prime field, which is a root of `self.modulus()`.

    Unless a custom modulus was given when constructing this prime field, this returns \(1\).

    INPUT:

    - `n` – must be 0

    OUTPUT:

    An element \(a\) 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

        sage: k = GF(13)
        sage: k.gen()
        1

        sage: k = GF(1009, modulus='primitive')
        sage: k.gen()  # this gives a primitive element
        11
        sage: k.gen(1)
        Traceback (most recent call last):
        ...
        IndexError: only one generator

    Python

        >>> from sage.all import *
        >>> k = GF(Integer(13))
        >>> k.gen()
        1

        >>> k = GF(Integer(1009), modulus='primitive')
        >>> k.gen()  # this gives a primitive element
        11
        >>> k.gen(Integer(1))
        Traceback (most recent call last):
        ...
        IndexError: only one generator

  gens()

    Return a tuple containing the generator of `self`.

    Warning

    The 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

        sage: k = GF(1009, modulus='primitive')
        sage: k.gens()
        (11,)

        sage: k = GF(1009)
        sage: k.gens()
        (1,)

    Python

        >>> from sage.all import *
        >>> k = GF(Integer(1009), modulus='primitive')
        >>> k.gens()
        (11,)

        >>> k = GF(Integer(1009))
        >>> k.gens()
        (1,)

  is_prime_field()

    Return `True` since this is a prime field.

    EXAMPLES:

    Sage

        sage: k.<a> = GF(3)
        sage: k.is_prime_field()
        True

        sage: k.<a> = GF(3^2)
        sage: k.is_prime_field()
        False

    Python

        >>> from sage.all import *
        >>> k = GF(Integer(3), names=('a',)); (a,) = k._first_ngens(1)
        >>> k.is_prime_field()
        True

        >>> k = GF(Integer(3)**Integer(2), names=('a',)); (a,) = k._first_ngens(1)
        >>> k.is_prime_field()
        False

  order()

    Return the order of this finite field.

    EXAMPLES:

    Sage

        sage: k = GF(5)
        sage: k.order()
        5

    Python

        >>> from sage.all import *
        >>> k = GF(Integer(5))
        >>> k.order()
        5

  polynomial(name=None)

    Return the polynomial `name`.

    EXAMPLES:

    Sage

        sage: k.<a> = GF(3)
        sage: k.polynomial()
        x

    Python

        >>> from sage.all import *
        >>> k = GF(Integer(3), names=('a',)); (a,) = k._first_ngens(1)
        >>> k.polynomial()
        x