Interface WeightedPattern
- All Superinterfaces:
Pattern
- All Known Implementing Classes:
AbstractWeightedPattern
-
Field Summary
Fields inherited from interface net.algart.math.patterns.Pattern
MAX_COORDINATE
-
Method Summary
Modifier and TypeMethodDescriptionboolean
Returns true if the weights of all points are the same.multiply
(double multiplier) Returns the pattern consisting of points, generated from points of this instance by multiplying on the mult argument viaIPoint.multiply(double)
method.productDecomposition
(int minimalPointCount) Returns the product decomposition: the list of patterns such that the convolution with this pattern is equivalent to sequential convolution with all patterns from the list.scale
(double... multipliers) Returns this pattern, scaled by the specified multipliers along all coordinates.Returns the pattern shifted by the argument, that is consisting of points with the sameweights
, generated from points of this instance by adding the argument viaIPoint.add(IPoint)
method.Returns the symmetric pattern: equivalent tomultiply(-1.0)
.double
Returns the weight of the given point of the pattern.Returns the minimal and maximal weights of all points of this pattern.Methods inherited from interface net.algart.math.patterns.Pattern
allUnionDecompositions, carcass, coordArea, coordMax, coordMin, coordRange, dimCount, hasMinkowskiDecomposition, isSurelyInteger, isSurelyOriginPoint, isSurelySinglePoint, largePointCount, maxBound, maxCarcassMultiplier, minBound, minkowskiAdd, minkowskiDecomposition, minkowskiSubtract, pointCount, points, projectionAlongAxis, round, roundedCoordArea, roundedCoordRange, roundedPoints, shift, unionDecomposition
-
Method Details
-
weight
Returns the weight of the given point of the pattern. The result is undefined if this point is outside the pattern.- Parameters:
point
- someinteger point
.- Returns:
- the weight of this point.
- Throws:
NullPointerException
- if the argument is null.IllegalArgumentException
- if point.coordCount()
!=Pattern.dimCount()
.
-
weightRange
Range weightRange()Returns the minimal and maximal weights of all points of this pattern.- Returns:
- the minimal and maximal weights of all points of this pattern.
-
isConstant
boolean isConstant()Returns true if the weights of all points are the same. Equivalent toweightRange()
.size()
==0.0.- Returns:
- true if the weights of all points are the same.
-
shift
Returns the pattern shifted by the argument, that is consisting of points with the sameweights
, generated from points of this instance by adding the argument viaIPoint.add(IPoint)
method.- Parameters:
shift
- the shift.- Returns:
- the shifted pattern.
- Throws:
NullPointerException
- if the argument is null.IllegalArgumentException
- if point.coordCount()
!=Pattern.dimCount()
.
-
multiply
Returns the pattern consisting of points, generated from points of this instance by multiplying on the mult argument viaIPoint.multiply(double)
method.If mult is not an integer, the generated real coordinates are rounded to integer values. If several source points are rounded to the same integer point, the
weights
of the resulting points may differ from the weights of the source ones, but the sum of all weights will be approximately same. If the all source points are transformed to different points, their weights are preserved.Please note: if mult is not an integer, the algorithm of rounding is not strictly specified! However, you can be sure that the new pattern will be near from the precise result.
-
scale
Description copied from interface:Pattern
Returns this pattern, scaled by the specified multipliers along all coordinates.More precisely, the resulting pattern consists of the points, obtained from all points of this pattern by the call point.
scale
(multipliers).The returned pattern always implements
DirectPointSetPattern
if this pattern implementsDirectPointSetPattern
The returned pattern always implements
RectangularPattern
if this pattern implementsRectangularPattern
.The returned pattern always implements
UniformGridPattern
if this pattern implementsUniformGridPattern
.There is a guarantee, that this method does not try to allocate much more memory, that it is required for storing this pattern itself, and that it never throws
TooManyPointsInPatternError
. For comparison, an attempt to do the same operation via getting all points (Pattern.points()
method), correcting them and forming a new pattern viaPatterns.newPattern(java.util.Collection)
will lead toTooManyPointsInPatternError
/ OutOfMemoryError for some forms of large patterns.Warning: this method can fail with
TooLargePatternCoordinatesException
, if some of new points violate restrictions, described in thecomments to this interface
, section "Coordinate restrictions" (for example, due to very large multipliers). However, such failure is obviously impossible, if all multipliers are in range -1.0<=multipliers[k]<=1.0. -
symmetric
WeightedPattern symmetric()Returns the symmetric pattern: equivalent tomultiply(-1.0)
. -
productDecomposition
Returns the product decomposition: the list of patterns such that the convolution with this pattern is equivalent to sequential convolution with all patterns from the list.Let the pattern consists of n-dimensional points p1, p2, ... with
weights
w1, w2, ..., and let the integer vector i defines the position of some element of the n-dimensional numeric matrix A. Here the convolution by this pattern means transforming the matrix A to another matrix B by the following rules:B[i] = ∑ wkA[i-pk]
This method allows to optimize calculation of this convolution with help of several passes: first you calculate the convolution with the 1st element of the returned list, then you calculate the convolution of the new matrix with the 2nd element of the returned list, etc. The last convolution will be equal (or almost equal, due to possible rounding errors) to the convolution of the source matrix with full this pattern.
The simplest example of such decomposition is a case of the
rectangular
constant
pattern. In this case, this method should return a list ofPattern.dimCount()
linear constant patterns (one-dimensional segments), the minkowski sum of which is equal to this one. The linear constant segments should not be further decomposed, because there is an optimal algorithm for convolution of any matrix with a linear constant segment, requiring 2 operations per element only.There is no guarantee that this method returns a good decomposition. If this method cannot find required decomposition, it returns the list containing this instance as the only element.
The number of space dimensions in all returned patterns (
Pattern.dimCount()
is the same as in this one.The result of this method is immutable (Collections.unmodifiableList).
- Parameters:
minimalPointCount
- this method does not try to decompose patterns that contain less than minimalPointCount points.- Returns:
- the decomposition of this pattern to the "product" (convolution) of smaller patterns.
- Throws:
IllegalArgumentException
- if the argument is negative.
-