mimiqcircuits.lazy¶
Lazy evaluation and composition functions.
Functions
|
Apply a control to a quantum operation or creating a lazy expression. |
|
Compute the inverse of a quantum operation. |
|
Create a parallel execution of a quantum operation or a lazy expression. |
|
Raise a quantum operation to a power or create a lazy expression. |
Classes
- mimiqcircuits.lazy.control(*args)[source]¶
Apply a control to a quantum operation or creating a lazy expression.
This function can be used in two ways: 1. To create a controlled version of a Gate or Operation. 2. To create a lazy expression that will apply a control to a future argument.
- Parameters:
*args –
Variable length argument list. - If one argument is provided:
If it’s an operation, returns a lazy expression control(?, op).
If it’s an integer (num_controls), returns a lazy expression control(n, ?).
If two arguments are provided (num_controls, gate): - Returns the controlled operation gate.control(num_controls).
- Returns:
The controlled operation or a lazy expression.
- Return type:
- Raises:
TypeError – If the arguments are of invalid types or count.
Examples
>>> from mimiqcircuits import * >>> op = control(2, GateX()) >>> op C₂X >>> lazy_ctrl = control(2) >>> lazy_ctrl(GateX()) C₂X
- mimiqcircuits.lazy.parallel(*args)[source]¶
Create a parallel execution of a quantum operation or a lazy expression.
This function can be used to apply an operation multiple times in parallel across different qubits.
- Parameters:
*args –
Variable length argument list. - If one argument is provided:
If it’s an operation, returns a lazy expression parallel(?, op).
If it’s an integer (num_repeats), returns a lazy expression parallel(n, ?).
- If two arguments are provided (num_repeats, gate):
Returns the parallel operation gate.parallel(num_repeats).
- Returns:
The parallel operation or a lazy expression.
- Return type:
- Raises:
TypeError – If the arguments are of invalid types or count.
Examples
>>> from mimiqcircuits import * >>> op = parallel(3, GateH()) >>> op ⨷ ³ H
- mimiqcircuits.lazy.inverse(op)[source]¶
Compute the inverse of a quantum operation.
- Parameters:
op (Operation) – The operation to invert.
- Returns:
The inverse of the operation.
- Return type:
Examples
>>> from mimiqcircuits import * >>> op = inverse(GateS()) >>> op S†
- mimiqcircuits.lazy.power(*args)[source]¶
Raise a quantum operation to a power or create a lazy expression.
- Parameters:
*args –
Variable length argument list. - If one argument is provided:
If it’s an operation, returns a lazy expression power(op, ?).
If it’s a number (exponent), returns a lazy expression power(?, exponent).
If two arguments are provided (gate, exponent): - Returns the powered operation gate.power(exponent).
- Returns:
The powered operation or a lazy expression.
- Return type:
- Raises:
TypeError – If the arguments are of invalid types or count.
Examples
>>> from mimiqcircuits import * >>> op = power(GateX(), 0.5) >>> op SX