# Homset for finite fields#

This is the set of all field homomorphisms between two finite fields.

EXAMPLES:

```sage: R.<t> = ZZ[]
sage: E.<a> = GF(25, modulus = t^2 - 2)
sage: F.<b> = GF(625)
sage: H = Hom(E, F)
sage: f = H([4*b^3 + 4*b^2 + 4*b]); f
Ring morphism:
From: Finite Field in a of size 5^2
To:   Finite Field in b of size 5^4
Defn: a |--> 4*b^3 + 4*b^2 + 4*b
sage: f(2)
2
sage: f(a)
4*b^3 + 4*b^2 + 4*b
sage: len(H)
2
sage: [phi(2*a)^2 for phi in Hom(E, F)]
[3, 3]
```
```>>> from sage.all import *
>>> R = ZZ['t']; (t,) = R._first_ngens(1)
>>> E = GF(Integer(25), modulus = t**Integer(2) - Integer(2), names=('a',)); (a,) = E._first_ngens(1)
>>> F = GF(Integer(625), names=('b',)); (b,) = F._first_ngens(1)
>>> H = Hom(E, F)
>>> f = H([Integer(4)*b**Integer(3) + Integer(4)*b**Integer(2) + Integer(4)*b]); f
Ring morphism:
From: Finite Field in a of size 5^2
To:   Finite Field in b of size 5^4
Defn: a |--> 4*b^3 + 4*b^2 + 4*b
>>> f(Integer(2))
2
>>> f(a)
4*b^3 + 4*b^2 + 4*b
>>> len(H)
2
>>> [phi(Integer(2)*a)**Integer(2) for phi in Hom(E, F)]
[3, 3]
```

We can also create endomorphisms:

```sage: End(E)
Automorphism group of Finite Field in a of size 5^2
sage: End(GF(7))[0]
Ring endomorphism of Finite Field of size 7
Defn: 1 |--> 1
sage: H = Hom(GF(7), GF(49, 'c'))
sage: H[0](2)
2
```
```>>> from sage.all import *
>>> End(E)
Automorphism group of Finite Field in a of size 5^2
>>> End(GF(Integer(7)))[Integer(0)]
Ring endomorphism of Finite Field of size 7
Defn: 1 |--> 1
>>> H = Hom(GF(Integer(7)), GF(Integer(49), 'c'))
>>> H[Integer(0)](Integer(2))
2
```
class sage.rings.finite_rings.homset.FiniteFieldHomset(R, S, category=None)[source]#

Set of homomorphisms with domain a given finite field.

index(item)[source]#

Return the index of `self`.

EXAMPLES:

```sage: K.<z> = GF(1024)
sage: g = End(K)[3]
sage: End(K).index(g) == 3
True
```
```>>> from sage.all import *
>>> K = GF(Integer(1024), names=('z',)); (z,) = K._first_ngens(1)
>>> g = End(K)[Integer(3)]
>>> End(K).index(g) == Integer(3)
True
```
is_aut()[source]#

Check if `self` is an automorphism

EXAMPLES:

```sage: Hom(GF(4, 'a'), GF(16, 'b')).is_aut()
False
sage: Hom(GF(4, 'a'), GF(4, 'c')).is_aut()
False
sage: Hom(GF(4, 'a'), GF(4, 'a')).is_aut()
True
```
```>>> from sage.all import *
>>> Hom(GF(Integer(4), 'a'), GF(Integer(16), 'b')).is_aut()
False
>>> Hom(GF(Integer(4), 'a'), GF(Integer(4), 'c')).is_aut()
False
>>> Hom(GF(Integer(4), 'a'), GF(Integer(4), 'a')).is_aut()
True
```
list()[source]#

Return a list of all the elements in this set of field homomorphisms.

EXAMPLES:

