From e9fc5b2849543b2d82e85c92b0abf65ad0c6c811 Mon Sep 17 00:00:00 2001 From: miha-q <> Date: Sun, 11 Feb 2024 20:40:19 -0500 Subject: [PATCH] Sun Feb 11 08:40:19 PM EST 2024 --- examples/bb84.txt | 2 +- examples/bellstate.txt | 2 +- examples/belltest_c.txt | 2 +- examples/belltest_q.txt | 2 +- examples/decoherence.txt | 2 +- examples/hidden_variable.txt | 6 +++--- examples/swaptest.txt | 2 +- src/QAnsel.c | 30 +++++++++++++++--------------- 8 files changed, 24 insertions(+), 24 deletions(-) diff --git a/examples/bb84.txt b/examples/bb84.txt index a283806..60a44b3 100644 --- a/examples/bb84.txt +++ b/examples/bb84.txt @@ -15,7 +15,7 @@ h q[1]; //The first should now be random noise // while the second unmeasured one // should be 0 -sample; +born; //In a full BB84 Alice would randomly // apply the gate or not apply the diff --git a/examples/bellstate.txt b/examples/bellstate.txt index d10fea4..31fe104 100644 --- a/examples/bellstate.txt +++ b/examples/bellstate.txt @@ -2,4 +2,4 @@ qreg q[2]; h q[0]; cx q[0], q[1]; -sample; +born; diff --git a/examples/belltest_c.txt b/examples/belltest_c.txt index e80d1da..fd0282f 100644 --- a/examples/belltest_c.txt +++ b/examples/belltest_c.txt @@ -57,4 +57,4 @@ measure q[1] -> c[1]; measure q[1] -> c[2]; measure q[1] -> c[3]; -fullsample; \ No newline at end of file +sample; \ No newline at end of file diff --git a/examples/belltest_q.txt b/examples/belltest_q.txt index e0a862d..f869569 100644 --- a/examples/belltest_q.txt +++ b/examples/belltest_q.txt @@ -67,4 +67,4 @@ measure q[1] -> c[1]; measure q[1] -> c[2]; measure q[1] -> c[3]; -fullsample; \ No newline at end of file +sample; \ No newline at end of file diff --git a/examples/decoherence.txt b/examples/decoherence.txt index d5b10d7..97e74a5 100644 --- a/examples/decoherence.txt +++ b/examples/decoherence.txt @@ -10,4 +10,4 @@ measure q[0] -> c[1]; h q[0]; measure q[0] -> c[0]; reset c[1]; -fullsample; +sample; diff --git a/examples/hidden_variable.txt b/examples/hidden_variable.txt index c857d6f..747d512 100644 --- a/examples/hidden_variable.txt +++ b/examples/hidden_variable.txt @@ -1,21 +1,21 @@ qreg q[1]; creg c[4]; -hiddenvar 12.34; +hvar 12.34; h q[0]; measure q[0] -> c[0]; h q[0]; measure q[0] -> c[1]; h q[0]; measure q[0] -> c[2]; h q[0]; measure q[0] -> c[3]; print c; -truerand; +rand; h q[0]; measure q[0] -> c[0]; h q[0]; measure q[0] -> c[1]; h q[0]; measure q[0] -> c[2]; h q[0]; measure q[0] -> c[3]; print c; -hiddenvar 43.21; +hvar 43.21; h q[0]; measure q[0] -> c[0]; h q[0]; measure q[0] -> c[1]; h q[0]; measure q[0] -> c[2]; diff --git a/examples/swaptest.txt b/examples/swaptest.txt index 19454e0..7a25038 100644 --- a/examples/swaptest.txt +++ b/examples/swaptest.txt @@ -6,4 +6,4 @@ h q[0]; cswap q[0], q[1], q[2]; h q[0]; -sample q[0]; +born q[0]; diff --git a/src/QAnsel.c b/src/QAnsel.c index 456f9f7..dcd889e 100644 --- a/src/QAnsel.c +++ b/src/QAnsel.c @@ -419,7 +419,7 @@ void qansel_run(uint8_t qubitCount, uint8_t bitCount, QInstr* instr, uint8_t* re } cpx_mtx_free(&tmp); } - else if (strcmp(instr[i].n, "sample_all") == 0) + else if (strcmp(instr[i].n, "born_all") == 0) { for (uint32_t j = 0; j < qubitCountPow2; j++) { @@ -434,7 +434,7 @@ void qansel_run(uint8_t qubitCount, uint8_t bitCount, QInstr* instr, uint8_t* re printf(": %.00f%%\n", cpx_magsqr(&n) * 100); } } - else if (strcmp(instr[i].n, "sample") == 0) + else if (strcmp(instr[i].n, "born") == 0) { double prob = 0; for (uint32_t j = 0; j < qubitCountPow2; j++) @@ -448,7 +448,7 @@ void qansel_run(uint8_t qubitCount, uint8_t bitCount, QInstr* instr, uint8_t* re } printf("%.00f%%\n", prob * 100.0); } - else if (strcmp(instr[i].n, "hiddenvar") == 0) + else if (strcmp(instr[i].n, "hvar") == 0) { HIDDEN_VARIABLE = 1; float tmp1 = (float)instr[i].arg0; @@ -456,7 +456,7 @@ void qansel_run(uint8_t qubitCount, uint8_t bitCount, QInstr* instr, uint8_t* re memcpy(&tmp2, &tmp1, sizeof(uint32_t)); srand(tmp2); } - else if (strcmp(instr[i].n, "truerand") == 0) + else if (strcmp(instr[i].n, "rand") == 0) { HIDDEN_VARIABLE = 0; } @@ -1052,7 +1052,7 @@ void process(int argc, char** argv) strcpy(instr[instrLen].n, "printc"); instr[instrLen++].q0 = q0; } - else if (strcmp(lines[i], "sample") == 0 || strcmp(lines[i], "sample q") == 0) + else if (strcmp(lines[i], "born") == 0 || strcmp(lines[i], "born q") == 0) { if (qubitCount == 0xFF) { @@ -1061,10 +1061,10 @@ void process(int argc, char** argv) break; } instr = realloc(instr, (instrLen + 1) * sizeof(QInstr)); - strcpy(instr[instrLen].n, "sample_all"); + strcpy(instr[instrLen].n, "born_all"); instrLen++; } - else if (sscanf(lines[i], "sample q[%i]", &q0) == 1) + else if (sscanf(lines[i], "born q[%i]", &q0) == 1) { if (qubitCount == 0xFF) { @@ -1079,7 +1079,7 @@ void process(int argc, char** argv) break; } instr = realloc(instr, (instrLen + 1) * sizeof(QInstr)); - strcpy(instr[instrLen].n, "sample"); + strcpy(instr[instrLen].n, "born"); instr[instrLen++].q0 = q0; } else if (sscanf(lines[i], "reset q[%i]", &q0) == 1) @@ -1154,29 +1154,29 @@ void process(int argc, char** argv) // optimizations that this instruction // would prevent } - else if (sscanf(lines[i], "hiddenvar %f", &a0) == 1) + else if (sscanf(lines[i], "hvar %f", &a0) == 1) { instr = realloc(instr, (instrLen + 1) * sizeof(QInstr)); - strcpy(instr[instrLen].n, "hiddenvar"); + strcpy(instr[instrLen].n, "hvar"); instr[instrLen++].arg0 = a0; } - else if (strcmp(lines[i], "truerand") == 0) + else if (strcmp(lines[i], "rand") == 0) { instr = realloc(instr, (instrLen + 1) * sizeof(QInstr)); - strcpy(instr[instrLen].n, "truerand"); + strcpy(instr[instrLen].n, "rand"); instrLen++; } - else if (strcmp(lines[i], "fullsample") == 0) + else if (strcmp(lines[i], "sample") == 0) { if (i != linesLen - 1) { - fprintf(stderr, "QAnsel: fullsample should be used at the end of the program."); + fprintf(stderr, "QAnsel: Sampling should be performed at the end of the program."); errFound = 1; break; } if (bitCount == 0xFF) { - fprintf(stderr, "QAnsel: fullsample cannot be used without initializing classical bits."); + fprintf(stderr, "QAnsel: Sampling cannot be used without initializing classical bits."); errFound = 1; break; } -- 2.39.5