Skip to content

Commit d54ba2b

Browse files
authored
compute qubit indices in linear time instead of quadratic (#71)
1 parent d99d7bc commit d54ba2b

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

docs/qaoa/landscape_analysis.ipynb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -640,8 +640,9 @@
640640
"def compute_energies(row):\n",
641641
" permutation = []\n",
642642
" qubit_map = {}\n",
643+
" final_qubit_index = {q: i for i, q in enumerate(row['final_qubits'])}\n",
643644
" for i, q in enumerate(row['qubits']):\n",
644-
" fi = row['final_qubits'].index(q)\n",
645+
" fi = final_qubit_index[q]\n",
645646
" permutation.append(fi)\n",
646647
" qubit_map[i] = q\n",
647648
" \n",

0 commit comments

Comments
 (0)