Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make PARI the default for EllipticCurve_field.weierstrass_p() #33223

Closed
yyyyx4 opened this issue Jan 24, 2022 · 31 comments
Closed

make PARI the default for EllipticCurve_field.weierstrass_p() #33223

yyyyx4 opened this issue Jan 24, 2022 · 31 comments

Comments

@yyyyx4
Copy link
Member

yyyyx4 commented Jan 24, 2022

On 9.5.rc3:

sage: E = EllipticCurve(GF(65537), [1, 2, 3, 4, 5])
sage: %timeit E.weierstrass_p(prec=1000)
229 ms ± 1.81 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)
sage: %timeit E.weierstrass_p(prec=1000, algorithm='pari')
52.1 ms ± 1.15 ms per loop (mean ± std. dev. of 7 runs, 10 loops each)

PARI is significantly faster in all examples I've tried. We should use it by default instead of Sage's own implementation.

Depends on #33224

CC: @JohnCremona @defeo @videlec

Component: elliptic curves

Author: Lorenz Panny

Branch/Commit: fbffbf3

Reviewer: Sébastien Labbé, John Cremona, Samuel Lelièvre

Issue created by migration from https://trac.sagemath.org/ticket/33223

@yyyyx4 yyyyx4 added this to the sage-9.6 milestone Jan 24, 2022
@yyyyx4

This comment has been minimized.

@yyyyx4
Copy link
Member Author

yyyyx4 commented Jan 24, 2022

Dependencies: #33224

@yyyyx4 yyyyx4 changed the title make PARI the default for EllipticCurve_field.weierstrass_p make PARI the default for EllipticCurve_field.weierstrass_p() Jan 24, 2022
@yyyyx4
Copy link
Member Author

yyyyx4 commented Jan 24, 2022

Author: Lorenz Panny

@yyyyx4
Copy link
Member Author

yyyyx4 commented Jan 24, 2022

New commits:

6b2cd18use PARI's ellwp() by default (it's faster than the "fast" implementation)

@yyyyx4
Copy link
Member Author

yyyyx4 commented Jan 24, 2022

Commit: 6b2cd18

@yyyyx4
Copy link
Member Author

yyyyx4 commented Jan 24, 2022

Branch: public/use_pari_ellwp_by_default

@seblabbe
Copy link
Contributor

comment:5

I confirm the new default is better:

sage: %timeit E.weierstrass_p(prec=1000, algorithm='fast')
268 ms ± 580 µs per loop (mean ± std. dev. of 7 runs, 1 loop each)
sage: %timeit E.weierstrass_p(prec=1000, algorithm='pari')
58.3 ms ± 160 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)
sage: %timeit E.weierstrass_p(prec=1000, algorithm='quadratic')
86.4 ms ± 167 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)
sage: %timeit E.weierstrass_p(prec=1000)
57.7 ms ± 197 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)

While reviewing, I noticed typos in the documentation:

sage: E.weierstrass_p??

I suggest to fix as follows:

-        - ``mprec`` - precision
+        - ``prec`` - precision

-        - ``algorithm`` - string (default:``None``) an algorithm identifier
-                      indicating using the ``pari``, ``fast`` or ``quadratic``
-                      algorithm. If the algorithm is ``None``, then this
-                      function determines the best algorithm to use.
+        - ``algorithm`` - string (default: ``None``) an algorithm identifier
+          indicating using the ``pari``, ``fast`` or ``quadratic``
+          algorithm. If the algorithm is ``None``, then this
+          function determines the best algorithm to use.

@seblabbe
Copy link
Contributor

Reviewer: Sébastien Labbé

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Jan 28, 2022

Changed commit from 6b2cd18 to 8daecaf

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Jan 28, 2022

Branch pushed to git repo; I updated commit sha1. New commits:

8daecafdoc tweaks

@yyyyx4
Copy link
Member Author

yyyyx4 commented Jan 28, 2022

comment:7

Thanks! Updated documentation.

@seblabbe
Copy link
Contributor

comment:8

I checked the changes. Looks good. Only one thing.

I don't agree with the following change:

