Template Function sequant::evaluate_multiroot

Function Documentation

template<Trace EvalTrace = Trace::Default, typename node_t, typename F, typename N, bool FHC>
container::svector<ResultPtr> sequant::evaluate_multiroot(container::svector<node_t> const &roots, container::svector<std::string> const &layouts, F const &leaf_evaluator, CacheManager<N, FHC> &cache)

The multi-root dispatch entry. Consults the cache’s multiroot_driver() (cache_manager.hpp) and routes the whole set of independent roots through it, returning one result per root with no cross-root summation (a map, not a sum). A multi-root caller has no cheap per-tree fallback that would still give the cross-root CSE this entry point exists for (see multiroot_driver_type’s own doc comment) &#8212; so with no driver installed this throws rather than silently degrading to N independent (non-CSE’d) evaluations. The intended driver (installed via cache.set_multiroot_driver(...)) is the ordered executor’s evaluate_ordered_multiroot (ordered_executor.hpp), closed over the caller’s own OrderedSchedule/RichSchedule/target/batching policy.

Parameters:
  • roots – The independent root trees to evaluate; a subexpression shared across two or more of them is built exactly once by a driver that concatenates them into one schedule (the ordered executor’s own contract &#8212; see evaluate_ordered_multiroot).

  • layouts – The layout each root’s own result is permuted to, one entry per element of roots in the same order; same meaning as the forest-range evaluate’s layout, applied per-root (not once across a cross-root sum) &#8212; this is what lets heterogeneous roots (e.g. distinct CC residual annotations) each land in their own layout.

  • leaf_evaluator – Unused when a driver is installed (its own leaf evaluator lives inside the driver’s closure) &#8212; present only so this entry’s own call signature matches the rest of the evaluate family; kept for interface symmetry, not consulted directly here (there being no per-tree fallback path to consult it on).

  • cache – The cache whose multiroot_driver() is consulted.

Throws:
  • Exception – if cache.multiroot_driver() is unset &#8212; there is no per-root fallback; a multi-root caller must explicitly install a driver that understands the cross-root CSE contract.

  • Exception – if layouts.size() != roots.size().

Returns:

One ResultPtr per element of roots, in roots' own order.