|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Object | +--de.flexiprovider.common.math.IntegerFunctions
Class of number-theory related functions for use with integers represented as int's or FlexiBigInt objects.
| Method Summary | |
static FlexiBigInt |
binomial(int n,
int t)
Computes the binomial coefficient (n|t) ("n over t"). |
static int |
bitCount(int a)
|
static int |
ceilLog(FlexiBigInt a)
Compute the smallest integer that is greater than or equal to the logarithm to the base 2 of the given FlexiBigInt. |
static int |
ceilLog(int a)
Compute the smallest integer that is greater than or equal to the logarithm to the base 2 of the given integer. |
static int |
ceilLog256(int n)
Compute ceil(log_256 n), the number of bytes needed to encode the integer n. |
static int |
ceilLog256(long n)
Compute ceil(log_256 n), the number of bytes needed to encode the long integer n. |
static FlexiBigInt[] |
divideAndRound(FlexiBigInt[] a,
FlexiBigInt b)
|
static FlexiBigInt |
divideAndRound(FlexiBigInt a,
FlexiBigInt b)
|
static FlexiBigInt[] |
extgcd(FlexiBigInt a,
FlexiBigInt b)
Extended euclidian algorithm (computes gcd and representation). |
static int[] |
extGCD(int a,
int b)
Extended euclidian algorithm (computes gcd and representation). |
static float |
floatLog(float param)
Calculation of a logarithmus of a float param |
static float |
floatPow(float f,
int i)
int power of a base float, only use for small ints |
static int |
floorLog(FlexiBigInt a)
Compute the integer part of the logarithm to the base 2 of the given integer. |
static int |
floorLog(int a)
Compute the integer part of the logarithm to the base 2 of the given integer. |
static int |
gcd(int u,
int v)
Computes the greatest common divisor of the two specified integers |
static byte[] |
integerToOctets(FlexiBigInt val)
|
static float |
intRoot(int base,
int root)
Takes an approximation of the root from an integer base, using newton's algorithm |
static boolean |
isIncreasing(int[] a)
|
static int |
isPower(int a,
int p)
Tests whether an integer a is power of another integer p. |
static boolean |
isPrime(int n)
Miller-Rabin-Test, determines wether the given integer is probably prime or composite. |
static int |
jacobi(FlexiBigInt A,
FlexiBigInt B)
Computes the value of the Jacobi symbol (A|B). |
static FlexiBigInt |
leastCommonMultiple(FlexiBigInt[] numbers)
Computation of the least common multiple of a set of FlexiBigInts. |
static int |
leastDiv(int a)
Find and return the least non-trivial divisor of an integer a. |
static double |
log(double x)
Deprecated. use MathFunctions.log(double) instead |
static double |
log(long x)
Deprecated. use MathFunctions.log(long) instead |
static void |
main(java.lang.String[] args)
|
static int |
maxPower(int a)
Compute the largest h with 2^h | a if a!=0. |
static long |
mod(long a,
long m)
Returns a long integer whose value is (a mod m). |
static int |
modInverse(int a,
int mod)
Computes the modular inverse of an integer a |
static long |
modInverse(long a,
long mod)
Computes the modular inverse of an integer a |
static int |
modPow(int a,
int e,
int n)
Compute ae mod n. |
static FlexiBigInt |
nextPrime(long n)
Computes the next prime greater than n. |
static FlexiBigInt |
nextProbablePrime(FlexiBigInt n)
Compute the next probable prime greater than n with the default certainty (20). |
static FlexiBigInt |
nextProbablePrime(FlexiBigInt n,
int certainty)
Compute the next probable prime greater than n with the specified certainty. |
static int |
nextSmallerPrime(int n)
Returns the largest prime smaller than the given integer |
static FlexiBigInt |
octetsToInteger(byte[] data)
|
static FlexiBigInt |
octetsToInteger(byte[] data,
int offset,
int length)
|
static int |
order(int g,
int p)
determines the order of g modulo p, p prime and 1 < g < p. |
static boolean |
passesSmallPrimeTest(FlexiBigInt candidate)
Short trial-division test to find out whether a number is not prime. |
static int |
pow(int a,
int e)
Compute ae. |
static long |
pow(long a,
int e)
Compute ae. |
static FlexiBigInt |
randomize(FlexiBigInt upperBound)
|
static FlexiBigInt |
randomize(FlexiBigInt upperBound,
SecureRandom prng)
|
static FlexiBigInt |
reduceInto(FlexiBigInt n,
FlexiBigInt begin,
FlexiBigInt end)
Reduces an integer into a given interval |
static FlexiBigInt |
ressol(FlexiBigInt a,
FlexiBigInt p)
Computes the square root of a FlexiBigInt modulo a prime employing the Shanks-Tonelli algorithm. |
static FlexiBigInt |
squareRoot(FlexiBigInt a)
Extract the truncated square root of a FlexiBigInt. |
| Methods inherited from class java.lang.Object |
|
| Method Detail |
public static int jacobi(FlexiBigInt A,
FlexiBigInt B)
(A|B) = 0 IF gcd(A,B) > 1
(-1|B) = 1 IF n = 1 (mod 1)
(-1|B) = -1 IF n = 3 (mod 4)
(A|B) (C|B) = (AC|B)
(A|B) (A|C) = (A|CB)
(A|B) = (C|B) IF A = C (mod B)
(2|B) = 1 IF N = 1 OR 7 (mod 8)
(2|B) = 1 IF N = 3 OR 5 (mod 8)
A - integer valueB - integer value
public static FlexiBigInt ressol(FlexiBigInt a,
FlexiBigInt p)
throws NoQuadraticResidueException
a - value out of which we extract the square rootp - prime modulus that determines the underlying fieldNoQuadraticResidueException - if a is a quadratic non-residue modulo p
public static int gcd(int u,
int v)
u - - first integerv - - second integer
public static int[] extGCD(int a,
int b)
a - the first integerb - the second integer
public static FlexiBigInt divideAndRound(FlexiBigInt a,
FlexiBigInt b)
public static FlexiBigInt[] divideAndRound(FlexiBigInt[] a,
FlexiBigInt b)
public static int ceilLog(FlexiBigInt a)
a - the integerpublic static int ceilLog(int a)
a - the integerpublic static int ceilLog256(int n)
n - the integerpublic static int ceilLog256(long n)
n - the long integerpublic static int floorLog(FlexiBigInt a)
a - the integerpublic static int floorLog(int a)
a - the integerpublic static int maxPower(int a)
a - an integerpublic static int bitCount(int a)
a - an integer
public static int order(int g,
int p)
g - an integer with 1 < g < pp - a prime
public static FlexiBigInt reduceInto(FlexiBigInt n,
FlexiBigInt begin,
FlexiBigInt end)
n - - the integerbegin - - left bound of the intervalend - - right bound of the interval
public static int pow(int a,
int e)
a - the basee - the exponent
public static long pow(long a,
int e)
a - the basee - the exponent
public static int modPow(int a,
int e,
int n)
a - the basee - the exponentn - the modulus
public static FlexiBigInt[] extgcd(FlexiBigInt a,
FlexiBigInt b)
a - - the first integerb - - the second integerpublic static FlexiBigInt leastCommonMultiple(FlexiBigInt[] numbers)
numbers - - the set of numbers
public static long mod(long a,
long m)
a - value on which the modulo operation has to be performed.m - the modulus.
public static int modInverse(int a,
int mod)
a - - the integer to invertmod - - the modulus
public static long modInverse(long a,
long mod)
a - - the integer to invertmod - - the modulus
public static int isPower(int a,
int p)
a - - the first integerp - - the second integerpublic static int leastDiv(int a)
a - - the integerpublic static boolean isPrime(int n)
n - the integer to test for primalitypublic static boolean passesSmallPrimeTest(FlexiBigInt candidate)
candidate - the number to testpublic static int nextSmallerPrime(int n)
n - - upper bound
public static FlexiBigInt nextProbablePrime(FlexiBigInt n,
int certainty)
n - a integer numbercertainty - the certainty that the generated number is primepublic static FlexiBigInt nextProbablePrime(FlexiBigInt n)
n - a integer numberpublic static FlexiBigInt nextPrime(long n)
n - a integer number
public static FlexiBigInt binomial(int n,
int t)
n - - the "upper" integert - - the "lower" integerpublic static FlexiBigInt randomize(FlexiBigInt upperBound)
public static FlexiBigInt randomize(FlexiBigInt upperBound,
SecureRandom prng)
public static FlexiBigInt squareRoot(FlexiBigInt a)
a - - value out of which we extract the square root
public static float intRoot(int base,
int root)
base - the base to take the root fromroot - the root, for example 2 for a square rootpublic static float floatLog(float param)
param -
public static float floatPow(float f,
int i)
f - i - public static double log(double x)
x - any double valuepublic static double log(long x)
x - any long value >=1public static boolean isIncreasing(int[] a)
public static byte[] integerToOctets(FlexiBigInt val)
public static FlexiBigInt octetsToInteger(byte[] data,
int offset,
int length)
public static FlexiBigInt octetsToInteger(byte[] data)
public static void main(java.lang.String[] args)
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||