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

Commit

Permalink
use {identity,negation}_morphism() throughout
Browse files Browse the repository at this point in the history
  • Loading branch information
yyyyx4 committed Jan 21, 2022
1 parent a9b8ecc commit 253cd33
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 19 deletions.
12 changes: 5 additions & 7 deletions src/sage/schemes/elliptic_curves/ell_curve_isogeny.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
from sage.rings.number_field.number_field_base import is_NumberField

from sage.schemes.elliptic_curves.weierstrass_morphism \
import WeierstrassIsomorphism, isomorphisms, baseWI
import WeierstrassIsomorphism, isomorphisms, baseWI, negation_morphism

from sage.sets.set import Set

Expand Down Expand Up @@ -1272,9 +1272,7 @@ def __neg__(self):
"""
output = copy(self)
E2 = output.__E2
iso = WeierstrassIsomorphism(E2, (-1,0,-E2.a1(),-E2.a3()))
output._set_post_isomorphism(iso)
output._set_post_isomorphism(negation_morphism(output.__E2))
return output

#
Expand Down Expand Up @@ -1345,8 +1343,8 @@ def __clear_cached_values(self):
sage: E = EllipticCurve(QQ, [0,0,0,1,0])
sage: phi = EllipticCurveIsogeny(E, x)
sage: old_ratl_maps = phi.rational_maps()
sage: from sage.schemes.elliptic_curves.weierstrass_morphism import WeierstrassIsomorphism
sage: phi.set_post_isomorphism(WeierstrassIsomorphism(phi.codomain(), (-1,0,0,0)))
sage: from sage.schemes.elliptic_curves.weierstrass_morphism import negation_morphism
sage: phi.set_post_isomorphism(negation_morphism(phi.codomain()))
...
sage: old_ratl_maps == phi.rational_maps()
False
Expand Down Expand Up @@ -3218,7 +3216,7 @@ def switch_sign(self):
from sage.misc.superseded import deprecation
deprecation(32388, 'Elliptic-curve isogenies will be immutable in a future release of Sage.'
' Use -phi instead of phi.switch_sign() to obtain the negated isogeny.')
self._set_post_isomorphism(WeierstrassIsomorphism(self.__E2, (-1,0,-self.__E2.a1(),-self.__E2.a3())))
self._set_post_isomorphism(negation_morphism(self.__E2))

def dual(self):
r"""
Expand Down
6 changes: 3 additions & 3 deletions src/sage/schemes/elliptic_curves/hom.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,11 +126,11 @@ def _richcmp_(self, other, op):
::
sage: from sage.schemes.elliptic_curves.weierstrass_morphism import WeierstrassIsomorphism
sage: from sage.schemes.elliptic_curves.weierstrass_morphism import WeierstrassIsomorphism, identity_morphism
sage: E = EllipticCurve([9,9])
sage: F = E.change_ring(GF(71))
sage: wE = WeierstrassIsomorphism(E, (1,0,0,0))
sage: wF = WeierstrassIsomorphism(F, (1,0,0,0))
sage: wE = identity_morphism(E)
sage: wF = identity_morphism(F)
sage: mE = E.multiplication_by_m_isogeny(1)
sage: mF = F.multiplication_by_m_isogeny(1)
sage: [mE == wE, mF == wF]
Expand Down
6 changes: 3 additions & 3 deletions src/sage/schemes/elliptic_curves/hom_composite.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@
from sage.schemes.elliptic_curves.ell_generic import EllipticCurve_generic
from sage.schemes.elliptic_curves.hom import EllipticCurveHom
from sage.schemes.elliptic_curves.ell_curve_isogeny import EllipticCurveIsogeny
from sage.schemes.elliptic_curves.weierstrass_morphism import WeierstrassIsomorphism
from sage.schemes.elliptic_curves.weierstrass_morphism import WeierstrassIsomorphism, identity_morphism

