Template Class HermitianObsBase

Inheritance Relationships

Base Type

Class Documentation

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

Base class for Hermitian observables.

Template Parameters

StateVectorT – State vector class.

Public Types

using PrecisionT = typename StateVectorT::PrecisionT
using ComplexT = typename StateVectorT::ComplexT
using MatrixT = std::vector<ComplexT>

Public Functions

inline HermitianObsBase(MatrixT matrix, std::vector<std::size_t> wires)

Create an Hermitian observable.

Parameters
  • matrix – Matrix in row major format.

  • wires – Wires the observable applies to.

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

Get the wires the observable applies to.

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

Get the name of the observable.

inline virtual void applyInPlace(StateVectorT &sv) const override

Apply the observable to the given statevector in place.

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

Protected Attributes

MatrixT matrix_
std::vector<std::size_t> wires_