Template Function sequant::apply_one_op¶
Defined in File eval.hpp
Function Documentation¶
-
template<meta::can_evaluate Node>
ResultPtr sequant::apply_one_op(Node const &node, ResultPtr const &left, ResultPtr const &right)¶ The single-op compute kernel.
The raw op applied to already-evaluated operand results, dispatched by
node'sop type, with the contraction annotation computed fromnode. Value-in, value-out: it takes the operands’Resultbuffers and returns the op’s raw result, touching no cache and no value identity. It is exactly the innermostleft->adjoint/sum/prod(...)compute that both the tree-walkingevaluate_impland the value/occurrence-driven ordered executor perform, so both reach the op through this one function. Not handled here (all caller-side): a leaf (aleaf_evaluatorfetch, not an op), the shaped-product hook (the caller calls this only when the hook declines),apply_phase+ store, the in-place-Sum fast path, and all tally / trace / timing /last_op_flopssentinel.Note
The traversal is iterative: it maintains its own explicit work stack (a
std::dequeof frames) rather than recursing, so evaluation depth is bounded by the heap, not the C++ call stack. This keeps deep trees (e.g. a Sum or product chain with thousands of operands) stack-safe. Custom-evaluator interception is preserved exactly: it is consulted when a frame is first visited and a non-null result short-circuits the subtree (its children are never pushed), so subtree pruning — the mechanism batched eval relies on — is unaffected.- Template Parameters:
EvalTrace – If Trace::On, trace is written to the logger’s stream. Default is to follow Trace::Default, which is itself equal to Trace::On or Trace::Off.
Cache – If CacheCache::Checked (default) the root
nodeis looked up incachebefore evaluating; a hit short-circuits it. Child nodes are always evaluated Checked. Unchecked skips the lookup for the root only.
- Parameters:
node – A node that can be evaluated using
leaf_evaluatoras the leaf evaluator.leaf_evaluator – The leaf evaluator that satisfies
meta::leaf_node_evaluator<Node, F>.cache – The cache for common sub-expression elimination.
- Returns:
Evaluated result as ResultPtr.