I have a state
psi as an ndarray of shape (
2 ** 3,) s.t.
psi= amplitude of 000
psi = amplitude of 001.
So my qubit ordering is reversed w.r.t. qiskit's. To initialize the circuit correctly and apply the IQFT on the first 2 qubits from the left I tried the following code:
import qiskit as qt from qiskit.aqua.circuits import FourierTransformCircuits as QFT circuit = qt.QuantumCircuit(3) circuit.initialize( psi, [i for i in reversed(circuit.qubits)]) QFT.construct_circuit(circuit=circuit, qubits=circuit.qubits[:2], inverse=True) backend = qt.Aer.get_backend('statevector_simulator') final_state = qt.execute(circuit, backend, shots=1).result().get_statevector()
From the tests I've run,
final_state is not what I expected: defining
exact = np.kron(IQFT_matrix(2),np.eye(2)).dot(state) with IQFT_matrix(2)= IQFT_matrix for 2 qubits.
fails. Can you please help me find the problem?