Class OpRegistry¶
Defined in File op_registry.hpp
Class Documentation¶
-
class OpRegistry¶
A Registry for MBPT Operators.
A registry that keeps track of MBPT operators by their labels and properties.
Copy semantics is shallow (operator map shared via
std::shared_ptr), allowing multiple mbpt::Context objects to share operator definitions. Use OpRegistry::clone() for deep copies.Public Functions
-
inline OpRegistry()¶
default constructor, creates an empty registry
constructs an OpRegistry from an existing map of operators and their classes
-
inline OpRegistry(const OpRegistry &other)¶
copy constructor
-
inline OpRegistry(OpRegistry &&other) noexcept¶
move constructor
-
OpRegistry &operator=(const OpRegistry &other)¶
copy assignment operator
-
OpRegistry &operator=(OpRegistry &&other) noexcept¶
move assignment operator
-
inline decltype(auto) begin() const¶
const iterator to beginning of registry
-
inline decltype(auto) end() const¶
const iterator to end of registry
-
OpRegistry clone() const¶
clones this OpRegistry, creates a copy of ops_
-
OpRegistry &add(const std::wstring &op, OpClass action)¶
Adds a new operator to the registry.
Note
the operator’s Hermiticity defaults to default_hermiticity(action)
- Parameters:
op – the operator label
action – the class of the operator
-
OpRegistry &add(const std::wstring &op, OpClass action, Hermiticity hermiticity)¶
Adds a new operator to the registry with an explicit Hermiticity.
- Parameters:
op – the operator label
action – the class of the operator
hermiticity – the operator’s Hermiticity (overrides the default implied by
action)
-
OpRegistry &set_hermiticity(const std::wstring &op, Hermiticity hermiticity)¶
Overrides the Hermiticity of an already-registered operator.
- Parameters:
op – the operator label (must already be registered)
hermiticity – the operator’s Hermiticity
-
OpRegistry &grant_basis(const std::wstring &op, const IndexSpace &leg_space, IndexBasis::instance_type instance)¶
Grants the basis instance
instanceto the legs ofopthat OpMaker mints inleg_space.- Parameters:
op – the operator label (must be a registered Ex or Deex operator)
- Throws:
Exception – if
opis not registered or is a general operator
-
std::optional<std::wstring> resolve(std::wstring_view op) const¶
- Returns:
the registered label that
opstands for:opitself if registered, else its base label (perturbation-order superscript stripped) if that is, e.g.t¹stands fortunlesst¹is registered; null if neither is. Never throws
-
bool has_basis_grants(const std::wstring &op) const¶
- Returns:
true if the label
opstands for (see resolve) has a basis grant on any leg space; never throws
-
IndexBasis::optional_instance basis_grant(const std::wstring &op, const IndexSpace &leg_space) const¶
- Returns:
the basis instance granted to the legs of the label
opstands for (see resolve) in exactlyleg_space, if any; never throws
-
OpRegistry &remove(const std::wstring &op)¶
Removes an operator from the registry.
-
bool contains(const std::wstring &op) const¶
Checks if the registry contains an operator with the given label.
- Parameters:
op – the operator label
- Returns:
true if the operator exists, false otherwise
-
OpClass to_class(const std::wstring &op) const¶
Returns the class of the operator corresponding to the given label if it exists.
- Parameters:
op – the operator label
- Returns:
the class of the operator
-
Hermiticity hermiticity(const std::wstring &op) const¶
Returns the Hermiticity of the operator with the given label.
- Parameters:
op – the operator label
- Returns:
the operator’s Hermiticity (the per-operator override if set, else default_hermiticity(to_class(op)))
-
inline auto ops() const¶
returns a view of registered operator labels
-
inline void purge()¶
clears all registered operators (and their Hermiticity overrides and basis grants)
-
inline OpRegistry()¶