org.apfloat.internal
Class DoubleParallelFNTStrategy
java.lang.Object
org.apfloat.internal.DoubleElementaryModMath
org.apfloat.internal.DoubleModMath
org.apfloat.internal.DoubleTableFNTStrategy
org.apfloat.internal.DoubleParallelFNTStrategy
- All Implemented Interfaces:
- ParallelNTTStrategy, NTTStrategy
- Direct Known Subclasses:
- DoubleFactor3SixStepNTTStrategy, DoubleSixStepFNTStrategy, DoubleTwoPassFNTStrategy
public abstract class DoubleParallelFNTStrategy
- extends DoubleTableFNTStrategy
- implements ParallelNTTStrategy
Common methods to calculate Fast Number Theoretic Transforms
in parallel using multiple threads.
Note that to get any performance gain from running many
threads in parallel, the JVM must be executing native threads.
If the JVM is running in green threads mode, there is no
advantage of having multiple threads, as the JVM will in fact
execute just one thread and divide its time to multiple
simulated threads.
- Version:
- 1.5.1
- Author:
- Mikko Tommila
Method Summary |
protected void |
multiplyElements(ArrayAccess arrayAccess,
int startRow,
int rows,
int columns,
double w,
double scaleFactor)
Multiply each matrix element (i, j) by wi * j * scaleFactor . |
void |
setParallelRunner(ParallelRunner parallelRunner)
Set the parallel runner to be used when executing the transform. |
protected void |
transformRows(int length,
int count,
boolean isInverse,
ArrayAccess arrayAccess,
double[] wTable,
int[] permutationTable)
Transform the rows of the data matrix. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
parallelRunner
protected ParallelRunner parallelRunner
- The parallel runner.
DoubleParallelFNTStrategy
protected DoubleParallelFNTStrategy()
- Default constructor.
setParallelRunner
public void setParallelRunner(ParallelRunner parallelRunner)
- Description copied from interface:
ParallelNTTStrategy
- Set the parallel runner to be used when executing the transform.
- Specified by:
setParallelRunner
in interface ParallelNTTStrategy
- Parameters:
parallelRunner
- The parallel runner.
multiplyElements
protected void multiplyElements(ArrayAccess arrayAccess,
int startRow,
int rows,
int columns,
double w,
double scaleFactor)
throws ApfloatRuntimeException
- Multiply each matrix element
(i, j)
by wi * j * scaleFactor
.
The matrix size is n1 x n2.
- Parameters:
arrayAccess
- The memory array to multiply.startRow
- Which row in the whole matrix the starting row in the arrayAccess
is.rows
- The number of rows in the arrayAccess
to multiply.columns
- The number of columns in the matrix (= n2).w
- The n:th root of unity (where n = n1 * n2).scaleFactor
- An extra factor by which all elements are multiplied.
- Throws:
ApfloatRuntimeException
transformRows
protected void transformRows(int length,
int count,
boolean isInverse,
ArrayAccess arrayAccess,
double[] wTable,
int[] permutationTable)
throws ApfloatRuntimeException
- Transform 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 using
ApfloatContext.getNumberOfProcessors()
.
- Parameters:
length
- Length of one transform (one row).count
- Number of rows.isInverse
- true
if an inverse transform is performed, false
if a forward transform is performed.arrayAccess
- The memory array to split to rows and to transform.wTable
- Table of powers of n:th root of unity (where n is the transform length
).permutationTable
- Table of permutation indexes, or null
if no permutation should be done.
- Throws:
ApfloatRuntimeException