mindquantum.core.circuit.QubitIDConstrain
- class mindquantum.core.circuit.QubitIDConstrain(qubit_ids: Union[int, List[int]], add_after: bool = True)[source]
Select gate with qubit id in given list.
- Parameters
Examples
>>> from mindquantum.core.circuit import MixerAdder, BitFlipAdder, QubitIDConstrain, Circuit >>> circ = Circuit().h(0).h(1).h(2).x(1, 0).x(2, 1) >>> circ ┏━━━┓ q0: ──┨ H ┠───■─────────── ┗━━━┛ ┃ ┏━━━┓ ┏━┻━┓ q1: ──┨ H ┠─┨╺╋╸┠───■───── ┗━━━┛ ┗━━━┛ ┃ ┏━━━┓ ┏━┻━┓ q2: ──┨ H ┠───────┨╺╋╸┠─── ┗━━━┛ ┗━━━┛ >>> adder = MixerAdder([ ... QubitIDConstrain([0, 1]), ... BitFlipAdder(0.1), ... ]) >>> adder(circ) ┏━━━┓ ╔═════════════╗ ╔═════════════╗ q0: ──┨ H ┠─╢ BFC(p=1/10) ╟───■───╢ BFC(p=1/10) ╟───────── ┗━━━┛ ╚═════════════╝ ┃ ╚═════════════╝ ┏━━━┓ ╔═════════════╗ ┏━┻━┓ ╔═════════════╗ q1: ──┨ H ┠─╢ BFC(p=1/10) ╟─┨╺╋╸┠─╢ BFC(p=1/10) ╟───■───── ┗━━━┛ ╚═════════════╝ ┗━━━┛ ╚═════════════╝ ┃ ┏━━━┓ ┏━┻━┓ q2: ──┨ H ┠───────────────────────────────────────┨╺╋╸┠─── ┗━━━┛ ┗━━━┛