mimiqcircuits.operations.repeat¶
Repeat operation.
Functions
|
Classes
|
Repeat operation: applies the same operation multiple times. |
- class mimiqcircuits.operations.repeat.Repeat(repeats, op)[source]¶
Bases:
OperationRepeat operation: applies the same operation multiple times.
Repeats a given quantum operation n times on the same qubits, bits, and z-variables. This is useful for constructing repeated sequences of the same gate without manually duplicating it.
Examples
>>> from mimiqcircuits import * >>> from symengine import * >>> Repeat(5, GateX()) ∏⁵ X
>>> Repeat(3, GateRX(Symbol("x"))) ∏³ RX(x)
>>> Repeat(2, Repeat(3, GateX())) ∏² ∏³ X
>>> Parallel(2, GateH()).repeat() lazy repeat(?, ⨷ ² H)
>>> Parallel(2, GateH()).repeat()(10) ∏¹⁰ ⨷ ² H
>>> c = Circuit().push(Repeat(2, GateX()), 0) >>> c 1-qubit circuit with 1 instruction: └── ∏² X @ q[0]
>>> Repeat(2, GateX()).decompose() 1-qubit circuit with 2 instructions: ├── X @ q[0] └── X @ q[0]
>>> Repeat(3, GateSWAP()).decompose() 2-qubit circuit with 3 instructions: ├── SWAP @ q[0:1] ├── SWAP @ q[0:1] └── SWAP @ q[0:1]
Note
The repeat function is a shorthand that may return other types (e.g., Power) if simplifications apply. It returns a Repeat instance only when appropriate.
- copy()[source]¶
- Creates a shallow copy of the operation.
To create a full copy use deepcopy() instead.
- Returns:
A new Operation object containing references to the same attributes as the original circuit
- Return type: