Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

Commit

Permalink
turn .scaling_factor() into a public function
Browse files Browse the repository at this point in the history
  • Loading branch information
yyyyx4 committed May 18, 2022
1 parent 2e88ff0 commit fb571d3
Show file tree
Hide file tree
Showing 4 changed files with 76 additions and 21 deletions.
23 changes: 15 additions & 8 deletions src/sage/schemes/elliptic_curves/ell_curve_isogeny.py
Original file line number Diff line number Diff line change
Expand Up @@ -2768,19 +2768,26 @@ def x_rational_map(self):
self.__initialize_rational_maps()
return self.__X_coord_rational_map

def _scaling_factor(self):
def scaling_factor(self):
r"""
Return ``self.formal()[1]``, but faster.
Return the Weierstrass scaling factor associated to this
elliptic-curve isogeny.
The scaling factor is the constant `u` (in the base field)
such that `\varphi^* \omega_2 = u \omega_1`, where
`\varphi: E_1\to E_2` is this isogeny and `\omega_i` are
the standard Weierstrass differentials on `E_i` defined by
`\mathrm dx/(2y+a_1x+a_3)`.
EXAMPLES::
sage: E = EllipticCurve(GF(257^2), [0,1])
sage: phi = E.isogeny(E.lift_x(240))
sage: phi.degree()
43
sage: phi._scaling_factor()
sage: phi.scaling_factor()
1
sage: phi.dual()._scaling_factor()
sage: phi.dual().scaling_factor()
43
ALGORITHM: The "inner" isogeny is normalized by construction,
Expand All @@ -2789,9 +2796,9 @@ def _scaling_factor(self):
"""
sc = Integer(1)
if self.__pre_isomorphism is not None:
sc *= self.__pre_isomorphism._scaling_factor()
sc *= self.__pre_isomorphism.scaling_factor()
if self.__post_isomorphism is not None:
sc *= self.__post_isomorphism._scaling_factor()
sc *= self.__post_isomorphism.scaling_factor()
return sc

def kernel_polynomial(self):
Expand Down Expand Up @@ -3346,7 +3353,7 @@ def dual(self):

# trac 7096
# this should take care of the case when the isogeny is not normalized.
u = self._scaling_factor()
u = self.scaling_factor()
isom = WeierstrassIsomorphism(E2pr, (u/F(d), 0, 0, 0))

E2 = isom.codomain()
Expand All @@ -3369,7 +3376,7 @@ def dual(self):
# the composition has the degree as a leading coefficient in
# the formal expansion.

phihat_sc = phi_hat._scaling_factor()
phihat_sc = phi_hat.scaling_factor()

sc = u * phihat_sc/F(d)

Expand Down
39 changes: 33 additions & 6 deletions src/sage/schemes/elliptic_curves/hom.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,36 @@ def x_rational_map(self):
raise NotImplementedError('children must implement')


def scaling_factor(self):
r"""
Return the Weierstrass scaling factor associated to this
elliptic-curve morphism.
The scaling factor is the constant `u` (in the base field)
such that `\varphi^* \omega_2 = u \omega_1`, where
`\varphi: E_1\to E_2` is this morphism and `\omega_i` are
the standard Weierstrass differentials on `E_i` defined by
`\mathrm dx/(2y+a_1x+a_3)`.
Implemented by child classes. For examples, see:
- :meth:`EllipticCurveIsogeny.scaling_factor`
- :meth:`sage.schemes.elliptic_curves.weierstrass_morphism.WeierstrassIsomorphism.scaling_factor`
- :meth:`sage.schemes.elliptic_curves.hom_composite.EllipticCurveHom_composite.scaling_factor`
TESTS::
sage: from sage.schemes.elliptic_curves.hom import EllipticCurveHom
sage: EllipticCurveHom.scaling_factor(None)
Traceback (most recent call last):
...
NotImplementedError: ...
"""
#TODO: could have a default implementation that simply
# returns .formal()[1], but it seems safer to fail
# visibly to make sure we would notice regressions
raise NotImplementedError('children must implement')

