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

Updated the example



Signed-off-by: default avatarThien Nguyen <nguyentm@ornl.gov>
parent aba05edf
Loading
Loading
Loading
Loading
+9 −13
Original line number Diff line number Diff line
#include <qalloc>

// Creates a 4-qubit GHZ state |0000> + |1111>
// which, on ibmq_ourense, will require mapping
// to fit its connectivity graph  
__qpu__ void test_xasm(qreg q) {
  using qcor::xasm;
// Create a multi-qubit entangled state 
__qpu__ void entangleQubits(qreg q) {
  H(q[0]);
  CX(q[0],q[1]);
  CX(q[0],q[2]);
  CX(q[0],q[3]);
  Measure(q[0]);
  Measure(q[1]);
  Measure(q[2]);
  Measure(q[3]);
  for (int i = 1; i < q.size(); i++) {
    CX(q[0],q[i]);
  }
  for (int i = 0; i < q.size(); i++) {
    Measure(q[i]);
  }
}

// Example: using ibmq_ourense (5 qubits) which has 
@@ -34,7 +30,7 @@ __qpu__ void test_xasm(qreg q) {
int main() {
  // This circuit requires 4 qubits.
  auto q = qalloc(4);
  test_xasm(q);
  entangleQubits(q);
  // Expect: ~50-50 for "0000" and "1111"
  // (plus some variations due to noise)
  q.print();