Skip to content

Commit

Permalink
reviewer comments
Browse files Browse the repository at this point in the history
  • Loading branch information
yyyyx4 committed Oct 21, 2024
1 parent 21675e1 commit a2fdcc9
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 43 deletions.
39 changes: 4 additions & 35 deletions src/sage/rings/finite_rings/finite_field_base.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -1948,6 +1948,8 @@ cdef class FiniteField(Field):
To: Algebraic closure of Finite Field of size 2
Defn: a |--> ...
"""
if self.characteristic() != K.characteristic():
raise ValueError(f'no embedding from {self} to {K}: incompatible characteristics')
try:
return super().an_embedding(K)
except (NotImplementedError, ValueError):
Expand Down Expand Up @@ -1985,42 +1987,9 @@ cdef class FiniteField(Field):
From: Finite Field in z2 of size 2^2
To: Algebraic closure of Finite Field of size 2
Defn: z2 |--> z2 + 1]
::
sage: CyclotomicField(5).embeddings(QQbar)
[
Ring morphism:
From: Cyclotomic Field of order 5 and degree 4
To: Algebraic Field
Defn: zeta5 |--> 0.3090169943749474? + 0.9510565162951536?*I,
Ring morphism:
From: Cyclotomic Field of order 5 and degree 4
To: Algebraic Field
Defn: zeta5 |--> -0.8090169943749474? + 0.5877852522924731?*I,
Ring morphism:
From: Cyclotomic Field of order 5 and degree 4
To: Algebraic Field
Defn: zeta5 |--> -0.8090169943749474? - 0.5877852522924731?*I,
Ring morphism:
From: Cyclotomic Field of order 5 and degree 4
To: Algebraic Field
Defn: zeta5 |--> 0.3090169943749474? - 0.9510565162951536?*I
]
sage: CyclotomicField(3).embeddings(CyclotomicField(7))
[ ]
sage: CyclotomicField(3).embeddings(CyclotomicField(6))
[
Ring morphism:
From: Cyclotomic Field of order 3 and degree 2
To: Cyclotomic Field of order 6 and degree 2
Defn: zeta3 |--> zeta6 - 1,
Ring morphism:
From: Cyclotomic Field of order 3 and degree 2
To: Cyclotomic Field of order 6 and degree 2
Defn: zeta3 |--> -zeta6
]
"""
if self.characteristic() != K.characteristic():
return []
if K not in FiniteFields():
from sage.rings.algebraic_closure_finite_field import AlgebraicClosureFiniteField_generic
if not isinstance(K, AlgebraicClosureFiniteField_generic):
Expand Down
35 changes: 35 additions & 0 deletions src/sage/rings/number_field/number_field.py
Original file line number Diff line number Diff line change
Expand Up @@ -9345,6 +9345,41 @@ def embeddings(self, K):
Defn: a |--> 1.25992104989487
]
Some more (possible and impossible) embeddings of cyclotomic fields::
sage: CyclotomicField(5).embeddings(QQbar)
[
Ring morphism:
From: Cyclotomic Field of order 5 and degree 4
To: Algebraic Field
Defn: zeta5 |--> 0.3090169943749474? + 0.9510565162951536?*I,
Ring morphism:
From: Cyclotomic Field of order 5 and degree 4
To: Algebraic Field
Defn: zeta5 |--> -0.8090169943749474? + 0.5877852522924731?*I,
Ring morphism:
From: Cyclotomic Field of order 5 and degree 4
To: Algebraic Field
Defn: zeta5 |--> -0.8090169943749474? - 0.5877852522924731?*I,
Ring morphism:
From: Cyclotomic Field of order 5 and degree 4
To: Algebraic Field
Defn: zeta5 |--> 0.3090169943749474? - 0.9510565162951536?*I
]
sage: CyclotomicField(3).embeddings(CyclotomicField(7))
[ ]
sage: CyclotomicField(3).embeddings(CyclotomicField(6))
[
Ring morphism:
From: Cyclotomic Field of order 3 and degree 2
To: Cyclotomic Field of order 6 and degree 2
Defn: zeta3 |--> zeta6 - 1,
Ring morphism:
From: Cyclotomic Field of order 3 and degree 2
To: Cyclotomic Field of order 6 and degree 2
Defn: zeta3 |--> -zeta6
]
Test that :issue:`15053` is fixed::
sage: K = NumberField(x^3 - 2, 'a')
Expand Down
3 changes: 3 additions & 0 deletions src/sage/rings/number_field/number_field_rel.py
Original file line number Diff line number Diff line change
Expand Up @@ -2072,6 +2072,9 @@ def embeddings(self, K):
sage: f[0](a+b)
-0.62996052494743693 - 0.091123635971721295*I
"""
if K.characteristic():
return Sequence([], immutable=True, check=False, universe=self.Hom(K))

Check warning on line 2076 in src/sage/rings/number_field/number_field_rel.py

View check run for this annotation

Codecov / codecov/patch

src/sage/rings/number_field/number_field_rel.py#L2076

Added line #L2076 was not covered by tests

try:
# this should be concordant with automorphisms
return self.__embeddings[K]
Expand Down
18 changes: 10 additions & 8 deletions src/sage/rings/rational_field.py
Original file line number Diff line number Diff line change
Expand Up @@ -601,7 +601,8 @@ def signature(self):

def embeddings(self, K):
r"""
Return list of the one embedding of `\QQ` into `K`, if it exists.
Return the list containing the unique embedding of `\QQ` into `K`,
if it exists, and an empty list otherwise.
EXAMPLES::
Expand All @@ -612,16 +613,17 @@ def embeddings(self, K):
From: Rational Field
To: Cyclotomic Field of order 5 and degree 4]
`K` must have characteristic 0::
The field `K` must have characteristic `0` for an embedding of `\QQ`
to exist::
sage: QQ.embeddings(GF(3))
Traceback (most recent call last):
...
ValueError: no embeddings of the rational field into K.
[]
"""
if K.characteristic():
raise ValueError("no embeddings of the rational field into K.")
return [self.hom(K)]
if K.characteristic() == 0:
v = [self.hom(K)]
else:
v = []
return Sequence(v, check=False, universe=self.Hom(K))

def automorphisms(self):
r"""
Expand Down
3 changes: 3 additions & 0 deletions src/sage/rings/ring.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -1526,6 +1526,9 @@ cdef class Field(CommutativeRing):
To: Cyclotomic Field of order 6 and degree 2
Defn: zeta3 -> zeta6 - 1
"""
if self.characteristic() != K.characteristic():
raise ValueError(f'no embedding from {self} to {K}: incompatible characteristics')

H = self.Hom(K)
try:
return H.natural_map()
Expand Down

0 comments on commit a2fdcc9

Please sign in to comment.