Package functions.unitary.piecewise
Class DomainRestrictor
Object
GeneralFunction
UnitaryFunction
PiecewiseFunction
DomainRestrictor
- All Implemented Interfaces:
Differentiable
,Evaluable
,Outputable
,Simplifiable
,Comparable<GeneralFunction>
,Iterable<GeneralFunction>
public class DomainRestrictor extends PiecewiseFunction
The
DomainRestrictor
class allows for the restriction of domains of ranges of functions.
When domainTester
returns true, this class functions as the identity,
but when domainTester
returns false, evaluate
returns Double.NaN
.-
Field Summary
Fields Modifier and Type Field Description BiPredicate<Double,Map<String,Double>>
domainTester
ThisBiPredicate
describes the domain of this function given an argument and list of variable values -
Constructor Summary
Constructors Constructor Description DomainRestrictor(GeneralFunction operand, BiPredicate<Double,Map<String,Double>> domainTester)
Constructs a newDomainRestrictor
DomainRestrictor(GeneralFunction operand, DoublePredicate domainTester)
Constructs a newDomainRestrictor
-
Method Summary
Modifier and Type Method Description double
evaluate(Map<String,Double> variableValues)
Evaluates aGeneralFunction
at a point denoted by aMap
GeneralFunction
getDerivative(String varID)
Returns the derivative of aGeneralFunction
with respect to a variable.UnitaryFunction
getInstance(GeneralFunction operand)
Returns a new instance of thisUnitaryFunction
String
toString()
Returns a String representation of thisGeneralFunction
Methods inherited from class UnitaryFunction
clone, compareSelf, equalsFunction, hashCode, iterator, newInstanceOf, simplify, simplifyFOC, simplifyInternal, simplifyInverse, substituteAll, toOutputFunction
Methods inherited from class GeneralFunction
compareTo, derivativeAt, equals, equalsSimplified, getNthDerivative, getSimplifiedDerivative, substituteVariables
-
Field Details
-
domainTester
public final BiPredicate<Double,Map<String,Double>> domainTesterThisBiPredicate
describes the domain of this function given an argument and list of variable values
-
-
Constructor Details
-
DomainRestrictor
public DomainRestrictor(GeneralFunction operand, BiPredicate<Double,Map<String,Double>> domainTester)Constructs a newDomainRestrictor
- Parameters:
operand
- The function whose output will be restricteddomainTester
- theBiPredicate<Double, Map<String, Double>>
describing the domain of the function
-
DomainRestrictor
Constructs a newDomainRestrictor
- Parameters:
operand
- The function whose output will be restricteddomainTester
- theDoublePredicate
describing the domain of the function
-
-
Method Details
-
getInstance
Description copied from class:UnitaryFunction
Returns a new instance of thisUnitaryFunction
- Specified by:
getInstance
in classUnitaryFunction
- Parameters:
operand
- theGeneralFunction
to be operated on- Returns:
- a new instance of this
UnitaryFunction
-
getDerivative
Description copied from interface:Differentiable
Returns the derivative of aGeneralFunction
with respect to a variable. Should not be used in general;GeneralFunction.getSimplifiedDerivative(java.lang.String)
is strongly preferred.- Parameters:
varID
- the ID of the variable that is differentiated against- Returns:
- the derivative of the function with respect to
varID
-
evaluate
public double evaluate(Map<String,Double> variableValues)Description copied from interface:Evaluable
Evaluates aGeneralFunction
at a point denoted by aMap
- Parameters:
variableValues
- the values of the variables in theGeneralFunction
at the point- Returns:
- the value of the
GeneralFunction
at the point
-
toString
public String toString()Description copied from class:GeneralFunction
Returns a String representation of thisGeneralFunction
- Overrides:
toString
in classUnitaryFunction
- Returns:
- String representation of this function
-