|Modifier and Type||Field and Description|
|Modifier||Constructor and Description|
Creates an instance of this class with the given context.
|Modifier and Type||Method and Description|
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.
This method is implemented here via cloning this object (by standard clone() call) and replacing the value of the field, where a reference to the current context is stored, with newContext value.
Returns true, if this class works in the default
context, contextPart, memoryModel
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
protected final boolean incrementForUnsigned
protected final boolean incrementByHalfForInteger
protected AbstractConvolution(ArrayContext context, boolean incrementForUnsigned, boolean incrementByHalfForInteger)
context- the context used by this instance for all operations.
incrementForUnsigned- if true, when the type of the convolution result is an unsigned number in terms of AlgART libraries — byte, short, char — it is automatically incremented by 128 (byte) or 32768 (short and char).
incrementByHalfForInteger- if true, when the type of the convolution result is integer, the precise result is automatically increments by 0.5 before casting.
public Convolution context(ArrayContext newContext)
This method is implemented here via cloning this object (by standard clone() call) and replacing the value of the field, where a reference to the current context is stored, with newContext value. This technique is suitable for most implementation. However, if you need, you can override this method; maybe, it is enough to override clone() instead.
newContext- another context, used by the returned instance; may be null.
public abstract boolean isPseudoCyclic()
pseudo-cyclic continuation mode.
More precisely, it means that when the value in some element of the processed matrix,
returned by a method of this class, depends on elements of the source matrix, lying outside its bounds,
then it is supposed that the values outside the source matrix are calculated as described in
Matrix.ContinuationMode.PSEUDO_CYCLIC. Exactly such behaviour is specified in
the comments to the
method as the default definition of convolution.
This method returns true in
However, it usually returns false in
— excepting the only degenerated case when the used
continuation mode is
public double increment(java.lang.Class<?> elementType)
public Matrix<? extends PArray> asConvolution(Matrix<? extends PArray> src, WeightedPattern pattern)
type(PArray.class), src, pattern). In other words, the element type of the returned matrix is chosen the same as in src matrix.
public abstract <T extends PArray> Matrix<T> asConvolution(java.lang.Class<? extends T> requiredType, Matrix<? extends PArray> src, WeightedPattern pattern)
Convolution.convolution(Class, Matrix, WeightedPattern)method about the "convolution" term.
The matrix, returned by this method, is immutable, and the class of its built-in array
implements one of the basic interfaces
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.
public Matrix<? extends UpdatablePArray> convolution(Matrix<? extends PArray> src, WeightedPattern pattern)
asConvolution(Class, Matrix, WeightedPattern)method and copies it into a newly created matrix via
Matrices.copy(ArrayContext, Matrix, Matrix)method. This method should be usually overridden to provide better implementations.
src- the source matrix.
pattern- the pattern.
java.lang.NullPointerException- if one of the arguments is null.
asConvolution(Class, Matrix, WeightedPattern)
public <T extends PArray> Matrix<? extends T> convolution(java.lang.Class<? extends T> requiredType, Matrix<? extends PArray> src, WeightedPattern pattern)