Loading examples/bell/bell_control.cpp 0 → 100644 +14 −0 Original line number Diff line number Diff line __qpu__ void bell(qubit q, qubit r) { H(q); X::ctrl(q,r); Measure(q); Measure(r); } int main() { auto q = qalloc(1); auto r = qalloc(1); bell(q[0],r[0]); q.print(); r.print(); } No newline at end of file python/py-qcor.cpp +7 −3 Original line number Diff line number Diff line Loading @@ -58,9 +58,9 @@ namespace { // Here we enumerate them as a Variant using AllowedKernelArgTypes = xacc::Variant<bool, int, double, std::string, xacc::internal_compiler::qreg, std::vector<double>, std::vector<int>, qcor::PauliOperator, qcor::FermionOperator, qcor::PairList<int>, std::vector<qcor::PauliOperator>, xacc::internal_compiler::qubit, std::vector<double>, std::vector<int>, qcor::PauliOperator, qcor::FermionOperator, qcor::PairList<int>, std::vector<qcor::PauliOperator>, std::vector<qcor::FermionOperator>>; // We will take as input a mapping of arg variable names to the argument itself. Loading Loading @@ -539,6 +539,10 @@ PYBIND11_MODULE(_pyqcor, m) { [](xacc::internal_compiler::qreg &q, const std::string &key) { return q.results()->getInformation(key); }, "") .def( "__getitem__", [](xacc::internal_compiler::qreg &q, int index) { return q[index]; }, ""); // m.def("createObjectiveFunction", [](const std::string name, )) py::class_<qcor::QJIT, std::shared_ptr<qcor::QJIT>>(m, "QJIT", "") Loading python/tests/test_jit_simple.py +20 −0 Original line number Diff line number Diff line Loading @@ -211,6 +211,26 @@ class TestKernelJIT(unittest.TestCase): self.assertEqual(comp.nInstructions(), counter) def test_multi_qregs(self): set_qpu('qpp', {'shots':1024}) @qjit def bell_qubits(q: qubit, r: qubit): H(q) X.ctrl(q, r) Measure(q) Measure(r) q = qalloc(1) r = qalloc(1) bell_qubits(q[0], r[0]) q.print() r.print() self.assertEqual(len(q.counts()), 2) self.assertEqual(len(r.counts()), 2) # entangled self.assertEqual(q.counts()["0"], r.counts()["0"]) self.assertEqual(q.counts()["1"], r.counts()["1"]) if __name__ == '__main__': unittest.main() No newline at end of file Loading
examples/bell/bell_control.cpp 0 → 100644 +14 −0 Original line number Diff line number Diff line __qpu__ void bell(qubit q, qubit r) { H(q); X::ctrl(q,r); Measure(q); Measure(r); } int main() { auto q = qalloc(1); auto r = qalloc(1); bell(q[0],r[0]); q.print(); r.print(); } No newline at end of file
python/py-qcor.cpp +7 −3 Original line number Diff line number Diff line Loading @@ -58,9 +58,9 @@ namespace { // Here we enumerate them as a Variant using AllowedKernelArgTypes = xacc::Variant<bool, int, double, std::string, xacc::internal_compiler::qreg, std::vector<double>, std::vector<int>, qcor::PauliOperator, qcor::FermionOperator, qcor::PairList<int>, std::vector<qcor::PauliOperator>, xacc::internal_compiler::qubit, std::vector<double>, std::vector<int>, qcor::PauliOperator, qcor::FermionOperator, qcor::PairList<int>, std::vector<qcor::PauliOperator>, std::vector<qcor::FermionOperator>>; // We will take as input a mapping of arg variable names to the argument itself. Loading Loading @@ -539,6 +539,10 @@ PYBIND11_MODULE(_pyqcor, m) { [](xacc::internal_compiler::qreg &q, const std::string &key) { return q.results()->getInformation(key); }, "") .def( "__getitem__", [](xacc::internal_compiler::qreg &q, int index) { return q[index]; }, ""); // m.def("createObjectiveFunction", [](const std::string name, )) py::class_<qcor::QJIT, std::shared_ptr<qcor::QJIT>>(m, "QJIT", "") Loading
python/tests/test_jit_simple.py +20 −0 Original line number Diff line number Diff line Loading @@ -211,6 +211,26 @@ class TestKernelJIT(unittest.TestCase): self.assertEqual(comp.nInstructions(), counter) def test_multi_qregs(self): set_qpu('qpp', {'shots':1024}) @qjit def bell_qubits(q: qubit, r: qubit): H(q) X.ctrl(q, r) Measure(q) Measure(r) q = qalloc(1) r = qalloc(1) bell_qubits(q[0], r[0]) q.print() r.print() self.assertEqual(len(q.counts()), 2) self.assertEqual(len(r.counts()), 2) # entangled self.assertEqual(q.counts()["0"], r.counts()["0"]) self.assertEqual(q.counts()["1"], r.counts()["1"]) if __name__ == '__main__': unittest.main() No newline at end of file