Package functions.binary
Class BinaryFunction
Object
GeneralFunction
BinaryFunction
- All Implemented Interfaces:
Differentiable,Evaluable,Outputable,Simplifiable,Comparable<GeneralFunction>,Iterable<GeneralFunction>
- Direct Known Subclasses:
IntegerBinaryFunction,Logb,Pow,Rand
public abstract class BinaryFunction extends GeneralFunction
The abstract
BinaryFunction class represents function of two inputs and that aren't commutable. Ex: log_{2}(x) or 3^(x)-
Field Summary
Fields Modifier and Type Field Description protected GeneralFunctionfunction1OneGeneralFunctionin the binary operationprotected GeneralFunctionfunction2The otherGeneralFunctionin the binary operation -
Constructor Summary
Constructors Constructor Description BinaryFunction(GeneralFunction function1, GeneralFunction function2)Constructs a newBinaryFunction -
Method Summary
Modifier and Type Method Description intcompareSelf(GeneralFunction that)Used internally for comparing two functions of the same exact typebooleanequalsFunction(GeneralFunction that)Returns true when the two fully-simplified functions are equalGeneralFunctiongetFunction1()Returnssimplify()function1GeneralFunctiongetFunction2()Returnssimplify()function2abstract BinaryFunctiongetInstance(GeneralFunction function1, GeneralFunction function2)Returns an instance of thisGeneralFunction, using the correct subclassinthashCode()Returns a hash code value for this object@NotNull Iterator<GeneralFunction>iterator()Returns an iterator over the operands of thisGeneralFunctionGeneralFunctionsimplifyFOC()GeneralFunctionsubstituteAll(Predicate<? super GeneralFunction> test, Function<? super GeneralFunction,? extends GeneralFunction> replacer)Substitutes allVariablein the function with a specifiedGeneralFunctionOutputFunctiontoOutputFunction()Converts this function into anOutputFunctionfor use in string conversionMethods inherited from class GeneralFunction
clone, compareTo, derivativeAt, equals, equalsSimplified, getNthDerivative, getSimplifiedDerivative, substituteVariables, toString
-
Field Details
-
function1
OneGeneralFunctionin the binary operation -
function2
The otherGeneralFunctionin the binary operation
-
-
Constructor Details
-
BinaryFunction
Constructs a newBinaryFunction- Parameters:
function1- The firstGeneralFunctionin the binary operationfunction2- The secondGeneralFunctionin the binary operation
-
-
Method Details
-
getFunction1
Returnssimplify()function1- Returns:
simplify()function1
-
getFunction2
Returnssimplify()function2- Returns:
simplify()function2
-
getInstance
Returns an instance of thisGeneralFunction, using the correct subclass- Parameters:
function1- Constructor parameter 1function2- Constructor parameter 2- Returns:
- an instance of this
GeneralFunction
-
substituteAll
public GeneralFunction substituteAll(Predicate<? super GeneralFunction> test, Function<? super GeneralFunction,? extends GeneralFunction> replacer)Substitutes allVariablein the function with a specifiedGeneralFunction- Specified by:
substituteAllin classGeneralFunction- Parameters:
test- the variable to be substituted intoreplacer- theGeneralFunctionthat will be substituted- Returns:
- the function after the given substitution was made
-
equalsFunction
Description copied from class:GeneralFunctionReturns true when the two fully-simplified functions are equal- Specified by:
equalsFunctionin classGeneralFunction- Parameters:
that- TheGeneralFunctionthat the current function is being checked against- Returns:
- true if the two functions are equal
-
compareSelf
Description copied from class:GeneralFunctionUsed internally for comparing two functions of the same exact type- Specified by:
compareSelfin classGeneralFunction- Parameters:
that- theGeneralFunctionthat this is compared against- Returns:
- the comparison
-
toOutputFunction
Description copied from interface:OutputableConverts this function into anOutputFunctionfor use in string conversion- Returns:
- this function as an
OutputFunction
-
simplifyFOC
- Returns:
- a new
Constantof theBinaryFunctionevaluated if both operands are aConstant
-
hashCode
public int hashCode()Description copied from class:GeneralFunctionReturns a hash code value for this object- Specified by:
hashCodein classGeneralFunction- Returns:
- a hash code value for this object
-
iterator
Description copied from class:GeneralFunctionReturns an iterator over the operands of thisGeneralFunction- Specified by:
iteratorin interfaceIterable<GeneralFunction>- Specified by:
iteratorin classGeneralFunction- Returns:
- an iterator over the operands of this
GeneralFunction
-