Skip to content

Commit

Permalink
Create ghz_state.py
Browse files Browse the repository at this point in the history
  • Loading branch information
KOSASIH authored Aug 9, 2024
1 parent ec06044 commit 7614665
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions projects/pi-nexus-iam/qc-simulators/qiskit/ghz_state.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
from qiskit_simulator import QiskitSimulator

def get_qc_for_n_qubit_GHZ_state(n: int) -> QuantumCircuit:
qc = QuantumCircuit(n)
qc.h(0)
for i in range(n - 1):
qc.cx(i, i + 1)
return qc

def simulate_GHZ_state(n: int):
simulator = QiskitSimulator(n)
qc = get_qc_for_n_qubit_GHZ_state(n)
simulator.circuit = qc
result = simulator.run()
return result

0 comments on commit 7614665

Please sign in to comment.