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

Update the adder test



Signed-off-by: default avatarThien Nguyen <nguyentm@ornl.gov>
parent 81d6ac32
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
#include <qcor_arithmetic>

__qpu__ void test_adder(qreg a, qreg b, qubit cin, qubit cout) {
  X(a[0]); // Set input a = 01
  X(b);    // Set input b = 11
  integer_init(a, 1); // Set input a = 01
  integer_init(b, 3); // Set input b = 11
  // Apply the adder
  ripple_add(a, b, cin, cout);
  Measure(b);
+11 −1
Original line number Diff line number Diff line
@@ -31,3 +31,13 @@ __qpu__ void ripple_add(qreg a, qreg b, qubit c_in, qubit c_out) {
  }
  unmajority(c_in, b[0], a[0]);
}

// Init a qubit register in an integer value
__qpu__ void integer_init(qreg a, int val) {
  Reset(a);
  for (auto i: range(a.size())) {
    if (val & (1 << i)) {
      X(a[i]);
    }
  }
}
 No newline at end of file