|
AlgART Home | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
public interface Func
Abstract mathematical function f(x0, x1, ..., xn-1), or f(x), where x is a point of the n-dimensional space.
Implementations of this interface are usually immutable and always thread-safe: get methods of this interface may be freely used while simultaneous accessing to the same instance from several threads. All implementations of this interface from this package are immutable.
AlgART Laboratory 2007-2013
| Modifier and Type | Interface and Description |
|---|---|
static interface |
Func.Updatable
"Updatable" mathematical function: an extension of Func interface
allowing assigning values to the function result, that leads to
corresponding correction of arguments. |
| Modifier and Type | Field and Description |
|---|---|
static Func |
ABS
Absolute value function: f(x0) = |x0|. |
static Func |
ABS_DIFF
Absolute value of the difference of 2 numbers: f(x0, x1) = |x0-x1|. |
static LinearFunc |
HALF_X_MINUS_Y
An instance of LinearFunc class, describing the linear function
(x0 - x1)/2:
LinearFunc.getInstance(0.0, 0.5, -0.5). |
static LinearFunc |
HALF_X_PLUS_Y
An instance of LinearFunc class, describing the linear function
(x0 + x1)/2:
LinearFunc.getInstance(0.0, 0.5, 0.5). |
static LinearFunc |
HALF_Y_MINUS_X
An instance of LinearFunc class, describing the linear function
(x1 - x0)/2:
LinearFunc.getInstance(0.0, -0.5, 0.5). |
static Func |
IDENTITY
Identity function, just returning its first argument: f(x0, x1, ..., xn-1) = x0. |
static Func |
MAX
Maximum from several numbers: f(x0, x1, ..., xn-1) = min(x0, x1, ..., xn-1). |
static Func |
MIN
Minimum from several numbers: f(x0, x1, ..., xn-1) = min(x0, x1, ..., xn-1). |
static Func |
POSITIVE_DIFF
Positive difference of 2 numbers: f(x0, x1) = max(x0-x1,0). |
static LinearFunc |
REVERSE
An instance of LinearFunc class, describing the linear function
1.0 - x0:
LinearFunc.getInstance(1.0, -1.0). |
static Func |
SELECT
Select function: f(x0, x1, ..., xn-1) = xi+1, where i is x0 cast to integer type: i=(int)x[0]. |
static Func |
SELECT_FROM_8_DIRECTIONS_2D
Selecting from 8 "integer" directions on 2D plane: f(x0, x1) = |
static Func |
SELECT_IF_GREATER
Select function: f(x0, x1, x2, x3) = x0 > x1 ? x2 : x3. |
static Func |
SELECT_IF_GREATER_OR_EQUAL
Select function: f(x0, x1, x2, x3) = x0 >= x1 ? x2 : x3. |
static java.util.List<IPoint> |
SHIFTS_ALONG_8_DIRECTIONS_2D
Vectors, corresponding to 8 directions recognized by SELECT_FROM_8_DIRECTIONS_2D function. |
static Func.Updatable |
UPDATABLE_IDENTITY
Updatable version of IDENTITY function. |
static LinearFunc |
X_MINUS_Y
An instance of LinearFunc class, describing the linear function
x0 - x1:
LinearFunc.getInstance(0.0, 1.0, -1.0). |
static LinearFunc |
X_PLUS_Y
An instance of LinearFunc class, describing the linear function
x0 + x1:
LinearFunc.getInstance(0.0, 1.0, 1.0). |
static LinearFunc |
Y_MINUS_X
An instance of LinearFunc class, describing the linear function
x1 - x0:
LinearFunc.getInstance(0.0, -1.0, 1.0). |
| Modifier and Type | Method and Description |
|---|---|
double |
get()
Equivalent to get(new double[0]). |
double |
get(double... x)
Returns the result of this function for the given arguments: f(x0, x1, ..., xx.length-1). |
double |
get(double x0)
Equivalent to get(new double[] {x0}). |
double |
get(double x0,
double x1)
Equivalent to get(new double[] {x0, x1}). |
double |
get(double x0,
double x1,
double x2)
Equivalent to get(new double[] {x0, x1, x2}). |
double |
get(double x0,
double x1,
double x2,
double x3)
Equivalent to get(new double[] {x0, x1, x2, x3}). |
| Field Detail |
|---|
static final Func IDENTITY
get(double...) method of this object requires at least 1 argument
and throws IndexOutOfBoundsException if the number of arguments is 0.
This instance is immutable and thread-safe: there are no ways to modify its settings.
static final Func.Updatable UPDATABLE_IDENTITY
IDENTITY function.
This instance is immutable and thread-safe: there are no ways to modify its settings.
static final Func MAX
get(double...) method of this object may process any number of arguments.
If the number of arguments is 0, it returns Double.NEGATIVE_INFINITY.
Unlike standard Math.max method, this function supposes that max(x,y) = x>y ? x : y
This instance is immutable and thread-safe: there are no ways to modify its settings.
static final Func MIN
get(double...) method of this object may process any number of arguments.
If the number of arguments is 0, it returns Double.POSITIVE_INFINITY.
Unlike standard Math.min method, this function supposes that min(x,y) = x<y ? x : y
This instance is immutable and thread-safe: there are no ways to modify its settings.
static final Func ABS
get(double...) method of this object requires at least 1 argument
and throws IndexOutOfBoundsException if the number of arguments is 0.
All calculations are performed in strictfp mode, so the result
is absolutely identical on all platforms.
This instance is immutable and thread-safe: there are no ways to modify its settings.
static final Func ABS_DIFF
get(double...) method of this object requires at least 2 arguments
and throws IndexOutOfBoundsException if the number of arguments is 0 or 1.
All calculations are performed in strictfp mode, so the result
is absolutely identical on all platforms.
This instance is immutable and thread-safe: there are no ways to modify its settings.
static final Func POSITIVE_DIFF
get(double...) method of this object requires at least 2 arguments
and throws IndexOutOfBoundsException if the number of arguments is 0 or 1.
All calculations are performed in strictfp mode, so the result
is absolutely identical on all platforms.
This instance is immutable and thread-safe: there are no ways to modify its settings.
static final LinearFunc X_PLUS_Y
LinearFunc class, describing the linear function
x0 + x1:
LinearFunc.getInstance(0.0, 1.0, 1.0).
This instance is immutable and thread-safe: there are no ways to modify its settings.
static final LinearFunc X_MINUS_Y
LinearFunc class, describing the linear function
x0 - x1:
LinearFunc.getInstance(0.0, 1.0, -1.0).
This instance is immutable and thread-safe: there are no ways to modify its settings.
static final LinearFunc Y_MINUS_X
LinearFunc class, describing the linear function
x1 - x0:
LinearFunc.getInstance(0.0, -1.0, 1.0).
This instance is immutable and thread-safe: there are no ways to modify its settings.
static final LinearFunc HALF_X_PLUS_Y
LinearFunc class, describing the linear function
(x0 + x1)/2:
LinearFunc.getInstance(0.0, 0.5, 0.5).
This instance is immutable and thread-safe: there are no ways to modify its settings.
static final LinearFunc HALF_X_MINUS_Y
LinearFunc class, describing the linear function
(x0 - x1)/2:
LinearFunc.getInstance(0.0, 0.5, -0.5).
This instance is immutable and thread-safe: there are no ways to modify its settings.
static final LinearFunc HALF_Y_MINUS_X
LinearFunc class, describing the linear function
(x1 - x0)/2:
LinearFunc.getInstance(0.0, -0.5, 0.5).
This instance is immutable and thread-safe: there are no ways to modify its settings.
static final LinearFunc REVERSE
LinearFunc class, describing the linear function
1.0 - x0:
LinearFunc.getInstance(1.0, -1.0).
This instance describes logical NOT operation in a case when the arguments are bits (0 and 1 values).
This instance is immutable and thread-safe: there are no ways to modify its settings.
static final Func SELECT
get(double...) method of this object requires at least 2 arguments
and throws IndexOutOfBoundsException if the number of arguments is 0 or 1.
This instance is immutable and thread-safe: there are no ways to modify its settings.
static final Func SELECT_IF_GREATER
get(double...) method of this object requires at least 4 arguments
and throws IndexOutOfBoundsException if the number of arguments is 0, 1, 2 or 3.
Note: call of this function is almost equivalent to calling SELECT_IF_GREATER_OR_EQUAL function
with another order of the arguments:
SELECT_IF_GREATER_OR_EQUAL will choose x2, because in Java any comparison with
Double.NaN returns false.
This instance is immutable and thread-safe: there are no ways to modify its settings.
static final Func SELECT_IF_GREATER_OR_EQUAL
get(double...) method of this object requires at least 4 arguments
and throws IndexOutOfBoundsException if the number of arguments is 0, 1, 2 or 3.
Note: call of this function is almost equivalent to calling SELECT_IF_GREATER function
with another order of the arguments:
SELECT_IF_GREATER will choose x2, because in Java any comparison with
Double.NaN returns false.
This instance is immutable and thread-safe: there are no ways to modify its settings.
static final Func SELECT_FROM_8_DIRECTIONS_2D
(A strange formula "337.5° < φ ≤ 22.5°" just means that the direction lies between 337.5°=-22.5° and +22.5° — in other words, "almost rightward" along X axis.)
This function is useful while processing 2-dimensional matrices, for example, in algorithms like Canny edge detector.
The get(double...) method of this object requires at least 2 arguments
and throws IndexOutOfBoundsException if the number of arguments is 0 or 1.
All calculations are performed in strictfp mode, so the result
is absolutely identical on all platforms.
This instance is immutable and thread-safe: there are no ways to modify its settings.
static final java.util.List<IPoint> SHIFTS_ALONG_8_DIRECTIONS_2D
SELECT_FROM_8_DIRECTIONS_2D function.
More precisely, if is an unmodifiable list consisting of the following elements:
IPoint.valueOf(1,0),IPoint.valueOf(1,1),IPoint.valueOf(0,1),IPoint.valueOf(-1,1),IPoint.valueOf(-1,0),IPoint.valueOf(-1,-1),IPoint.valueOf(0,-1),IPoint.valueOf(1,-1).So, if the direction returned by SELECT_FROM_8_DIRECTIONS_2D is n, then the corresponding
"rounding" direction is described by SHIFTS_ALONG_8_DIRECTIONS_2D.get(n).
This instance is immutable and thread-safe: there are no ways to modify it.
| Method Detail |
|---|
double get(double... x)
This method must not change the values of x elements!
x - the function arguments.java.lang.IndexOutOfBoundsException - may be thrown if the number of passed arguments is less
than the required number of this function arguments.double get()
get(new double[0]).
Provides better performance because it does not require Java array creation.
java.lang.IndexOutOfBoundsException - may be thrown this function requires at least 1 argument.double get(double x0)
get(new double[] {x0}).
Provides better performance because it does not require Java array creation.
x0 - the function argument.java.lang.IndexOutOfBoundsException - may be thrown this function requires at least 2 arguments.
double get(double x0,
double x1)
get(new double[] {x0, x1}).
Provides better performance because it does not require Java array creation.
x0 - the first function argument.x1 - the second function argument.java.lang.IndexOutOfBoundsException - may be thrown this function requires at least 3 arguments.
double get(double x0,
double x1,
double x2)
get(new double[] {x0, x1, x2}).
Provides better performance because it does not require Java array creation.
x0 - the first function argument.x1 - the second function argument.x2 - the third function argument.java.lang.IndexOutOfBoundsException - may be thrown this function requires at least 4 arguments.
double get(double x0,
double x1,
double x2,
double x3)
get(new double[] {x0, x1, x2, x3}).
Provides better performance because it does not require Java array creation.
x0 - the first function argument.x1 - the second function argument.x2 - the third function argument.x3 - the fourth function argument.java.lang.IndexOutOfBoundsException - may be thrown this function requires at least 5 arguments.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||