org.apache.commons.math3.analysis
Class FunctionUtils

java.lang.Object
  extended by org.apache.commons.math3.analysis.FunctionUtils

public class FunctionUtils
extends Object

Utilities for manipulating function objects.

Since:
3.0
Version:
$Id: FunctionUtils.java 7721 2013-02-14 14:07:13Z CardosoP $

Method Summary
static DifferentiableUnivariateFunction add(DifferentiableUnivariateFunction... f)
          Deprecated. as of 3.1 replaced by add(UnivariateDifferentiableFunction...)
static UnivariateDifferentiableFunction add(UnivariateDifferentiableFunction... f)
          Adds functions.
static UnivariateFunction add(UnivariateFunction... f)
          Adds functions.
static MultivariateFunction collector(BivariateFunction combiner, double initialValue)
          Returns a MultivariateFunction h(x[]) defined by
static MultivariateFunction collector(BivariateFunction combiner, UnivariateFunction f, double initialValue)
          Returns a MultivariateFunction h(x[]) defined by
static UnivariateFunction combine(BivariateFunction combiner, UnivariateFunction f, UnivariateFunction g)
          Returns the univariate function
h(x) = combiner(f(x), g(x)).
static DifferentiableUnivariateFunction compose(DifferentiableUnivariateFunction... f)
          Deprecated. as of 3.1 replaced by compose(UnivariateDifferentiableFunction...)
static UnivariateDifferentiableFunction compose(UnivariateDifferentiableFunction... f)
          Composes functions.
static UnivariateFunction compose(UnivariateFunction... f)
          Composes functions.
static UnivariateFunction fix1stArgument(BivariateFunction f, double fixed)
          Creates a unary function by fixing the first argument of a binary function.
static UnivariateFunction fix2ndArgument(BivariateFunction f, double fixed)
          Creates a unary function by fixing the second argument of a binary function.
static DifferentiableUnivariateFunction multiply(DifferentiableUnivariateFunction... f)
          Deprecated. as of 3.1 replaced by multiply(UnivariateDifferentiableFunction...)
static UnivariateDifferentiableFunction multiply(UnivariateDifferentiableFunction... f)
          Multiplies functions.
static UnivariateFunction multiply(UnivariateFunction... f)
          Multiplies functions.
static double[] sample(UnivariateFunction f, double min, double max, int n)
          Samples the specified univariate real function on the specified interval.
static DifferentiableMultivariateFunction toDifferentiableMultivariateFunction(MultivariateDifferentiableFunction f)
          Deprecated. this conversion method is temporary in version 3.1, as the DifferentiableMultivariateFunction interface itself is deprecated
static DifferentiableMultivariateVectorFunction toDifferentiableMultivariateVectorFunction(MultivariateDifferentiableVectorFunction f)
          Deprecated. this conversion method is temporary in version 3.1, as the DifferentiableMultivariateVectorFunction interface itself is deprecated
static DifferentiableUnivariateFunction toDifferentiableUnivariateFunction(UnivariateDifferentiableFunction f)
          Deprecated. this conversion method is temporary in version 3.1, as the DifferentiableUnivariateFunction interface itself is deprecated
static MultivariateDifferentiableFunction toMultivariateDifferentiableFunction(DifferentiableMultivariateFunction f)
          Deprecated. this conversion method is temporary in version 3.1, as the DifferentiableMultivariateFunction interface itself is deprecated
static MultivariateDifferentiableVectorFunction toMultivariateDifferentiableVectorFunction(DifferentiableMultivariateVectorFunction f)
          Deprecated. this conversion method is temporary in version 3.1, as the DifferentiableMultivariateFunction interface itself is deprecated
static UnivariateDifferentiableFunction toUnivariateDifferential(DifferentiableUnivariateFunction f)
          Deprecated. this conversion method is temporary in version 3.1, as the DifferentiableUnivariateFunction interface itself is deprecated
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

compose

public static UnivariateFunction compose(UnivariateFunction... f)
Composes functions.
The functions in the argument list are composed sequentially, in the given order. For example, compose(f1,f2,f3) acts like f1(f2(f3(x))).

