# SuanShu, a Java numerical and statistical library

com.numericalmethod.suanshu.analysis.function

## Class SubFunction<R>

• Type Parameters:
R - the range of a function
All Implemented Interfaces:
Function<Vector,R>
Direct Known Subclasses:
RealScalarSubFunction, RealVectorSubFunction

public abstract class SubFunction<R>
extends Object
implements Function<Vector,R>
A sub-function, g, is defined over a subset of the domain of another (original) function, f. g(x) = f(x) when they are both defined. This implementation constructs a sub-function by restricting/fixing the values of a subset of variables of another function.

• ### Nested classes/interfaces inherited from interface com.numericalmethod.suanshu.analysis.function.Function

Function.EvaluationException
• ### Field Summary

Fields
Modifier and Type Field and Description
protected Function<Vector,R> f
the original, unrestricted function
protected Map<Integer,Double> fixing
the restrictions or fixed values
• ### Constructor Summary

Constructors
Constructor and Description
SubFunction(Function<Vector,R> f, Map<Integer,Double> fixing)
Constructs a sub-function.
• ### Method Summary

All Methods
Modifier and Type Method and Description
int dimensionOfDomain()
Get the number of variables the function has.
int dimensionOfRange()
Get the dimension of the range space of the function.
static Vector getAllParts(Vector variables, Map<Integer,Double> fixing)
Combines the variable and fixed values to form an input to the original function.
static double[] getVariablePart(double[] z, Map<Integer,Double> fixing)
Given an input to the original function, this extracts the variable parts (excluding the fixed values).
boolean isFixedIndex(int i)
Checks whether a particular index corresponds a fixed variable/value.
static boolean isFixedIndex(int i, Map<Integer,Double> fixing)
Checks whether a particular index corresponds a fixed variable/value.
• ### Methods inherited from class java.lang.Object

clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
• ### Methods inherited from interface com.numericalmethod.suanshu.analysis.function.Function

evaluate
• ### Field Detail

• #### f

protected final Function<Vector,R> f
the original, unrestricted function
• #### fixing

protected final Map<Integer,Double> fixing
the restrictions or fixed values
• ### Constructor Detail

• #### SubFunction

public SubFunction(Function<Vector,R> f,
Map<Integer,Double> fixing)
Constructs a sub-function.
Parameters:
f - the original, unrestricted function
fixing - the values held fixed for a subset of variables
• ### Method Detail

• #### isFixedIndex

public static boolean isFixedIndex(int i,
Map<Integer,Double> fixing)
Checks whether a particular index corresponds a fixed variable/value.
Parameters:
i - an index, counting from 1
fixing - fixed values
Returns:
true if xi is fixed to some value
• #### getVariablePart

public static double[] getVariablePart(double[] z,
Map<Integer,Double> fixing)
Given an input to the original function, this extracts the variable parts (excluding the fixed values).
Parameters:
z - an input to the original function
fixing - fixed values
Returns:
the variable part in z
• #### getAllParts

public static Vector getAllParts(Vector variables,
Map<Integer,Double> fixing)
Combines the variable and fixed values to form an input to the original function.
Parameters:
variables - the non-fixed variables/values to the restricted function
fixing - the fixed values to the original function
Returns:
an input to the original function
• #### dimensionOfDomain

public int dimensionOfDomain()
Description copied from interface: Function
Get the number of variables the function has. For example, for a univariate function, the domain dimension is 1; for a bivariate function, the domain dimension is 2.
Specified by:
dimensionOfDomain in interface Function<Vector,R>
Returns:
the number of variables
• #### dimensionOfRange

public int dimensionOfRange()
Description copied from interface: Function
Get the dimension of the range space of the function. For example, for a Rn->Rm function, the dimension of the range is m.
Specified by:
dimensionOfRange in interface Function<Vector,R>
Returns:
the dimension of the range
• #### isFixedIndex

public boolean isFixedIndex(int i)
Checks whether a particular index corresponds a fixed variable/value.
Parameters:
i - an index, counting from 1
Returns:
true if xi is fixed to some value