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

Open
bmkessler opened this Issue Sep 21, 2017 · 2 comments

Comments

Projects
None yet
3 participants
@bmkessler
Copy link
Contributor

bmkessler commented Sep 21, 2017

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

This comment has been minimized.

Copy link
Contributor

ianlancetaylor commented Sep 21, 2017

@ALTree

This comment has been minimized.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.