Package dev.nm.analysis.function
Class SubFunction<R>
- java.lang.Object
-
- dev.nm.analysis.function.SubFunction<R>
-
- Type Parameters:
R
- the range of a function
- 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 Class Summary
-
Nested classes/interfaces inherited from interface dev.nm.analysis.function.Function
Function.EvaluationException
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method 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.
-
-
-
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 1fixing
- 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 functionfixing
- 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 functionfixing
- 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 interfaceFunction<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 interfaceFunction<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
-
-