mindquantum.core.circuit.dagger

View Source On Gitee
mindquantum.core.circuit.dagger(circuit_fn)[source]

Get the hermitian dagger of a quantum circuit or a quantum operator.

(a function that can generate a quantum circuit)

Parameters

circuit_fn (Union[Circuit, FunctionType, MethodType]) – A quantum circuit, or a function that can generate a quantum circuit.

Returns

Circuit or a function that can generate Circuit.

Raises

TypeError – If circuit_fn is not a Circuit or can not return a Circuit.

Examples

>>> from mindquantum.algorithm.library import qft
>>> from mindquantum.core.circuit import dagger
>>> u1 = qft([0, 1])
>>> u2 = dagger(u1)
>>> u3 = dagger(qft)
>>> u3 = u3([0, 1])
>>> u2
              ┏━━━━━━━━━━┓ ┏━━━┓
q0: ──╳───────┨ PS(-π/2) ┠─┨ H ┠───
      ┃       ┗━━━━━┳━━━━┛ ┗━━━┛
      ┃ ┏━━━┓       ┃
q1: ──╳─┨ H ┠───────■──────────────
        ┗━━━┛
>>> u3
              ┏━━━━━━━━━━┓ ┏━━━┓
q0: ──╳───────┨ PS(-π/2) ┠─┨ H ┠───
      ┃       ┗━━━━━┳━━━━┛ ┗━━━┛
      ┃ ┏━━━┓       ┃
q1: ──╳─┨ H ┠───────■──────────────
        ┗━━━┛