Function sequant::eval::detail::read_multiplicity

Function Documentation

inline std::size_t sequant::eval::detail::read_multiplicity(TableCell const &source, CellScope const &consumer_scope, std::function<std::size_t(LoopKey const&)> const &n_batches_of)

Multiplicity of one read of a source cell by a consumer cell: one factor of max(1, n_batches_of(key)) per loop instance on the consumer’s scope path that is not on the source’s residency scope path (residency_scope(source), not its raw scope &#8212; an Assemble’s residency can extend past its own scope, and a read must be weighted against where the source actually still lives, not merely where it was produced) &#8212; a consumer nested one extra (non-resident) loop deeper re-reads the source once per batch of each such loop. Takes the source source as a whole TableCell (never a bare scope) so this is the only place residency is applied to multiplicity; the single place both the builder (life bookkeeping) and the validator (rule 4) compute this, so they never drift apart. A null n_batches_of (the validator’s default) is treated as returning 1 everywhere.