Expand description
Infrastructure for representing math expressions as trees and graphs
There are two families of representations in this module:
- A
Tree
is 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.Tree
objects are typically used when building up expressions; they should be converted toNode
objects (in a particularContext
) after they have been constructed. - A
Context
is an arena for unique (deduplicated) math expressions, which are represented asNode
handles. EachNode
is specific to a particular context. OnlyNode
objects can be converted intoFunction
objects for evaluation.
In other words, the typical workflow is Tree → (Context, Node) → Function
.
Structs§
- Context
- A
Context
holds a set of deduplicated constants, variables, and operations. - Node
- An index in the
Context::ops
map - 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