mimiqcircuits.operations.repeat

Repeat operation.

Functions

repeat(*args)

Classes

Repeat(repeats, op)

Repeat operation: applies the same operation multiple times.

class mimiqcircuits.operations.repeat.Repeat(repeats, op)[source]

Bases: Operation

Repeat 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.

__init__(repeats, op)[source]
get_operation()[source]
getparam(name)[source]
getparams()[source]
power(pow)[source]
parallel(repeat)[source]
control(repeat)[source]
inverse()[source]
iswrapper()[source]
evaluate(d)[source]
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:

Operation

deepcopy()[source]

Creates a copy of the object and for all its attributes

Returns:

A new Operation object fully identical the original circuit

Return type:

Operation

format_with_targets(qubits, bits, zvars)[source]
mimiqcircuits.operations.repeat.repeat(*args)[source]