I would like to perform an Hadamard test on a given Hamiltonian operator $\hat{H}$ acting on a 2-qubits system. For instance, suppose $\hat{H}$ can be decomposed into a qml.PauliX
on the first wire and a qml.PauliZ
on the second wire, and it could be created in Pennylane by H = qml.Hamiltonian(qml.PauliX(0) @ qml.PauliZ(1))
and measured by returning qml.expval(H)
.
But because I would like to perform the Hadamard test, I need to transform the Hamiltonian into a controlled gate in the circuit: how can I do it in Pennylane?