Skip to content

Commit

Permalink
Changed _number_field_from_algebraics in projective point as well
Browse files Browse the repository at this point in the history
Fixed numerous bugs, including handling the case where QQbar elements land in QQ
  • Loading branch information
pfili committed Sep 9, 2017
1 parent 8548426 commit 693578c
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 6 deletions.
16 changes: 11 additions & 5 deletions src/sage/schemes/projective/projective_morphism.py
Original file line number Diff line number Diff line change
Expand Up @@ -5204,7 +5204,7 @@ def _number_field_from_algebraics(self):
sage: P.<x,y>=ProjectiveSpace(QQbar,1)
sage: H = Hom(P,P)
sage: f = H([s*x^3-13*y^3, y^3-15*y^3])
sage: print f
sage: f
Scheme endomorphism of Projective Space of dimension 1 over Algebraic Field
Defn: Defined on coordinates by sending (x : y) to
((-0.6823278038280193?)*x^3 + (-13)*y^3 : (-14)*y^3)
Expand All @@ -5220,10 +5220,16 @@ def _number_field_from_algebraics(self):
raise NotImplementedError("not implemented for subschemes")

K_pre,C,phi = number_field_elements_from_algebraics([c for f in self for c in f.coefficients()])
# The field K_pre returned above does not have its embedding set, so we redefine it:
K = NumberField(K_pre.polynomial(), embedding=phi(K_pre.gen()), name='b')
psi = K_pre.hom([K.gen()], K)
C = [ psi(c) for c in C ]
# Trac 23808: The field K_pre returned above does not have its embedding set to be phi
# and phi is forgotten, so we redefine K_pre to be a field K with phi as the specified
# embedding:
if K_pre is QQ:
K = QQ
else:
from sage.rings.number_field.number_field import NumberField
K = NumberField(K_pre.polynomial(), embedding=phi(K_pre.gen()), name='a')
psi = K_pre.hom([K.gen()], K) # Identification of K_pre with K
C = [ psi(c) for c in C ] # The elements of C were in K_pre, move them to K
from sage.schemes.projective.projective_space import ProjectiveSpace
N = self.domain().dimension_relative()
PS = ProjectiveSpace(K,N,'z')
Expand Down
26 changes: 25 additions & 1 deletion src/sage/schemes/projective/projective_point.py
Original file line number Diff line number Diff line change
Expand Up @@ -1748,12 +1748,36 @@ def _number_field_from_algebraics(self):
(1/2*a^3 + a^2 - 1/2*a : 1)
sage: S.codomain()
Projective Space of dimension 1 over Number Field in a with defining polynomial y^4 + 1
The following was fixed in :trac:`23808`::
sage: R.<x> = PolynomialRing(QQ)
sage: P.<x,y> = ProjectiveSpace(QQbar,1)
sage: Q = P([-1/2*QQbar(sqrt(2)) + QQbar(I), 1]);Q
(-0.7071067811865475? + 1*I : 1)
sage: S = Q._number_field_from_algebraics(); S
(1/2*a^3 + a^2 - 1/2*a : 1)
sage: T = S.change_ring(QQbar) # Used to fail
sage: T
(-0.7071067811865475? + 1.000000000000000?*I : 1)
sage: Q[0] == T[0]
True
"""
from sage.schemes.projective.projective_space import is_ProjectiveSpace
if not is_ProjectiveSpace(self.codomain()):
raise NotImplementedError("not implemented for subschemes")

K,P,phi = number_field_elements_from_algebraics(list(self))
# Trac #23808: Keep the embedding info associated with the number field K
# used below, instead of in the separate embedding map phi which is
# forgotten.
K_pre,P,phi = number_field_elements_from_algebraics(list(self))
if K_pre is QQ:
K = QQ
else:
from sage.rings.number_field.number_field import NumberField
K = NumberField(K_pre.polynomial(), embedding=phi(K_pre.gen()), name='a')
psi = K_pre.hom([K.gen()], K) # Identification of K_pre with K
P = [ psi(p) for p in P ] # The elements of P were elements of K_pre
from sage.schemes.projective.projective_space import ProjectiveSpace
PS = ProjectiveSpace(K,self.codomain().dimension_relative(),'z')
return(PS(P))
Expand Down

0 comments on commit 693578c

Please sign in to comment.