Closed dime10 closed 1 year ago
An simpler version still giving the same error:
herm = qml.Hermitian([[1,0], [0,1]], wires=4)
H3 = qml.Hamiltonian([1.0, 1.0], [qml.PauliX(0), herm])
H3.simplify()
A solution: wrap the hermitian matrix into a numpy array instead of representing it as a list of lists:
herm = qml.Hermitian(np.array([[1,0], [0,1]]), wires=4)
Maybe we should run some validation on the Hermitian matrix to make sure its a matrix and not a list of lists.
Seems to raise no issues with op arithmetic.
tensor = qml.prod(qml.PauliX(0), qml.PauliX(1))
herm = qml.Hermitian([[1,0], [0,1]], wires=4)
qml.prod(qml.s_prod(1.0, tensor), qml.s_prod(1.0, qml.PauliX(2)), qml.s_prod(1.0, herm))
(1.0*(PauliX(wires=[0]) @ PauliX(wires=[1]))) @ (1.0*(PauliX(wires=[2]))) @ (1.0*(Hermitian([[1, 0], [0, 1]], wires=[4])))
Expected behavior
I've been playing around with the different observable types in Pennylane and noticed we do support multiplying Hamiltonians together, both from tensor products of Paulis and from Hermitian observables:
Actual behavior
However, for this case I get an unexpected error:
Additional information
No response
Source code
No response
Tracebacks
System information
Existing GitHub issues