0
$\begingroup$

I'm new with Qiskit and I'm struggling with creating my own controlled gates. I'm trying to create a ZYZ decomposition of a controlled unitary gate I created. I'm trying to use the method TwoQubitBasisDecomposer. Here is a piece of my code

U = Operator([[a,b],[c,d]]) #forms an unitary matrix

ucirc = QuantumCircuit(1)
ucirc.unitary(U,0)

c_ucirc = ucirc.control()

Ug = c_ucirc.to_gate()
UgZYZ = TwoQubitBasisDecomposer(Ug, euler_basis="ZYZ")
print(UgZYZ.basis)

When printing the basis Qiskit returns the equivalent two-qubit decomposed gate

enter image description here

However, I don't know how to actually get the gate itself to insert on other algorithms. How can I proceed? All methods within TwoQubitBasisDecomposer ask for a target. What is such a target?

$\endgroup$

1 Answer 1

1
$\begingroup$

The class TwoQubitBasisDecomposer decomposes 2-qubit unitaries using the minimum number of a 2-qubit basis gate of your choice. You pass this basis gate to the class constructor. In your code snippet, Ug is the basis gate that will be used to decompose the other unitaries.

Given a 2-qubit unitary G, you can decompose it as follows. Note that, TwoQubitBasisDecomposer implements __call__ so we can call its instance as a function.

# Here, we create a random 2-qubit unitary:
from qiskit.quantum_info.random import random_unitary
G = random_unitary(4).data

# Now, we decompose it using your decomposer:
circ = UgZYZ(G)
circ.draw('mpl')

enter image description here

$\endgroup$
1
  • $\begingroup$ Thanks a lot! It did help me. $\endgroup$ Feb 11 at 13:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.