mindquantum.core.circuit.add_prefix
- mindquantum.core.circuit.add_prefix(circuit_fn, prefix: str)[source]
Add a prefix on the parameter of a parameterized quantum circuit or a parameterized quantum operator.
(a function that can generate a parameterized quantum circuit).
- Parameters
- Returns
Circuit or a function that can generate a Circuit.
- Raises
Examples
>>> from mindquantum.algorithm.library import qft >>> from mindquantum.core.circuit import add_prefix >>> from mindquantum import RX, H, Circuit >>> u = lambda qubit: Circuit([H.on(0), RX('a').on(qubit)]) >>> u1 = u(0) >>> u2 = add_prefix(u1, 'ansatz') >>> u3 = add_prefix(u, 'ansatz') >>> u3 = u3(0) >>> u2 ┏━━━┓ ┏━━━━━━━━━━━━━━┓ q0: ──┨ H ┠─┨ RX(ansatz_a) ┠─── ┗━━━┛ ┗━━━━━━━━━━━━━━┛ >>> u3 ┏━━━┓ ┏━━━━━━━━━━━━━━┓ q0: ──┨ H ┠─┨ RX(ansatz_a) ┠─── ┗━━━┛ ┗━━━━━━━━━━━━━━┛