Class PowerFunc
- All Implemented Interfaces:
Func
- Direct Known Subclasses:
PowerFunc.Updatable
Power function: f(x0, x1) = scale*x0x1 or f(x0) = scale*x0c, where c and scale are constants. More precisely, the result of this function is:
-
scale * Math.pow(x[0], x[1]) or scale * Math.pow(x[0], c)
for the instance returned by
getBinaryInstance(double scale)
orgetInstance(double c, double scale)
methods; - scale * StrictMath.pow(x[0], x[1]) or scale * StrictMath.pow(x[0], c)
for the instance returned by
getStrictBinaryInstance(double scale)
orgetStrictInstance(double c, double scale)
methods.
get(double...)
method of the instance of this class requires at least 2 or 1 arguments
(for the cases x0x1 and
x0c correspondingly)
and throws IndexOutOfBoundsException if the number of arguments is less.
In a case of using getStrictBinaryInstance(double scale)
/
getStrictInstance(double c, double scale)
methods,
all calculations are performed with help of StrictMath class, so the result
is absolutely identical on all platforms.
This class is immutable and thread-safe: there are no ways to modify settings of the created instance.
- Author:
- Daniel Alievsky
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
Updatable extension
of thepower function
with one argument. -
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
-
Method Summary
Modifier and TypeMethodDescriptionabstract double
get()
Equivalent toget
(new double[0]).abstract double
get
(double x0) Equivalent toget
(new double[] {x0}).abstract double
get
(double... x) Returns the result of this function for the given arguments: f(x0, x1, ..., xx.length-1).abstract double
get
(double x0, double x1) Equivalent toget
(new double[] {x0, x1}).abstract double
get
(double x0, double x1, double x2) Equivalent toget
(new double[] {x0, x1, x2}).static PowerFunc
getBinaryInstance
(double scale) Returns an instance of this class, a case of binary function scale*x0x1, using Math.pow method.static PowerFunc
getInstance
(double c) Returns an instance of this class, a case of unary function x0c, using Math.pow method.static PowerFunc
getInstance
(double c, double scale) Returns an instance of this class, a case of unary function scale*x0c, using Math.pow method.static PowerFunc
getStrictBinaryInstance
(double scale) Returns an instance of this class, a case of binary function scale*x0x1, using StrictMath.pow method.static PowerFunc
getStrictInstance
(double c) Returns an instance of this class, a case of unary function x0c, using StrictMath.pow method.static PowerFunc
getStrictInstance
(double c, double scale) Returns an instance of this class, a case of unary function scale*x0c, using StrictMath.pow method.static PowerFunc.Updatable
getUpdatableInstance
(double c, double scale) Returns an instance of the updatable version of this class, a case of unary function scale*x0c, using Math.pow method.static PowerFunc.Updatable
getUpdatableStrictInstance
(double c, double scale) Returns an instance of the updatable version of this class, a case of unary function scale*x0c, using StrictMath.pow method.toString()
Returns a brief string description of this object.
-
Method Details
-
getBinaryInstance
Returns an instance of this class, a case of binary function scale*x0x1, using Math.pow method.- Parameters:
scale
- the constant scale.- Returns:
- an instance of this class, a case of binary function, using Math.pow method.
-
getStrictBinaryInstance
Returns an instance of this class, a case of binary function scale*x0x1, using StrictMath.pow method.- Parameters:
scale
- the constant scale.- Returns:
- an instance of this class, a case of binary function, using StrictMath.pow method.
-
getInstance
Returns an instance of this class, a case of unary function scale*x0c, using Math.pow method.This method returns special optimized versions of this class for several popular values of cargument. In particular, there are optimized version for
c = 1.0, 2.0, 3.0, 0.5, 1.0/3.0 .- Parameters:
c
- the constant c.scale
- the constant scale.- Returns:
- an instance of this class, a case of unary function, using Math.pow method.
-
getInstance
Returns an instance of this class, a case of unary function x0c, using Math.pow method. Equivalent togetInstance
(c,1.0).- Parameters:
c
- the constant c.- Returns:
- an instance of this class, a case of unary function, using Math.pow method.
-
getStrictInstance
Returns an instance of this class, a case of unary function scale*x0c, using StrictMath.pow method.This method returns special optimized versions of this class for several popular values of cargument. In particular, there are optimized version for
c = 1.0, 2.0, 3.0, 0.5, 1.0/3.0 .- Parameters:
c
- the constant c.scale
- the constant scale.- Returns:
- an instance of this class, a case of unary function, using StrictMath.pow method.
-
getStrictInstance
Returns an instance of this class, a case of unary function x0c, using StrictMath.pow method. Equivalent togetStrictInstance
(c,1.0).- Parameters:
c
- the constant c.- Returns:
- an instance of this class, a case of unary function, using StrictMath.pow method.
-
getUpdatableInstance
Returns an instance of the updatable version of this class, a case of unary function scale*x0c, using Math.pow method.This method returns special optimized versions of this class for several popular values of cargument. In particular, there are optimized version for
c = 1.0, 2.0, 3.0, 0.5, 1.0/3.0 .- Parameters:
c
- the constant c.scale
- the constant scale.- Returns:
- an instance of this class, a case of unary function, using Math.pow method.
-
getUpdatableStrictInstance
Returns an instance of the updatable version of this class, a case of unary function scale*x0c, using StrictMath.pow method.This method returns special optimized versions of this class for several popular values of cargument. In particular, there are optimized version for
c = 1.0, 2.0, 3.0, 0.5, 1.0/3.0 .- Parameters:
c
- the constant c.scale
- the constant scale.- Returns:
- an instance of this class, a case of unary function, using StrictMath.pow method.
-
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 abstract double get()Description copied from interface:Func
Equivalent toget
(new double[0]). Provides better performance because it does not require Java array creation. -
get
public abstract double get(double x0) Description copied from interface:Func
Equivalent toget
(new double[] {x0}). Provides better performance because it does not require Java array creation. -
get
public abstract double get(double x0, double x1) Description copied from interface:Func
Equivalent toget
(new double[] {x0, x1}). Provides better performance because it does not require Java array creation. -
get
public abstract double get(double x0, double x1, double x2) Description copied from interface:Func
Equivalent toget
(new double[] {x0, x1, x2}). Provides better performance because it does not require Java array creation. -
toString
Returns a brief string description of this object.
-