The problem is described in the title. I am trying to obtain a unitary matrix for a specific quantum circuit using pennylane, but I can’t find the available qml. function to get it. Thanks for the help!
Hi @cyrie_wang! If you are using the latest GitHub version of PennyLane, installable using
pip install git+https://github.com/PennyLaneAI/pennylane.git#egg=pennylane
then you can access the new qml.transforms.get_unitary_matrix()
function:
def circuit(theta):
qml.RX(theta, wires=1)
qml.PauliZ(wires=0)
We can use get_unitary_matrix()
to generate a new function that returns the unitary matrix corresponding to the function circuit:
>>> get_matrix = get_unitary_matrix(circuit)
>>> theta = np.pi/4
>>> get_matrix(theta)
4 Likes
wonderful! thank you so much.
Hi All,
I just wanted to give a quick update on this topic as it is still well referenced in search engines, and I spent some time trying to find the answer myself.
Since Release 0.23.0 (see release notes) qml.transforms.get_unitary_matrix
has been deprecated and the new function to call is qml.matrix
you can find the doc here
2 Likes
Thank you so much for posting this here @alicewithoutbob!