Loading examples/arithmetic/simple.cpp +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); Loading lib/impl/integer_arithmetic.hpp +11 −1 Original line number Diff line number Diff line Loading @@ -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 Loading
examples/arithmetic/simple.cpp +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); Loading
lib/impl/integer_arithmetic.hpp +11 −1 Original line number Diff line number Diff line Loading @@ -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