mindquantum.core.circuit.SequentialAdder

View Source On Gitee
class mindquantum.core.circuit.SequentialAdder(adders: List[ChannelAdderBase])[source]

Execute each adder in this sequential.

Parameters

adders (List[ChannelAdderBase]) – The adder you want to apply.

Examples

>>> 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 ├───
                           ┗━━━┛ ╚════════════╝ ╚═════════════╝ ┕━━━━━━┙