Template Class TensorProdObs

Inheritance Relationships

Base Type

Class Documentation

template<typename T>
class TensorProdObs : public Pennylane::Algorithms::Observable<T>

Tensor product observable class.

Public Functions

template<typename ...Ts>
inline explicit TensorProdObs(Ts&&... arg)

Create a tensor product of observables.

Parameters

arg – Arguments perfect forwarded to vector of observables.

inline auto getSize() const -> size_t

Get the number of operations in observable.

Returns

size_t

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

Get the wires for each observable operation.

Returns

const std::vector<std::vector<size_t>>&

inline virtual void applyInPlace(StateVectorManagedCPU<T> &sv) const override

Apply the observable to the given statevector in place.

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

Get the name of the observable.

Public Static Functions

static inline auto create(std::initializer_list<std::shared_ptr<Observable<T>>> obs) -> std::shared_ptr<TensorProdObs<T>>

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

obs – List of observables

static inline auto create(std::vector<std::shared_ptr<Observable<T>>> obs) -> std::shared_ptr<TensorProdObs<T>>