Class VertexPainterImpl¶
Defined in File vertex_painter.hpp
Inheritance Relationships¶
Derived Types¶
public sequant::VertexPainter< TN >(Template Class VertexPainter)public sequant::VertexPainter< TensorNetworkV1 >(Template Class VertexPainter< TensorNetworkV1 >)
Class Documentation¶
-
class VertexPainterImpl¶
Can be used to assign unique colors to a set of objects. The class automatically ensures that there are no accidental color duplications for objects that actually should have different colors (i.e. this is more than a hash function). It is intended to be used to determine the vertex colors in a colored graph representing a tensor network.
Subclassed by sequant::VertexPainter< TN >, sequant::VertexPainter< TensorNetworkV1 >
Public Types
-
using Color = tensor_network::VertexColor¶
-
using NamedIndexSet = tensor_network::NamedIndexSet¶
-
using VertexData = std::variant<const AbstractTensor*, Index, const ProtoBundle*, BraGroup, KetGroup, AuxGroup, ColumnGroup>¶
-
using ColorMap = container::map<Color, VertexData>¶
Public Functions
-
VertexPainterImpl(const NamedIndexSet &named_indices, bool distinct_named_indices = true)¶
- Parameters:
named_indices – indices not in this list will use colors based on their Index::color()
distinct_named_indices – if false, will use same color for all named indices that have same Index::color(), else will use distinct color for each named_index
-
Color operator()(const ProtoBundle &bundle)¶
-
Color operator()(const ColumnGroup &group)¶
-
void apply_shade(std::size_t shade)¶
will apply
shadeto all subsequent colors. use this to shade colors of all tensor components by the color of its type
-
Color apply_shade(const AbstractTensor &t)¶
unlike the deprecated operator() computes a more complete hash (see VertexPainter::to_hash_value(const AbstractTensor&)) and sets it as the shade to all subsequent color computation. Use this before coloring other vertices of this the tensor.
-
void reset_shade()¶
Protected Functions
-
inline std::size_t salt() const¶
- Returns:
the salt value used for hashing; if not set by apply_shade use default_salt_
-
std::size_t to_hash_value(std::initializer_list<std::size_t> hash_values) const¶
-
std::size_t to_hash_value(const AbstractTensor &tensor) const¶
computes color of a tensor
See also
Note
The color should ideally depend on the “type” of the tensor. Unless we assume that tensor labels are unique (this is too restrictive), the type is defined by many things, including label, order (i.e. number of bra, ket, and aux slots), types of each slot, symmetries etc. For tensors with symmetries in general it is not possible to compute color uniquely without doing some sort of canonicalization of the slots. To avoid the need for canonicalization the color will only depend on the attrributes that are invariant wrt to slot permutations. This means label, order, and symmetries. More elaborate versions are possible, but have to stop somewhere.
Warning
this includes the default_salt
-
Color to_color(std::size_t color) const¶
produces a (not necessaryly unique) Color from an input size_t-sized color
-
Color to_color(std::initializer_list<std::size_t> hash_values) const¶
produces a (not necessaryly unique) Color from several input size_t-sized hash values
-
bool may_have_same_color(const VertexData &data, const AbstractTensor &tensor)¶
-
bool may_have_same_color(const VertexData &data, const BraGroup &group)¶
-
bool may_have_same_color(const VertexData &data, const KetGroup &group)¶
-
bool may_have_same_color(const VertexData &data, const AuxGroup &group)¶
-
bool may_have_same_color(const VertexData &data, const ColumnGroup &group)¶
-
bool may_have_same_color(const VertexData &data, const Index &idx)¶
-
bool may_have_same_color(const VertexData &data, const ProtoBundle &bundle)¶
Protected Attributes
-
const NamedIndexSet &named_indices_¶
-
bool distinct_named_indices_ = true¶
-
std::optional<std::size_t> salt_¶
Protected Static Attributes
-
static constexpr std::size_t default_salt = 0x43d2c59cb15b73f0¶
-
using Color = tensor_network::VertexColor¶