Files
sdk/pkg/math/lib
srawlins@google.com 400ffc0c48 Addressing Issue 5991, where functions are requested for:
* greatest common denominator
* modulo inverse
* modulo exponentiation

In addition, I implemented functions for least common multiple and extended gcd, as they are so closely related.

These functions are respectively named gcd(), invert(), modexp(), lcm(), gcdext(), provided in the math package,
and tested in the math package.

When passed arguments larger than 2^53, a javascript implementation of dart will yield unpredictable results,
as is true with all of the dart:int methods.

Some of the function names are arbitrary, as they go by different names in different languages:

* For modular multiplicative inverse, I chose "invert." It goes by "invert" in GMP [1], "modInverse" in Java and Go,
"invmod" in Julia, "PowerMod" in Mathematica, and "pow" in Python.
* For modular exponentiation, I chose "powmod." It goes by "powm" in GMP, "exp" in Go, "modPow" in Java,
"powermod" in Julia and Mathematica, and "pow" in Python (optional arg).
* For extended gcd, I chose "gcdext." It goes by "gcdext" in GMP, "gcd" in Go (optional return args), "gcdx" in Julia,
and "ExtendedGCD" in Mathematica.

BUG= https://code.google.com/p/dart/issues/detail?id=5991

[1] https://gmplib.org/

R=lrn@google.com

Review URL: https://codereview.chromium.org//475463005

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@39769 260f80e4-7a28-3924-810f-c04153c831b5
2014-09-02 19:49:48 +00:00
..