Package functions
Class GeneralFunction
Object
GeneralFunction
- All Implemented Interfaces:
Differentiable,Evaluable,Outputable,Simplifiable,Comparable<GeneralFunction>,Iterable<GeneralFunction>
- Direct Known Subclasses:
BinaryFunction,CommutativeFunction,EndpointFunction,UnitaryFunction
public abstract class GeneralFunction extends Object implements Evaluable, Differentiable, Simplifiable, Comparable<GeneralFunction>, Iterable<GeneralFunction>, Outputable
A
GeneralFunction is the generalized abstract function used throughout the CAS.
It is critical to note that ALL FUNCTIONS ARE IMMUTABLE: as a consequence, methods such as Simplifiable.simplify() return a function that has been simplified rather than simplifying the caller in place.-
Field Summary
Fields Modifier and Type Field Description protected Map<String,GeneralFunction>derivativesCaches derivatives with the key corresponding to thevarIDof the derivativestatic Class<?>[]sortOrderDescribes the order that aGeneralFunctionshould appear in a sorted array (used incompareTo(GeneralFunction)) -
Constructor Summary
Constructors Constructor Description GeneralFunction() -
Method Summary
Modifier and Type Method Description abstract GeneralFunctionclone()Returns a clone of thisGeneralFunctionprotected abstract intcompareSelf(GeneralFunction that)Used internally for comparing two functions of the same exact typeintcompareTo(@NotNull GeneralFunction that)GeneralFunctions of different types are sorted according tosortOrderandMiscTools.findClassValue(GeneralFunction), and functions of the same exact type are sorted usingcompareSelf(GeneralFunction)doublederivativeAt(String varID, Map<String,Double> point)Returns the value of the derivative atpointbooleanequals(Object that)Compares two functions withequalsFunction(GeneralFunction)abstract booleanequalsFunction(GeneralFunction that)Returns true when the two fully-simplified functions are equalbooleanequalsSimplified(GeneralFunction that)Simplifies the two functions, then compares them withequalsFunction(GeneralFunction)GeneralFunctiongetNthDerivative(String varID, int N)Returns theNth derivative of aGeneralFunctionwith respect to a variableGeneralFunctiongetSimplifiedDerivative(String varID)abstract inthashCode()Returns a hash code value for this objectabstract @NotNull Iterator<GeneralFunction>iterator()Returns an iterator over the operands of thisGeneralFunctionabstract GeneralFunctionsubstituteAll(Predicate<? super GeneralFunction> test, Function<? super GeneralFunction,? extends GeneralFunction> replacer)GeneralFunctionsubstituteVariables(Map<String,? extends GeneralFunction> toSubstitute)Substitutes variables with functions as specified in a mapabstract StringtoString()Returns a String representation of thisGeneralFunction
-
Field Details
-
sortOrder
public static final Class<?>[] sortOrderDescribes the order that aGeneralFunctionshould appear in a sorted array (used incompareTo(GeneralFunction)) -
derivatives
Caches derivatives with the key corresponding to thevarIDof the derivative
-
-
Constructor Details
-
GeneralFunction
public GeneralFunction()
-
-
Method Details
-
toString
public abstract String toString()Returns a String representation of thisGeneralFunction- Overrides:
toStringin classObject- Returns:
- String representation of this function
-
clone
Returns a clone of thisGeneralFunction- Overrides:
clonein classObject- Returns:
- a clone of this function
-
getSimplifiedDerivative
-
getNthDerivative
Description copied from interface:DifferentiableReturns theNth derivative of aGeneralFunctionwith respect to a variable- Specified by:
getNthDerivativein interfaceDifferentiable- Parameters:
varID- the ID of the variable that is differentiated againstN- the amount of times to differentiate- Returns:
- the
Nth derivative of the function with respect tovarID
-
derivativeAt
public double derivativeAt(String varID, Map<String,Double> point)Returns the value of the derivative atpoint- Parameters:
varID- the variable being differentiated againstpoint- the point to find the derivative at- Returns:
- the value of the derivative at
point
-
substituteAll
public abstract GeneralFunction substituteAll(Predicate<? super GeneralFunction> test, Function<? super GeneralFunction,? extends GeneralFunction> replacer)- Parameters:
test- checks if the function should be replacedreplacer- replaces the function- Returns:
- a new
GeneralFunctionwith all replacements made
-
substituteVariables
Substitutes variables with functions as specified in a map- Parameters:
toSubstitute- the map betweenVariablestrings andGeneralFunctions- Returns:
- the new
GeneralFunctionafter all substitutions are preformed
-
equalsFunction
Returns true when the two fully-simplified functions are equal- Parameters:
that- TheGeneralFunctionthat the current function is being checked against- Returns:
- true if the two functions are equal
-
equalsSimplified
Simplifies the two functions, then compares them withequalsFunction(GeneralFunction)- Parameters:
that- the function to be compared against- Returns:
- true if they're equal when simplified
-
equals
public boolean equals(Object that)Compares two functions withequalsFunction(GeneralFunction)- Overrides:
equalsin classObject- Parameters:
that- the object to be compared against- Returns:
- true if they're equal
-
compareSelf
Used internally for comparing two functions of the same exact type- Parameters:
that- theGeneralFunctionthat this is compared against- Returns:
- the comparison
-
compareTo
GeneralFunctions of different types are sorted according tosortOrderandMiscTools.findClassValue(GeneralFunction), and functions of the same exact type are sorted usingcompareSelf(GeneralFunction)- Specified by:
compareToin interfaceComparable<GeneralFunction>- Parameters:
that- theGeneralFunctionthat this is compared against- Returns:
- the comparison
-
hashCode
public abstract int hashCode()Returns a hash code value for this object- Overrides:
hashCodein classObject- Returns:
- a hash code value for this object
-
iterator
Returns an iterator over the operands of thisGeneralFunction- Specified by:
iteratorin interfaceIterable<GeneralFunction>- Returns:
- an iterator over the operands of this
GeneralFunction
-