From 41cb6e912e3c0b668aaabc41b39d43e18bcc5ba3 Mon Sep 17 00:00:00 2001 From: Gareth Ma Date: Wed, 11 Sep 2024 22:48:18 +0100 Subject: [PATCH] use _order in has_order when possible --- .../elliptic_curves/ell_finite_field.py | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/sage/schemes/elliptic_curves/ell_finite_field.py b/src/sage/schemes/elliptic_curves/ell_finite_field.py index 50b0fb4727c..87fa0ec67b8 100755 --- a/src/sage/schemes/elliptic_curves/ell_finite_field.py +++ b/src/sage/schemes/elliptic_curves/ell_finite_field.py @@ -1399,6 +1399,7 @@ def has_order(self, value, num_checks=8): True sage: E.has_order(N^2) True + sage: del E._order sage: E.has_order(N^2 + N) True @@ -1419,7 +1420,7 @@ def has_order(self, value, num_checks=8): # orders So we go with computing directly instead. # In #38341, the bound has been increased to a large value (2^64), but # it should be decreased (to ~100) after bug #38617 is fixed. - if q <= 2**64: + if q <= 2**64 or hasattr(self, "_order"): return self.order() == value # This might be slow @@ -3008,24 +3009,24 @@ def EllipticCurve_with_prime_order(N): sage: set_random_seed(1337) sage: for _, E in zip(range(3), EllipticCurve_with_prime_order(10^9 + 7)): ....: print(E) - verbose 2 (2866: ell_finite_field.py, EllipticCurve_with_prime_order) Computing the Hilbert class polynomial H_-163 + verbose 2 (...: ell_finite_field.py, EllipticCurve_with_prime_order) Computing the Hilbert class polynomial H_-163 Elliptic Curve defined by y^2 = x^3 + 265977778*x + 120868502 over Finite Field of size 1000041437 - verbose 2 (2866: ell_finite_field.py, EllipticCurve_with_prime_order) Computing the Hilbert class polynomial H_-667 + verbose 2 (...: ell_finite_field.py, EllipticCurve_with_prime_order) Computing the Hilbert class polynomial H_-667 Elliptic Curve defined by y^2 = x^3 + 689795416*x + 188156157 over Finite Field of size 999969307 Elliptic Curve defined by y^2 = x^3 + 999178436*x + 900579394 over Finite Field of size 999969307 sage: set_verbose(4) sage: set_random_seed(1337) sage: for _, E in zip(range(3), EllipticCurve_with_prime_order(10^9 + 7)): ....: print(E) - verbose 4 (2866: ell_finite_field.py, EllipticCurve_with_prime_order) Testing D=-19 + verbose 4 (...: ell_finite_field.py, EllipticCurve_with_prime_order) Testing D=-19 ... - verbose 4 (2866: ell_finite_field.py, EllipticCurve_with_prime_order) Testing D=-163 - verbose 2 (2866: ell_finite_field.py, EllipticCurve_with_prime_order) Computing the Hilbert class polynomial H_-163 + verbose 4 (...: ell_finite_field.py, EllipticCurve_with_prime_order) Testing D=-163 + verbose 2 (...: ell_finite_field.py, EllipticCurve_with_prime_order) Computing the Hilbert class polynomial H_-163 Elliptic Curve defined by y^2 = x^3 + 265977778*x + 120868502 over Finite Field of size 1000041437 - verbose 4 (2866: ell_finite_field.py, EllipticCurve_with_prime_order) Testing D=-179 + verbose 4 (...: ell_finite_field.py, EllipticCurve_with_prime_order) Testing D=-179 ... - verbose 4 (2866: ell_finite_field.py, EllipticCurve_with_prime_order) Testing D=-667 - verbose 2 (2866: ell_finite_field.py, EllipticCurve_with_prime_order) Computing the Hilbert class polynomial H_-667 + verbose 4 (...: ell_finite_field.py, EllipticCurve_with_prime_order) Testing D=-667 + verbose 2 (...: ell_finite_field.py, EllipticCurve_with_prime_order) Computing the Hilbert class polynomial H_-667 Elliptic Curve defined by y^2 = x^3 + 689795416*x + 188156157 over Finite Field of size 999969307 Elliptic Curve defined by y^2 = x^3 + 999178436*x + 900579394 over Finite Field of size 999969307