Skip to content

Commit

Permalink
patched distributed multiControlledTwoQubitUnitary
Browse files Browse the repository at this point in the history
In the unlikely scenario where both target qubits need to be swapped in-node, and the control qubits BOTH {0,1}, only one control qubit was being correctly swapped (due to an unnecessary `else` statement).
  • Loading branch information
TysonRayJones committed Jan 17, 2020
1 parent 2001043 commit 7fcd19b
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions QuEST/src/CPU/QuEST_cpu_distributed.c
Original file line number Diff line number Diff line change
Expand Up @@ -1409,13 +1409,14 @@ void statevec_multiControlledTwoQubitUnitary(Qureg qureg, long long int ctrlMask
statevec_swapQubitAmps(qureg, q1, qSwap);

} else {
// we know with certainty that both q1 and q2 >= 2
int swap1 = 0;
int swap2 = 1;

// ensure ctrl == swap1 or swap2, ensure ctrlMask updates under the swap
// if ctrl == swap1 or swap2, ensure ctrlMask updates under the swap
if (maskContainsBit(ctrlMask, swap1))
ctrlMask = flipBit(flipBit(ctrlMask, swap1), q1);
else if (maskContainsBit(ctrlMask, swap2))
if (maskContainsBit(ctrlMask, swap2))
ctrlMask = flipBit(flipBit(ctrlMask, swap2), q2);

statevec_swapQubitAmps(qureg, q1, swap1);
Expand Down

0 comments on commit 7fcd19b

Please sign in to comment.