Module context

Module context 

Source
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 to Tree::constant(1.0) will allocate two different objects. Tree objects are typically used when building up expressions; they should be converted to Node objects (in a particular Context) after they have been constructed.
  • A Context is an arena for unique (deduplicated) math expressions, which are represented as Node handles. Each Node is specific to a particular context. Only Node objects can be converted into Function 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§

BinaryOpcode
A two-argument math operation
Op
An operation in a math expression
TreeOp
Opcode type for trees
UnaryOpcode
A one-argument math operation

Traits§

IntoNode
Helper trait for things that can be converted into a Node given a Context.