Commit 1ce4a0cd authored by Nguyen, Thien Minh's avatar Nguyen, Thien Minh
Browse files

Bug fixed



Index limit in the SWAP loop for the QFT example.

Signed-off-by: default avatarThien Nguyen <nguyentm@ornl.gov>
parent 569cea20
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -30,7 +30,7 @@ __qpu__ void qft(qreg q, int startIdx, int nbQubits, int shouldSwap) {
  // A *hacky* way to do conditional (convert to a for loop)
  int swapCount = (shouldSwap == 0) ? 0 : 1;
  for (int count = 0; count < swapCount; ++count) {
    for (int qIdx = 0; qIdx < (nbQubits - 1)/2; ++qIdx) {
    for (int qIdx = 0; qIdx < nbQubits/2; ++qIdx) {
      Swap(q[startIdx + qIdx], q[startIdx + nbQubits - qIdx - 1]);
    }
  }
@@ -40,7 +40,7 @@ __qpu__ void iqft(qreg q, int startIdx, int nbQubits, int shouldSwap) {
  int swapCount = (shouldSwap == 0) ? 0 : 1;
  for (int count = 0; count < swapCount; ++count) {
    // Swap qubits
    for (int qIdx = 0; qIdx < (nbQubits - 1)/2; ++qIdx) {
    for (int qIdx = 0; qIdx < nbQubits/2; ++qIdx) {
      Swap(q[startIdx + qIdx], q[startIdx + nbQubits - qIdx - 1]);
    }
  }