mindquantum.algorithm.library.bitphaseflip_operator

View Source On Gitee
mindquantum.algorithm.library.bitphaseflip_operator(phase_inversion_index, n_qubits)[source]

Generate a circuit that can flip the sign of any calculation bases.

Parameters
  • phase_inversion_index (list[int]) – Index of calculation bases want to flip phase.

  • n_qubits (int) – Total number of qubits.

Examples

>>> from mindquantum.core.circuit import Circuit, UN
>>> from mindquantum.core.gates import H, Z
>>> from mindquantum.algorithm.library import bitphaseflip_operator
>>> circuit = Circuit()
>>> circuit += UN(H, 3)
>>> circuit += bitphaseflip_operator([1, 3], 3)
>>> print(circuit.get_qs(ket=True))
√2/4¦000⟩
-√2/4¦001⟩
√2/4¦010⟩
-√2/4¦011⟩
√2/4¦100⟩
√2/4¦101⟩
√2/4¦110⟩
√2/4¦111⟩
Returns

Circuit, the bit phase flip circuit.