Skip to content

Commit

Permalink
Merge pull request #79 from PESchoenberg/develop
Browse files Browse the repository at this point in the history
Maint.
  • Loading branch information
PESchoenberg authored Apr 10, 2020
2 parents b9af76e + 5971e88 commit 4f634c7
Show file tree
Hide file tree
Showing 31 changed files with 148 additions and 125 deletions.
2 changes: 1 addition & 1 deletion examples/example1.scm
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
;
; ==============================================================================
;
; Copyright (C) 2018 - 2019 Pablo Edronkin (pablo.edronkin at yahoo.com)
; Copyright (C) 2018 - 2020 Pablo Edronkin (pablo.edronkin at yahoo.com)
;
; This program is free software: you can redistribute it and/or modify
; it under the terms of the GNU Lesser General Public License as published by
Expand Down
2 changes: 1 addition & 1 deletion examples/example10.qasm
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// example10.qasm;
// Compiled with g2q - v1.2.4;
// Compiled with g2q - v1.2.5;
OPENQASM 2.0;
include "qelib1.inc";
qreg q[5];
Expand Down
2 changes: 1 addition & 1 deletion examples/example10.scm
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
;
; ==============================================================================
;
; Copyright (C) 2018 - 2019 Pablo Edronkin (pablo.edronkin at yahoo.com)
; Copyright (C) 2018 - 2020 Pablo Edronkin (pablo.edronkin at yahoo.com)
;
; This program is free software: you can redistribute it and/or modify
; it under the terms of the GNU Lesser General Public License as published by
Expand Down
2 changes: 1 addition & 1 deletion examples/example11.qasm
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// example11.qasm;
// Compiled with g2q - v1.2.4;
// Compiled with g2q - v1.2.5;
OPENQASM 2.0;
include "qelib1.inc";
qreg q[5];
Expand Down
2 changes: 1 addition & 1 deletion examples/example11.scm
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
;
; ==============================================================================
;
; Copyright (C) 2018 - 2019 Pablo Edronkin (pablo.edronkin at yahoo.com)
; Copyright (C) 2018 - 2020 Pablo Edronkin (pablo.edronkin at yahoo.com)
;
; This program is free software: you can redistribute it and/or modify
; it under the terms of the GNU Lesser General Public License as published by
Expand Down
2 changes: 1 addition & 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.4;
// Compiled with g2q - v1.2.5;
OPENQASM 2.0;
include "qelib1.inc";
qreg q[3];
Expand Down
2 changes: 1 addition & 1 deletion examples/example12.scm
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
;
; ==============================================================================
;
; Copyright (C) 2018 - 2019 Pablo Edronkin (pablo.edronkin at yahoo.com)
; Copyright (C) 2018 - 2020 Pablo Edronkin (pablo.edronkin at yahoo.com)
;
; This program is free software: you can redistribute it and/or modify
; it under the terms of the GNU Lesser General Public License as published by
Expand Down
2 changes: 1 addition & 1 deletion examples/example13.qasm
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// example13.qasm;
// Compiled with g2q - v1.2.4;
// Compiled with g2q - v1.2.5;
OPENQASM 2.0;
include "qelib1.inc";
qreg q[3];
Expand Down
2 changes: 1 addition & 1 deletion examples/example13.scm
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
;
; ==============================================================================
;
; Copyright (C) 2018 - 2019 Pablo Edronkin (pablo.edronkin at yahoo.com)
; Copyright (C) 2018 - 2020 Pablo Edronkin (pablo.edronkin at yahoo.com)
;
; This program is free software: you can redistribute it and/or modify
; it under the terms of the GNU Lesser General Public License as published by
Expand Down
2 changes: 1 addition & 1 deletion examples/example14.qasm
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// example14.qasm;
// Compiled with g2q - v1.2.4;
// Compiled with g2q - v1.2.5;
OPENQASM 2.0;
include "qelib1.inc";
qreg q[5];
Expand Down
2 changes: 1 addition & 1 deletion examples/example14.scm
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
;
; ==============================================================================
;
; Copyright (C) 2018 - 2019 Pablo Edronkin (pablo.edronkin at yahoo.com)
; Copyright (C) 2018 - 2020 Pablo Edronkin (pablo.edronkin at yahoo.com)
;
; This program is free software: you can redistribute it and/or modify
; it under the terms of the GNU Lesser General Public License as published by
Expand Down
2 changes: 1 addition & 1 deletion examples/example15.qasm
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// example15.qasm;
// Compiled with g2q - v1.2.4;
// Compiled with g2q - v1.2.5;
OPENQASM 2.0;
include "qelib1.inc";
qreg q[5];
Expand Down
2 changes: 1 addition & 1 deletion examples/example15.scm
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
;
; ==============================================================================
;
; Copyright (C) 2018 - 2019 Pablo Edronkin (pablo.edronkin at yahoo.com)
; Copyright (C) 2018 - 2020 Pablo Edronkin (pablo.edronkin at yahoo.com)
;
; This program is free software: you can redistribute it and/or modify
; it under the terms of the GNU Lesser General Public License as published by
Expand Down
2 changes: 1 addition & 1 deletion examples/example16.qasm
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// example16.qasm;
// Compiled with g2q - v1.2.4;
// Compiled with g2q - v1.2.5;
OPENQASM 2.0;
include "qelib1.inc";
qreg q[5];
Expand Down
2 changes: 1 addition & 1 deletion examples/example16.scm
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
;
; ==============================================================================
;
; Copyright (C) 2018 - 2019 Pablo Edronkin (pablo.edronkin at yahoo.com)
; Copyright (C) 2018 - 2020 Pablo Edronkin (pablo.edronkin at yahoo.com)
;
; This program is free software: you can redistribute it and/or modify
; it under the terms of the GNU Lesser General Public License as published by
Expand Down
2 changes: 1 addition & 1 deletion examples/example2.scm
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
;
; ==============================================================================
;
; Copyright (C) 2018 - 2019 Pablo Edronkin (pablo.edronkin at yahoo.com)
; Copyright (C) 2018 - 2020 Pablo Edronkin (pablo.edronkin at yahoo.com)
;
; This program is free software: you can redistribute it and/or modify
; it under the terms of the GNU Lesser General Public License as published by
Expand Down
2 changes: 1 addition & 1 deletion examples/example3.scm
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
;
; ==============================================================================
;
; Copyright (C) 2018 - 2019 Pablo Edronkin (pablo.edronkin at yahoo.com)
; Copyright (C) 2018 - 2020 Pablo Edronkin (pablo.edronkin at yahoo.com)
;
; This program is free software: you can redistribute it and/or modify
; it under the terms of the GNU Lesser General Public License as published by
Expand Down
17 changes: 2 additions & 15 deletions examples/example4.qasm
Original file line number Diff line number Diff line change
Expand Up @@ -2,50 +2,38 @@
// Compiled with g2q - v1.2.5;
OPENQASM 2.0;
include "qelib1.inc";
qreg q[5];
creg c[5];
qreg q[4];
creg c[4];
// 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;
Expand All @@ -54,5 +42,4 @@ 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;
2 changes: 1 addition & 1 deletion examples/example4.scm
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
;
; ==============================================================================
;
; Copyright (C) 2018 - 2019 Pablo Edronkin (pablo.edronkin at yahoo.com)
; Copyright (C) 2018 - 2020 Pablo Edronkin (pablo.edronkin at yahoo.com)
;
; This program is free software: you can redistribute it and/or modify
; it under the terms of the GNU Lesser General Public License as published by
Expand Down
2 changes: 1 addition & 1 deletion examples/example5.scm
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
;
; ==============================================================================
;
; Copyright (C) 2018 - 2019 Pablo Edronkin (pablo.edronkin at yahoo.com)
; Copyright (C) 2018 - 2020 Pablo Edronkin (pablo.edronkin at yahoo.com)
;
; This program is free software: you can redistribute it and/or modify
; it under the terms of the GNU Lesser General Public License as published by
Expand Down
2 changes: 1 addition & 1 deletion examples/example6.scm
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
;
; ==============================================================================
;
; Copyright (C) 2018 - 2019 Pablo Edronkin (pablo.edronkin at yahoo.com)
; Copyright (C) 2018 - 2020 Pablo Edronkin (pablo.edronkin at yahoo.com)
;
; This program is free software: you can redistribute it and/or modify
; it under the terms of the GNU Lesser General Public License as published by
Expand Down
2 changes: 1 addition & 1 deletion examples/example7.scm
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
;
; ==============================================================================
;
; Copyright (C) 2018 - 2019 Pablo Edronkin (pablo.edronkin at yahoo.com)
; Copyright (C) 2018 - 2020 Pablo Edronkin (pablo.edronkin at yahoo.com)
;
; This program is free software: you can redistribute it and/or modify
; it under the terms of the GNU Lesser General Public License as published by
Expand Down
2 changes: 1 addition & 1 deletion examples/example8.qasm
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// example8.qasm;
// Compiled with g2q - v1.2.4;
// Compiled with g2q - v1.2.5;
OPENQASM 2.0;
include "qelib1.inc";
qreg q[5];
Expand Down
2 changes: 1 addition & 1 deletion examples/example8.scm
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
;
; ==============================================================================
;
; Copyright (C) 2018 - 2019 Pablo Edronkin (pablo.edronkin at yahoo.com)
; Copyright (C) 2018 - 2020 Pablo Edronkin (pablo.edronkin at yahoo.com)
;
; This program is free software: you can redistribute it and/or modify
; it under the terms of the GNU Lesser General Public License as published by
Expand Down
2 changes: 1 addition & 1 deletion examples/example9.qasm
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// example9.qasm;
// Compiled with g2q - v1.2.4;
// Compiled with g2q - v1.2.5;
OPENQASM 2.0;
include "qelib1.inc";
qreg q[5];
Expand Down
2 changes: 1 addition & 1 deletion examples/example9.scm
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
;
; ==============================================================================
;
; Copyright (C) 2018 - 2019 Pablo Edronkin (pablo.edronkin at yahoo.com)
; Copyright (C) 2018 - 2020 Pablo Edronkin (pablo.edronkin at yahoo.com)
;
; This program is free software: you can redistribute it and/or modify
; it under the terms of the GNU Lesser General Public License as published by
Expand Down
36 changes: 23 additions & 13 deletions g2q0.scm
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
;
; ==============================================================================
;
; Copyright (C) 2018 - 2019 Pablo Edronkin (pablo.edronkin at yahoo.com)
; Copyright (C) 2018 - 2020 Pablo Edronkin (pablo.edronkin at yahoo.com)
;
; This program is free software: you can redistribute it and/or modify
; it under the terms of the GNU Lesser General Public License as published by
Expand Down Expand Up @@ -209,10 +209,14 @@
; target q quibt.
;
(define (g2 p_n1 p_r1 p_y1 p_r2 p_y2)
(cond ((equal? "cx" p_n1)(qcx p_n1 p_r1 p_y1 p_r2 p_y2))
((equal? "cy-fast" p_n1)(qcx "cy" p_r1 p_y1 p_r2 p_y2))
((equal? "cz-fast" p_n1)(qcx "cz" p_r1 p_y1 p_r2 p_y2))
((equal? "ch-fast" p_n1)(qcx "ch" p_r1 p_y1 p_r2 p_y2))
(cond ((equal? "cx" p_n1)
(qcx p_n1 p_r1 p_y1 p_r2 p_y2))
((equal? "cy-fast" p_n1)
(qcx "cy" p_r1 p_y1 p_r2 p_y2))
((equal? "cz-fast" p_n1)
(qcx "cz" p_r1 p_y1 p_r2 p_y2))
((equal? "ch-fast" p_n1)
(qcx "ch" p_r1 p_y1 p_r2 p_y2))
(else (qcx p_n1 p_r1 p_y1 p_r2 p_y2))))


Expand Down Expand Up @@ -261,7 +265,8 @@
;
(define (qcond1 p_c1 p_y1 p_y2)
(let ((qsen " "))
(cond ((equal? (qvalid-conditional p_c1) #t)(set! qsen (strings-append (list (g2q-txt 5) p_y1 p_c1 (grsp-n2s p_y2) (g2q-txt 4)) 0))))
(cond ((equal? (qvalid-conditional p_c1) #t)
(set! qsen (strings-append (list (g2q-txt 5) p_y1 p_c1 (grsp-n2s p_y2) (g2q-txt 4)) 0))))
(display qsen)))


Expand All @@ -276,7 +281,8 @@
(define (qcond2 p_c1 p_y1 p_y3 p_y2)
(let ((qsen " "))

(cond ((equal? (qvalid-conditional p_c1) #t)(set! qsen (strings-append (list (g2q-txt 5) p_y1 "[" (grsp-n2s p_y3) "]" p_c1 (grsp-n2s p_y2) (g2q-txt 4)) 0))))
(cond ((equal? (qvalid-conditional p_c1) #t)
(set! qsen (strings-append (list (g2q-txt 5) p_y1 "[" (grsp-n2s p_y3) "]" p_c1 (grsp-n2s p_y2) (g2q-txt 4)) 0))))
(display qsen)))


Expand All @@ -291,8 +297,10 @@
(define (qvalid-conditional p_s1)
(let ((res #f))

(cond ((equal? p_s1 "==")(set! res #t)))
(cond ((equal? p_s1 "!=")(set! res #t)))
(cond ((equal? p_s1 "==")
(set! res #t)))
(cond ((equal? p_s1 "!=")
(set! res #t)))

res))

Expand Down Expand Up @@ -322,14 +330,16 @@
; Arguments:
; - p_s: string (gate name).
; - p_v: value indicating the kind of gate comment.
; - 0: begin block.
; - 1: end block.
; - 0: begin block.
; - 1: end block.
;
(define (qcomg p_s p_v)
(let ((s ""))

(cond ((eq? p_v 0)(set! s (strings-append (list (g2q-txt 6) "Begin " p_s ";") 0))))
(cond ((eq? p_v 1)(set! s (strings-append (list (g2q-txt 6) "End " p_s ";") 0))))
(cond ((eq? p_v 0)
(set! s (strings-append (list (g2q-txt 6) "Begin " p_s ";") 0))))
(cond ((eq? p_v 1)
(set! s (strings-append (list (g2q-txt 6) "End " p_s ";") 0))))
(display s)
(newline)))

Loading

0 comments on commit 4f634c7

Please sign in to comment.