mindquantum.algorithm.library.bitphaseflip_operator
- mindquantum.algorithm.library.bitphaseflip_operator(phase_inversion_index, n_qubits)[源代码]
此算子生成一个可以翻转任意计算基的符号的电路。
- 参数:
phase_inversion_index (list[int]) - 需要翻转相位的计算基的索引。
n_qubits (int) - 量子比特总数。
- 返回:
Circuit,位相位翻转后的线路。
样例:
>>> 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⟩