Function sequant::subset_target_indices

Function Documentation

auto sequant::subset_target_indices(meta::range_of<Index, 2> auto const &rng, meta::range_of<Index> auto const &tixs)

Determines the target indices for all subsets of a given range of index groups.

This function computes the set of “target” indices for each subset of rng. An index is considered a target for a subset if it appears exactly once within that subset (making it an open index for that subset) or if it is present in the provided tixs (target indices) and also appears in the subset. Additionally, indices that appear in the subset and also appear in the complementary subset (implied by counts.at(counts.size() - i - 1).contains(k)) are included, which effectively identifies contracted indices that need to be preserved as open indices if they are matched in the complement.

Parameters:
  • rng – A range of ranges of Index. The outer range represents a collection of index groups.

  • tixs – A range of Index representing the global target indices (e.g., indices of the result tensor).

Returns:

A vector of sets, where result[mask] contains the set of target Index objects for the subset defined by mask.