EvaluatorInstructions
Symbolica documentation for getting started, symbolic expressions, numerical evaluation, pattern matching, and APIs in Python and Rust.
EvaluatorInstructions
EvaluatorInstructions()A portable instruction stream for evaluating an expression.
Attributes
| Name | Description |
|---|---|
constants |
Exact constants referenced by ('const', index) slots. |
input_count |
The number of input parameter values expected by this instruction stream. |
instructions |
Return a portable instruction representation for efficiently evaluating the expression |
output_count |
The number of output values produced by this instruction stream. |
sub_evaluators |
Non-inlined function bodies referenced by fun instructions in this stream. |
temporary_count |
The number of temporary storage slots required by instructions. |
constants
EvaluatorInstructions.constants: list[Expression]Exact constants referenced by ('const', index) slots.
input_count
EvaluatorInstructions.input_count: intThe number of input parameter values expected by this instruction stream.
instructions
EvaluatorInstructions.instructions: list[tuple]Return a portable instruction representation for efficiently evaluating the expression. This can be used to generate code for the expression evaluation in any programming language.
There are four lists that are used in the evaluation instructions:
param: the list of input parameters.temp: the list of temporary slots. Its size is available astemporary_count.const: the list of constants.out: the list of outputs.
The instructions are of the form:
('add', ('out', 0), [('const', 1), ('param', 0)], 0)which meansout[0] = const[1] + param[0]where the first0arguments are real.('mul', ('out', 0), [('temp', 0), ('param', 0)], 1)which meansout[0] = temp[0] * param[0], where the first1arguments are real.('pow', ('out', 0), ('param', 0), -1, true)which meansout[0] = param[0]^-1and the output is real (true).('powf', ('out', 0), ('param', 0), ('param', 1), false)which meansout[0] = param[0]^param[1].('fun', ('temp', 1), f, ["0"], [('param', 0)], true)which meanstemp[1] = f(0, param[0])and the output is real (true).('if_else', ('temp', 0), 5)which meansif temp[0] == 0 goto label 5(false branch).('goto', 10)which meansgoto label 10.('label', 3)which meanslabel 3.('join', ('out', 0), ('temp', 0), 3, 7)which meansout[0] = (temp[0] != 0) ? label 3 : label 7.
output_count
EvaluatorInstructions.output_count: intThe number of output values produced by this instruction stream.
sub_evaluators
EvaluatorInstructions.sub_evaluators: list[EvaluatorFunction]Non-inlined function bodies referenced by fun instructions in this stream.
temporary_count
EvaluatorInstructions.temporary_count: intThe number of temporary storage slots required by instructions.
Methods
| Name | Description |
|---|---|
__repr__ |
__repr__
EvaluatorInstructions.__repr__() -> str