Package sage :: Package rings :: Module finite_field :: Class FiniteField
[show private | hide private]
[frames | no frames]

Type FiniteField

            Gens --+
                   |
            Ring --+
                   |
      object --+   |
               |   |
_uniqFiniteField --+
                   |
                  FiniteField


Finite field of order q, where q is a prime power.

Create with the command
      FiniteField(modulus)

INPUT:
    q -- int, prime power, order of the finite field
OUTPUT:
    FiniteField -- finite field of order q.

EXAMPLES:
    >>> k = FiniteField(9)
    >>> k
    Finite field of size 3^2
    >>> k.is_field()
    True
    >>> k.characteristic()
    3
    >>> a = k.gen()
    >>> a 
    a
    >>> a.parent()
    Finite field of size 3^2
    >>> a.charpoly()
    x^2 + x + 2
    >>> [a**i for i in range(8)]
    [1, a, 2*a + 1, 2*a + 2, 2, 2*a, a + 2, a + 1]

Fields can be coerced into sets or list and iterated over:
    >>> list(k)
    [1, a, 2*a + 1, 2*a + 2, 2, 2*a, a + 2, a + 1, 0]
    >>> set(k)
    set([a, 2*a + 1, a + 2, a + 1, 0, 1, 2*a + 2, 2, 2*a])
    >>> for x in k: print x," ",
    1   a   2*a + 1   2*a + 2   2   2*a   a + 2   a + 1   0  
    
Next we compute with the finite field of order 16, where
the variable is named b.
    >>> k16 = FiniteField(16, "b")
    >>> z = k16.gen()
    >>> z
    b
    >>> z.charpoly()
    x^4 + x + 1
    >>> k16.is_field()
    True
    >>> k16.characteristic() 
    2
    >>> z.order()
    15

Of course one can also make prime finite fields.
    >>> k = FiniteField(7)
    >>> k.gen()
    3
    >>> k.gen().order()
    6

Method Summary
  __init__(self, q, var)
Create finite field of order q with variable var.
  __call__(self, x)
Coerce x into the finite field.
  __cmp__(self, other)
Compares this finite field with other.
  __contains__(self, x)
  __getitem__(self, n)
Returns the n-th element of the field.
  __iter__(self)
Return iterator over elements of the finite field, ending with 0.
  __len__(self)
The number of elements of the finite field.
  __repr__(self)
  characteristic(self)
Returns the characteristic of the finite field, which is a prime int.
  degree(self)
Returns the degree of the finite field, which is a positive integer.
  gen(self, n)
Return chosen generator of the finite field.
  is_field(self)
Returns whether or not the finite field is a field, i.e., always returns True.
  modulus(self)
Return the modulus of this finite field, i.e., the polynomial f(x) so elements of the finite field as elements modulo f.
  name(self)
Short description string that determines the finite field.
  ngens(self)
The number of generators of the finite field.
  order(self)
The number of elements of the finite field.
  polynomial(self)
Return the modulus of this finite field, i.e., the polynomial f(x) so elements of the finite field as elements modulo f.
  polynomial_ring(self)
Returns the polynomial ring over the prime subfield in the same variable as this finite field.
  prime_field(self)
Returns the prime subfield of this field.
  prime_subfield(self)
Returns the prime subfield of this field.
  random(self)
A random element of the finite field.
  unit_group_exponent(self)
The exponent of the unit group of the finite field.
    Inherited from object
  __delattr__(...)
x.__delattr__('name') <==> del x.name
  __getattribute__(...)
x.__getattribute__('name') <==> x.name
  __hash__(x)
x.__hash__() <==> hash(x)
  __reduce__(...)
helper for pickle
  __reduce_ex__(...)
helper for pickle
  __setattr__(...)
x.__setattr__('name', value) <==> x.name = value
  __str__(x)
x.__str__() <==> str(x)
    Inherited from Ring
  is_atomic_repr(self)
True if the elements have atomic string representations, in the sense that they print if they print at s, then -s means the negative of s.
  type(self)
    Inherited from Gens
  __getattr__(self, attrname)
  __getslice__(self, n, m)
  gens(self)
  list(self)

Instance Method Details

__init__(self, q, var='a')
(Constructor)

Create finite field of order q with variable var.

INPUT:
    q -- integer, size of the finite field
    var -- (optional, defaults to 'a') variable used for
           printing element of the finite field.  Also,
           two finite fields are considered equivalent
           if they have the same variable.
OUTPUT:
    FiniteField -- a finite field of order q with variable var.
EXAMPLES:
    >>> FiniteField(17)
    Finite field of size 17
    >>> FiniteField(2**10)
    Finite field of size 2^10
    >>> FiniteField(3**5, "b")
    Finite field of size 3^5
    >>> FiniteField(3**5, "b").gen()
    b

You can also create a finite field using GF, which is a synonym 
for FiniteField.
    >>> GF(19**2)
    Finite field of size 19^2
Overrides:
__builtin__.object.__init__

__call__(self, x)
(Call operator)

Coerce x into the finite field.

INPUT:
    x -- object

OUTPUT:
    FiniteFieldElement -- if possible, makes a finite field element from x.
    
EXAMPLES:
    >>> k = GF(3**4,'a')
    >>> b = k(5)
    >>> b.parent()
    Finite field of size 3^4
    >>> a = k.gen()
    >>> k(a + 2)
    a + 2

