# Class LongCarryCRTStepStrategy

java.lang.Object
org.apfloat.internal.LongBaseMath
org.apfloat.internal.LongCRTMath
org.apfloat.internal.LongCarryCRTStepStrategy

All Implemented Interfaces:
  `Serializable, CarryCRTStepStrategy<long[]>`

public class LongCarryCRTStepStrategy extends LongCRTMath implements CarryCRTStepStrategy<long[]>
Class for performing the final steps of a three-modulus Number Theoretic Transform based convolution. Works for the `long` type.

All access to this class must be externally synchronized.

Since:
  1.7.0
Version:
  1.9.0
Author:
  Mikko Tommila
See Also:
  - Serialized Form

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `LongCarryCRTStepStrategy(int radix)`
  Creates a carry-CRT steps object using the specified radix.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `long[]`
  `carry(DataStorage dataStorage, long size, long resultSize, long offset, long length, long[] results, long[] previousResults)`
  Propagate carries from the previous block computed with the CRT method.
  `long[]`
  `crt(DataStorage resultMod0, DataStorage resultMod1, DataStorage resultMod2, DataStorage dataStorage, long size, long resultSize, long offset, long length)`
  Perform the Chinese Remainder Theorem (CRT) on each element of the three result data sets to get the result of each element modulo the product of the three moduli.

  ### Methods inherited from class LongCRTMath

  `add, compare, divide, multiply, subtract`

  ### Methods inherited from class LongBaseMath

  `baseAdd, baseDivide, baseMultiplyAdd, baseSubtract`

  ### Methods inherited from class Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### LongCarryCRTStepStrategy

    public LongCarryCRTStepStrategy(int radix)
    Creates a carry-CRT steps object using the specified radix.
    Parameters:
      `radix` - The radix that will be used.

- ## Method Details

  - ### crt

    public long[] crt(DataStorage resultMod0, DataStorage resultMod1, DataStorage resultMod2, DataStorage dataStorage, long size, long resultSize, long offset, long length) throws ApfloatRuntimeException
    Description copied from interface: `CarryCRTStepStrategy`
    Perform the Chinese Remainder Theorem (CRT) on each element of the three result data sets to get the result of each element modulo the product of the three moduli. Then it calculates the carries for the block of data to get the final result.

    Note that the return value's initial word may be zero or non-zero, depending on how large the result is.

    Assumes that `MODULUS[0] > MODULUS[1] > MODULUS[2]`.

    Specified by:
      `crt` in interface `CarryCRTStepStrategy<long[]>`
    Parameters:
      `resultMod0` - The result modulo `MODULUS[0]`.
      `resultMod1` - The result modulo `MODULUS[1]`.
      `resultMod2` - The result modulo `MODULUS[2]`.
      `dataStorage` - The destination data storage of the computation.
      `size` - The number of elements in the whole data set.
      `resultSize` - The number of elements needed in the final result.
      `offset` - The offset within the data for the block to be computed.
      `length` - Length of the block to be computed.
    Returns:
      The carries overflowing from this block (two elements).
    Throws:
      `ApfloatRuntimeException`

  - ### carry

    public long[] carry(DataStorage dataStorage, long size, long resultSize, long offset, long length, long[] results, long[] previousResults) throws ApfloatRuntimeException
    Description copied from interface: `CarryCRTStepStrategy`
    Propagate carries from the previous block computed with the CRT method.
    Specified by:
      `carry` in interface `CarryCRTStepStrategy<long[]>`
    Parameters:
      `dataStorage` - The destination data storage of the computation.
      `size` - The number of elements in the whole data set.
      `resultSize` - The number of elements needed in the final result.
      `offset` - The offset within the data for the block to be computed.
      `length` - Length of the block to be computed.
      `results` - The carry overflow from this block (two elements).
      `previousResults` - The carry overflow from the previous block (two elements).
    Returns:
      The carries overflowing from this block (two elements).
    Throws:
      `ApfloatRuntimeException`