from sage.misc.superseded import experimental_warning
experimental_warning(32744, 'EllipticCurveHom_composite is experimental code.')
Expand Down Expand Up @@ -266,7 +266,7 @@ def __init__(self, E, kernel, codomain=None):
self._phis = _compute_factored_isogeny(kernel)

if not self._phis:
self._phis = [WeierstrassIsomorphism(E, (1,0,0,0))]
self._phis = [identity_morphism(E)]

if codomain is not None:
if not isinstance(codomain, EllipticCurve_generic):
Expand Down Expand Up @@ -362,7 +362,7 @@ def from_factors(cls, maps, E=None, strict=True):
E = phi.codomain()

if not maps:
maps = (WeierstrassIsomorphism(E, (1,0,0,0)),)
maps = (identity_morphism(E),)

if len(maps) == 1 and not strict:
return maps[0]
Expand Down
4 changes: 2 additions & 2 deletions src/sage/schemes/elliptic_curves/hom_scalar.py
Original file line number Diff line number Diff line change
Expand Up @@ -306,10 +306,10 @@ def _richcmp_(self, other, op):
TESTS:
sage: from sage.schemes.elliptic_curves.weierstrass_morphism import WeierstrassIsomorphism
sage: from sage.schemes.elliptic_curves.weierstrass_morphism import negation_morphism
sage: from sage.schemes.elliptic_curves.hom_composite import EllipticCurveHom_composite
doctest:warning ...
sage: neg = WeierstrassIsomorphism(E, [-1,0,0,0])
sage: neg = negation_morphism(E)
sage: neg_psi = EllipticCurveHom_composite.from_factors([psi,neg])
sage: psi_neg = EllipticCurveHom_composite.from_factors([neg,psi])
sage: phi == neg_psi == psi_neg == -psi
Expand Down
25 changes: 21 additions & 4 deletions src/sage/schemes/elliptic_curves/weierstrass_morphism.py
Original file line number Diff line number Diff line change
Expand Up @@ -870,10 +870,10 @@ def __neg__(self):
::
sage: from sage.schemes.elliptic_curves.weierstrass_morphism import WeierstrassIsomorphism
sage: from sage.schemes.elliptic_curves.weierstrass_morphism import WeierstrassIsomorphism, identity_morphism
sage: E = EllipticCurve(QuadraticField(-1), [1,0])
sage: t = WeierstrassIsomorphism(E, (i,0,0,0))
sage: -t^2 == WeierstrassIsomorphism(E, (1,0,0,0))
sage: -t^2 == identity_morphism(E)
True
"""
a1,_,a3,_,_ = self._domain.a_invariants()
Expand All @@ -882,6 +882,23 @@ def __neg__(self):
return WeierstrassIsomorphism(self._domain, urst, self._codomain)


def identity_morphism(E):
r"""
Given an elliptic curve `E`, return the identity morphism
on `E` as a :class:`WeierstrassIsomorphism`.
EXAMPLES::
sage: from sage.schemes.elliptic_curves.weierstrass_morphism import identity_morphism
sage: E = EllipticCurve([5,6,7,8,9])
sage: id_ = identity_morphism(E)
sage: id_.rational_maps()
(x, y)
"""
R = E.base_ring()
zero = R.zero()
return WeierstrassIsomorphism(E, (R.one(), zero, zero, zero))

def negation_morphism(E):
r"""
Given an elliptic curve `E`, return the negation endomorphism
Expand All @@ -895,6 +912,6 @@ def negation_morphism(E):
sage: neg.rational_maps()
(x, -5*x - y - 7)
"""
a1,_,a3,_,_ = E.a_invariants()
return WeierstrassIsomorphism(E, (-1, 0, -a1, -a3))
R = E.base_ring()
return WeierstrassIsomorphism(E, (-R.one(), R.zero(), -E.a1(), -E.a3()))

0 comments on commit 253cd33

Please sign in to comment.