Template Class NamedObsBase

Inheritance Relationships

Base Type

Class Documentation

template<class StateVectorT>
class NamedObsBase : public Pennylane::Observables::Observable<StateVectorT>

Base class for named observables (PauliX, PauliY, PauliZ, etc.)

Template Parameters

StateVectorT – State vector class.

Public Types

using PrecisionT = typename StateVectorT::PrecisionT

Public Functions

inline NamedObsBase(std::string obs_name, std::vector<size_t> wires, std::vector<PrecisionT> params = {})

Construct a NamedObsBase object, representing a given observable.

Parameters
  • obs_name – Name of the observable.

  • wires – Argument to construct wires.

  • params – Argument to construct parameters

inline virtual auto getObsName() const -> std::string override

Get the name of the observable.

inline virtual auto getWires() const -> std::vector<size_t> override

Get the wires the observable applies to.

inline virtual void applyInPlace(StateVectorT &sv) const override

Apply the observable to the given statevector in place.

inline virtual void applyInPlaceShots(StateVectorT &sv, std::vector<std::vector<PrecisionT>> &eigenValues, std::vector<size_t> &ob_wires) const override

Apply unitaries of an observable to the given statevector in place.

Parameters
  • sv – Reference to StateVector object.

  • eigenValues – Eigenvalues of an observable.

  • ob_wires – Reference to a std::vector object which stores wires of the observable.

Protected Attributes

std::string obs_name_
std::vector<size_t> wires_
std::vector<PrecisionT> params_