-        - ``algorithm`` - string (default:``None``) an algorithm identifier
-                      indicating using the ``pari``, ``fast`` or ``quadratic``
-                      algorithm. If the algorithm is ``None``, then this
-                      function determines the best algorithm to use.
+        - ``algorithm`` -- an algorithm name or (default) ``None``:
+          See :func:`sage.schemes.elliptic_curves.ell_wp.weierstrass_p`
+          for a list of possible values.

Because for any user that get there, it is force one more step to get the possible values which is very often a question that comes to mind. Also, for normal user, they might just not be able to get to this other method.

In summary, I think it is better to leave it with an explicit list even if the information is doubled.

@JohnCremona
Copy link
Member

comment:9

I agree with slabbe's comment. (I hate it when a function has a *kwds argument and the docstring does not explain them but sends you some where else, which is similar.)

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Jan 29, 2022

Branch pushed to git repo; I updated commit sha1. New commits:

741f1dbun-deduplicate documentation per comments in #33223

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Jan 29, 2022

Changed commit from 8daecaf to 741f1db

@yyyyx4
Copy link
Member Author

yyyyx4 commented Jan 29, 2022

comment:11

Alright, makes sense. I changed it back (and added a comment to ell_wp.py to remind people of the duplication).

@seblabbe
Copy link
Contributor

comment:12

Thanks for the changes.

I still have some comments with respect to coding conventions in sage with respect to documentation. Sorry if it is troublesome: it is just some details.

The following change

-        - ``algorithm`` - string (default:``None``) an algorithm identifier
+        - ``algorithm`` -- string or (default) ``None``: an algorithm

does not respect the coding convention for the documentation. See https://doc.sagemath.org/html/en/developer/coding_basics.html To be more precise, please keep string (default:``None``) as is (twice).

Also, it would more exact to write
``'pari'``
``'fast'``
``'quadratic'``
as opposed to
``pari``
``fast``
``quadratic``. Observe that ``None`` is okay, since it is not about the string ``'None'``.

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Jan 31, 2022

Changed commit from 741f1db to 07045c2

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Jan 31, 2022

Branch pushed to git repo; I updated commit sha1. New commits:

07045c2follow doc formatting convention

@yyyyx4
Copy link
Member Author

yyyyx4 commented Jan 31, 2022

comment:14

The reason I'd changed it was precisely that None is not a string, so saying that this parameter is "a string which defaults to None" is not type-correct. Realistically speaking it's clear enough either way.

@slel
Copy link
Member

slel commented Jan 31, 2022

comment:15

How about:

        - ``algorithm`` -- string or ``None`` (default: ``None``):
          a choice of algorithm among ``"pari"``, ``"fast"``
          ``"quadratic"``; or ``None`` to let this function
          determine the best algorithm to use.

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Jan 31, 2022

Branch pushed to git repo; I updated commit sha1. This was a forced push. New commits:

bf799aduse PARI's ellwp() by default (it's faster than the "fast" implementation)
fbffbf3doc tweaks

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Jan 31, 2022

Changed commit from 07045c2 to fbffbf3

@yyyyx4
Copy link
Member Author

yyyyx4 commented Jan 31, 2022

comment:17

Done, and squashed all the documentation edits to untangle the commit history a bit.

@slel
Copy link
Member

slel commented Jan 31, 2022

Changed reviewer from Sébastien Labbé to Sébastien Labbé, John Cremona, Samuel Lelièvre

@slel
Copy link
Member

slel commented Jan 31, 2022

comment:18

Looks good to me if other reviewers agree.

@JohnCremona
Copy link
Member

comment:19

Fine by me. The moral of this story is never to label an algorithm as 'fast'.

@seblabbe
Copy link
Contributor

seblabbe commented Feb 1, 2022

comment:20

Replying to @JohnCremona:

Fine by me. The moral of this story is never to label an algorithm as 'fast'.

Indeed!

@seblabbe
Copy link
Contributor

seblabbe commented Feb 1, 2022

comment:21

I confirm that make works including the doc:

[sagemath_doc_html-none] Build finished.

and All tests passed! in folder sage -tp src/sage/schemes/elliptic_curves.

@yyyyx4
Copy link
Member Author

yyyyx4 commented Feb 2, 2022

comment:22

Thanks everyone!

@vbraun
Copy link
Member

vbraun commented Mar 8, 2022

Changed branch from public/use_pari_ellwp_by_default to fbffbf3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants