Skip to content

Commit

Permalink
Merge pull request #44 from PESchoenberg/develop
Browse files Browse the repository at this point in the history
Improved functions.
  • Loading branch information
PESchoenberg authored Jul 2, 2019
2 parents 80d9f1a + 51afd74 commit 8905e6e
Show file tree
Hide file tree
Showing 17 changed files with 206 additions and 50 deletions.
26 changes: 25 additions & 1 deletion examples/example1.qasm
Original file line number Diff line number Diff line change
@@ -1,31 +1,39 @@
// This program does nothing in particular, but shows how to use g2q functions.;
// example1.qasm;
// Compiled with g2q - v1.2.3;
// Compiled with g2q - v1.2.4;
OPENQASM 2.0;
include "qelib1.inc";
qreg q[5];
creg c[5];
// Five reset gates.;
// Begin g1y;
reset q[0];
reset q[1];
reset q[2];
reset q[3];
reset q[4];
// End g1y;
// A swap gate.;
// Begin swap;
cx q[0],q[1];
cx q[1],q[0];
cx q[0],q[1];
// End swap;
// A swap-fast gate.;
swap q[0],q[1];
// Five h gates.;
// Begin g1y;
h q[0];
h q[1];
h q[2];
h q[3];
h q[4];
// End g1y;
// Two x gates.;
// Begin g1y;
x q[1];
x q[2];
// End g1y;
// Various basic gates.;
id q[3];
y q[4];
Expand All @@ -40,18 +48,23 @@ u3(1.6,1.6,1.6) q[2];
// Controlled x.;
cx q[2],q[0];
// Controlled y.;
// Begin cy;
sdg q[4];
cx q[3],q[4];
s q[4];
// End cy;
// Controlled y in fast form.;
cy q[3],q[1];
// Controlled z.;
// Begin cz;
h q[2];
cx q[4],q[2];
h q[2];
// End cz;
// Controlled z in fast form.;
cz q[4],q[2];
// Controlled h.;
// Begin ch;
h q[0];
sdg q[0];
cx q[2],q[0];
Expand All @@ -63,9 +76,11 @@ h q[0];
s q[0];
x q[0];
s q[2];
// End ch;
// Controlled h in fast form.;
ch q[2],q[0];
// Toffoli (ccx).;
// Begin ccx;
h q[2];
cx q[1],q[2];
tdg q[2];
Expand All @@ -81,6 +96,7 @@ cx q[0],q[1];
t q[0];
tdg q[1];
cx q[0],q[1];
// End ccx;
// Toffoli in fast form.;
ccx q[0],q[1],q[2];
// rx.;
Expand All @@ -96,38 +112,46 @@ u1(1.6) q[3];
// rz in fast form.;
rz(1.570795) q[3];
// crz.;
// Begin crz;
u1(0.8) q[4];
cx q[3],q[4];
u1(-0.8) q[4];
cx q[3],q[4];
// End crz;
// crz in fast form.;
crz(1.570795) q[3],q[4];
// Controlled u1.;
// Begin cu1;
u1(0.8) q[2];
cx q[2],q[0];
u1(-0.8) q[0];
cx q[2],q[0];
u1(0.8) q[2];
// End cu1;
// Controlled u1 in fast form.;
cu1(1.6) q[2],q[0];
// Controlled u3.;
// Begin cu3;
u1(0.0) q[0];
cx q[2],q[0];
u3(-0.8,0,-1.6) q[0];
cx q[2],q[0];
u3(0.8,1.6,0) q[0];
// End cu3;
// Controlled u3 in fast form.;
cu3(1.6,1.6,1.6) q[2],q[0];
// Conditional1 eq.;
if(q==1) y q[2];
// Conditional2 eq.;
if(q[2]!=1) y q[2];
// Barriers.;
// Begin g1y;
barrier q[0];
barrier q[1];
barrier q[2];
barrier q[3];
barrier q[4];
// End g1y;
// Measuring;
measure q[0] -> c[0];
measure q[1] -> c[1];
Expand Down
8 changes: 7 additions & 1 deletion examples/example10.qasm
Original file line number Diff line number Diff line change
@@ -1,23 +1,29 @@
// example10.qasm;
// Compiled with g2q - v1.2.3;
// Compiled with g2q - v1.2.4;
OPENQASM 2.0;
include "qelib1.inc";
qreg q[5];
creg c[5];
// Begin g1y;
h q[0];
h q[1];
h q[2];
h q[3];
h q[4];
// End g1y;
// Begin g1y;
x q[0];
x q[1];
x q[2];
x q[3];
x q[4];
// End g1y;
// Begin qmeasy;
measure q[0] -> c[0];
measure q[1] -> c[1];
measure q[2] -> c[2];
measure q[3] -> c[3];
measure q[4] -> c[4];
// End qmeasy;
// qdeclare qx-simulator error_model depolarizing_channel,0.001;
// qdeclare qlib-simulator // Hello qlib-simulator;
6 changes: 5 additions & 1 deletion examples/example11.qasm
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
// example11.qasm;
// Compiled with g2q - v1.2.3;
// Compiled with g2q - v1.2.4;
OPENQASM 2.0;
include "qelib1.inc";
qreg q[5];
creg c[5];
sdg q[0];
// Begin g1y;
id q[1];
id q[2];
id q[3];
id q[4];
// End g1y;
h q[0];
sdg q[3];
h q[3];
Expand All @@ -29,10 +31,12 @@ h q[3];
h q[4];
cx q[3],q[2];
h q[3];
// Begin qmeasy;
measure q[0] -> c[0];
measure q[1] -> c[1];
measure q[2] -> c[2];
measure q[3] -> c[3];
measure q[4] -> c[4];
// End qmeasy;
// qdeclare qx-simulator error_model depolarizing_channel,0.001;
// qdeclare qlib-simulator // Hello qlib-simulator;
6 changes: 5 additions & 1 deletion examples/example12.qasm
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// example12.qasm;
// Compiled with g2q - v1.2.3;
// Compiled with g2q - v1.2.4;
OPENQASM 2.0;
include "qelib1.inc";
qreg q[3];
Expand All @@ -8,6 +8,7 @@ x q[0];
h q[1];
h q[2];
h q[0];
// Begin ccx;
h q[0];
cx q[1],q[0];
tdg q[0];
Expand All @@ -23,6 +24,7 @@ cx q[2],q[1];
t q[2];
tdg q[1];
cx q[2],q[1];
// End ccx;
h q[1];
h q[2];
x q[1];
Expand All @@ -34,7 +36,9 @@ x q[1];
x q[2];
h q[1];
h q[2];
// Begin qmeasy;
measure q[1] -> c[1];
measure q[2] -> c[2];
// End qmeasy;
// qdeclare qx-simulator error_model depolarizing_channel,0.001;
// qdeclare qlib-simulator // Hello qlib-simulator;
2 changes: 1 addition & 1 deletion examples/example2.qasm
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// example2.qasm;
// Compiled with g2q - v1.2.3;
// Compiled with g2q - v1.2.4;
OPENQASM 2.0;
include "qelib1.inc";
qreg q[2];
Expand Down
20 changes: 19 additions & 1 deletion examples/example3.qasm
Original file line number Diff line number Diff line change
@@ -1,29 +1,47 @@
// example3.qasm;
// Compiled with g2q - v1.2.3;
// Compiled with g2q - v1.2.4;
OPENQASM 2.0;
include "qelib1.inc";
qreg q[5];
creg c[5];
// Begin g1y;
h q[0];
h q[1];
// End g1y;
// Begin g1y;
s q[0];
s q[1];
// End g1y;
// Begin g1cxg1;
h q[0];
cx q[1],q[0];
h q[0];
// End g1cxg1;
// Begin g1y;
s q[0];
s q[1];
// End g1y;
// Begin g1y;
h q[0];
h q[1];
// End g1y;
// Begin g1y;
x q[0];
x q[1];
// End g1y;
// Begin g1cxg1;
h q[0];
cx q[1],q[0];
h q[0];
// End g1cxg1;
// Begin g1y;
x q[0];
x q[1];
// End g1y;
// Begin g1y;
h q[0];
h q[1];
// End g1y;
// Measuring;
measure q[0] -> c[0];
measure q[1] -> c[1];
18 changes: 17 additions & 1 deletion examples/example4.qasm
Original file line number Diff line number Diff line change
@@ -1,42 +1,58 @@
// example4.qasm;
// Compiled with g2q - v1.2.3;
// Compiled with g2q - v1.2.4;
OPENQASM 2.0;
include "qelib1.inc";
qreg q[5];
creg c[5];
// Begin g1y;
h q[0];
h q[1];
h q[2];
h q[3];
h q[4];
// End g1y;
// Begin g1xy;
// Begin g1y;
id q[0];
id q[1];
id q[2];
id q[3];
id q[4];
// End g1y;
// Begin g1y;
id q[0];
id q[1];
id q[2];
id q[3];
id q[4];
// End g1y;
// Begin g1y;
id q[0];
id q[1];
id q[2];
id q[3];
id q[4];
// End g1y;
// Begin g1y;
id q[0];
id q[1];
id q[2];
id q[3];
id q[4];
// End g1y;
// Begin g1y;
id q[0];
id q[1];
id q[2];
id q[3];
id q[4];
// End g1y;
// End g1xy;
// Measuring;
// Begin qmeasy;
measure q[0] -> c[0];
measure q[1] -> c[1];
measure q[2] -> c[2];
measure q[3] -> c[3];
measure q[4] -> c[4];
// End qmeasy;
4 changes: 3 additions & 1 deletion examples/example5.qasm
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
// example5.qasm;
// Compiled with g2q - v1.2.3;
// Compiled with g2q - v1.2.4;
OPENQASM 2.0;
include "qelib1.inc";
qreg q[4];
creg c[2];
// Begin g1y;
h q[0];
h q[1];
h q[2];
h q[3];
// End g1y;
cx q[0],q[1];
h q[2];
h q[0];
Expand Down
4 changes: 3 additions & 1 deletion examples/example6.qasm
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
// example6.qasm;
// Compiled with g2q - v1.2.3;
// Compiled with g2q - v1.2.4;
OPENQASM 2.0;
include "qelib1.inc";
qreg q[4];
creg c[2];
// Begin g1y;
h q[0];
h q[1];
h q[2];
h q[3];
// End g1y;
cx q[0],q[1];
h q[2];
h q[0];
Expand Down
4 changes: 3 additions & 1 deletion examples/example7.qasm
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
// example7.qasm;
// Compiled with g2q - v1.2.3;
// Compiled with g2q - v1.2.4;
OPENQASM 2.0;
include "qelib1.inc";
qreg q[4];
creg c[2];
// Begin g1y;
h q[0];
h q[1];
h q[2];
h q[3];
// End g1y;
cx q[0],q[1];
h q[2];
h q[0];
Expand Down
Loading

0 comments on commit 8905e6e

Please sign in to comment.