Add Gauss-Legendre algorithm for PI
Bug: 25394792
(Cherrypick from calculator tree.)
Make Gauss-Legendre the default, but keep the old one available as
atan_PI for now. We did not yet remove the old atan-based
algorithm, for two distinct reasons:
1. We can test by comparing the two.
2. Depending on the BigInteger implementation, it's conceivable
the old one may be faster in some environments.
In theory, Gauss-Legendre is generally faster if we have an
asymptotically fast BigInteger multiplication or a high constant
overhead for smaller BigInteger computations. With quadratic
multiplication and small constant overhead, atan_PI should be faster.
In practice, Gauss-Legendre currently blows the atan algorithm out of
the water on Android, which satisfies both of the above hypotheses.
Test: Cherrypick of ancient code. Passes AOSP test.
Change-Id: I643038a8f980e8c4e7840d5c978b971677717a8c
2 files changed