| java.lang.Object java.math.Multiplication
Multiplication | class Multiplication (Code) | | Static library that provides all multiplication of
BigInteger methods.
author: Intel Middleware Product Division author: Instituto Tecnologico de Cordoba |
Field Summary | |
final static BigInteger | bigFivePows An array with the first powers of five in
BigInteger version. | final static BigInteger[] | bigTenPows An array with the first powers of ten in
BigInteger version. | final static int | fivePows An array with powers of five that fit in the type
int . | final static int | tenPows An array with powers of ten that fit in the type
int . | final static int | whenUseKaratsuba Break point in digits (number of
int elements)
between Karatsuba and Pencil and Paper multiply. |
Method Summary | |
static BigInteger | karatsuba(BigInteger op1, BigInteger op2) Performs the multiplication with the Karatsuba's algorithm. | static BigInteger | multiply(BigInteger x, BigInteger y) Performs a multiplication of two BigInteger and hides the algorithm used. | static BigInteger | multiplyByFivePow(BigInteger val, int exp) Multiplies a number by a power of five. | static int | multiplyByInt(int a, int aSize, int factor) Multiplies an array of integers by an integer value. | static BigInteger | multiplyByPositiveInt(BigInteger val, int factor) Multiplies a number by a positive integer. | static BigInteger | multiplyByTenPow(BigInteger val, long exp) Multiplies a number by a power of ten. | static BigInteger | multiplyPAP(BigInteger a, BigInteger b) Multiplies two BigIntegers. | static BigInteger | pow(BigInteger base, int exponent) | static BigInteger | powerOf10(long exp) It calculates a power of ten, which exponent could be out of 32-bit range.
Note that internally this method will be used in the worst case with
an exponent equals to:
Integer.MAX_VALUE - Integer.MIN_VALUE .
Parameters: exp - the exponent of power of ten, it must be positive. | static int[] | square(int[] a, int s) |
bigFivePows | final static BigInteger bigFivePows(Code) | | An array with the first powers of five in
BigInteger version.
(
5^0,5^1,...,5^31 )
|
bigTenPows | final static BigInteger[] bigTenPows(Code) | | An array with the first powers of ten in
BigInteger version.
(
10^0,10^1,...,10^31 )
|
fivePows | final static int fivePows(Code) | | An array with powers of five that fit in the type
int .
(
5^0,5^1,...,5^13 )
|
tenPows | final static int tenPows(Code) | | An array with powers of ten that fit in the type
int .
(
10^0,10^1,...,10^9 )
|
whenUseKaratsuba | final static int whenUseKaratsuba(Code) | | Break point in digits (number of
int elements)
between Karatsuba and Pencil and Paper multiply.
|
karatsuba | static BigInteger karatsuba(BigInteger op1, BigInteger op2)(Code) | | Performs the multiplication with the Karatsuba's algorithm.
Karatsuba's algorithm:
u = u1 * B + u0
v = v1 * B + v0
u*v = (u1 * v1) * B2 + ((u1 - u0) * (v0 - v1) + u1 * v1 +
u0 * v0 ) * B + u0 * v0
Parameters: op1 - first factor of the product Parameters: op2 - second factor of the product op1 * op2 See Also: Multiplication.multiply(BigInteger,BigInteger) |
multiplyByFivePow | static BigInteger multiplyByFivePow(BigInteger val, int exp)(Code) | | Multiplies a number by a power of five.
This method is used in
BigDecimal class.
Parameters: val - the number to be multiplied Parameters: exp - a positive int exponent val * 5exp |
multiplyByInt | static int multiplyByInt(int a, int aSize, int factor)(Code) | | Multiplies an array of integers by an integer value.
Parameters: a - the array of integers Parameters: aSize - the number of elements of intArray to be multiplied Parameters: factor - the multiplier the top digit of production |
multiplyByPositiveInt | static BigInteger multiplyByPositiveInt(BigInteger val, int factor)(Code) | | Multiplies a number by a positive integer.
Parameters: val - an arbitrary BigInteger Parameters: factor - a positive int number val * factor |
multiplyByTenPow | static BigInteger multiplyByTenPow(BigInteger val, long exp)(Code) | | Multiplies a number by a power of ten.
This method is used in
BigDecimal class.
Parameters: val - the number to be multiplied Parameters: exp - a positive long exponent val * 10exp |
multiplyPAP | static BigInteger multiplyPAP(BigInteger a, BigInteger b)(Code) | | Multiplies two BigIntegers.
Implements traditional scholar algorithm described by Knuth.
A= |
a3 |
a2 |
a1 |
a0 |
|
|
B= |
|
b2 |
b1 |
b1 |
|
|
|
|
|
b0*a3 |
b0*a2 |
b0*a1 |
b0*a0 |
|
|
b1*a3 |
b1*a2 |
b1*a1 |
b1*a0 |
+ |
b2*a3 |
b2*a2 |
b2*a1 |
b2*a0 |
|
______ |
______ |
______ |
______ |
______ |
______ |
A*B=R= |
r5 |
r4 |
r3 |
r2 |
r1 |
r0 |
|
Parameters: op1 - first factor of the multiplication op1 >= 0 Parameters: op2 - second factor of the multiplication op2 >= 0 a BigInteger of value op1 * op2 |
powerOf10 | static BigInteger powerOf10(long exp)(Code) | | It calculates a power of ten, which exponent could be out of 32-bit range.
Note that internally this method will be used in the worst case with
an exponent equals to:
Integer.MAX_VALUE - Integer.MIN_VALUE .
Parameters: exp - the exponent of power of ten, it must be positive. a BigInteger with value 10exp . |
square | static int[] square(int[] a, int s)(Code) | | Performs a2
Parameters: a - The number to square. Parameters: length - The length of the number to square. |
|
|