# Class ThreeNTTConvolutionStrategy

java.lang.Object
org.apfloat.internal.ThreeNTTConvolutionStrategy
All Implemented Interfaces:
`ConvolutionStrategy`
Direct Known Subclasses:
`ParallelThreeNTTConvolutionStrategy`

public class ThreeNTTConvolutionStrategy extends Object implements ConvolutionStrategy
Convolution using three Number Theoretic Transforms and the Chinese Remainder Theorem to get the final result.

Multiplication can be done in linear time in the transform domain, where the multiplication is simply an element-by-element multiplication.

Since:
1.7.0
Version:
1.7.0
Author:
Mikko Tommila
• ## Field Summary

Fields
Modifier and Type
Field
Description
`protected CarryCRTStrategy`
`carryCRTStrategy`
The carry-CRT to use.
`protected NTTStrategy`
`nttStrategy`
The transform to use.
`protected NTTConvolutionStepStrategy`
`stepStrategy`
The convolution steps to use.
• ## Constructor Summary

Constructors
Constructor
Description
```ThreeNTTConvolutionStrategy(int radix, NTTStrategy nttStrategy)```
Creates a new convoluter that uses the specified transform for transforming the data.
• ## Method Summary

Modifier and Type
Method
Description
`protected DataStorage`
```autoConvolute(DataStorage x, long resultSize)```
Convolutes a data set with itself.
`protected DataStorage`
```autoConvoluteOne(DataStorage x, long length, int modulus, boolean cached)```
Performs an autoconvolution modulo one modulus, of the specified transform length.
`DataStorage`
```convolute(DataStorage x, DataStorage y, long resultSize)```
Convolutes the two sets of data.
`protected DataStorage`
```convoluteOne(DataStorage x, DataStorage y, long length, int modulus, boolean cached)```
Performs a convolution modulo one modulus, of the specified transform length.
`protected DataStorage`
`createCachedDataStorage(long size)`
Create a cached (if possible) data storage for the specified number of elements.
`protected DataStorage`
`createDataStorage(DataStorage dataStorage)`
Create a cached data storage from the (possibly) cached data storage.
`protected void`
`lock(long length)`
Lock the execution against a synchronization lock.
`protected void`
`unlock()`
Remove the synchronization lock.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`
• ## Field Details

• ### nttStrategy

protected NTTStrategy nttStrategy
The transform to use.
• ### carryCRTStrategy

protected CarryCRTStrategy carryCRTStrategy
The carry-CRT to use.
• ### stepStrategy

protected NTTConvolutionStepStrategy stepStrategy
The convolution steps to use.
• ## Constructor Details

• ### ThreeNTTConvolutionStrategy

Creates a new convoluter that uses the specified transform for transforming the data.
Parameters:
`radix` - The radix to be used.
`nttStrategy` - The transform to be used.
• ## Method Details

• ### convolute

public DataStorage convolute(DataStorage x, DataStorage y, long resultSize) throws ApfloatRuntimeException
Description copied from interface: `ConvolutionStrategy`
Convolutes the two sets of data.
Specified by:
`convolute` in interface `ConvolutionStrategy`
Parameters:
`x` - First data set.
`y` - Second data set.
`resultSize` - Number of elements needed in the result data.
Returns:
The convolved data.
Throws:
`ApfloatRuntimeException`
• ### convoluteOne

protected DataStorage convoluteOne(DataStorage x, DataStorage y, long length, int modulus, boolean cached) throws ApfloatRuntimeException
Performs a convolution modulo one modulus, of the specified transform length.
Parameters:
`x` - First data set.
`y` - Second data set.
`length` - Length of the transformation.
`modulus` - Which modulus to use.
`cached` - If the result data should be kept cached in memory when possible.
Returns:
The result of the convolution for one modulus.
Throws:
`ApfloatRuntimeException`
• ### autoConvolute

protected DataStorage autoConvolute(DataStorage x, long resultSize) throws ApfloatRuntimeException
Convolutes a data set with itself.
Parameters:
`x` - The data set.
`resultSize` - Number of elements needed in the result data.
Returns:
The convolved data.
Throws:
`ApfloatRuntimeException`
• ### autoConvoluteOne

protected DataStorage autoConvoluteOne(DataStorage x, long length, int modulus, boolean cached) throws ApfloatRuntimeException
Performs an autoconvolution modulo one modulus, of the specified transform length.
Parameters:
`x` - The data set.
`length` - Length of the transformation.
`modulus` - Which modulus to use.
`cached` - If the result data should be kept cached in memory when possible.
Returns:
The result of the convolution for one modulus.
Throws:
`ApfloatRuntimeException`
• ### lock

protected void lock(long length)
Lock the execution against a synchronization lock.
Parameters:
`length` - The length of the data being processed for determining the type of lock to use.
• ### unlock

protected void unlock()
Remove the synchronization lock.
• ### createCachedDataStorage

protected DataStorage createCachedDataStorage(long size) throws ApfloatRuntimeException
Create a cached (if possible) data storage for the specified number of elements.
Parameters:
`size` - The number of elements.
Returns:
The data storage.
Throws:
`ApfloatRuntimeException`
• ### createDataStorage

protected DataStorage createDataStorage(DataStorage dataStorage) throws ApfloatRuntimeException
Create a cached data storage from the (possibly) cached data storage.
Parameters:
`dataStorage` - The data storage, which may be cached.
Returns:
The data storage, which isn't cached.
Throws:
`ApfloatRuntimeException`