mindquantum.core.circuit.MixerAdder
- class mindquantum.core.circuit.MixerAdder(adders: List[ChannelAdderBase], add_after=True)[source]
Execute each adder if all accepter and excluder are met.
- Parameters
adders (List[
BitFlipChannel
]) – The adders you want to mix.add_after (bool) – Whether add channel after quantum gate or not. If
False
, the channel will add before quantum gate. This add_after will override all`add_after` of sub adder. Default:True
.
Examples
>>> from mindquantum.core.circuit import MeasureAccepter, BitFlipAdder, MixerAdder >>> from mindquantum.core.circuit import Circuit >>> circ = Circuit().rx('a', 0).h(0).measure_all() >>> only_measure = MixerAdder([BitFlipAdder(0.1), MeasureAccepter()], add_after=False) >>> only_measure(circ) ┏━━━━━━━┓ ┏━━━┓ ╔═════════════╗ ┍━━━━━━┑ q0: ──┨ RX(a) ┠─┨ H ┠─╢ BFC(p=1/10) ╟─┤ M q0 ├─── ┗━━━━━━━┛ ┗━━━┛ ╚═════════════╝ ┕━━━━━━┙