Details
Description
Summary
Add a parallel multiply method to BigInteger
.
Problem
Multiplication of large integers is computationally intensive but parallelizable when employing recursive algorithms such as the 3way ToomCook multiplication algorithm.
Solution
Add a method BigInteger.parallelMultiply
that multiplies large integers, typically in the thousands of bits, in parallel utilizing multiple threads, bounded by the number of runtime processors. Thereby, BigInteger.parallelMultiply
is able to compute the same result faster than BigInteger.multiply
. For smaller integers parallelMultiply
computes the result in the calling thread as if by calling multiply
.
Specification
/**
* Returns a BigInteger whose value is {@code (this * val)}.
* When both {@code this} and {@code val} are large, typically
* in the thousands of bits, parallel multiply might be used.
* This method returns the exact same mathematical result as
* {@link #multiply}.
*
* @implNote This implementation may offer better algorithmic
* performance when {@code val == this}.
*
* @implNote Compared to {@link #multiply}, an implementation's
* parallel multiplication algorithm would typically use more
* CPU resources to compute the result faster, and may do so
* with a slight increase in memory consumption.
*
* @param val value to be multiplied by this BigInteger.
* @return {@code this * val}
* @see #multiply
*/
public BigInteger parallelMultiply(BigInteger val)
Attachments
Issue Links
 csr of

JDK8277175 Add a parallel multiply method to BigInteger
 Resolved