mindquantum.core.circuit.QubitNumberConstrain
- class mindquantum.core.circuit.QubitNumberConstrain(n_qubits: int, with_ctrl: bool = True, add_after: bool = True)[source]
Only add noise channel for
n_qubits
quantum gate.- Parameters
Examples
>>> from mindquantum.core.circuit import QubitNumberConstrain, Circuit, BitFlipAdder, MixerAdder >>> circ = Circuit().h(0).x(1, 0) >>> circ ┏━━━┓ q0: ──┨ H ┠───■───── ┗━━━┛ ┃ ┏━┻━┓ q1: ────────┨╺╋╸┠─── ┗━━━┛ >>> adder = MixerAdder([ ... QubitNumberConstrain(2), ... BitFlipAdder(0.1) ... ]) >>> adder(circ) ┏━━━┓ ╔═════════════╗ q0: ──┨ H ┠───■───╢ BFC(p=1/10) ╟─── ┗━━━┛ ┃ ╚═════════════╝ ┏━┻━┓ ╔═════════════╗ q1: ────────┨╺╋╸┠─╢ BFC(p=1/10) ╟─── ┗━━━┛ ╚═════════════╝