mindquantum.core.circuit.NoiseExcluder

View Source On Gitee
class mindquantum.core.circuit.NoiseExcluder(add_after=True)[source]

Exclude a noise channel.

Parameters

add_after (bool) – Whether add channel after gate or before gate. Default: True.

Examples

>>> from mindquantum.core.circuit import Circuit, NoiseExcluder, BitFlipAdder, MixerAdder
>>> from mindquantum.core.gates import DepolarizingChannel
>>> circ = Circuit().x(0)
>>> circ += DepolarizingChannel(0.1).on(0)
>>> circ
      ┏━━━┓ ╔════════════╗
q0: ──┨╺╋╸┠─╢ DC(p=1/10) ╟───
      ┗━━━┛ ╚════════════╝
>>> BitFlipAdder(0.1)(circ)
      ┏━━━┓ ╔═════════════╗ ╔════════════╗ ╔═════════════╗
q0: ──┨╺╋╸┠─╢ BFC(p=1/10) ╟─╢ DC(p=1/10) ╟─╢ BFC(p=1/10) ╟───
      ┗━━━┛ ╚═════════════╝ ╚════════════╝ ╚═════════════╝
>>> adder = MixerAdder([NoiseExcluder(), BitFlipAdder(0.1)])
>>> adder(circ)
      ┏━━━┓ ╔═════════════╗ ╔════════════╗
q0: ──┨╺╋╸┠─╢ BFC(p=1/10) ╟─╢ DC(p=1/10) ╟───
      ┗━━━┛ ╚═════════════╝ ╚════════════╝