org.apache.commons.math.analysis
Class ComposableFunction

java.lang.Object
  extended by org.apache.commons.math.analysis.ComposableFunction
All Implemented Interfaces:
UnivariateRealFunction

public abstract class ComposableFunction
extends java.lang.Object
implements UnivariateRealFunction

Base class for UnivariateRealFunction that can be composed with other functions.

Since:
2.1
Version:
$Revision: 924453 $ $Date: 2010-03-17 16:05:20 -0400 (Wed, 17 Mar 2010) $

Field Summary
static ComposableFunction ABS
          The Math.abs method wrapped as a ComposableFunction.
static ComposableFunction ACOS
          The Math.abs method wrapped as a ComposableFunction.
static ComposableFunction ASIN
          The Math.asin method wrapped as a ComposableFunction.
static ComposableFunction ATAN
          The Math.atan method wrapped as a ComposableFunction.
static ComposableFunction CBRT
          The Math.cbrt method wrapped as a ComposableFunction.
static ComposableFunction CEIL
          The Math.ceil method wrapped as a ComposableFunction.
static ComposableFunction COS
          The Math.cos method wrapped as a ComposableFunction.
static ComposableFunction COSH
          The Math.cosh method wrapped as a ComposableFunction.
static ComposableFunction EXP
          The Math.exp method wrapped as a ComposableFunction.
static ComposableFunction EXPM1
          The Math.expm1 method wrapped as a ComposableFunction.
static ComposableFunction FLOOR
          The Math.floor method wrapped as a ComposableFunction.
static ComposableFunction IDENTITY
          The identity function.
static ComposableFunction INVERT
          The invert operator wrapped as a ComposableFunction.
static ComposableFunction LOG
          The Math.log method wrapped as a ComposableFunction.
static ComposableFunction LOG10
          The Math.log10 method wrapped as a ComposableFunction.
static ComposableFunction LOG1P
          The Math.log1p method wrapped as a ComposableFunction.
static ComposableFunction NEGATE
          The - operator wrapped as a ComposableFunction.
static ComposableFunction ONE
          The constant function always returning 1.
static ComposableFunction RINT
          The Math.rint method wrapped as a ComposableFunction.
static ComposableFunction SIGNUM
          The Math.signum method wrapped as a ComposableFunction.
static ComposableFunction SIN
          The Math.sin method wrapped as a ComposableFunction.
static ComposableFunction SINH
          The Math.sinh method wrapped as a ComposableFunction.
static ComposableFunction SQRT
          The Math.sqrt method wrapped as a ComposableFunction.
static ComposableFunction TAN
          The Math.tan method wrapped as a ComposableFunction.
static ComposableFunction TANH
          The Math.tanh method wrapped as a ComposableFunction.
static ComposableFunction ULP
          The Math.ulp method wrapped as a ComposableFunction.
static ComposableFunction ZERO
          The constant function always returning 0.
 
Constructor Summary
ComposableFunction()
           
 
Method Summary
 ComposableFunction add(double a)
          Return a function adding a constant term to the instance.
 ComposableFunction add(UnivariateRealFunction f)
          Return a function adding the instance and another function.
 MultivariateRealFunction asCollector()
          Generates a function that iteratively apply instance function on all elements of an array.
 MultivariateRealFunction asCollector(BivariateRealFunction combiner)
          Generates a function that iteratively apply instance function on all elements of an array.
 MultivariateRealFunction asCollector(BivariateRealFunction combiner, double initialValue)
          Generates a function that iteratively apply instance function on all elements of an array.
 MultivariateRealFunction asCollector(double initialValue)
          Generates a function that iteratively apply instance function on all elements of an array.
 ComposableFunction combine(UnivariateRealFunction f, BivariateRealFunction combiner)
          Return a function combining the instance and another function.
 ComposableFunction divide(UnivariateRealFunction f)
          Return a function dividing the instance by another function.
 ComposableFunction multiply(double scaleFactor)
          Return a function scaling the instance by a constant factor.
 ComposableFunction multiply(UnivariateRealFunction f)
          Return a function multiplying the instance and another function.
 ComposableFunction of(UnivariateRealFunction f)
          Precompose the instance with another function.
 ComposableFunction postCompose(UnivariateRealFunction f)
          Postcompose the instance with another function.
 ComposableFunction subtract(UnivariateRealFunction f)
          Return a function subtracting another function from the instance.
