Package org.apache.commons.math.analysis
Class ComposableFunction
- java.lang.Object
-
- org.apache.commons.math.analysis.ComposableFunction
-
- All Implemented Interfaces:
UnivariateRealFunction
public abstract class ComposableFunction extends java.lang.Object implements UnivariateRealFunction
Base class forUnivariateRealFunctionthat can be composed with other functions.- Since:
- 2.1
- Version:
- $Revision: 1070725 $ $Date: 2011-02-15 02:31:12 +0100 (mar. 15 févr. 2011) $
-
-
Field Summary
Fields Modifier and Type Field Description static ComposableFunctionABSTheFastMath.absmethod wrapped as aComposableFunction.static ComposableFunctionACOSTheFastMath.absmethod wrapped as aComposableFunction.static ComposableFunctionASINTheFastMath.asinmethod wrapped as aComposableFunction.static ComposableFunctionATANTheFastMath.atanmethod wrapped as aComposableFunction.static ComposableFunctionCBRTTheFastMath.cbrtmethod wrapped as aComposableFunction.static ComposableFunctionCEILTheFastMath.ceilmethod wrapped as aComposableFunction.static ComposableFunctionCOSTheFastMath.cosmethod wrapped as aComposableFunction.static ComposableFunctionCOSHTheFastMath.coshmethod wrapped as aComposableFunction.static ComposableFunctionEXPTheFastMath.expmethod wrapped as aComposableFunction.static ComposableFunctionEXPM1TheFastMath.expm1method wrapped as aComposableFunction.static ComposableFunctionFLOORTheFastMath.floormethod wrapped as aComposableFunction.static ComposableFunctionIDENTITYThe identity function.static ComposableFunctionINVERTThe invert operator wrapped as aComposableFunction.static ComposableFunctionLOGTheFastMath.logmethod wrapped as aComposableFunction.static ComposableFunctionLOG10TheFastMath.log10method wrapped as aComposableFunction.static ComposableFunctionLOG1PTheFastMath.log1pmethod wrapped as aComposableFunction.static ComposableFunctionNEGATEThe - operator wrapped as aComposableFunction.static ComposableFunctionONEThe constant function always returning 1.static ComposableFunctionRINTTheFastMath.rintmethod wrapped as aComposableFunction.static ComposableFunctionSIGNUMTheFastMath.signummethod wrapped as aComposableFunction.static ComposableFunctionSINTheFastMath.sinmethod wrapped as aComposableFunction.static ComposableFunctionSINHTheFastMath.sinhmethod wrapped as aComposableFunction.static ComposableFunctionSQRTTheFastMath.sqrtmethod wrapped as aComposableFunction.static ComposableFunctionTANTheFastMath.tanmethod wrapped as aComposableFunction.static ComposableFunctionTANHTheFastMath.tanhmethod wrapped as aComposableFunction.static ComposableFunctionULPTheFastMath.ulpmethod wrapped as aComposableFunction.static ComposableFunctionZEROThe constant function always returning 0.
-
Constructor Summary
Constructors Constructor Description ComposableFunction()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description ComposableFunctionadd(double a)Return a function adding a constant term to the instance.ComposableFunctionadd(UnivariateRealFunction f)Return a function adding the instance and another function.MultivariateRealFunctionasCollector()Generates a function that iteratively apply instance function on all elements of an array.MultivariateRealFunctionasCollector(double initialValue)Generates a function that iteratively apply instance function on all elements of an array.MultivariateRealFunctionasCollector(BivariateRealFunction combiner)Generates a function that iteratively apply instance function on all elements of an array.MultivariateRealFunctionasCollector(BivariateRealFunction combiner, double initialValue)Generates a function that iteratively apply instance function on all elements of an array.ComposableFunctioncombine(UnivariateRealFunction f, BivariateRealFunction combiner)Return a function combining the instance and another function.ComposableFunctiondivide(UnivariateRealFunction f)Return a function dividing the instance by another function.ComposableFunctionmultiply(double scaleFactor)Return a function scaling the instance by a constant factor.ComposableFunctionmultiply(UnivariateRealFunction f)Return a function multiplying the instance and another function.ComposableFunctionof(UnivariateRealFunction f)Precompose the instance with another function.ComposableFunctionpostCompose(UnivariateRealFunction f)Postcompose the instance with another function.ComposableFunctionsubtract(UnivariateRealFunction f)Return a function subtracting another function from the instance.abstract doublevalue(double x)Compute the value for the function.
-
-
-
Field Detail
-
ZERO
public static final ComposableFunction ZERO
The constant function always returning 0.
-
ONE
public static final ComposableFunction ONE
The constant function always returning 1.
-
IDENTITY
public static final ComposableFunction IDENTITY
The identity function.
-
ABS
public static final ComposableFunction ABS
TheFastMath.absmethod wrapped as aComposableFunction.
-
NEGATE
public static final ComposableFunction NEGATE
The - operator wrapped as aComposableFunction.
-
INVERT
public static final ComposableFunction INVERT
The invert operator wrapped as aComposableFunction.
-
SIN
public static final ComposableFunction SIN
TheFastMath.sinmethod wrapped as aComposableFunction.
-
SQRT
public static final ComposableFunction SQRT
TheFastMath.sqrtmethod wrapped as aComposableFunction.
-
SINH
public static final ComposableFunction SINH
TheFastMath.sinhmethod wrapped as aComposableFunction.
-
EXP
public static final ComposableFunction EXP
TheFastMath.expmethod wrapped as aComposableFunction.
-
EXPM1
public static final ComposableFunction EXPM1
TheFastMath.expm1method wrapped as aComposableFunction.
-
ASIN
public static final ComposableFunction ASIN
TheFastMath.asinmethod wrapped as aComposableFunction.
-
ATAN
public static final ComposableFunction ATAN
TheFastMath.atanmethod wrapped as aComposableFunction.
-
TAN
public static final ComposableFunction TAN
TheFastMath.tanmethod wrapped as aComposableFunction.
-
TANH
public static final ComposableFunction TANH
TheFastMath.tanhmethod wrapped as aComposableFunction.
-
CBRT
public static final ComposableFunction CBRT
TheFastMath.cbrtmethod wrapped as aComposableFunction.
-
CEIL
public static final ComposableFunction CEIL
TheFastMath.ceilmethod wrapped as aComposableFunction.
-
FLOOR
public static final ComposableFunction FLOOR
TheFastMath.floormethod wrapped as aComposableFunction.
-
LOG
public static final ComposableFunction LOG
TheFastMath.logmethod wrapped as aComposableFunction.
-
LOG10
public static final ComposableFunction LOG10
TheFastMath.log10method wrapped as aComposableFunction.
-
LOG1P
public static final ComposableFunction LOG1P
TheFastMath.log1pmethod wrapped as aComposableFunction.
-
COS
public static final ComposableFunction COS
TheFastMath.cosmethod wrapped as aComposableFunction.
-
ACOS
public static final ComposableFunction ACOS
TheFastMath.absmethod wrapped as aComposableFunction.
-
COSH
public static final ComposableFunction COSH
TheFastMath.coshmethod wrapped as aComposableFunction.
-
RINT
public static final ComposableFunction RINT
TheFastMath.rintmethod wrapped as aComposableFunction.
-
SIGNUM
public static final ComposableFunction SIGNUM
TheFastMath.signummethod wrapped as aComposableFunction.
-
ULP
public static final ComposableFunction ULP
TheFastMath.ulpmethod wrapped as aComposableFunction.
-
-
Method Detail
-
of
public ComposableFunction of(UnivariateRealFunction f)
Precompose the instance with another function.The composed function h created by
h = g.of(f)is such thath.value(x) == g.value(f.value(x))for all x.- Parameters:
f- function to compose with- Returns:
- a new function which computes
this.value(f.value(x)) - See Also:
postCompose(UnivariateRealFunction)
-
postCompose
public ComposableFunction postCompose(UnivariateRealFunction f)
Postcompose the instance with another function.The composed function h created by
h = g.postCompose(f)is such thath.value(x) == f.value(g.value(x))for all x.- Parameters:
f- function to compose with- Returns:
- a new function which computes
f.value(this.value(x)) - See Also:
of(UnivariateRealFunction)
-
combine
public ComposableFunction combine(UnivariateRealFunction f, BivariateRealFunction combiner)
Return a function combining the instance and another function.The function h created by
h = g.combine(f, combiner)is such thath.value(x) == combiner.value(g.value(x), f.value(x))for all x.- Parameters:
f- function to combine with the instancecombiner- bivariate function used for combining- Returns:
- a new function which computes
combine.value(this.value(x), f.value(x))
-
add
public ComposableFunction add(UnivariateRealFunction f)
Return a function adding the instance and another function.- Parameters:
f- function to combine with the instance- Returns:
- a new function which computes
this.value(x) + f.value(x)
-
add
public ComposableFunction add(double a)
Return a function adding a constant term to the instance.- Parameters:
a- term to add- Returns:
- a new function which computes
this.value(x) + a
-
subtract
public ComposableFunction subtract(UnivariateRealFunction f)
Return a function subtracting another function from the instance.- Parameters:
f- function to combine with the instance- Returns:
- a new function which computes
this.value(x) - f.value(x)
-
multiply
public ComposableFunction multiply(UnivariateRealFunction f)
Return a function multiplying the instance and another function.- Parameters:
f- function to combine with the instance- Returns:
- a new function which computes
this.value(x) * f.value(x)
-
multiply
public ComposableFunction multiply(double scaleFactor)
Return a function scaling the instance by a constant factor.- Parameters:
scaleFactor- constant scaling factor- Returns:
- a new function which computes
this.value(x) * scaleFactor
-
divide
public ComposableFunction divide(UnivariateRealFunction f)
Return a function dividing the instance by another function.- Parameters:
f- function to combine with the instance- Returns:
- a new function which computes
this.value(x) / f.value(x)
-
asCollector
public MultivariateRealFunction asCollector(BivariateRealFunction combiner, double initialValue)
Generates a function that iteratively apply instance function on all elements of an array.The generated function behaves as follows:
- initialize result = initialValue
- iterate:
result = combiner.value(result, this.value(nextMultivariateEntry)); - return result
- Parameters:
combiner- combiner to use between entriesinitialValue- initial value to use before first entry- Returns:
- a new function that iteratively apply instance function on all elements of an array.
-
asCollector
public MultivariateRealFunction asCollector(BivariateRealFunction combiner)
Generates a function that iteratively apply instance function on all elements of an array.Calling this method is equivalent to call
asCollector(BivariateRealFunction, 0.0).- Parameters:
combiner- combiner to use between entries- Returns:
- a new function that iteratively apply instance function on all elements of an array.
- See Also:
asCollector(BivariateRealFunction, double)
-
asCollector
public MultivariateRealFunction asCollector(double initialValue)
Generates a function that iteratively apply instance function on all elements of an array.Calling this method is equivalent to call
asCollector(BinaryFunction.ADD, initialValue).- Parameters:
initialValue- initial value to use before first entry- Returns:
- a new function that iteratively apply instance function on all elements of an array.
- See Also:
asCollector(BivariateRealFunction, double),BinaryFunction.ADD
-
asCollector
public MultivariateRealFunction asCollector()
Generates a function that iteratively apply instance function on all elements of an array.Calling this method is equivalent to call
asCollector(BinaryFunction.ADD, 0.0).- Returns:
- a new function that iteratively apply instance function on all elements of an array.
- See Also:
asCollector(BivariateRealFunction, double),BinaryFunction.ADD
-
value
public abstract double value(double x) throws FunctionEvaluationExceptionCompute the value for the function.- Specified by:
valuein interfaceUnivariateRealFunction- Parameters:
x- the point for which the function value should be computed- Returns:
- the value
- Throws:
FunctionEvaluationException- if the function evaluation fails
-
-