Class TensorCanonicalizer¶
Defined in File abstract_tensor.hpp
Inheritance Relationships¶
Derived Types¶
public sequant::DefaultTensorCanonicalizer
(Class DefaultTensorCanonicalizer)public sequant::NullTensorCanonicalizer
(Class NullTensorCanonicalizer)
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
- 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 labellabel
; leave the label empty ifcanonicalizer
is to apply to Tensor objects with any labelNote
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 labellabel
; leave the label empty ifcanonicalizer
is to apply to Tensor objects with any labelSee 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)
Protected Functions
-
inline auto bra_range(AbstractTensor &t)¶
-
inline auto ket_range(AbstractTensor &t)¶
-
virtual ~TensorCanonicalizer()¶