abstract  double value(double x)
          Compute the value for the function.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

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
The Math.abs method wrapped as a ComposableFunction.


NEGATE

public static final ComposableFunction NEGATE
The - operator wrapped as a ComposableFunction.


INVERT

public static final ComposableFunction INVERT
The invert operator wrapped as a ComposableFunction.


SIN

public static final ComposableFunction SIN
The Math.sin method wrapped as a ComposableFunction.


SQRT

public static final ComposableFunction SQRT
The Math.sqrt method wrapped as a ComposableFunction.


SINH

public static final ComposableFunction SINH
The Math.sinh method wrapped as a ComposableFunction.


EXP

public static final ComposableFunction EXP
The Math.exp method wrapped as a ComposableFunction.


EXPM1

public static final ComposableFunction EXPM1
The Math.expm1 method wrapped as a ComposableFunction.


ASIN

public static final ComposableFunction ASIN
The Math.asin method wrapped as a ComposableFunction.


ATAN

public static final ComposableFunction ATAN
The Math.atan method wrapped as a ComposableFunction.


TAN

public static final ComposableFunction TAN
The Math.tan method wrapped as a ComposableFunction.


TANH

public static final ComposableFunction TANH
The Math.tanh method wrapped as a ComposableFunction.


CBRT

public static final ComposableFunction CBRT
The Math.cbrt method wrapped as a ComposableFunction.


CEIL

public static final ComposableFunction CEIL
The Math.ceil method wrapped as a ComposableFunction.


FLOOR

public static final ComposableFunction FLOOR
The Math.floor method wrapped as a ComposableFunction.


LOG

public static final ComposableFunction LOG
The Math.log method wrapped as a ComposableFunction.


LOG10

public static final ComposableFunction LOG10
The Math.log10 method wrapped as a ComposableFunction.


LOG1P

public static final ComposableFunction LOG1P
The Math.log1p method wrapped as a ComposableFunction.


COS

public static final ComposableFunction COS
The Math.cos method wrapped as a ComposableFunction.


ACOS

public static final ComposableFunction ACOS
The Math.abs method wrapped as a ComposableFunction.


COSH

public static final ComposableFunction COSH
The Math.cosh method wrapped as a ComposableFunction.


RINT

public static final ComposableFunction RINT
The Math.rint method wrapped as a ComposableFunction.


SIGNUM

public static final ComposableFunction SIGNUM
The Math.signum method wrapped as a ComposableFunction.


ULP

public static final ComposableFunction ULP
The Math.ulp method wrapped as a ComposableFunction.

Constructor Detail

ComposableFunction

public ComposableFunction()
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 that h.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 that h.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 that h.value(x) == combiner.value(g.value(x), f.value(x)) for all x.

Parameters:
f - function to combine with the instance
combiner - 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:

Parameters:
combiner - combiner to use between entries
initialValue - initial value to use before first entry
Returns:
a new function that iteratively applie 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 applie 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 applie 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 applie instance function on all elements of an array.
See Also:
asCollector(BivariateRealFunction, double), BinaryFunction.ADD

value

public abstract double value(double x)
                      throws FunctionEvaluationException
Compute the value for the function.

Specified by:
value in interface UnivariateRealFunction
Parameters:
x - the point for which the function value should be computed
Returns:
the value
Throws:
FunctionEvaluationException - if the function evaluation fails


Copyright (c) 2003-2010 Apache Software Foundation