Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8278886

Add a parallel multiply method to BigInteger

XMLWordPrintable

    • Icon: CSR CSR
    • Resolution: Approved
    • Icon: P4 P4
    • 19
    • core-libs
    • None
    • source
    • minimal
    • It is technically possible, but unlikely, that a user-defined BigInteger subclass has a conflicting parallel-multiply method.
    • Java API
    • SE

      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 3-way Toom-Cook 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)

            psandoz Paul Sandoz
            webbuggrp Webbug Group
            Brian Burkhalter
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: