ApplyTransposition operation
Warning
This documentation refers to the Classic QDK, which has been replaced by the Modern QDK.
Please see https://aka.ms/qdk.api for the API documentation for the Modern QDK.
Namespace: Microsoft.Quantum.Synthesis
Package: Microsoft.Quantum.Standard
operation ApplyTransposition (a : Int, b : Int, qubits : Microsoft.Quantum.Arithmetic.LittleEndian) : Unit is Adj + Ctl
Description
This operation swaps the amplitude at index a
with the
amplitude at index b
in the given state-vector of
register
of length $n$. If a
equals b
, the state-vector
is not changed.
Input
a : Int
First index (must be a value from 0 to $2^n - 1$)
b : Int
Second index (must be a value from 0 to $2^n - 1$)
qubits : LittleEndian
A list of $n$ qubits to which the transposition is applied to.
Output : Unit
Example
Prepare a uniform superposition of number states $|1\rangle$, $|2\rangle$, and $|3\rangle$ on 2 qubits.
using (qubits = Qubit[2]) {
let register = LittleEndian(qubits);
PrepareUniformSuperposition(3, register);
ApplyTransposition(0, 3, register);
}
Feedback
https://aka.ms/ContentUserFeedback.
Coming soon: Throughout 2024 we will be phasing out GitHub Issues as the feedback mechanism for content and replacing it with a new feedback system. For more information see:Submit and view feedback for