Package de.tilman_neumann.jml.gcd
Class Gcd63
java.lang.Object
de.tilman_neumann.jml.gcd.Gcd63
public class Gcd63
extends java.lang.Object
GCD implementations for longs.
The binary gcd is much faster than the Euclidean, and also faster than the built-in BigInteger gcd().
-
Constructor Summary
Constructors Constructor Description Gcd63()
-
Method Summary
Modifier and Type Method Description long
gcd(long a, long b)
Faster binary gcd adapted from OpenJdk's MutableBigInteger.binaryGcd(int, int).java.lang.Long
gcd(java.util.Collection<java.lang.Long> arguments)
GCD of all arguments.long
gcd_binary1(long m, long n)
Binary gcd implementation.long
gcd_euclid_withDivision(long m, long n)
Greatest common divisor of the given two arguments.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Constructor Details
-
Gcd63
public Gcd63()
-
-
Method Details
-
gcd_euclid_withDivision
public long gcd_euclid_withDivision(long m, long n)Greatest common divisor of the given two arguments. Euclid's algorithm implementation with division.- Parameters:
m
-n
-- Returns:
- gcd(m, n)
-
gcd_binary1
public long gcd_binary1(long m, long n)Binary gcd implementation.- Parameters:
m
-n
-- Returns:
- gcd(m, n)
-
gcd
public long gcd(long a, long b)Faster binary gcd adapted from OpenJdk's MutableBigInteger.binaryGcd(int, int).- Parameters:
a
-b
-- Returns:
- gcd(a, b)
-
gcd
public java.lang.Long gcd(java.util.Collection<java.lang.Long> arguments)GCD of all arguments.- Parameters:
arguments
-- Returns:
- gcd of all arguments
-