Template Function sequant::evaluate(Node const&, F const&, CacheManager<N, FHC>&)

Function Documentation

template<Trace EvalTrace = Trace::Default, detail::CacheCheck Cache = detail::CacheCheck::Checked, meta::can_evaluate Node, typename F, typename N, bool FHC>
ResultPtr sequant::evaluate(Node const &node, F const &le, CacheManager<N, FHC> &cache)

Note

The traversal is iterative: it maintains its own explicit work stack (a std::deque of 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 &#8212; the mechanism batched eval relies on &#8212; 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 node is looked up in cache before 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 le as the leaf evaluator.

  • le – The leaf evaluator that satisfies meta::leaf_node_evaluator<Node, F>.

  • cache – The cache for common sub-expression elimination.

Returns:

Evaluated result as ResultPtr.