Package org.apfloat.internal
Class DoubleCarryCRTStepStrategy
- java.lang.Object
-
- org.apfloat.internal.DoubleBaseMath
-
- org.apfloat.internal.DoubleCRTMath
-
- org.apfloat.internal.DoubleCarryCRTStepStrategy
-
- All Implemented Interfaces:
java.io.Serializable,CarryCRTStepStrategy<double[]>
public class DoubleCarryCRTStepStrategy extends DoubleCRTMath implements CarryCRTStepStrategy<double[]>
Class for performing the final steps of a three-modulus Number Theoretic Transform based convolution. Works for thedoubletype.All access to this class must be externally synchronized.
- Since:
- 1.7.0
- Version:
- 1.9.0
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description private static double[]M01private static double[]M012private static double[]M02private static double[]M12private static DoubleModMathMATH_MOD_0private static DoubleModMathMATH_MOD_1private static DoubleModMathMATH_MOD_2private static longserialVersionUIDprivate static doubleT0private static doubleT1private static doubleT2
-
Constructor Summary
Constructors Constructor Description DoubleCarryCRTStepStrategy(int radix)Creates a carry-CRT steps object using the specified radix.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private static DataStorage.IteratorarrayIterator(double[] data)private doublebaseCarry(DataStorage.Iterator srcDst, double carry, long size)double[]carry(DataStorage dataStorage, long size, long resultSize, long offset, long length, double[] results, double[] previousResults)Propagate carries from the previous block computed with the CRT method.private static DataStorage.IteratorcompositeIterator(DataStorage.Iterator iterator1, long size, DataStorage.Iterator iterator2)double[]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 org.apfloat.internal.DoubleCRTMath
add, compare, divide, multiply, subtract
-
Methods inherited from class org.apfloat.internal.DoubleBaseMath
baseAdd, baseDivide, baseMultiplyAdd, baseSubtract
-
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
MATH_MOD_0
private static final DoubleModMath MATH_MOD_0
-
MATH_MOD_1
private static final DoubleModMath MATH_MOD_1
-
MATH_MOD_2
private static final DoubleModMath MATH_MOD_2
-
T0
private static final double T0
-
T1
private static final double T1
-
T2
private static final double T2
-
M01
private static final double[] M01
-
M02
private static final double[] M02
-
M12
private static final double[] M12
-
M012
private static final double[] M012
-
-
Method Detail
-
crt
public double[] crt(DataStorage resultMod0, DataStorage resultMod1, DataStorage resultMod2, DataStorage dataStorage, long size, long resultSize, long offset, long length) throws ApfloatRuntimeException
Description copied from interface:CarryCRTStepStrategyPerform 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:
crtin interfaceCarryCRTStepStrategy<double[]>- Parameters:
resultMod0- The result moduloMODULUS[0].resultMod1- The result moduloMODULUS[1].resultMod2- The result moduloMODULUS[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 double[] carry(DataStorage dataStorage, long size, long resultSize, long offset, long length, double[] results, double[] previousResults) throws ApfloatRuntimeException
Description copied from interface:CarryCRTStepStrategyPropagate carries from the previous block computed with the CRT method.- Specified by:
carryin interfaceCarryCRTStepStrategy<double[]>- 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
-
baseCarry
private double baseCarry(DataStorage.Iterator srcDst, double carry, long size) throws ApfloatRuntimeException
- Throws:
ApfloatRuntimeException
-
arrayIterator
private static DataStorage.Iterator arrayIterator(double[] data)
-
compositeIterator
private static DataStorage.Iterator compositeIterator(DataStorage.Iterator iterator1, long size, DataStorage.Iterator iterator2)
-
-