mimiqcircuits.operations.parallel¶
Parallel gate operation.
Functions
|
Classes
|
Copies of a gate applied in parallel on separate qubits. |
- class Parallel(num_repeats, op)[source]¶
Bases:
GateCopies of a gate applied in parallel on separate qubits.
Parallel(n, gate)appliesgatentimes, each copy on its own group of qubits: the firstgate.num_qubitstargets go to the first copy, the next ones to the second, and so on. Its matrix is the tensor product ofncopies of the gate’s matrix.The
parallelmethod of a gate is the usual way to build one.- Parameters:
num_repeats – Number of copies, at least 2.
op (Gate) – The gate to repeat.
- Raises:
TypeError – If
opis not a gate.ValueError – If
num_repeatsis less than 2.
Examples
>>> from mimiqcircuits import * >>> # three X gates on qubits 1, 2 and 3 as a single instruction >>> c = Circuit() >>> c.push(Parallel(3, GateX()), 1, 2, 3) 4-qubit circuit with 1 instruction: └── ⨷ ³ X @ q[1], q[2], q[3] >>> # a two-qubit gate in parallel: CX on (0, 1) and on (2, 3) >>> Parallel(2, GateCX()).decompose() 4-qubit circuit with 2 instructions: ├── CX @ q[0], q[1] └── CX @ q[2], q[3]
- property num_repeats¶
Number of parallel copies. Read-only.
- property op¶
The repeated gate. Read-only.
- power(*args)[source]¶
Raise each parallel copy to a power.
- Parameters:
*args – The exponent. When omitted, a lazy expression is returned that takes the exponent later.
- Returns:
Parallel(num_repeats, Power(op, p)), or a lazy expression when called without arguments.- Return type:
- Raises:
ValueError – If more than one argument is given.
- control(*args)[source]¶
Return the gate controlled by
num_controlsqubits.Gates with a named controlled form return it directly (for example
GateX().control(1)isGateCX()); otherwise the gate is wrapped inControl. The controls are the first qubits.- Parameters:
*args – The number of controls. Without it, return a
LazyExprthat takes the number later.- Raises:
ValueError – If more than one argument is given.
- parallel(*args)[source]¶
Repeat in parallel again, multiplying the number of copies.
- Parameters:
*args – The extra repetition factor
n. When omitted, a lazy expression is returned that takes it later.- Returns:
Parallel(num_repeats * n, op), or a lazy expression when called without arguments.- Return type:
- Raises:
ValueError – If more than one argument is given.
Examples
>>> from mimiqcircuits import * >>> Parallel(2, GateH()).parallel(3) ⨷ ⁶ H