Template Function Pennylane::Algorithms::statevectorVJP¶
Defined in File StateVecAdjDiff.hpp
Function Documentation¶
-
template<typename PrecisionT>
void Pennylane::Algorithms::statevectorVJP(std::span<std::complex<PrecisionT>> jac, const JacobianData<PrecisionT> &jd, std::span<const std::complex<PrecisionT>> dy, bool apply_operations = false)¶ Compute vector Jacobian product for a statevector Jacobian.
Product of statevector Jacobian \(J_{ij} = \partial_{\theta_j} \psi_{\pmb{\theta}}(i)\) and a vector, i.e. this function returns \(w = v^\dagger J\). This is equivalent to
\[w_j = \langle v | \partial_{\theta_j} \psi_{\pmb{\theta}} \rangle\]where \(\pmb{\theta}=(\theta_1, \theta_2, \cdots)\) is a list of all parameters and $v = dy$.
Note that \(J\) is \(2^n \times m\) matrix where \(n\) is the number of qubits and \(m\) is the number of trainable parameters in the tape. Thus the result vector is length \(m\).
- Parameters
jac – Preallocated vector for Jacobian data results.
jd – Jacobian data
vec – A cotangent vector of size 2^n
apply_operations – Assume the given state is an input state and apply operations if true