Expand description
Infrastructure for representing math expressions as trees and graphs
There are two families of representations in this module:
- A
Treeis a free-floating math expression, which can be cloned and has overloaded operators for ease of use. It is not deduplicated; two calls toTree::constant(1.0)will allocate two different objects.Treeobjects are typically used when building up expressions; they should be converted toNodeobjects (in a particularContext) after they have been constructed. - A
Contextis an arena for unique (deduplicated) math expressions, which are represented asNodehandles. EachNodeis specific to a particular context. OnlyNodeobjects can be converted intoFunctionobjects for evaluation.
In other words, the typical workflow is Tree → (Context, Node) → Function.
Structs§
- Context
- A
Contextholds a set of deduplicated constants, variables, and operations. - Node
- An index in the
Context::opsmap - Tree
- Owned handle for a standalone math tree
Enums§
- Binary
Opcode - A two-argument math operation
- Op
- An operation in a math expression
- TreeOp
- Opcode type for trees
- Unary
Opcode - A one-argument math operation