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

math/big: implement recursive division algorithm #21960

Closed
bmkessler opened this issue Sep 21, 2017 · 3 comments
Closed

math/big: implement recursive division algorithm #21960

bmkessler opened this issue Sep 21, 2017 · 3 comments

Comments

@bmkessler
Copy link
Contributor

math/big currently only has an implementation of "schoolbook" long division which is O(n^2). An implementation of Burnikel and Ziegler's Fast Recursive Division (1998) would improve division's asymptotic complexity to the multiplication time. The multiplication asymptotic complexity is currently ~n^1.6 for the karatsuba implementation, but could be improved with other algorithms in the future and recursive division would automatically benefit.

Note, The Handbook of Elliptic and Hyperelliptic Cryptography Algorithm 10.35 on page 188 has a more explicit version of the div2NxN algorithm. This algorithm is directly recursive and avoids the mutual recursion of the original paper's calls between div2NxN and div3Nx2N. Algorithm 10.35 along with the Burnikel and Ziegler's handling of unbalanced division in blocks of 2NxN "digits" seems like the best candidate for implementation.

In addition to speeding up division in general, this will improve String output #20906 which relies on repeated large divisions.

@ianlancetaylor
Copy link
Contributor

CC @griesemer

@ianlancetaylor ianlancetaylor added this to the Unplanned milestone Sep 21, 2017
@ianlancetaylor ianlancetaylor added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Sep 21, 2017
@ALTree
Copy link
Member

ALTree commented Oct 28, 2017

Note: Burnikel and Ziegler's Fast Recursive Division is also an ingredient of the Karatsuba Square Root algorithm [1], which is the method gmp and mpfr use for computing square roots. It should be faster than the Newton approach currently used in Float.Sqrt.

[1] Paul Zimmermann. Karatsuba Square Root. [Research Report] RR-3805, INRIA. 1999, pp.8.

@ALTree ALTree added Performance and removed NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. labels Oct 28, 2017
@gopherbot
Copy link

Change https://golang.org/cl/172018 mentions this issue: math/big: implement recursive algorithm for division

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

No branches or pull requests

4 participants