I have a question regarding the
qml.Hamiltonian function. Given that I have a Hamiltonian written as a
qml.Hamiltonian, can I see it’s matrix representation as a
np.array? The point of this is because I want to use a circuit that does the following:
def circuit(params): # performs some operations return qml.expval(qml.Hermitian(array), wires = [...])
I know that a possibility is to use
qml.ExpvalCost() instead of doing this. However, I want to use JAX here so that instead of working with
circuit I work with
vcircuit = jax.vmap(circuit) so I can run the same circuit for multiple parameters simultaneously.
Also, the point of this is because I know how to write my Hamiltonian efficiently in terms of the parameters needed for
qml.Hamiltonian (it’s basically a sum of local terms so I can use
qml.PauliX operations together with the Y and Z).
On the other hand, in the
qml.Hamiltonian documentation I see that it is possible to go from
qml.Hamiltonian, so I wonder whether it is possible to do it the other way around, i.e., given that I have a
qml.Hamiltonian, could I generate the corresponding
Thank you very much for your attention.