workbench_algorithms.subroutines.permutations
Submodule for qubricks which permute qubit registers.
BitonicPermutation
Bases: Qubrick
A routine that permutes qubit registers.
compute
compute(
target_reg: Qubits,
reg_size: int,
register_permutation_function: Callable,
ctrl: Qubits | int = 0,
)
Compute the circuit for the canonical swap-up-type permutation.
The sorting/permutation logic to perform a permutation of a register is independent of the particular quantum op used to effect a permutation. to use. This compute method exists so we can write down this logic just once and re-use it with your favorite "payload".
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
target_reg
|
(Qubits, list)
|
Register we apply the permutation to. This register can conceptually be interpreted as a single large register, or as several registers of equal size. To facilitate this dual use, we currently allow passing a list of Qubits objects (though this is likely to be refactored). |
required |
reg_size
|
int
|
Number of bits in each target sub-register of |
required |
register_permutation_function
|
callable
|
Which quantum operation to use to effect the permutation of the target register. |
required |
ctrl
|
Optional[Qubits, int]
|
Qreg to control on. Defaults to 0. |
0
|
Note
target_reg is given as a single register or as a list of multiple registers.
get_default_register_permutation_function
Factory to generate the default register permutation function.
This function acts as a factory to return a callable that permutes two qubit registers according to the index passed into the returned callable, which indicates which iteration of the total permutation we are currently on.
All register permutation functions must adhere to the contract of having a signature of permutation_index (int), reg1 (Qubits), reg2 (Qubits), and ctrl (Qubits or int), such that the permutation Qubricks that call them are promised a certain signature.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
index_reg
|
(Optional, Qubits)
|
An index register which coherently controls the application of quantum operations that effect a permutation of two qubit registers. Defaults to 0, in which case a permutation will occur regardless. |
0
|
Returns:
| Type | Description |
|---|---|
Callable
|
callable register permutation function. |
get_reversed_binary_to_unary_permutation_function
Factory to generate permutation circuits which undo a binary-to-unary conversion.
This function acts as a factory to return a callable that permutes two qubit registers according to the index passed into the returned callable, which indicates which iteration of the total permutation we are currently on.
All register permutation functions must adhere to the contract of having a signature of permutation_index (int), reg1 (Qubits), reg2 (Qubits), and ctrl (Qubits or int), such that the permutation Qubricks that call them are promised a certain signature.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
index_reg
|
(Optional, Qubits)
|
An index register which coherently controls the application of quantum operations that effect a permutation of two qubit registers. Defaults to 0, in which case a permutation will occur regardless. |
0
|
Returns:
| Type | Description |
|---|---|
Callable
|
callable register permutation function. |