def formal(self, prec=20):
r"""
Return the formal isogeny associated to this elliptic-curve
Expand Down Expand Up @@ -326,11 +356,6 @@ def is_normalized(self):
`\omega_2` are the invariant differentials on `E_1` and
`E_2` corresponding to the given equation.
ALGORITHM:
The method checks if the leading term of the formal series
associated to this isogeny equals `1`.
EXAMPLES::
sage: from sage.schemes.elliptic_curves.weierstrass_morphism import WeierstrassIsomorphism
Expand Down Expand Up @@ -393,8 +418,10 @@ def is_normalized(self):
sage: phi = isom * phi
sage: phi.is_normalized()
True
ALGORITHM: We check if :meth:`scaling_factor` returns `1`.
"""
return self._scaling_factor() == 1
return self.scaling_factor() == 1


def is_separable(self):
Expand Down
19 changes: 15 additions & 4 deletions src/sage/schemes/elliptic_curves/hom_composite.py
Original file line number Diff line number Diff line change
Expand Up @@ -765,9 +765,16 @@ def formal(self, prec=20):
res = res(phi.formal(prec=prec))
return res

def _scaling_factor(self):
def scaling_factor(self):
r"""
Return ``self.formal()[1]``, but faster.
Return the Weierstrass scaling factor associated to this
composite morphism.
The scaling factor is the constant `u` (in the base field)
such that `\varphi^* \omega_2 = u \omega_1`, where
`\varphi: E_1\to E_2` is this morphism and `\omega_i` are
the standard Weierstrass differentials on `E_i` defined by
`\mathrm dx/(2y+a_1x+a_3)`.
EXAMPLES::
Expand All @@ -779,10 +786,14 @@ def _scaling_factor(self):
sage: phi = WeierstrassIsomorphism(phi.codomain(), [7,8,9,10]) * phi
sage: phi.formal()
7*t + 65474*t^2 + 511*t^3 + 61316*t^4 + 20548*t^5 + 45511*t^6 + 37285*t^7 + 48414*t^8 + 9022*t^9 + 24025*t^10 + 35986*t^11 + 55397*t^12 + 25199*t^13 + 18744*t^14 + 46142*t^15 + 9078*t^16 + 18030*t^17 + 47599*t^18 + 12158*t^19 + 50630*t^20 + 56449*t^21 + 43320*t^22 + O(t^23)
sage: phi._scaling_factor()
sage: phi.scaling_factor()
7
ALGORITHM: The scaling factor is multiplicative under
composition, so we return the product of the individual
scaling factors associated to each factor.
"""
return prod(phi._scaling_factor() for phi in self._phis)
return prod(phi.scaling_factor() for phi in self._phis)

def is_injective(self):
"""
Expand Down
16 changes: 13 additions & 3 deletions src/sage/schemes/elliptic_curves/weierstrass_morphism.py
Original file line number Diff line number Diff line change
Expand Up @@ -899,15 +899,25 @@ def __neg__(self):
urst = baseWI.__mul__(self, w).tuple()
return WeierstrassIsomorphism(self._domain, urst, self._codomain)

def _scaling_factor(self):
def scaling_factor(self):
r"""
Return ``self.formal()[1]``, but faster.
Return the Weierstrass scaling factor associated to this
Weierstrass isomorphism.
The scaling factor is the constant `u` (in the base field)
such that `\varphi^* \omega_2 = u \omega_1`, where
`\varphi: E_1\to E_2` is this isomorphism and `\omega_i` are
the standard Weierstrass differentials on `E_i` defined by
`\mathrm dx/(2y+a_1x+a_3)`.
EXAMPLES::
sage: E = EllipticCurve(QQbar, [0,1])
sage: all(f._scaling_factor() == f.formal()[1] for f in E.automorphisms())
sage: all(f.scaling_factor() == f.formal()[1] for f in E.automorphisms())
True
ALGORITHM: The scaling factor equals the `u` component of
the tuple `(u,r,s,t)` defining the isomorphism.
"""
return self.u

0 comments on commit fb571d3

Please sign in to comment.