mindquantum.core.circuit.BitFlipAdder
- class mindquantum.core.circuit.BitFlipAdder(flip_rate: float, with_ctrl=True, focus_on: int = None, add_after: bool = True)[source]
Add BitFlip channel after or before quantum gate.
- Parameters
flip_rate (float) – The flip rate for bit flip channel. For more detail please refers to
BitFlipChannel
.with_ctrl (bool) – Whether add bit flip channel for control qubits. Default:
True
.focus_on (int) – Only add this noise channel on
focus_on
qubit. IfNone
, add to all qubits of selected quantum gate. Default:None
.add_after (bool) – Whether add this channel after quantum gate or not. If
False
, the channel will add before quantum gate. Default:True
.
Examples
>>> from mindquantum.core.circuit import BitFlipAdder >>> from mindquantum.core.circuit import Circuit >>> circ = Circuit().h(0).x(1, 0) >>> adder1 = BitFlipAdder(0.1, with_ctrl=False) >>> adder1(circ) ┏━━━┓ ╔═════════════╗ q0: ──┨ H ┠─╢ BFC(p=1/10) ╟───■───────────────────── ┗━━━┛ ╚═════════════╝ ┃ ┏━┻━┓ ╔═════════════╗ q1: ────────────────────────┨╺╋╸┠─╢ BFC(p=1/10) ╟─── ┗━━━┛ ╚═════════════╝ >>> adder2 = BitFlipAdder(0.1, with_ctrl=False, focus_on=1) >>> adder2(circ) ┏━━━┓ q0: ──┨ H ┠───■───────────────────── ┗━━━┛ ┃ ┏━┻━┓ ╔═════════════╗ q1: ────────┨╺╋╸┠─╢ BFC(p=1/10) ╟─── ┗━━━┛ ╚═════════════╝