Skip to content

math/big: implement recursive division algorithm #21960

@bmkessler

Description

@bmkessler

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions