public final class FunctionVariable extends java.lang.Object implements Function
Function
interface
are leave nodes within the abstract syntax tree of a function, representing indexed inputs to a function.
When parsing an expression into a function then these inputs are recognized by the character 'i' or 'I',
followed by the character 'j' or 'J' (optionally wrapped by '[' and ']'), which is a placeholder for the index
of the argument within the list/array of arguments passed to a concrete Function
instance. Function.of(java.lang.String)
( "3 * sum( (I[j] + 4) * I[0] )" ) Function.Callable
Constructor and Description |
---|
FunctionVariable(java.lang.String equation) |
Modifier and Type | Method and Description |
---|---|
double |
call(double[] inputs,
int j)
Invokes this
Function with the provided array of inputs ad an index for input dependent indexing. |
boolean |
dependsOn(int index)
Use this to determine if this function directly or indirectly references an input with the provided index.
|
double |
derive(double[] inputs,
int index)
Calculates the derivative of a particular input with respect to the output of this
Function
based on the provided array of inputs and an index targeting the input to be derived. |
double |
derive(double[] inputs,
int index,
int j)
Calculates the derivative of a particular input with respect to the output of this
Function
based on the provided array of inputs, an index targeting the input to be derived
and an index for input dependent indexing. |
Tensor<?> |
execute(Args arguments,
Tensor<?>... inputs)
|
Function |
getDerivative(int index)
|
AbstractOperation |
getOperation() |
java.util.List<Function> |
getSubFunctions() |
boolean |
isDoingAD()
Only branch
Function s can do autograd / 'Auto-Differentiation', meaning functions
whose Function.isFlat() flag is set to false! |
boolean |
isFlat() |
boolean |
providesGradient() |
java.lang.String |
toString()
Turns this function into a string representation which can be used to
reconstruct this function or combine it with other function strings to parse entirely new functions...
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
call, call, call, call, call, call, call, call, call, derive, derive, derive, derive, execute, execute, execute, executeDerive, executeDerive, getAllFunctions, invoke, invoke, invoke, invoke, invoke, invoke, invoke, invoke, invoke, numberOfArgs, of, of, with, with
public boolean providesGradient()
public boolean isFlat()
public boolean isDoingAD()
Function
Function
s can do autograd / 'Auto-Differentiation', meaning functions
whose Function.isFlat()
flag is set to false!public AbstractOperation getOperation()
getOperation
in interface Function
Operation
implementation instance responsible for executing any inputs received by this Function
or null if this Function.isFlat()
.public boolean dependsOn(int index)
Function
dependsOn
in interface Function
index
- The index which ought to match the input index of a potentially referenced FunctionInput
.Function
(or any sub-functions) reference a FunctionInput
with the provided index.public Function getDerivative(int index)
Function
Function
which is the derivative of this Function
with respect to the provided input index.getDerivative
in interface Function
index
- The index of the input which ought to serve as the variable which ought to be derived.Function
.public java.util.List<Function> getSubFunctions()
getSubFunctions
in interface Function
Function
nodes of this Function
AST node.public double call(double[] inputs, int j)
Function
Function
with the provided array of inputs ad an index for input dependent indexing.
This method is functionally equivalent to Function.invoke(double[], int)
.public double derive(double[] inputs, int index)
Function
Function
based on the provided array of inputs and an index targeting the input to be derived.public double derive(double[] inputs, int index, int j)
Function
Function
based on the provided array of inputs, an index targeting the input to be derived
and an index for input dependent indexing.public Tensor<?> execute(Args arguments, Tensor<?>... inputs)
Function
public java.lang.String toString()
Function