workbench_algorithms.subroutines.sort
Qubricks for sort.
BitonicSort
Bases: Qubrick
Qubrick for performing a bitonic sort on a list of qubits.
compute
Sort a list of qubit registers.
Sort in ascending order if direction = 0, and descending otherwise. See : https://en.wikipedia.org/wiki/Bitonic_sorter#/media/File:BitonicSort.svg
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
regs_list
|
list[Qubits] or VectorRegister
|
List of qubit registers to sort. |
required |
direction
|
int
|
Direction of the sort (0-ascending vs 1-descending). |
required |
ctrl
|
(int, Qubits)
|
Control qubit for the routine. Defaults to 0. |
0
|
Note
This assumes same size register for all registers in regs_list.
unsort
Uncompute sort a list of qubit registers.
This performs a measurement in the X basis for each record qubit. If the outcome is one, it will require a phase-fixup performed by a comparator.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
regs_list
|
list[Qubits]
|
List of qubit registers to unsort. |
required |
ctrl
|
(int, Qubits)
|
Control qubit for the routine. |
0
|