-
Notifications
You must be signed in to change notification settings - Fork 32
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
Factor is terribly slow #49
Comments
this is pull request. |
Did you mean |
@rfourquet that's what I did on my machine, but I forgo to change it on GitHub, where I was preparing this issue. This number however avoids calling Pollard Rho at all. |
Currently, As an experiment, I implemented the Continued Fraction Factorization Method (CFRAC) in Julia, which is able to factorize The code is available at: It works best for numbers with 30-50 digits in size that do not have small factors. Additionally, a very simple implementation of the Elliptic Curve Factorization Method (ECM) in Julia: It can find very quickly factors of about 10-17 digits in size, without strongly depending on the size of Feel free to use both methods inside the More special-purpose factorization algorithms are described at: |
@trizen would you be willing to re-license ecm to an MIT license? I would be interested in adding them to Primes.jl for factoring numbers. |
I removed any license restrictions. Life is too short to care about licenses and arbitrary restrictions. :) |
Can you confirm I haven't done anything especially stupid here? #104 |
Also, how hard do you think it would be to add the second stage of the algorithm? According to https://www.rieselprime.de/ziki/Elliptic_curve_method it can significantly increase the success chance. |
Looks good to me.
Should be doable, although I haven't tried implementing the second stage. Maybe @danaj can provide some help here. See also: https://github.com/danaj/Math-Prime-Util-GMP/blob/master/ecm.c#L487 |
Regarding the second stage of the ECM, the SymPy library has very nice and readable code for it: https://github.com/sympy/sympy/blob/master/sympy/ntheory/ecm.py Just for fun, I also made two translations of the Python code (a slightly older version), which can also be used for reference: |
I got most of the way time with a Julia implementation in #104 |
Hello.
I believe that after finding every consecutive prime factor, performing
isprime
on resultant is harmful for performance of such function. Consider such snippet:Compare it with equivalent Python:
Considering the fact that
sympy
is written in pure Python, this is pathetic.Profiling Julia version brings such result (this time taking the product of first 3000 primes):
Ha! I suspected that checking is number is prime after excluding one particular factor is superfluous, and I know it's basically one of the worst cases for such design, but after all, how such difference in time (with sympy) could be explained?
I propose the call to
isprime
to be supressed.The text was updated successfully, but these errors were encountered: