mindquantum.algorithm.library.general_ghz_state
- mindquantum.algorithm.library.general_ghz_state(qubits)[source]
Circuit that prepare a general GHZ State based on zero state.
The GHZ State is defined as the equality superposition of three zeros state and three ones state:
\[\left|\text{GHZ}\right> = (\left|000\right> + \left|111\right>)/\sqrt{2}\]Here in this API, we can create a general GHZ state on arbitrary sub qubits of any total qubits.
- Parameters
qubits (list[int]) – Qubits you want to apply general GHZ state.
- Returns
Circuit, circuit that can prepare ghz state.
Examples
>>> from mindquantum.algorithm.library import general_ghz_state >>> print(general_ghz_state(range(3)).get_qs(ket=True)) √2/2¦000⟩ √2/2¦111⟩ >>> print(general_ghz_state([1, 2]).get_qs(ket=True)) √2/2¦000⟩ √2/2¦110⟩