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 GeneralFunction
function1
OneGeneralFunction
in the binary operationprotected GeneralFunction
function2
The otherGeneralFunction
in the binary operation -
Constructor Summary
Constructors Constructor Description BinaryFunction(GeneralFunction function1, GeneralFunction function2)
Constructs a newBinaryFunction
-
Method Summary
Modifier and Type Method Description int
compareSelf(GeneralFunction that)
Used internally for comparing two functions of the same exact typeboolean
equalsFunction(GeneralFunction that)
Returns true when the two fully-simplified functions are equalGeneralFunction
getFunction1()
Returnssimplify()
function1
GeneralFunction
getFunction2()
Returnssimplify()
function2
abstract BinaryFunction
getInstance(GeneralFunction function1, GeneralFunction function2)
Returns an instance of thisGeneralFunction
, using the correct subclassint
hashCode()
Returns a hash code value for this object@NotNull Iterator<GeneralFunction>
iterator()
Returns an iterator over the operands of thisGeneralFunction
GeneralFunction
simplifyFOC()
GeneralFunction
substituteAll(Predicate<? super GeneralFunction> test, Function<? super GeneralFunction,? extends GeneralFunction> replacer)
Substitutes allVariable
in the function with a specifiedGeneralFunction
OutputFunction
toOutputFunction()
Converts this function into anOutputFunction
for use in string conversionMethods inherited from class GeneralFunction
clone, compareTo, derivativeAt, equals, equalsSimplified, getNthDerivative, getSimplifiedDerivative, substituteVariables, toString
-
Field Details
-
function1
OneGeneralFunction
in the binary operation -
function2
The otherGeneralFunction
in the binary operation
-
-
Constructor Details
-
BinaryFunction
Constructs a newBinaryFunction
- Parameters:
function1
- The firstGeneralFunction
in the binary operationfunction2
- The secondGeneralFunction
in 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 allVariable
in the function with a specifiedGeneralFunction
- Specified by:
substituteAll
in classGeneralFunction
- Parameters:
test
- the variable to be substituted intoreplacer
- theGeneralFunction
that will be substituted- Returns:
- the function after the given substitution was made
-
equalsFunction
Description copied from class:GeneralFunction
Returns true when the two fully-simplified functions are equal- Specified by:
equalsFunction
in classGeneralFunction
- Parameters:
that
- TheGeneralFunction
that the current function is being checked against- Returns:
- true if the two functions are equal
-
compareSelf
Description copied from class:GeneralFunction
Used internally for comparing two functions of the same exact type- Specified by:
compareSelf
in classGeneralFunction
- Parameters:
that
- theGeneralFunction
that this is compared against- Returns:
- the comparison
-
toOutputFunction
Description copied from interface:Outputable
Converts this function into anOutputFunction
for use in string conversion- Returns:
- this function as an
OutputFunction
-
simplifyFOC
- Returns:
- a new
Constant
of theBinaryFunction
evaluated if both operands are aConstant
-
hashCode
public int hashCode()Description copied from class:GeneralFunction
Returns a hash code value for this object- Specified by:
hashCode
in classGeneralFunction
- Returns:
- a hash code value for this object
-
iterator
Description copied from class:GeneralFunction
Returns an iterator over the operands of thisGeneralFunction
- Specified by:
iterator
in interfaceIterable<GeneralFunction>
- Specified by:
iterator
in classGeneralFunction
- Returns:
- an iterator over the operands of this
GeneralFunction
-