Template Function Pennylane::Algorithms::adjointJacobian¶
Defined in File AdjointDiff.hpp
Function Documentation¶
-
template<typename T>
void Pennylane::Algorithms::adjointJacobian(std::span<T> jac, const JacobianData<T> &jd, bool apply_operations = false)¶ Calculates the Jacobian for the statevector for the selected set of parametric gates.
For the statevector data associated with
psi
of lengthnum_elements
, we make internal copies to aStateVectorManagedCPU<T>
object, with one per required observable. Theoperations
will be applied to the internal statevector copies, with the operation indices participating in the gradient calculations given intrainableParams
, and the overall number of parameters for the gradient calculation provided withinnum_params
. The resulting row-major orderedjac
matrix representation will be of sizejd.getSizeStateVec() * jd.getObservables().size()
. OpenMP is used to enable independent operations to be offloaded to threads.- Parameters
jac – Preallocated vector for Jacobian data results.
jd – JacobianData represents the QuantumTape to differentiate.
apply_operations – Indicate whether to apply operations to tape.psi prior to calculation.