| java.lang.Object java.math.Division
Division | class Division (Code) | | Static library that provides all operations related with division and modular
arithmetic to
BigInteger . Some methods are provided in both mutable
and immutable way. There are several variants provided listed below:
- Division
- Modular arithmetic
author: Intel Middleware Product Division author: Instituto Tecnologico de Cordoba |
Method Summary | |
static int[] | divide(int quot, int quotLength, int a, int aLength, int b, int bLength) Divides the array 'a' by the array 'b' and gets the quotient and the
remainder. | static BigInteger[] | divideAndRemainderByInteger(BigInteger val, int divisor, int divisorSign) Computes the quotient and the remainder after a division by an
int number. | static int | divideArrayByInt(int dest, int src, int srcLength, int divisor) Divides an array by an integer value. | static long | divideLongByInt(long a, int b) Divides an unsigned long a by an unsigned int b. | static BigInteger | evenModPow(BigInteger base, BigInteger exponent, BigInteger modulus) Performs modular exponentiation using the Montgomery Reduction. | static BigInteger | finalSubtraction(int t, int tLength, int s, BigInteger modulus) | static BigInteger | gcdBinary(BigInteger op1, BigInteger op2) | static long | gcdBinary(long op1, long op2) Performs the same as
Division.gcdBinary(BigInteger,BigInteger) , but
with numbers of 63 bits, represented in positives values of
long type. | static void | inplaceModPow2(BigInteger x, int n) Performs
x = x mod (2n) . | static BigInteger | modInverseLorencz(BigInteger a, BigInteger modulo) Based on "New Algorithm for Classical Modular Inverse" Róbert Lórencz. | static BigInteger | modInverseMontgomery(BigInteger a, BigInteger p) | static BigInteger | modPow2Inverse(BigInteger x, int n) Parameters: x - an odd positive number. Parameters: n - the exponent by which 2 is raised. | static BigInteger | monPro(BigInteger a, BigInteger b, BigInteger modulus, long n2) Implements the Montgomery Product of two integers represented by
int arrays. | static BigInteger | monSquare(BigInteger aBig, BigInteger modulus, long n2) Implements the Montgomery Square of a BigInteger. | static int | multiplyAndSubtract(int a, int start, int b, int bLen, long c) Multiplies an array by int and subtracts it from a subarray of another
array. | static BigInteger | oddModPow(BigInteger base, BigInteger exponent, BigInteger modulus) Performs modular exponentiation using the Montgomery Reduction. | static BigInteger | pow2ModPow(BigInteger base, BigInteger exponent, int j) It requires that all parameters be positive. | static int | remainder(BigInteger dividend, int divisor) Divides a BigInteger by a signed int and
returns the remainder.
Parameters: dividend - the BigInteger to be divided. | static int | remainderArrayByInt(int src, int srcLength, int divisor) Divides an array by an integer value. | static BigInteger | slidingWindow(BigInteger x2, BigInteger a2, BigInteger exponent, BigInteger modulus, long n2) | static BigInteger | squareAndMultiply(BigInteger x2, BigInteger a2, BigInteger exponent, BigInteger modulus, long n2) |
divide | static int[] divide(int quot, int quotLength, int a, int aLength, int b, int bLength)(Code) | | Divides the array 'a' by the array 'b' and gets the quotient and the
remainder. Implements the Knuth's division algorithm. See D. Knuth, The
Art of Computer Programming, vol. 2. Steps D1-D8 correspond the steps in
the algorithm description.
Parameters: quot - the quotient Parameters: quotLength - the quotient's length Parameters: a - the dividend Parameters: aLength - the dividend's length Parameters: b - the divisor Parameters: bLength - the divisor's length the remainder |
divideAndRemainderByInteger | static BigInteger[] divideAndRemainderByInteger(BigInteger val, int divisor, int divisorSign)(Code) | | Computes the quotient and the remainder after a division by an
int number.
an array of the form [quotient, remainder] . |
divideArrayByInt | static int divideArrayByInt(int dest, int src, int srcLength, int divisor)(Code) | | Divides an array by an integer value. Implements the Knuth's division
algorithm. See D. Knuth, The Art of Computer Programming, vol. 2.
Parameters: dest - the quotient Parameters: src - the dividend Parameters: srcLength - the length of the dividend Parameters: divisor - the divisor remainder |
divideLongByInt | static long divideLongByInt(long a, int b)(Code) | | Divides an unsigned long a by an unsigned int b. It is supposed that the
most significant bit of b is set to 1, i.e. b < 0
Parameters: a - the dividend Parameters: b - the divisor the long value containing the unsigned integer remainder in theleft half and the unsigned integer quotient in the right half |
evenModPow | static BigInteger evenModPow(BigInteger base, BigInteger exponent, BigInteger modulus)(Code) | | Performs modular exponentiation using the Montgomery Reduction. It
requires that all parameters be positive and the modulus be even. Based
The square and multiply algorithm and the Montgomery Reduction C. K.
Koc - Montgomery Reduction with Even Modulus. The square and
multiply algorithm and the Montgomery Reduction.
See Also: BigInteger.modPow(BigIntegerBigInteger) |
inplaceModPow2 | static void inplaceModPow2(BigInteger x, int n)(Code) | | Performs
x = x mod (2n) .
Parameters: x - a positive number, it will store the result. Parameters: n - a positive exponent of 2 . |
modInverseLorencz | static BigInteger modInverseLorencz(BigInteger a, BigInteger modulo)(Code) | | Based on "New Algorithm for Classical Modular Inverse" Róbert Lórencz.
LNCS 2523 (2002)
a^(-1) mod m |
modInverseMontgomery | static BigInteger modInverseMontgomery(BigInteger a, BigInteger p)(Code) | | Calculates a.modInverse(p) Based on: Savas, E; Koc, C "The Montgomery Modular
Inverse - Revised"
|
modPow2Inverse | static BigInteger modPow2Inverse(BigInteger x, int n)(Code) | | Parameters: x - an odd positive number. Parameters: n - the exponent by which 2 is raised. x-1 (mod 2n) . |
multiplyAndSubtract | static int multiplyAndSubtract(int a, int start, int b, int bLen, long c)(Code) | | Multiplies an array by int and subtracts it from a subarray of another
array.
Parameters: a - the array to subtract from Parameters: start - the start element of the subarray of a Parameters: b - the array to be multiplied and subtracted Parameters: bLen - the length of b Parameters: c - the multiplier of b the carry element of subtraction |
oddModPow | static BigInteger oddModPow(BigInteger base, BigInteger exponent, BigInteger modulus)(Code) | | Performs modular exponentiation using the Montgomery Reduction. It
requires that all parameters be positive and the modulus be odd. >
See Also: BigInteger.modPow(BigIntegerBigInteger) See Also: Division.monPro(BigInteger,BigInteger,BigInteger,long) See Also: Division.slidingWindow(BigInteger,BigInteger,BigInteger,BigInteger,long) See Also: Division.squareAndMultiply(BigInteger,BigInteger,BigInteger,BigInteger,long) |
remainder | static int remainder(BigInteger dividend, int divisor)(Code) | | Divides a BigInteger by a signed int and
returns the remainder.
Parameters: dividend - the BigInteger to be divided. Must be non-negative. Parameters: divisor - a signed int divide % divisor |
remainderArrayByInt | static int remainderArrayByInt(int src, int srcLength, int divisor)(Code) | | Divides an array by an integer value. Implements the Knuth's division
algorithm. See D. Knuth, The Art of Computer Programming, vol. 2.
Parameters: src - the dividend Parameters: srcLength - the length of the dividend Parameters: divisor - the divisor remainder |
|
|