Package org.apfloat.internal
Class LongNTTStepStrategy
- java.lang.Object
-
- org.apfloat.internal.LongElementaryModMath
-
- org.apfloat.internal.LongModMath
-
- org.apfloat.internal.LongTableFNT
-
- org.apfloat.internal.LongNTTStepStrategy
-
- All Implemented Interfaces:
Parallelizable,NTTStepStrategy
- Direct Known Subclasses:
LongAparapiNTTStepStrategy
public class LongNTTStepStrategy extends LongTableFNT implements NTTStepStrategy, Parallelizable
Common methods to calculate Fast Number Theoretic Transforms in parallel using multiple threads.All access to this class must be externally synchronized.
- Since:
- 1.7.0
- Version:
- 1.9.0
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private classLongNTTStepStrategy.MultiplyRunnableprivate classLongNTTStepStrategy.TableFNTRunnable
-
Constructor Summary
Constructors Constructor Description LongNTTStepStrategy()Default constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected ParallelRunnablecreateMultiplyElementsParallelRunnable(ArrayAccess arrayAccess, int startRow, int startColumn, int rows, int columns, long length, long totalTransformLength, boolean isInverse, int modulus)Create a ParallelRunnable object for multiplying the elements of the matrix.protected ParallelRunnablecreateTransformRowsParallelRunnable(ArrayAccess arrayAccess, int length, int count, boolean isInverse, boolean permute, int modulus)Create a ParallelRunnable object for transforming the rows of the matrix.longgetMaxTransformLength()Get the maximum transform length.voidmultiplyElements(ArrayAccess arrayAccess, int startRow, int startColumn, int rows, int columns, long length, long totalTransformLength, boolean isInverse, int modulus)Multiply each matrix element(i, j)bywi * j / totalTransformLength.voidtransformRows(ArrayAccess arrayAccess, int length, int count, boolean isInverse, boolean permute, int modulus)Transform the rows of the data matrix.-
Methods inherited from class org.apfloat.internal.LongTableFNT
inverseTableFNT, tableFNT
-
Methods inherited from class org.apfloat.internal.LongModMath
createWTable, getForwardNthRoot, getInverseNthRoot, modDivide, modInverse, modPow, negate
-
Methods inherited from class org.apfloat.internal.LongElementaryModMath
getModulus, modAdd, modMultiply, modSubtract, setModulus
-
-
-
-
Method Detail
-
multiplyElements
public void multiplyElements(ArrayAccess arrayAccess, int startRow, int startColumn, int rows, int columns, long length, long totalTransformLength, boolean isInverse, int modulus) throws ApfloatRuntimeException
Description copied from interface:NTTStepStrategyMultiply each matrix element(i, j)bywi * j / totalTransformLength. The matrix size is n1 x n2.- Specified by:
multiplyElementsin interfaceNTTStepStrategy- Parameters:
arrayAccess- The memory array to multiply.startRow- Which row in the whole matrix the starting row in thearrayAccessis.startColumn- Which column in the whole matrix the starting column in thearrayAccessis.rows- The number of rows in thearrayAccessto multiply.columns- The number of columns in the matrix (= n2).length- The length of data in the matrix being transformed.totalTransformLength- The total transform length, for the scaling factor. Used only for the inverse case.isInverse- If the multiplication is done for the inverse transform or not.modulus- Index of the modulus.- Throws:
ApfloatRuntimeException
-
transformRows
public void transformRows(ArrayAccess arrayAccess, int length, int count, boolean isInverse, boolean permute, int modulus) throws ApfloatRuntimeException
Description copied from interface:NTTStepStrategyTransform the rows of the data matrix. If only one processor is available, it runs all transforms in the current thread. If more than one processor are available, it dispatches the calculations to multiple threads to parallelize the calculation. The number of processors is determined usingApfloatContext.getNumberOfProcessors().- Specified by:
transformRowsin interfaceNTTStepStrategy- Parameters:
arrayAccess- The memory array to split to rows and to transform.length- Length of one transform (one row).count- Number of rows.isInverse-trueif an inverse transform is performed,falseif a forward transform is performed.permute- If permutation should be done.modulus- Index of the modulus.- Throws:
ApfloatRuntimeException
-
getMaxTransformLength
public long getMaxTransformLength()
Description copied from interface:NTTStepStrategyGet the maximum transform length.- Specified by:
getMaxTransformLengthin interfaceNTTStepStrategy- Returns:
- The maximum transform length.
-
createMultiplyElementsParallelRunnable
protected ParallelRunnable createMultiplyElementsParallelRunnable(ArrayAccess arrayAccess, int startRow, int startColumn, int rows, int columns, long length, long totalTransformLength, boolean isInverse, int modulus) throws ApfloatRuntimeException
Create a ParallelRunnable object for multiplying the elements of the matrix.- Parameters:
arrayAccess- The memory array to multiply.startRow- Which row in the whole matrix the starting row in thearrayAccessis.startColumn- Which column in the whole matrix the starting column in thearrayAccessis.rows- The number of rows in thearrayAccessto multiply.columns- The number of columns in the matrix (= n2).length- The length of data in the matrix being transformed.totalTransformLength- The total transform length, for the scaling factor. Used only for the inverse case.isInverse- If the multiplication is done for the inverse transform or not.modulus- Index of the modulus.- Returns:
- An object suitable for multiplying the elements of the matrix in parallel.
- Throws:
ApfloatRuntimeException
-
createTransformRowsParallelRunnable
protected ParallelRunnable createTransformRowsParallelRunnable(ArrayAccess arrayAccess, int length, int count, boolean isInverse, boolean permute, int modulus) throws ApfloatRuntimeException
Create a ParallelRunnable object for transforming the rows of the matrix.- Parameters:
arrayAccess- The memory array to split to rows and to transform.length- Length of one transform (one row).count- Number of rows.isInverse-trueif an inverse transform is performed,falseif a forward transform is performed.permute- If permutation should be done.modulus- Index of the modulus.- Returns:
- An object suitable for transforming the rows of the matrix in parallel.
- Throws:
ApfloatRuntimeException
-
-