Template Class LightningObsManager¶
Defined in File LightningObsManager.hpp
Class Documentation¶
-
template<typename PrecisionT>
class LightningObsManager¶ The LightningObsManager caches observables of a program at runtime and maps each one to a const unique index (
int64_t
) in the scope of the global context manager.Public Functions
-
LightningObsManager() = default¶
-
~LightningObsManager() = default¶
-
LightningObsManager(const LightningObsManager&) = delete¶
-
LightningObsManager &operator=(const LightningObsManager&) = delete¶
-
LightningObsManager(LightningObsManager&&) = delete¶
-
LightningObsManager &operator=(LightningObsManager&&) = delete¶
-
inline void clear()¶
A helper function to clear constructed observables in the program.
-
inline auto isValidObservables(const std::vector<ObsIdType> &obsKeys) const -> bool¶
Check the validity of observable keys.
- Parameters
obsKeys – The vector of observable keys
- Returns
bool
-
inline auto getObservable(ObsIdType key) -> std::shared_ptr<Observable<VectorStateT>>¶
Get the constructed observable instance.
- Parameters
key – The observable key
- Returns
std::shared_ptr<Observable<VectorStateT>>
-
inline auto numObservables() const -> size_t¶
Get the number of observables.
- Returns
size_t
-
inline auto createNamedObs(ObsId obsId, const std::vector<size_t> &wires) -> ObsIdType¶
Create and cache a new NamedObs instance.
- Parameters
obsId – The named observable id of type ObsId
wires – The vector of wires the observable acts on
- Returns
ObsIdType
-
inline auto createHermitianObs(const std::vector<ComplexT> &matrix, const std::vector<size_t> &wires) -> ObsIdType¶
Create and cache a new HermitianObs instance.
- Parameters
matrix – The row-wise Hermitian matrix
wires – The vector of wires the observable acts on
- Returns
ObsIdType
-
inline auto createTensorProdObs(const std::vector<ObsIdType> &obsKeys) -> ObsIdType¶
Create and cache a new TensorProd instance.
- Parameters
obsKeys – The vector of observable keys
- Returns
ObsIdType
-
inline auto createHamiltonianObs(const std::vector<PrecisionT> &coeffs, const std::vector<ObsIdType> &obsKeys) -> ObsIdType¶
Create and cache a new HamiltonianObs instance.
- Parameters
coeffs – The vector of coefficients
obsKeys – The vector of observable keys
- Returns
ObsIdType
-
LightningObsManager() = default¶