Generates a matrix based on the top-level control gate and nested control and target child gates.
Generates a matrix based on the top-level control gate and nested control and target child gates.
First, it generates an array of arrays. Each array is a binary representation of the decimal state vector index. For example, a vector of length 2 can be represented with the following matrix:
Array( Array(0, 0), Array(0, 1), Array(1, 0), Array(1, 1) )
Second, for each top-level array we check if control bits are triggered and if they are then we apply the final target gate to the target qubits.
control gate that this method generates a matrix for
final matrix representing the control gate acting on all involved qubits