Class TensorNetwork::Edge

Nested Relationships

This class is a nested type of Class TensorNetwork.

Nested Types

Class Documentation

class Edge

Edge in a TensorNetwork = the Index annotating it + a pair of indices to identify which Tensor terminals it’s connected to.

Note

tensor terminals in a sequence of tensors are indexed as follows:

  • >0 for bra terminals (i.e. “+7” indicated connection to a bra terminal of 7th tensor object in the sequence)

  • <0 for ket terminals

  • 0 if free (not attached to any tensor objects)

  • position records the terminal’s location in the sequence of bra/ket/aux terminals (always 0 for symmetric/antisymmetric tensors) Terminal indices are sorted by the tensor index (i.e. by the absolute value of the terminal index), followed by position

Public Functions

Edge() = default
inline explicit Edge(const Terminal &t)
inline Edge(const Terminal &t, const Index *idxptr)
inline Edge &connect_to(const Terminal &t)
inline bool operator<(const Edge &other) const
inline const auto &first() const
inline const auto &second() const
inline const auto &operator[](std::size_t i) const

access terminals by index, nonnull terminals first

Parameters:

i – the ordinal index, i must be 0 or 1

Returns:

if i==0 return first(), if nonnull, else second(), if nonnull, else null; if i==1 return second(), if nonnull, else else null;

inline auto size() const
Returns:

the number of attached terminals (0, 1, or 2)

inline const Index &idx() const

Friends

inline friend bool operator==(const Edge &a, const Edge &b)
struct Terminal

Public Functions

inline Terminal() noexcept
inline Terminal(int tensor_ord, TensorIndexSlotType slot_type, int slot_group_ord) noexcept
inline explicit operator bool() const
inline bool null() const
inline bool nonnull() const

Public Members

int tensor_ord = -1
TensorIndexSlotType slot_type = TensorIndexSlotType::Invalid
int slot_group_ord = -1

Friends

inline friend bool operator==(const Terminal &a, const Terminal &b)
inline friend bool operator<(const Terminal &a, const Terminal &b)