Loading examples/CMakeLists.txt +6 −1 Original line number Diff line number Diff line Loading @@ -42,7 +42,12 @@ add_test(NAME hadamard_ctrl_test COMMAND ${CMAKE_BINARY_DIR}/qcor ${CMAKE_CURREN add_test(NAME multi_ctrl_test COMMAND ${CMAKE_BINARY_DIR}/qcor ${CMAKE_CURRENT_SOURCE_DIR}/ctrl-gates/multiple_controls.cpp) add_qcor_compile_and_exe_test(qrt_bell_ctrl bell/bell_control.cpp) # Lambda tests add_qcor_compile_and_exe_test(qrt_qpu_lambda_simple qpu_lambda/lambda_test.cpp) add_qcor_compile_and_exe_test(qrt_qpu_lambda_bell qpu_lambda/lambda_test_bell.cpp) add_qcor_compile_and_exe_test(qrt_qpu_lambda_grover qpu_lambda/grover_lambda_oracle.cpp) # Arithmetic tests add_qcor_compile_and_exe_test(qrt_qpu_arith_adder arithmetic/simple.cpp) add_qcor_compile_and_exe_test(qrt_qpu_arith_integer_add arithmetic/integer_add.cpp) No newline at end of file examples/arithmetic/integer_add.cpp 0 → 100644 +23 −0 Original line number Diff line number Diff line #include <qcor_arithmetic> __qpu__ void test_add_integer(qreg q) { H(q[2]); // |000> + |001> add_integer(q, 3); // ==> |111> + |110> Measure(q); } int main(int argc, char **argv) { set_shots(1024); auto a = qalloc(3); test_add_integer::print_kernel(a); test_add_integer(a); a.print(); // Add 3 to a superposition of 0 and 4 // => superposition of 3 and 7 qcor_expect(a.counts().size() == 2); qcor_expect(a.counts()["111"] > 400); qcor_expect(a.counts()["110"] > 400); return 0; } No newline at end of file Loading
examples/CMakeLists.txt +6 −1 Original line number Diff line number Diff line Loading @@ -42,7 +42,12 @@ add_test(NAME hadamard_ctrl_test COMMAND ${CMAKE_BINARY_DIR}/qcor ${CMAKE_CURREN add_test(NAME multi_ctrl_test COMMAND ${CMAKE_BINARY_DIR}/qcor ${CMAKE_CURRENT_SOURCE_DIR}/ctrl-gates/multiple_controls.cpp) add_qcor_compile_and_exe_test(qrt_bell_ctrl bell/bell_control.cpp) # Lambda tests add_qcor_compile_and_exe_test(qrt_qpu_lambda_simple qpu_lambda/lambda_test.cpp) add_qcor_compile_and_exe_test(qrt_qpu_lambda_bell qpu_lambda/lambda_test_bell.cpp) add_qcor_compile_and_exe_test(qrt_qpu_lambda_grover qpu_lambda/grover_lambda_oracle.cpp) # Arithmetic tests add_qcor_compile_and_exe_test(qrt_qpu_arith_adder arithmetic/simple.cpp) add_qcor_compile_and_exe_test(qrt_qpu_arith_integer_add arithmetic/integer_add.cpp) No newline at end of file
examples/arithmetic/integer_add.cpp 0 → 100644 +23 −0 Original line number Diff line number Diff line #include <qcor_arithmetic> __qpu__ void test_add_integer(qreg q) { H(q[2]); // |000> + |001> add_integer(q, 3); // ==> |111> + |110> Measure(q); } int main(int argc, char **argv) { set_shots(1024); auto a = qalloc(3); test_add_integer::print_kernel(a); test_add_integer(a); a.print(); // Add 3 to a superposition of 0 and 4 // => superposition of 3 and 7 qcor_expect(a.counts().size() == 2); qcor_expect(a.counts()["111"] > 400); qcor_expect(a.counts()["110"] > 400); return 0; } No newline at end of file