You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
operation Main(): Unit {
use q = Qubit[5]; // little-endian 5-bit integer.
X(q[1]); // q:=2.
Relabel(q, q[2..4]+q[0..1]); // Cyclic shift right by 3, q:=q<<3, must get q=16.
Message($"ans={MeasureInteger(q)}"); // prints 4, expected 16.
}
Expected behavior
State of qubits before relabel is [0,1,0,0,0]. We would expect that after relabel state is [0,0,0,0,1]. In particular, any use of q[4] should refer to what was q[1]. However, the state we get after relabel is [0,0,1,0,0].
I ran into this issue while trying to use Relabel to implement cyclic shift of an integer like this. When I ran tests for it, they failed for some inputs for n>=5 qubits.
I found a workaround - write my own code to decompose permutation into swaps (aka transpositions), and then use Relabel to apply each swap individually (like this).
The text was updated successfully, but these errors were encountered:
Describe the bug
Relabel operation doesn't work correctly.
To Reproduce
Run the following code:
Expected behavior
State of qubits before relabel is
[0,1,0,0,0]
. We would expect that after relabel state is[0,0,0,0,1]
. In particular, any use ofq[4]
should refer to what wasq[1]
. However, the state we get after relabel is[0,0,1,0,0]
.Screenshots
N/A
System information
Additional context
The text was updated successfully, but these errors were encountered: