public class TiledConvolution extends java.lang.Object implements Convolution
The filter allowing to transform any Convolution
object to another instance of that interface,
which uses some given tiler
for processing the source matrix
(an argument of Convolution
methods).
This object is built on the base of some parent object,
implementing Convolution
, and some tiler (an instance of
TiledApertureProcessorFactory
class).
This object works almost identically to the parent object with the only difference,
that it uses the specified tiler for performing all operations.
More precisely, each method of this object creates an implementation p of ApertureProcessor
interface. The only thing, performed by
process
method of
that object p, is calling the same method of parent object with the arguments
of p.process(dest,src)
method
(the source matrix is retrieved from src, the result is saved into dest).
The dependence aperture p.dependenceAperture(...)
is calculated automatically on the base of the patterns and the performed operation.
Then, the method of this object executes the required operation with help of
tiler()
.tile
(p).process(dest,src)
The method asConvolution(Matrix, WeightedPattern)
is an exception
from this rule. These methods of this class works in the same way, as in
ContinuedConvolution
class, the continuation mode of which is equal to
tiler()
.continuationMode()
.
Note: in improbable cases, when the dimensions of the source matrix and/or
the sizes of the pattern are extremely large (about 2^{63}),
so that the necessary appended matrices should have dimensions or total number of elements,
greater than TiledApertureProcessorFactory
class, "Restriction" section for precise details.
Of course, these are very improbable cases.
This class is immutable and threadsafe: there are no ways to modify settings of the created instance.
AlgART Laboratory 2007–2014
Modifier and Type  Method and Description 

<T extends PArray> 
asConvolution(java.lang.Class<? extends T> requiredType,
Matrix<? extends PArray> src,
WeightedPattern pattern)
Returns an immutable view of the passed source matrix,
such that any reading data from it calculates and returns the convolution
of the source matrix by the specified pattern.

Matrix<? extends PArray> 
asConvolution(Matrix<? extends PArray> src,
WeightedPattern pattern)
Equivalent to
asConvolution (src.type (PArray.class), src, pattern). 
ArrayContext 
context()
Returns the current context used by this instance for all operations.

Convolution 
context(ArrayContext newContext)
Switches the context: returns an instance, identical to this one excepting
that it uses the specified newContext for all operations.

<T extends PArray> 
convolution(java.lang.Class<? extends T> requiredType,
Matrix<? extends PArray> src,
WeightedPattern pattern) 
Matrix<? extends UpdatablePArray> 
convolution(Matrix<? extends PArray> src,
WeightedPattern pattern)
Returns a new updatable matrix, containing the convolution
of the source matrix by the specified pattern.

void 
convolution(Matrix<? extends UpdatablePArray> dest,
Matrix<? extends PArray> src,
WeightedPattern pattern) 
static TiledConvolution 
getInstance(Convolution parent,
TiledApertureProcessorFactory tiler)
Returns new instance of this class with the passed parent
Convolution object
and the specified processing tiler. 
double 
increment(java.lang.Class<?> elementType) 
boolean 
isPseudoCyclic()
Returns true, if this class works in the default
pseudocyclic continuation mode . 
Convolution 
parent()
Returns the parent
Convolution object, passed to
getInstance(Convolution, TiledApertureProcessorFactory) method. 
TiledApertureProcessorFactory 
tiler()
Returns the processing tiler that will be used for tiled processing the source matrices.

public static TiledConvolution getInstance(Convolution parent, TiledApertureProcessorFactory tiler)
Convolution
object
and the specified processing tiler.
Note: the context
of the created object is retrieved from
parent.context()
, and
the context
of the passed tiler
is automatically replaced with the same one — the current tiler
of the created object is context
(newInstance.context()
)context
of the passed tiler is not important
and can be null.
parent
 parent object: the instance of Convolution
interface
that will perform all operations.tiler
 the tiler, which will be used for processing matrices by this class.java.lang.NullPointerException
 if parent or tiler argument is null.public Convolution parent()
Convolution
object, passed to
getInstance(Convolution, TiledApertureProcessorFactory)
method.Convolution
object.public TiledApertureProcessorFactory tiler()
getInstance(Convolution, TiledApertureProcessorFactory)
public ArrayContext context()
ArrayProcessor
ArrayContext.DEFAULT
context.context
in interface ArrayProcessor
public Convolution context(ArrayContext newContext)
subtask
of the full task.
More precisely, this method is equivalent to
getInstance
(parent()
.context
(newContext), tiler()
).
context
in interface ArrayProcessorWithContextSwitching
context
in interface Convolution
newContext
 another context, used by the returned instance; may be null.public boolean isPseudoCyclic()
pseudocyclic continuation mode
.
More precisely, returns true if and only if
tiler()
.continuationMode()
is PSEUDO_CYCLIC
.isPseudoCyclic
in interface Convolution
public double increment(java.lang.Class<?> elementType)
increment
in interface Convolution
public Matrix<? extends PArray> asConvolution(Matrix<? extends PArray> src, WeightedPattern pattern)
Convolution
asConvolution
(src.type
(PArray.class), src, pattern).
In other words, the element type of the returned matrix is chosen the same as in src matrix.asConvolution
in interface Convolution
src
 the source matrix.pattern
 the pattern.public <T extends PArray> Matrix<T> asConvolution(java.lang.Class<? extends T> requiredType, Matrix<? extends PArray> src, WeightedPattern pattern)
Convolution
Convolution.convolution(Class, Matrix, WeightedPattern)
method about the "convolution" term.
The matrix, returned by this method, is immutable, and the class of its builtin array
implements one of the basic interfaces
BitArray
, CharArray
,
ByteArray
, ShortArray
,
IntArray
, LongArray
,
FloatArray
or DoubleArray
.
The class of desired interface (one of 8 possible classes) must be passed as requiredType argument.
So, it defines the element type of the returned matrix.
For example, if requiredType=ByteArray
.class, the returned matrix consists of byte
elements. The rules of casting the real numbers, results of the convolution, to the desired element type
are the same as in
Arrays.asFuncArray(boolean, net.algart.math.functions.Func, Class, PArray...)
method with the argument truncateOverflows=true.
The result is usually "lazy", that means that this method finishes immediately and all
actual calculations are performed while getting elements of the returned matrix.
It is true for all implementations provided by this package.
However, some implementations may not support lazy dilation;
then this method will be equivalent to Convolution.convolution(Class, Matrix, WeightedPattern)
.
Please note: this method does not require time, but the resulting matrix can work slowly!
for example, reading all its content than work much slower than
Convolution.convolution(Class, Matrix, WeightedPattern)
method for some complex patterns.
Usually you should use it only for very little patterns, or if you know that the implementation
of this interface does not provide better algorithm for non"lazy"
Convolution.convolution(Class, , Matrix, WeightedPattern)
method.
asConvolution
in interface Convolution
requiredType
 desired type of the builtin array in the returned matrix.src
 the source matrix.pattern
 the pattern.public Matrix<? extends UpdatablePArray> convolution(Matrix<? extends PArray> src, WeightedPattern pattern)
Convolution
Usually convolution means the weighted sum of the set of matrices,
obtained by pseudocyclic shifting the source matrix by the vectors,
equal to all pattern points, with weights, equal to
weights
of the pattern points.
More precisely, let m_{i}=Matrices.asShifted
(src,ip.coordinates()
),
where ip is the point #i from all points contained in the pattern,
and let wi=pattern.weight
(ip).
Then the every element of the returned matrix is the weighted sum of all corresponding elements
of all m_{i} matrices:
∑ w_{i}m_{i}The
element type
of the created matrix is the same as the element type of the source one.
The byte and short elements are considered to be unsigned.
If the element type if integer, the precise is rounded to the nearest integer.
The BasicConvolution
class strictly complies this definition.
However, other implementations of this interface may use alternate definitions of the convolution term.
For example, elements outside the matrix may be supposed to be filled according some nontrivial rules
instead of pseudocyclic continuation
(as in ContinuedConvolution
objects),
or only some region of the matrix may be processed, etc.
convolution
in interface Convolution
src
 the source matrix.pattern
 the pattern.Convolution.asConvolution(Class, Matrix, WeightedPattern)
public <T extends PArray> Matrix<? extends T> convolution(java.lang.Class<? extends T> requiredType, Matrix<? extends PArray> src, WeightedPattern pattern)
convolution
in interface Convolution
public void convolution(Matrix<? extends UpdatablePArray> dest, Matrix<? extends PArray> src, WeightedPattern pattern)
convolution
in interface Convolution