Package net.algart.math.functions
Class AbstractFunc
java.lang.Object
net.algart.math.functions.AbstractFunc
- All Implemented Interfaces:
Func
- Direct Known Subclasses:
HyperboloidOfRevolutionFunc
,MaxFromTwoSelectedNumbersFunc
,MinFromTwoSelectedNumbersFunc
,ParaboloidOfRevolutionFunc
,UpperHalfEllipsoidOfRevolutionFunc
A skeletal implementation of the Func
interface to minimize
the effort required to implement this interface.
Warning: in most cases, we strongly recommend to override the overloaded versions of get method
(get()
, get(double)
, get(double, double)
, get(double, double, double)
),
if they are applicable for your function. The default implementations, provided by this class,
work relatively slowly, because they allocate a little Java array for passing to the basic
get(double...)
method. For example, if you create a function with two arguments
get(double, double)
.
- Author:
- Daniel Alievsky
-
Nested Class Summary
Nested classes/interfaces inherited from interface net.algart.math.functions.Func
Func.Updatable
-
Field Summary
Fields inherited from interface net.algart.math.functions.Func
ABS, ABS_DIFF, HALF_X_MINUS_Y, HALF_X_PLUS_Y, HALF_Y_MINUS_X, IDENTITY, MAX, MIN, POSITIVE_DIFF, REVERSE, SELECT, SELECT_FROM_8_DIRECTIONS_2D, SELECT_IF_GREATER, SELECT_IF_GREATER_OR_EQUAL, SHIFTS_ALONG_8_DIRECTIONS_2D, UPDATABLE_IDENTITY, X_MINUS_Y, X_PLUS_Y, Y_MINUS_X
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptiondouble
get()
This implementation callsget
(EMPTY), where EMPTY is a constant array double[0].double
get
(double x0) This implementation callsget
(new double[] {x0}).abstract double
get
(double... x) Returns the result of this function for the given arguments: f(x0, x1, ..., xx.length-1).double
get
(double x0, double x1) This implementation callsget
(new double[] {x0, x1}).double
get
(double x0, double x1, double x2) This implementation callsget
(new double[] {x0, x1, x2}).double
get
(double x0, double x1, double x2, double x3) This implementation callsget
(new double[] {x0, x1, x2, x3}).
-
Constructor Details
-
AbstractFunc
public AbstractFunc()
-
-
Method Details
-
get
public abstract double get(double... x) Description copied from interface:Func
Returns the result of this function for the given arguments: f(x0, x1, ..., xx.length-1).This method must not change the values of x elements!
-
get
public double get()This implementation callsget
(EMPTY), where EMPTY is a constant array double[0].- Specified by:
get
in interfaceFunc
- Returns:
- the function result.
- Throws:
IndexOutOfBoundsException
- may be thrown this function requires at least 1 argument.
-
get
public double get(double x0) This implementation callsget
(new double[] {x0}). May be overridden to provide better performance.- Specified by:
get
in interfaceFunc
- Parameters:
x0
- the function argument.- Returns:
- the function result.
- Throws:
IndexOutOfBoundsException
- may be thrown this function requires at least 2 arguments.
-
get
public double get(double x0, double x1) This implementation callsget
(new double[] {x0, x1}). May be overridden to provide better performance.- Specified by:
get
in interfaceFunc
- Parameters:
x0
- the first function argument.x1
- the second function argument.- Returns:
- the function result.
- Throws:
IndexOutOfBoundsException
- may be thrown this function requires at least 3 arguments.
-
get
public double get(double x0, double x1, double x2) This implementation callsget
(new double[] {x0, x1, x2}). May be overridden to provide better performance.- Specified by:
get
in interfaceFunc
- Parameters:
x0
- the first function argument.x1
- the second function argument.x2
- the third function argument.- Returns:
- the function result.
- Throws:
IndexOutOfBoundsException
- may be thrown this function requires at least 3 arguments.
-
get
public double get(double x0, double x1, double x2, double x3) This implementation callsget
(new double[] {x0, x1, x2, x3}). May be overridden to provide better performance.- Specified by:
get
in interfaceFunc
- Parameters:
x0
- the first function argument.x1
- the second function argument.x2
- the third function argument.x3
- the fourth function argument.- Returns:
- the function result.
- Throws:
IndexOutOfBoundsException
- may be thrown this function requires at least 3 arguments.
-