Template Function sequant::binarize(std::span<const ResultExpr>, const BinarizationOptions&)

Function Documentation

template<typename ExprT = EvalExpr>
InlinedSystem<ExprT> sequant::binarize(std::span<const ResultExpr> system, const BinarizationOptions &opts = {})

Creates the evaluation trees of a system of equations, inlining each definition into its uses.

A Tensor leaf whose label, bra/ket/aux ranks and per-slot index spaces and proto-index counts match the head of an equation, or match it with bra and ket swapped if the head is bra-ket symmetric (BraKetSymmetry::Symm), and a Variable leaf whose label matches a scalar head, is replaced by that equation’s tree, binarized as by binarize(ResultExpr const&) after renaming the head’s indices to the leaf’s and the other indices of its rhs to fresh ones. The subtree enters the consumer as one factor; its root carries the (renamed) head. Definitions inline recursively and may appear in any order.

Parameters:
  • system – the equations; every head must be labelled

  • opts – the options of every equation; opts.node_batch_axes must be empty: it annotates the nodes of a single term, so stamp the returned trees instead

Throws:

Exception – if opts.node_batch_axes is not empty, a head is unlabelled, two equations share a label and a shape (for a bra-ket symmetric head, also with bra and ket swapped), a matching leaf declares symmetries different from its head’s, a conjugated Variable leaf names a scalar head, a scalar head is the base of a scalar Power, a leaf spells a conjugate-symmetric (BraKetSymmetry::Conjugate) head with bra and ket swapped, or a definition reaches its own head