Parameters:
f - List of functions.
Returns:
the composite function.

compose

public static UnivariateDifferentiableFunction compose(UnivariateDifferentiableFunction... f)
Composes functions.
The functions in the argument list are composed sequentially, in the given order. For example, compose(f1,f2,f3) acts like f1(f2(f3(x))).

Parameters:
f - List of functions.
Returns:
the composite function.
Since:
3.1

compose

public static DifferentiableUnivariateFunction compose(DifferentiableUnivariateFunction... f)
Deprecated. as of 3.1 replaced by compose(UnivariateDifferentiableFunction...)

Composes functions.
The functions in the argument list are composed sequentially, in the given order. For example, compose(f1,f2,f3) acts like f1(f2(f3(x))).

Parameters:
f - List of functions.
Returns:
the composite function.

add

public static UnivariateFunction add(UnivariateFunction... f)
Adds functions.

Parameters:
f - List of functions.
Returns:
a function that computes the sum of the functions.

add

public static UnivariateDifferentiableFunction add(UnivariateDifferentiableFunction... f)
Adds functions.

Parameters:
f - List of functions.
Returns:
a function that computes the sum of the functions.
Since:
3.1

add

@Deprecated
public static DifferentiableUnivariateFunction add(DifferentiableUnivariateFunction... f)
Deprecated. as of 3.1 replaced by add(UnivariateDifferentiableFunction...)

Adds functions.

Parameters:
f - List of functions.
Returns:
a function that computes the sum of the functions.

multiply

public static UnivariateFunction multiply(UnivariateFunction... f)
Multiplies functions.

Parameters:
f - List of functions.
Returns:
a function that computes the product of the functions.

multiply

public static UnivariateDifferentiableFunction multiply(UnivariateDifferentiableFunction... f)
Multiplies functions.

Parameters:
f - List of functions.
Returns:
a function that computes the product of the functions.
Since:
3.1

multiply

public static DifferentiableUnivariateFunction multiply(DifferentiableUnivariateFunction... f)
Deprecated. as of 3.1 replaced by multiply(UnivariateDifferentiableFunction...)

Multiplies functions.

Parameters:
f - List of functions.
Returns:
a function that computes the product of the functions.

combine

public static UnivariateFunction combine(BivariateFunction combiner,
                                         UnivariateFunction f,
                                         UnivariateFunction g)
Returns the univariate function
h(x) = combiner(f(x), g(x)).

Parameters:
combiner - Combiner function.
f - Function.
g - Function.
Returns:
the composite function.

collector

public static MultivariateFunction collector(BivariateFunction combiner,
                                             UnivariateFunction f,
                                             double initialValue)
Returns a MultivariateFunction h(x[]) defined by
 
 h(x[]) = combiner(...combiner(combiner(initialValue,f(x[0])),f(x[1]))...),f(x[x.length-1]))
 

Parameters:
combiner - Combiner function.
f - Function.
initialValue - Initial value.
Returns:
a collector function.

collector

public static MultivariateFunction collector(BivariateFunction combiner,
                                             double initialValue)
Returns a MultivariateFunction h(x[]) defined by
 
 h(x[]) = combiner(...combiner(combiner(initialValue,x[0]),x[1])...),x[x.length-1])
 

Parameters:
combiner - Combiner function.
initialValue - Initial value.
Returns:
a collector function.

fix1stArgument

public static UnivariateFunction fix1stArgument(BivariateFunction f,
                                                double fixed)
Creates a unary function by fixing the first argument of a binary function.

Parameters:
f - Binary function.
fixed - Value to which the first argument of f is set.
Returns:
the unary function h(x) = f(fixed, x)

fix2ndArgument

public static UnivariateFunction fix2ndArgument(BivariateFunction f,
                                                double fixed)
Creates a unary function by fixing the second argument of a binary function.

Parameters:
f - Binary function.
fixed - Value to which the second argument of f is set.
Returns:
the unary function h(x) = f(x, fixed)

sample

