Template Class JacobianData

Class Documentation

template<class T>
class JacobianData

Represent the serialized data of a QuantumTape to differentiate.

Public Functions

inline JacobianData(size_t num_params, size_t num_elem, std::complex<T> *ps, std::vector<std::shared_ptr<Observable<T>>> obs, OpsData<T> ops, std::vector<size_t> trainP)

Construct a JacobianData object.

Each value \(i\) in trainable params means that we want to take a derivative respect to the \(i\)-th operation.

Further note that ops does not contain state preparation operations (e.g. QubitStateVector) or Hamiltonian coefficients.

Parameters
  • num_params – Number of parameters in the Tape.

  • num_elem – Length of the statevector data.

  • ps – Pointer to the statevector data.

  • obs – Observables for which to calculate Jacobian.

  • ops – Operations used to create given state.

  • trainP – Sorted list of parameters participating in Jacobian computation.

inline auto getNumParams() const -> size_t

Get Number of parameters in the Tape.

Returns

size_t

inline auto getSizeStateVec() const -> size_t

Get the length of the statevector data.

Returns

size_t

inline auto getPtrStateVec() const -> const std::complex<T>*

Get the pointer to the statevector data.

Returns

std::complex<T> *

inline auto getObservables() const -> const std::vector<std::shared_ptr<Observable<T>>>&

Get observables for which to calculate Jacobian.

Returns

List of observables

inline auto getNumObservables() const -> size_t

Get the number of observables for which to calculate Jacobian.

Returns

size_t

inline auto getOperations() const -> const OpsData<T>&

Get operations used to create given state.

Returns

OpsData<T>&

inline auto getTrainableParams() const -> const std::vector<size_t>&

Get list of parameters participating in Jacobian calculation.

Returns

std::vector<size_t>&

inline auto hasTrainableParams() const -> bool

Get if the number of parameters participating in Jacobian calculation is zero.

Returns

true If it has trainable parameters; false otherwise.