For this circuit, I am not sure why the cswap is leading to an error. Also, am I thinking about how to swap the middle matix rows correctly?
def decompose_two_qubit_QFT(basis_id):
“”"A circuit that computes the QFT on two qubits using elementary gates.
Args:
basis_id (int): An integer value identifying the basis state to construct.
Returns:
array[complex]: The state of the qubits after the QFT operation.
"""
# Prepare the basis state |basis_id>
bits = [int(x) for x in np.binary_repr(basis_id, width=dev.num_wires)]
qml.BasisStatePreparation(bits, wires=[0, 1])
##################
# YOUR CODE HERE #
##################
qml.ctrl(qml.SWAP, control = 0)(wires = [0,1])
qml.Hadamard(wires = 0)
qml.Hadamard(wires = 0)
qml.S(wires = 1)
qml.Hadamard(wires = 1)
qml.adjoint(qml.S)(wires = 1)
qml.Hadamard(wires = 1)
qml.ctrl(qml.SWAP, control = 0)(wires = [0,1])
return qml.state()