From 76146652e9351f04a8a100f6e4b994472cbdaccf Mon Sep 17 00:00:00 2001 From: KOSASIH Date: Fri, 9 Aug 2024 09:52:46 +0700 Subject: [PATCH] Create ghz_state.py --- .../qc-simulators/qiskit/ghz_state.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 projects/pi-nexus-iam/qc-simulators/qiskit/ghz_state.py diff --git a/projects/pi-nexus-iam/qc-simulators/qiskit/ghz_state.py b/projects/pi-nexus-iam/qc-simulators/qiskit/ghz_state.py new file mode 100644 index 000000000..3b136b467 --- /dev/null +++ b/projects/pi-nexus-iam/qc-simulators/qiskit/ghz_state.py @@ -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