WARNING: Finite fields are currently implemented somewhat
naively using polynomials modulo p and the PARI ffinit
function.  In particular, we do not use Conway polynomials and
define natural consistent inclusion maps between different
finite fields.
Overrides:
sage.rings.ring.Ring.__call__

__cmp__(self, other)
(Comparison operator)

Compares this finite field with other. Two finite fields are equal if and only if they have the same cardinality *and* the defining polynomials are the same.

EXAMPLES:
>>> FiniteField(3**2) == FiniteField(3**3)
False

>>> FiniteField(3**2) == FiniteField(3**2)
True

>>> FiniteField(3**2,'beta') == FiniteField(3**2,'alpha')
False

>>> FiniteField(3**2,'beta') == FiniteField(3**2,'beta')
True

__getitem__(self, n)
(Indexing operator)

Returns the n-th element of the field.  The elements of the
field are

     [a, a^2, a^3, ... , 0]

where a is the generator for the multiplicative group returned
by unit_gen().

EXAMPLES:
    >>> k = GF(8)
    >>> k[0]
    1
    >>> k[1]
    a
    >>> k[7]
    0
    >>> for i in xrange(8): print k[i]," ",
    1   a   a^2   a^2 + 1   a^2 + a + 1   a + 1   a^2 + a   0
Overrides:
sage.structure.gens.Gens.__getitem__

__iter__(self)

Return iterator over elements of the finite field, ending with 0.

EXAMPLES:
>>> k = GF(9)
>>> i = 0
>>> for x in k: print x, k[i]; i+= 1
1 1
a a
a + 1 a + 1
2*a + 1 2*a + 1
2 2
2*a 2*a
2*a + 2 2*a + 2
a + 2 a + 2
0 0

__len__(self)
(Length operator)

The number of elements of the finite field.

EXAMPLES:
>>> k = GF(2**10)
>>> k
Finite field of size 2^10

>>> len(k)
1024

characteristic(self)

Returns the characteristic of the finite field, which is a prime int.

EXAMPLES:
>>> k = FiniteField(3**4)
>>> k.characteristic()
3
Overrides:
sage.rings.ring.Ring.characteristic

degree(self)

Returns the degree of the finite field, which is a positive integer.

EXAMPLES:
>>> FiniteField(3).degree()
1

>>> FiniteField(3**20).degree()
20

gen(self, n=0)

Return chosen generator of the finite field.  This generator
is a root of the defining polynomial of the finite field, and
is guaranteed to be a generator for the multiplicative group.  

INPUT:
    nothing

OUTPUT:
    FiniteFieldElement -- field generator of finite field
    
EXAMPLES:
    >>> FiniteField(2**4, "b").gen()
    b
    >>> k = FiniteField(3**4, "alpha")
    >>> a = k.gen()
    >>> a
    alpha
    >>> a**4
    2*alpha + 1

is_field(self)

Returns whether or not the finite field is a field, i.e., always returns True.

EXAMPLES:
>>> k = FiniteField(3**4)
>>> k.is_field()
True
Overrides:
sage.rings.ring.Ring.is_field

modulus(self)

Return the modulus of this finite field, i.e., the polynomial f(x) so elements of the finite field as elements modulo f.

EXAMPLES:
>>> k = FiniteField(17)
>>> k.modulus()
x + 14

>>> k = FiniteField(9)
>>> k.modulus()
x^2 + 2*x + 2

name(self)

Short description string that determines the finite field. EXAMPLES:
>>> FiniteField(3**4).name()
'GF3_4'
Overrides:
sage.rings.ring.Ring.name

ngens(self)

The number of generators of the finite field. Always 1.

EXAMPLES:
>>> k = FiniteField(3**4)
>>> k.ngens()
1

order(self)

The number of elements of the finite field.

EXAMPLES:
>>> k = GF(2**10)
>>> k
Finite field of size 2^10

>>> k.order()
1024

polynomial(self)

Return the modulus of this finite field, i.e., the polynomial f(x) so elements of the finite field as elements modulo f.

EXAMPLES:
>>> k = FiniteField(17)
>>> k.modulus()
x + 14

>>> k = FiniteField(9)
>>> k.modulus()
x^2 + 2*x + 2

polynomial_ring(self)

Returns the polynomial ring over the prime subfield in the same variable as this finite field.

EXAMPLES:
>>> k = FiniteField(3**4, "alpha")
>>> k.polynomial_ring()
Univariate Polynomial Ring in alpha over Finite field of size 3

prime_field(self)

Returns the prime subfield of this field.

EXAMPLES:
>>> k = GF(9)
>>> k.prime_field()
Finite field of size 3

prime_subfield(self)

Returns the prime subfield of this field.

EXAMPLES:
>>> k = GF(9)
>>> k.prime_field()
Finite field of size 3

random(self)

A random element of the finite field.

EXAMPLES:
    >> k = GF(2**10)
    >> k.random()
    a^9 + a

unit_group_exponent(self)

The exponent of the unit group of the finite field. For a finite field, this is always the order minus 1.

EXAMPLES:
>>> k = GF(2**10)
>>> k.order()
1024

>>> k.unit_group_exponent()
1023

Generated by Epydoc 2.1 on Fri Jun 24 17:58:45 2005 http://epydoc.sf.net