Skip to content
This repository was archived by the owner on Jan 12, 2024. It is now read-only.
Open
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions Standard/src/Canon/Utils/Multiplexer.qs
Original file line number Diff line number Diff line change
Expand Up @@ -482,4 +482,41 @@ namespace Microsoft.Quantum.Canon {
return (N, n);
}

/// # Summary
/// Performs a table lookup operation.
///
/// # Description
/// A table lookup uses an address to return classical data from quantum registers.
/// Computes the following map:
/// $$\sum_{j=0}^{L-1}\ket{j}\ket{0} \rightarrow \sum_{j=0}^{L-1}\ket{j}\ket{T_j}$$
Comment thread
adrianleh marked this conversation as resolved.
Outdated
/// where L is the length of the table
Comment thread
adrianleh marked this conversation as resolved.
Outdated
///
/// # Input
/// ## data
/// The classical bit data that represents the table.
/// The length of data has to be in the interval [0, 2^(number of qubits in address)[.
Comment thread
adrianleh marked this conversation as resolved.
Outdated
/// Each element of data has to be of length equal to the number of qubits in target.
Comment thread
adrianleh marked this conversation as resolved.
Outdated
/// ## address
/// The address used to lookup from the table.
/// ## target
/// Qubits in which the result of the lookup will be stored.
///
/// # Example
/// ```qsharp
Comment thread
adrianleh marked this conversation as resolved.
/// operation InvertTwoBitNumber(address : LittleEndian, target : Qubit[]) : Unit {
/// let data = [[true, true], [true, false], [false, true], [false, false]];
/// TableLookup(data, address, target);
/// }
/// ```
///
/// # References
/// - Windowed quantum arithmetic
/// Craig Gidney
/// https://arxiv.org/abs/1905.07682
operation TableLookup(data : Bool[][], address : LittleEndian, target : Qubit[]) : Unit is Adj + Ctl {
let ApplyXFromBitString = ApplyPauliFromBitString(PauliX, true, _, _); // Applies X conditionally based on bitstring
Comment thread
adrianleh marked this conversation as resolved.
Outdated
let unitaries = Mapped(bitstring -> ApplyXFromBitString(bitstring, _), data); // Create unitaries based on data
Comment thread
adrianleh marked this conversation as resolved.
Outdated
MultiplexOperations(unitaries, address, target); // Multiplex over address onto target
}

}