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
Slightly fasten is_cyclotomic() #17695
Comments
Commit: |
Changed keywords from none to cyclotomic polynomials |
This comment has been minimized.
This comment has been minimized.
comment:3
Hello Bruno, Actually, I discussed this with Karim Belabas in Bordeaux few weeks ago. We should either call Pari or stick to their implementation. It is much faster:
Moreover they do have the function Vincent |
comment:5
Replying to @videlec:
It is not surprising indeed that Pari is faster for this. I don't understand what you mean by
Do you mean there are two ways to use Pari's implementation? |
comment:6
Replying to @bgrenet:
Nope. Either we should copy their implementation within Sage (I do not think this is justified) or just call Pari. And by the way there are two ways of using pari. Either with Vincent |
comment:7
A side remark: I would like to have a certificate (something like : this is the cyclotomic polynomial Phi_20) Is this allowed by the pari function ? |
comment:8
Replying to @fchapoton:
Of course ;-) From pari documentation
and you can already use it
Vincent |
comment:9
Replying to @videlec:
For concreteness, what do you propose to do now? If I understand correctly, you propose to wait for #17631 and then make |
comment:10
Replying to @bgrenet:
For now, we can already do the thing I proposed with the gp interface (and return the certificate instead of Vincent |
comment:11
Replying to @videlec:
I am not sure to agree since it actually makes the function slower: sage: p = cyclotomic_polynomial(150)
sage: %timeit p.is_cyclotomic()
100 loops, best of 3: 2.75 ms per loop
sage: %timeit p._gp_().poliscyclo()
100 loops, best of 3: 3.96 ms per loop As an aside, isn't it a problem for a method named |
comment:12
Replying to @bgrenet:
Right. Most of the time seems to be lost in the conversion
You are right. The best option would be:
A compromise can be:
Vincent |
comment:13
Replying to @videlec:
I like this proposition, I'll do it. |
Branch pushed to git repo; I updated commit sha1. New commits:
|
comment:15
Just typographical comment. The
Have a look to Docstring section of the developer manual. It is I would move the Vincent |
comment:16
I pushed too fast, and noticed my mistake on Thanks anyway for the feedback, and especially for the documentation! |
Branch pushed to git repo; I updated commit sha1. New commits:
|
comment:19
One more thing for the doc: for trac tickets you should use More seriously, we definitely do not want to test irreducibility at the beginning. You can possibly add this test in between step 2 and 3. That would prevent some useless factorization. But if you do so, I want to see some benchmarks first. Vincent |
comment:21
Replying to @videlec:
OK.
I do not understand your remark: irreducibility was tested as the first step before, and moving this test later is precisely the purpose of my ticket. |
comment:22
Replying to @bgrenet:
Right ;-) I will try a bit more optimization on my side. |
Branch pushed to git repo; I updated commit sha1. New commits:
|
comment:25
Actually, the factor at the end is overkill as we only want a square root. I did have a look at the method I am happy with your commits. Just review mine. Vincent New commits:
|
Changed branch from u/bruno/slightly_fasten_is_cyclotomic__ to u/vdelecroix/17695 |
Changed branch from u/vdelecroix/17695 to u/bruno/17695 |
comment:27
Replying to @videlec:
I am fine with your commit too, but for one typo that I've corrected in the docstring of def is_square(self, root=False):
"""
Returns whether or not polynomial is square. If the optional
- argument ``root`` is set to ``True, then also returns the square root
+ argument ``root`` is set to ``True``, then also returns the square root
(or ``None``, if the polynomial is not square). I do not know whether it is acceptable for me to set "positive review". I let you do so if you consider everything's OK. Thanks for the patient feedback! New commits:
|
comment:28
Looks good to me. I have just made a few typographical changes, so I allow myself to put this into positive review. New commits:
|
Changed branch from u/bruno/17695 to public/ticket/17695 |
comment:29
Ho great! Nice catch! Vincent |
Reviewer: Frédéric Chapoton |
Changed branch from public/ticket/17695 to |
In
src/sage/rings/polynomial/polynomial_element.pyx
, the methodis_cyclotomic()
begins by checking the irreducibility of the input polynomial, and then checks the leading and constant coefficients. I simply propose to invert those tests to fasten a bit the test for polynomials that are not monic or whose constant coefficient is not1
.CC: @fchapoton
Component: number theory
Keywords: cyclotomic polynomials
Author: Bruno Grenet
Branch/Commit:
a2a6f02
Reviewer: Frédéric Chapoton
Issue created by migration from https://trac.sagemath.org/ticket/17695
The text was updated successfully, but these errors were encountered: