Template Class HamiltonianBase¶
Defined in File Observables.hpp
Inheritance Relationships¶
Base Type¶
public Pennylane::Observables::Observable< StateVectorT >
(Template Class Observable)
Class Documentation¶
-
template<class StateVectorT>
class HamiltonianBase : public Pennylane::Observables::Observable<StateVectorT>¶ Base class for a general Hamiltonian representation as a sum of observables.
- Template Parameters
StateVectorT – State vector class.
Public Types
-
using PrecisionT = typename StateVectorT::PrecisionT¶
Public Functions
-
template<typename T1, typename T2>
inline HamiltonianBase(T1 &&coeffs, T2 &&obs)¶ Create a Hamiltonian from coefficients and observables.
- Parameters
coeffs – Arguments to construct coefficients
obs – Arguments to construct observables
-
inline void applyInPlace([[maybe_unused]] StateVectorT &sv) const override¶
-
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¶
-
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 auto getObs() const -> std::vector<std::shared_ptr<Observable<StateVectorT>>> override¶
Get the observable.
-
inline virtual auto getCoeffs() const -> std::vector<PrecisionT> override¶
Get the coefficients of the observable.
Public Static Functions
Convenient wrapper for the constructor as the constructor does not convert the std::shared_ptr with a derived class correctly.
This function is useful as std::make_shared does not handle brace-enclosed initializer list correctly.
- Parameters
coeffs – Arguments to construct coefficients
obs – Arguments to construct observables
- Returns
std::shared_ptr<HamiltonianBase<StateVectorT>>
Protected Attributes
-
std::vector<PrecisionT> coeffs_¶
-
std::vector<std::shared_ptr<Observable<StateVectorT>>> obs_¶