mindquantum.core.circuit.SequentialAdder
- class mindquantum.core.circuit.SequentialAdder(adders: List[ChannelAdderBase])[源代码]
依次执行每一个添加器。
- 参数:
adders (List[
ChannelAdderBase
]) - 想要执行的 adder 。
样例:
>>> from mindquantum.core.circuit import SequentialAdder, MixerAdder, BitFlipAdder, NoiseChannelAdder >>> from mindquantum.core.circuit import MeasureAccepter, ReverseAdder, NoiseChannelAdder, Circuit >>> from mindquantum.core.circuit import NoiseExcluder >>> from mindquantum.core.gates import DepolarizingChannel >>> circ = Circuit().h(0).x(1, 0).measure_all() >>> circ ┏━━━┓ ┍━━━━━━┑ q0: ──┨ H ┠───■───┤ M q0 ├─── ┗━━━┛ ┃ ┕━━━━━━┙ ┏━┻━┓ ┍━━━━━━┑ q1: ────────┨╺╋╸┠─┤ M q1 ├─── ┗━━━┛ ┕━━━━━━┙ >>> bitflip_error_for_measure = MixerAdder([ ... BitFlipAdder(0.1), ... MeasureAccepter(), ... NoiseExcluder() ... ], add_after=False) >>> depolarizing_for_gate = MixerAdder([ ... NoiseChannelAdder(DepolarizingChannel(0.1)), ... ReverseAdder(MeasureAccepter()), ... NoiseExcluder() ... ]) >>> adder = SequentialAdder([ ... bitflip_error_for_measure, ... depolarizing_for_gate, ... ]) >>> adder(circ) ┏━━━┓ ╔════════════╗ ╔════════════╗ ╔═════════════╗ ┍━━━━━━┑ q0: ──┨ H ┠─╢ DC(p=1/10) ╟───■───╢ DC(p=1/10) ╟─╢ BFC(p=1/10) ╟─┤ M q0 ├─── ┗━━━┛ ╚════════════╝ ┃ ╚════════════╝ ╚═════════════╝ ┕━━━━━━┙ ┏━┻━┓ ╔════════════╗ ╔═════════════╗ ┍━━━━━━┑ q1: ───────────────────────┨╺╋╸┠─╢ DC(p=1/10) ╟─╢ BFC(p=1/10) ╟─┤ M q1 ├─── ┗━━━┛ ╚════════════╝ ╚═════════════╝ ┕━━━━━━┙