Template Function sequant::detail::compute_index_replacement_rules

Function Documentation

template<Statistics S>
std::optional<std::pair<container::map<Index, Index>, bool>> sequant::detail::compute_index_replacement_rules(std::shared_ptr<Product> &product, const container::set<Index> &external_indices, const container::set<Index> &noncovariant_indices, const container::set<Index> &unpaired_indices, const std::set<Index, Index::LabelCompare> &all_indices, const std::shared_ptr<const IndexBasisRegistry> &isr)

computes index replacement rules

Kronecker deltas are translated into index replacement rules. Overlaps between indices in one orthonormal basis are Kronecker deltas (see is_kronecker_equivalent), hence such overlaps are also used to produce replacement rules. (N.B. dependent bases are not one basis if their protoindices differ). Summations are then reduced by index replacements. Reducing sums over dummy (internal) indices uses 2 rules:

  • if a Kronecker delta binds 2 internal indices I and J, replace them with a new internal index representing intersection of spaces of I and J, !!remove delta!!

  • if a Kronecker delta binds an internal index J and an external index I:

    • if space of J includes space of I, replace J with I, !!remove delta!!

    • if space of J is a subset of space of I, replace J with a new internal index representing intersection of spaces of I and J, !!keep the delta!! A basis instance (IndexBasis) is reduced like a subspace: an index without one is in its space’s own basis, which includes every instance of the space, and a delta or overlap between two different instances yields no rule. With a basis instance present the deltas are applied first, then the overlaps, those between two indices without one last, so that the rules do not depend on the order of the factors.

Parameters:
  • noncovariant_indices – the noncovariant indices, including those made so by a Kronecker delta (or an overlap equivalent to one) with another

  • unpaired_indices – the internal indices that do not appear exactly twice in nonproto slots, i.e. appear once or more than twice

Throws:

Exception – if a Kronecker delta binds indices of intersecting spaces whose bases resolve to different basis instances

Returns:

index replacement map + whether found any kronecker tensors or overlaps equivalent to them; the former may be empty even if the latter is true, if, e.g., contain trivial self-overlaps with identical indices; return null if product is zero for any reason, e.g. because it includes an overlap of 2 indices from nonoverlapping spaces