Given a quantum circuit consisting of two qubits, how is the compiled unitary of the circuit computed when we have different input type gates? (X-gate, H-gate are single-input gates, CNOT is a 2-input gate).
qc = QuantumCircuit(2)
qc.x(1)
qc.h(0)
qc.cnot(0,1)
usim = Aer.get_backend('unitary_simulator')
qobj = assemble(qc)
unitary = usim.run(qobj).result().get_unitary()
array_to_latex(unitary, pretext="\\text{Circuit = } ")
Section 2.2 of Qiskit shows how the simultaneous operations of two single-input gates are represented by computing the tensor product of the two gates, and that when we apply a gate to one bit at a time, we represent the unitary as the tensor product with the identity matrix. For the circuit above, how do we compile the circuit's unitary for the $4\times 4$ CNOT matrix,
$$ \text{CNOT} = \begin{pmatrix} 1 & 0 & 0 & 0\\ 0 & 0 & 0 & 1\\ 0 & 0 & 1 & 0\\ 0 & 1 & 0 & 0\\ \end{pmatrix}, $$
and the $2\times 2$ $X$ and $H$ matrices?