```sage: K.<a> = GF(25)
sage: End(K)
Automorphism group of Finite Field in a of size 5^2
sage: list(End(K))
[Ring endomorphism of Finite Field in a of size 5^2
Defn: a |--> 4*a + 1,
Ring endomorphism of Finite Field in a of size 5^2
Defn: a |--> a]
sage: L.<z> = GF(7^6)
sage: [g for g in End(L) if (g^3)(z) == z]
[Ring endomorphism of Finite Field in z of size 7^6
Defn: z |--> z,
Ring endomorphism of Finite Field in z of size 7^6
Defn: z |--> 5*z^4 + 5*z^3 + 4*z^2 + 3*z + 1,
Ring endomorphism of Finite Field in z of size 7^6
Defn: z |--> 3*z^5 + 5*z^4 + 5*z^2 + 2*z + 3]
```
```>>> from sage.all import *
>>> K = GF(Integer(25), names=('a',)); (a,) = K._first_ngens(1)
>>> End(K)
Automorphism group of Finite Field in a of size 5^2
>>> list(End(K))
[Ring endomorphism of Finite Field in a of size 5^2
Defn: a |--> 4*a + 1,
Ring endomorphism of Finite Field in a of size 5^2
Defn: a |--> a]
>>> L = GF(Integer(7)**Integer(6), names=('z',)); (z,) = L._first_ngens(1)
>>> [g for g in End(L) if (g**Integer(3))(z) == z]
[Ring endomorphism of Finite Field in z of size 7^6
Defn: z |--> z,
Ring endomorphism of Finite Field in z of size 7^6
Defn: z |--> 5*z^4 + 5*z^3 + 4*z^2 + 3*z + 1,
Ring endomorphism of Finite Field in z of size 7^6
Defn: z |--> 3*z^5 + 5*z^4 + 5*z^2 + 2*z + 3]
```

Between isomorphic fields with different moduli:

```sage: k1 = GF(1009)
sage: k2 = GF(1009, modulus="primitive")
sage: Hom(k1, k2).list()
[
Ring morphism:
From: Finite Field of size 1009
To:   Finite Field of size 1009
Defn: 1 |--> 1
]
sage: Hom(k2, k1).list()
[
Ring morphism:
From: Finite Field of size 1009
To:   Finite Field of size 1009
Defn: 11 |--> 11
]

sage: k1.<a> = GF(1009^2, modulus="first_lexicographic")
sage: k2.<b> = GF(1009^2, modulus="conway")
sage: Hom(k1, k2).list()
[
Ring morphism:
From: Finite Field in a of size 1009^2
To:   Finite Field in b of size 1009^2
Defn: a |--> 290*b + 864,
Ring morphism:
From: Finite Field in a of size 1009^2
To:   Finite Field in b of size 1009^2
Defn: a |--> 719*b + 145
]
```
```>>> from sage.all import *
>>> k1 = GF(Integer(1009))
>>> k2 = GF(Integer(1009), modulus="primitive")
>>> Hom(k1, k2).list()
[
Ring morphism:
From: Finite Field of size 1009
To:   Finite Field of size 1009
Defn: 1 |--> 1
]
>>> Hom(k2, k1).list()
[
Ring morphism:
From: Finite Field of size 1009
To:   Finite Field of size 1009
Defn: 11 |--> 11
]

>>> k1 = GF(Integer(1009)**Integer(2), modulus="first_lexicographic", names=('a',)); (a,) = k1._first_ngens(1)
>>> k2 = GF(Integer(1009)**Integer(2), modulus="conway", names=('b',)); (b,) = k2._first_ngens(1)
>>> Hom(k1, k2).list()
[
Ring morphism:
From: Finite Field in a of size 1009^2
To:   Finite Field in b of size 1009^2
Defn: a |--> 290*b + 864,
Ring morphism:
From: Finite Field in a of size 1009^2
To:   Finite Field in b of size 1009^2
Defn: a |--> 719*b + 145
]
```
order()[source]#

Return the order of this set of field homomorphisms.

EXAMPLES:

```sage: K.<a> = GF(125)
sage: End(K)
Automorphism group of Finite Field in a of size 5^3
sage: End(K).order()
3
sage: L.<b> = GF(25)
sage: Hom(L, K).order() == Hom(K, L).order() == 0
True
```
```>>> from sage.all import *
>>> K = GF(Integer(125), names=('a',)); (a,) = K._first_ngens(1)
>>> End(K)
Automorphism group of Finite Field in a of size 5^3
>>> End(K).order()
3
>>> L = GF(Integer(25), names=('b',)); (b,) = L._first_ngens(1)
>>> Hom(L, K).order() == Hom(K, L).order() == Integer(0)
True
```