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

Slow gcd for sparse polynomials #31957

Open
katestange opened this issue Jun 11, 2021 · 0 comments
Open

Slow gcd for sparse polynomials #31957

katestange opened this issue Jun 11, 2021 · 0 comments

Comments

@katestange
Copy link

The following code produces a couple small sparse polynomials and times the gcd function:

R.<Z> = PolynomialRing(ZZ, sparse=True)
g = R(0)
f = R(0)
for i in range(10):
    g += Z^randint(1,10^5)
    f += Z^randint(1,10^5)
timeit("gcd(f,g)")

The results are disappointing:

5 loops, best of 3: 880 ms per loop

However, if we remove the "sparse=True" tag, the results are much better:

5 loops, best of 3: 46.6 ms per loop

This is highly repeatable, on my laptop and on the single cell server, on both larger and smaller examples. I don't see any essential reason this ought to be true, so I'm calling it a defect, but perhaps the community knows more about the efficiency issues of sparse polynomials...

CC: @katestange

Component: basic arithmetic

Keywords: gcd, polynomials, sparse

Author: katestange

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

@katestange katestange added this to the sage-9.4 milestone Jun 11, 2021
@mkoeppe mkoeppe modified the milestones: sage-9.4, sage-9.5 Jul 19, 2021
@mkoeppe mkoeppe modified the milestones: sage-9.5, sage-9.6 Dec 18, 2021
@mkoeppe mkoeppe modified the milestones: sage-9.6, sage-9.7 Apr 1, 2022
@mkoeppe mkoeppe modified the milestones: sage-9.7, sage-9.8 Aug 31, 2022
@mkoeppe mkoeppe removed this from the sage-9.8 milestone Jan 29, 2023
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

2 participants