public class StepCarryCRTStrategy extends Object implements CarryCRTStrategy, Parallelizable
The algorithm is parallelized for multiprocessor computers, if the data fits in memory.
The parallelization works so that the carry-CRT is done in blocks in parallel. As a final step, a second pass is done through the data set to propagate the carries from one block to the next.
All access to this class must be externally synchronized.
CarryCRTStepStrategy
Constructor and Description |
---|
StepCarryCRTStrategy(int radix)
Creates a carry-CRT object using the specified radix.
|
Modifier and Type | Method and Description |
---|---|
DataStorage |
carryCRT(DataStorage resultMod0,
DataStorage resultMod1,
DataStorage resultMod2,
long resultSize)
Calculate the final result of a three-NTT convolution.
|
protected <T> ParallelRunnable |
createCarryCRTParallelRunnable(Class<T> elementArrayType,
DataStorage resultMod0,
DataStorage resultMod1,
DataStorage resultMod2,
DataStorage dataStorage,
long size,
long resultSize)
Create a ParallelRunnable object for doing the carry-CRT in parallel.
|
public StepCarryCRTStrategy(int radix)
radix
- The radix that will be used.public DataStorage carryCRT(DataStorage resultMod0, DataStorage resultMod1, DataStorage resultMod2, long resultSize) throws ApfloatRuntimeException
Performs a 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 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]
.
carryCRT
in interface CarryCRTStrategy
resultMod0
- The result modulo MODULUS[0]
.resultMod1
- The result modulo MODULUS[1]
.resultMod2
- The result modulo MODULUS[2]
.resultSize
- The number of elements needed in the final result.ApfloatRuntimeException
protected <T> ParallelRunnable createCarryCRTParallelRunnable(Class<T> elementArrayType, DataStorage resultMod0, DataStorage resultMod1, DataStorage resultMod2, DataStorage dataStorage, long size, long resultSize)
T
- The element array type used.elementArrayType
- The element array type used.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.Copyright © 2019. All rights reserved.