public static double[] sample(UnivariateFunction f,
                              double min,
                              double max,
                              int n)
Samples the specified univariate real function on the specified interval.
The interval is divided equally into n sections and sample points are taken from min to max - (max - min) / n; therefore f is not sampled at the upper bound max.

Parameters:
f - Function to be sampled
min - Lower bound of the interval (included).
max - Upper bound of the interval (excluded).
n - Number of sample points.
Returns:
the array of samples.
Throws:
NumberIsTooLargeException - if the lower bound min is greater than, or equal to the upper bound max.
NotStrictlyPositiveException - if the number of sample points n is negative.

toDifferentiableUnivariateFunction

@Deprecated
public static DifferentiableUnivariateFunction toDifferentiableUnivariateFunction(UnivariateDifferentiableFunction f)
Deprecated. this conversion method is temporary in version 3.1, as the DifferentiableUnivariateFunction interface itself is deprecated

Convert a UnivariateDifferentiableFunction into a DifferentiableUnivariateFunction.

Parameters:
f - function to convert
Returns:
converted function

toUnivariateDifferential

@Deprecated
public static UnivariateDifferentiableFunction toUnivariateDifferential(DifferentiableUnivariateFunction f)
Deprecated. this conversion method is temporary in version 3.1, as the DifferentiableUnivariateFunction interface itself is deprecated

Convert a DifferentiableUnivariateFunction into a UnivariateDifferentiableFunction.

Note that the converted function is able to handle DerivativeStructure up to order one. If the function is called with higher order, a NumberIsTooLargeException will be thrown.

Parameters:
f - function to convert
Returns:
converted function

toDifferentiableMultivariateFunction

@Deprecated
public static DifferentiableMultivariateFunction toDifferentiableMultivariateFunction(MultivariateDifferentiableFunction f)
Deprecated. this conversion method is temporary in version 3.1, as the DifferentiableMultivariateFunction interface itself is deprecated

Convert a MultivariateDifferentiableFunction into a DifferentiableMultivariateFunction.

Parameters:
f - function to convert
Returns:
converted function

toMultivariateDifferentiableFunction

@Deprecated
public static MultivariateDifferentiableFunction toMultivariateDifferentiableFunction(DifferentiableMultivariateFunction f)
Deprecated. this conversion method is temporary in version 3.1, as the DifferentiableMultivariateFunction interface itself is deprecated

Convert a DifferentiableMultivariateFunction into a MultivariateDifferentiableFunction.

Note that the converted function is able to handle DerivativeStructure elements that all have the same number of free parameters and order, and with order at most 1. If the function is called with inconsistent numbers of free parameters or higher order, a DimensionMismatchException or a NumberIsTooLargeException will be thrown.

Parameters:
f - function to convert
Returns:
converted function

toDifferentiableMultivariateVectorFunction

@Deprecated
public static DifferentiableMultivariateVectorFunction toDifferentiableMultivariateVectorFunction(MultivariateDifferentiableVectorFunction f)
Deprecated. this conversion method is temporary in version 3.1, as the DifferentiableMultivariateVectorFunction interface itself is deprecated

Convert a MultivariateDifferentiableVectorFunction into a DifferentiableMultivariateVectorFunction.

Parameters:
f - function to convert
Returns:
converted function

toMultivariateDifferentiableVectorFunction

@Deprecated
public static MultivariateDifferentiableVectorFunction toMultivariateDifferentiableVectorFunction(DifferentiableMultivariateVectorFunction f)
Deprecated. this conversion method is temporary in version 3.1, as the DifferentiableMultivariateFunction interface itself is deprecated

Convert a DifferentiableMultivariateVectorFunction into a MultivariateDifferentiableVectorFunction.

Note that the converted function is able to handle DerivativeStructure elements that all have the same number of free parameters and order, and with order at most 1. If the function is called with inconsistent numbers of free parameters or higher order, a DimensionMismatchException or a NumberIsTooLargeException will be thrown.

Parameters:
f - function to convert
Returns:
converted function


Copyright © 2017 CNES. All Rights Reserved.