Template Class LightningKokkosObsManager

Class Documentation

template<typename PrecisionT>
class LightningKokkosObsManager

The LightningKokkosObsManager 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

LightningKokkosObsManager() = default
~LightningKokkosObsManager() = default
LightningKokkosObsManager(const LightningKokkosObsManager&) = delete
LightningKokkosObsManager &operator=(const LightningKokkosObsManager&) = delete
LightningKokkosObsManager(LightningKokkosObsManager&&) = delete
LightningKokkosObsManager &operator=(LightningKokkosObsManager&&) = 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<ObservableT>

Get the constructed observable instance.

Parameters

key – The observable key

Returns

std::shared_ptr<ObservableT>

inline auto numObservables() const -> std::size_t

Get the number of observables.

Returns

std::size_t

inline auto createNamedObs(ObsId obsId, const std::vector<std::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<std::complex<PrecisionT>> &matrix, const std::vector<std::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