How to turn a custom unitary matrix into a quantum gate to be added to a quantum circuit?

image

I have constructed the matrix as shown in qml.math, but how do I turn it into a 3-bit quantum gate?

Hey @RX1 , do you mind sharing your code here and explaining how you want this gate to work? :slight_smile: It would help us understand what you’re hoping to do.

(Making an edit because I originally misunderstood the question.)
If you’re hoping to define a new gate in PennyLane, you can find some great instructions in our blog post about creating custom gates.
But if you’re trying to do something much simpler (and just use this operator once), you can see that this is a unitary matrix, so you could use qml.QubitUnitary. In the upcoming v0.31 of PennyLane, you will even be able t ouse qml.DiagonalQubitUnitary because your matrix there is diagonal.

Does this help? :slight_smile:

1 Like