In qiskit, you can get the unitary transformation matrix from a quantum circuit by running the following:
from qiskit import *
#circuit already defined
backend = Aer.get_backend('unitary_simulator')
job = execute(circuit, backend)
result = job.result()
and the matrix will output. As you increase the number of ...
While you can get the unitary matrix representation of a circuit using the unitary simulator as shown in the other answers, there is a much easier way using the Operator class in the qiskit.quantum_info library.
import qiskit.quantum_info as qi
op = qi.Operator(circ)
If you want the numpy array of the operator, this can be obtained via the data attribute (...
It is an issue. Adding control() to the gate introduces a phase difference.
You can verify that:
from qiskit.quantum_info import Operator, Pauli
gate = QuantumCircuit(1)
gate = gate.control()
[[ 1 0 0 0]
[ 0 0 0 1j]
[ 0 0 1 0]
[ 0 1j 0 0]]
Be cautious using logic like "it must be A or B, both of which imply C, therefore C" when dealing with quantum circuits. It can fail if A, B, or C don't commute (e.g. Hardy's paradox).
Personally, I would say the reason the circuit works is because of the no communication theorem and the deferred measurement principle. By the no communication ...