Class TensorCanonicalizer

Inheritance Relationships

Derived Types

Class Documentation

class TensorCanonicalizer

Base class for Tensor canonicalizers To make custom canonicalizer make a derived class and register an instance of that class with TensorCanonicalizer::register_instance.

Subclassed by sequant::DefaultTensorCanonicalizer, sequant::NullTensorCanonicalizer

Public Functions

virtual ~TensorCanonicalizer()
virtual ExprPtr apply(AbstractTensor&) = 0
Returns:

a side effect of canonicalization (e.g. phase), or nullptr if none

Public Static Functions

static std::shared_ptr< TensorCanonicalizer > instance_ptr (std::wstring_view label=L"")
Returns:

ptr to the TensorCanonicalizer object, if any, that had been previously registered via TensorCanonicalizer::register_instance() with label , or to the default canonicalizer, if any

static std::shared_ptr<TensorCanonicalizer> nondefault_instance_ptr(std::wstring_view label)

See also

instance_ptr

Returns:

ptr to the TensorCanonicalizer object, if any, that had been previously registered via TensorCanonicalizer::register_instance() with label

static std::shared_ptr< TensorCanonicalizer > instance (std::wstring_view label=L"")
Throws:

std::runtime_error – if no canonicalizer has been registered

Returns:

a TensorCanonicalizer previously registered via TensorCanonicalizer::register_instance() with label or to the default canonicalizer

static void register_instance (std::shared_ptr< TensorCanonicalizer > canonicalizer, std::wstring_view label=L"")

registers canonicalizer to be applied to Tensor objects with label label ; leave the label empty if canonicalizer is to apply to Tensor objects with any label

Note

if a canonicalizer registered with label label exists, it is replaced

static bool try_register_instance (std::shared_ptr< TensorCanonicalizer > canonicalizer, std::wstring_view label=L"")

tries to register canonicalizer to be applied to Tensor objects with label label ; leave the label empty if canonicalizer is to apply to Tensor objects with any label

See also

regiter_instance

Returns:

false if there is already a canonicalizer registered with label

static void deregister_instance (std::wstring_view label=L"")

deregisters canonicalizer (if any) registered previously to be applied to tensors with label label

static inline const auto &cardinal_tensor_labels()
Returns:

a list of Tensor labels with lexicographic preference (in order)

static inline void set_cardinal_tensor_labels(const container::vector<std::wstring> &labels)
Parameters:

labels – a list of Tensor labels with lexicographic preference (in order)

static const std::function<bool(const Index&, const Index&)> &index_comparer()

Note

the default is to use an object of type std::less<Index>

Returns:

reference to the object used to compare Index objects

static void index_comparer(std::function<bool(const Index&, const Index&)> comparer)
Parameters:

comparer – the compare object to be used by this

Protected Functions

inline auto bra_range(AbstractTensor &t)
inline auto ket_range(AbstractTensor &t)

Protected Static Attributes

static std::function<bool(const Index&, const Index&)> index_comparer_ = std::less<Index>{}

the object used to compare indices