Skip to content

Commit

Permalink
#5 Delete: Initialize leader circuit through statevector
Browse files Browse the repository at this point in the history
  • Loading branch information
mapa21 committed May 7, 2024
1 parent b3fa92c commit 4bd3a1a
Showing 1 changed file with 1 addition and 27 deletions.
28 changes: 1 addition & 27 deletions weak_global_coin.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,7 @@
" self.coin = None\n",
" self.leader = None\n",
" self.generate_coin_circuit()\n",
" #self.generate_leader_circuit()\n",
" self.generate_superposition_leader()\n",
" self.generate_leader_circuit()\n",
"\n",
" def generate_coin_circuit(self):\n",
" qc = QuantumCircuit(n)\n",
Expand All @@ -76,31 +75,7 @@
" qc.measure_all() \n",
" self.coin = qc\n",
" \n",
" def tensor_n_qudits(self, qudit, nr_times):\n",
" partial_copy = qudit.copy()\n",
" tensor_vec = qudit.tensor(partial_copy)\n",
" for i in range(1,nr_times-1):\n",
" tensor_vec = tensor_vec.tensor(partial_copy)\n",
" return tensor_vec\n",
" \n",
" def generate_leader_circuit(self):\n",
" qudit = Statevector.from_int(1,dims=dims_value)\n",
" final_ket = (1 / norm) * self.tensor_n_qudits(qudit,n)\n",
" #final_ket = (1 / norm) * qudit\n",
"\n",
" for i in range(2,n_cube+1):\n",
" qudit = Statevector.from_int(i,dims=dims_value)\n",
" final_ket += (1 / norm) * self.tensor_n_qudits(qudit,n)\n",
" #final_ket += (1 / norm) * qudit\n",
"\n",
" circuit_nr_bits = n * nr_bits\n",
" #circuit_nr_bits = nr_bits\n",
" another_qc = QuantumCircuit(circuit_nr_bits)\n",
" another_qc.initialize(final_ket.data)\n",
" another_qc.measure_all()\n",
" self.leader = another_qc\n",
"\n",
" def generate_superposition_leader(self):\n",
" qc = QuantumCircuit(total_qubits)\n",
" qc.h(range(0, qb_per_process))\n",
"\n",
Expand Down Expand Up @@ -287,7 +262,6 @@
" if coin_msgs[i].sender == leader_process_id:\n",
" coin_msgs[i].circuit.measure_circuit_sampler()\n",
" leader_coin = coin_msgs[i].circuit.memory\n",
"#print(\"highest_leader: \", leader_process_id)\n",
"print(\"leader_coin: \", leader_coin)"
]
}
Expand Down

0 comments on commit 4bd3a1a

Please sign in to comment.