Class SubFunction<R>

java.lang.Object
dev.nm.analysis.function.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.
  • Field Details

    • f

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

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

    • 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 Details

    • 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