Commit 7be06a8f authored by Mccaskey, Alex's avatar Mccaskey, Alex
Browse files

implemented more features, fixed some bugs, added more examples

parent 7c6bfa6a
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -16,6 +16,10 @@ const n = 10;
qubit q[n];

for i in [0:n] {
  if (i == 2) {
    print("not operating x on 2, should see 0 in result.");
    continue;
  }
  x q[i];
}

+6 −0
Original line number Diff line number Diff line
OPENQASM 3;
include "qelib1.inc";
bit c[4] = "1111";
int[4] t = int[4](c);
// should print 15
print(t);
 No newline at end of file
+47 −0
Original line number Diff line number Diff line
OPENQASM 3;
include "stdgates.inc";

// declarations
const n = 3;

//kernel vote(bit[n]) -> bit;
def vote(bit[n]:c) -> bit {
    int[32] vote_count = 0;
    for i in [0:n] {
        if (c[i] == 1) {
            vote_count += 1;
        }
    }

    bit ret;
    if (vote_count > 1) {
        ret = 1;
    } else {
        ret = 0;
    }
    return ret;
}

def logical_meas qubit[3]:d -> bit {
    bit c[3];
    bit r;
    measure d -> c;
    //r = vote(c);
    return r;
}

qubit q[3];
qubit a[3];
bit r;

// prep magic state
rz(pi/4) a;

// entangle two logical registers
cx q, a;

// measure out the ancilla
r = logical_meas a;

// if we get a logical |1> then we need to apply a logical Z correction
if (r == 1) z q;
 No newline at end of file
+2 −2
Original line number Diff line number Diff line
@@ -3,7 +3,7 @@ include "qelib1.inc";

qubit q;

const shots = 1024
const shots = 1024;
int[32] count = 0;

for i in [0:shots] {
@@ -18,7 +18,7 @@ for i in [0:shots] {

    // Measure, test that it is 1
    // to ensure reset is working right
    bit c = measure q;
    bit c;
    c = measure q;
    if (c == 1) {
        count += 1;
+7 −7
Original line number Diff line number Diff line
@@ -4,19 +4,19 @@ qubit q;
bit c;

const shots = 1024;
int[32] count = 0;
int[32] count2 = 0;
int[32] ones = 0;
int[32] zeros = 0;

for i in [0:shots] {
  h q;
  c = measure q;
  if (c == 1) {
   x q;
   count += 1;
   ones += 1;
  } else {
   count2 += 1;
   zeros += 1;
  }
  reset q;
}

print("total count was ", count);
print("total count2 was ", count2);
print("N |1> measured = ", ones);
print("N |0> measured = ", zeros);
Loading