From 5971e884e3a5b19410c1e8d7a72b40e5bb7a3f9b Mon Sep 17 00:00:00 2001 From: PESchoenberg Date: Fri, 10 Apr 2020 20:23:34 -0300 Subject: [PATCH] Maint. --- examples/example1.scm | 2 +- examples/example10.qasm | 2 +- examples/example10.scm | 2 +- examples/example11.qasm | 2 +- examples/example11.scm | 2 +- examples/example12.qasm | 2 +- examples/example12.scm | 2 +- examples/example13.qasm | 2 +- examples/example13.scm | 2 +- examples/example14.qasm | 2 +- examples/example14.scm | 2 +- examples/example15.qasm | 2 +- examples/example15.scm | 2 +- examples/example16.qasm | 2 +- examples/example16.scm | 2 +- examples/example2.scm | 2 +- examples/example3.scm | 2 +- examples/example4.qasm | 17 +------ examples/example4.scm | 2 +- examples/example5.scm | 2 +- examples/example6.scm | 2 +- examples/example7.scm | 2 +- examples/example8.qasm | 2 +- examples/example8.scm | 2 +- examples/example9.qasm | 2 +- examples/example9.scm | 2 +- g2q0.scm | 36 +++++++++----- g2q1.scm | 55 ++++++++++++++------- g2q2.scm | 106 +++++++++++++++++++++------------------- g2q3.scm | 7 +-- tests/test1.scm | 2 +- 31 files changed, 148 insertions(+), 125 deletions(-) diff --git a/examples/example1.scm b/examples/example1.scm index cd1ab31..68febbb 100644 --- a/examples/example1.scm +++ b/examples/example1.scm @@ -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 diff --git a/examples/example10.qasm b/examples/example10.qasm index 8b223eb..be5fca1 100644 --- a/examples/example10.qasm +++ b/examples/example10.qasm @@ -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]; diff --git a/examples/example10.scm b/examples/example10.scm index ce3c6ec..f0ff9b7 100644 --- a/examples/example10.scm +++ b/examples/example10.scm @@ -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 diff --git a/examples/example11.qasm b/examples/example11.qasm index dec97ea..5637aff 100644 --- a/examples/example11.qasm +++ b/examples/example11.qasm @@ -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]; diff --git a/examples/example11.scm b/examples/example11.scm index c4cde24..6d5a375 100644 --- a/examples/example11.scm +++ b/examples/example11.scm @@ -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 diff --git a/examples/example12.qasm b/examples/example12.qasm index 16bec31..44c5665 100644 --- a/examples/example12.qasm +++ b/examples/example12.qasm @@ -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]; diff --git a/examples/example12.scm b/examples/example12.scm index 4115f31..e6acee9 100644 --- a/examples/example12.scm +++ b/examples/example12.scm @@ -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 diff --git a/examples/example13.qasm b/examples/example13.qasm index a37c1bf..8f4f703 100644 --- a/examples/example13.qasm +++ b/examples/example13.qasm @@ -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]; diff --git a/examples/example13.scm b/examples/example13.scm index 84a9456..01b5255 100644 --- a/examples/example13.scm +++ b/examples/example13.scm @@ -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 diff --git a/examples/example14.qasm b/examples/example14.qasm index 926175a..cac4a0b 100644 --- a/examples/example14.qasm +++ b/examples/example14.qasm @@ -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]; diff --git a/examples/example14.scm b/examples/example14.scm index 9201de3..ace3218 100644 --- a/examples/example14.scm +++ b/examples/example14.scm @@ -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 diff --git a/examples/example15.qasm b/examples/example15.qasm index dda2a76..8ad2628 100644 --- a/examples/example15.qasm +++ b/examples/example15.qasm @@ -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]; diff --git a/examples/example15.scm b/examples/example15.scm index 057db12..af0cd59 100644 --- a/examples/example15.scm +++ b/examples/example15.scm @@ -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 diff --git a/examples/example16.qasm b/examples/example16.qasm index e5c388a..20ed9d8 100644 --- a/examples/example16.qasm +++ b/examples/example16.qasm @@ -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]; diff --git a/examples/example16.scm b/examples/example16.scm index 27ac958..60fe711 100644 --- a/examples/example16.scm +++ b/examples/example16.scm @@ -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 diff --git a/examples/example2.scm b/examples/example2.scm index 5279b18..ff22bf3 100644 --- a/examples/example2.scm +++ b/examples/example2.scm @@ -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 diff --git a/examples/example3.scm b/examples/example3.scm index 163f695..2442aea 100644 --- a/examples/example3.scm +++ b/examples/example3.scm @@ -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 diff --git a/examples/example4.qasm b/examples/example4.qasm index 66ffc29..fb9fab9 100644 --- a/examples/example4.qasm +++ b/examples/example4.qasm @@ -2,14 +2,13 @@ // 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; @@ -17,35 +16,24 @@ 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; @@ -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; diff --git a/examples/example4.scm b/examples/example4.scm index a109886..f58a7ce 100644 --- a/examples/example4.scm +++ b/examples/example4.scm @@ -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 diff --git a/examples/example5.scm b/examples/example5.scm index c62f323..794dcdb 100644 --- a/examples/example5.scm +++ b/examples/example5.scm @@ -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 diff --git a/examples/example6.scm b/examples/example6.scm index 571a777..6a03737 100644 --- a/examples/example6.scm +++ b/examples/example6.scm @@ -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 diff --git a/examples/example7.scm b/examples/example7.scm index 63aebcd..57cb116 100644 --- a/examples/example7.scm +++ b/examples/example7.scm @@ -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 diff --git a/examples/example8.qasm b/examples/example8.qasm index 8e6746b..09e19c2 100644 --- a/examples/example8.qasm +++ b/examples/example8.qasm @@ -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]; diff --git a/examples/example8.scm b/examples/example8.scm index 77b1a95..9591ef0 100644 --- a/examples/example8.scm +++ b/examples/example8.scm @@ -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 diff --git a/examples/example9.qasm b/examples/example9.qasm index db846fc..0057e7a 100644 --- a/examples/example9.qasm +++ b/examples/example9.qasm @@ -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]; diff --git a/examples/example9.scm b/examples/example9.scm index 965fec5..0419522 100644 --- a/examples/example9.scm +++ b/examples/example9.scm @@ -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 diff --git a/g2q0.scm b/g2q0.scm index 8ff3063..5b53493 100644 --- a/g2q0.scm +++ b/g2q0.scm @@ -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 @@ -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)))) @@ -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))) @@ -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))) @@ -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)) @@ -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))) diff --git a/g2q1.scm b/g2q1.scm index db6d590..46ddc75 100644 --- a/g2q1.scm +++ b/g2q1.scm @@ -12,7 +12,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 @@ -45,7 +45,7 @@ ; g2q-version - Returns the current version of the compiler. ; (define (g2q-version) - (let ((res "g2q - v1.2.5")) + (let ((res "g2q - v1.2.6")) res)) @@ -105,13 +105,20 @@ (set! res1 (read)) ; Not elegant, but works for now. - (if (< res1 0)(set! res1 0)) - (if (> res1 4)(set! res1 0)) - (if (= res1 0)(set! res "none")) - (if (= res1 1)(set! res (car(cdr(cdr(g2q-qre-config)))))) - (if (= res1 2)(set! res (car(cdr(cdr(cdr(cdr(g2q-qre-config)))))))) - (if (= res1 4)(set! res (car(cdr(cdr(cdr(cdr(cdr(g2q-qre-config))))))))) - (if (= res1 3)(set! res (car(cdr(cdr(cdr(g2q-qre-config))))))) + (if (< res1 0) + (set! res1 0)) + (if (> res1 4) + (set! res1 0)) + (if (= res1 0) + (set! res "none")) + (if (= res1 1) + (set! res (car(cdr(cdr(g2q-qre-config)))))) + (if (= res1 2) + (set! res (car(cdr(cdr(cdr(cdr(g2q-qre-config)))))))) + (if (= res1 4) + (set! res (car(cdr(cdr(cdr(cdr(cdr(g2q-qre-config))))))))) + (if (= res1 3) + (set! res (car(cdr(cdr(cdr(g2q-qre-config))))))) res)) @@ -124,16 +131,26 @@ (define (g2q-txt p_n) (let ((res "")) - (cond ((= p_n 0)(set! res "];"))) - (cond ((= p_n 1)(set! res "\n"))) - (cond ((= p_n 2)(set! res ";\n"))) - (cond ((= p_n 3)(set! res "];\n"))) - (cond ((= p_n 4)(set! res ") "))) - (cond ((= p_n 5)(set! res "if("))) - (cond ((= p_n 6)(set! res "// "))) - (cond ((= p_n 7)(set! res "charset=utf-8"))) - (cond ((= p_n 8)(set! res "application/x-www-form-urlencoded;"))) - (cond ((= p_n 9)(set! res "na"))) + (cond ((= p_n 0) + (set! res "];"))) + (cond ((= p_n 1) + (set! res "\n"))) + (cond ((= p_n 2) + (set! res ";\n"))) + (cond ((= p_n 3) + (set! res "];\n"))) + (cond ((= p_n 4) + (set! res ") "))) + (cond ((= p_n 5) + (set! res "if("))) + (cond ((= p_n 6) + (set! res "// "))) + (cond ((= p_n 7) + (set! res "charset=utf-8"))) + (cond ((= p_n 8) + (set! res "application/x-www-form-urlencoded;"))) + (cond ((= p_n 9) + (set! res "na"))) res)) diff --git a/g2q2.scm b/g2q2.scm index 6af0b72..f928862 100644 --- a/g2q2.scm +++ b/g2q2.scm @@ -12,7 +12,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 @@ -92,9 +92,12 @@ (define (qconst p_n1) (let ((res 0)) - (cond ((equal? p_n1 "Pi")(set! res 3.14159)) - ((equal? p_n1 "gr")(set! res 1.00)) - ((equal? p_n1 "e")(set! res 2.71828)) + (cond ((equal? p_n1 "Pi") + (set! res 3.14159)) + ((equal? p_n1 "gr") + (set! res 1.00)) + ((equal? p_n1 "e") + (set! res 2.71828)) (else (set! res 0))) res)) @@ -678,10 +681,10 @@ ; ; Output: ; - On p_l1[p_y1]. -; - |00> -> |0> -; - |11> -> |0> -; - |01> -> |1> -; - |10> -> |1> +; - |00> -> |0> +; - |11> -> |0> +; - |01> -> |1> +; - |10> -> |1> ; (define (qxor1 p_l1 p_y1 p_l2 p_y2 p_l3 p_y3 p_l4 p_y4) (qcomg "qxor1" 0) @@ -744,13 +747,13 @@ ; Arguments: ; - p_l: list of results as obtained by applying qfclvr. ; - p_r: choice between obtaining the max or min value. -; - "max" for maximum value. -; - "min" to get the minimum value. +; - "max" for maximum value. +; - "min" to get the minimum value. ; ; Output: ; - A list of two elements: -; - First element contains the label of the result. -; - Second element contains the max value obtained. +; - First element contains the label of the result. +; - Second element contains the max value obtained. ; (define (qfres p_l p_r) (let ((res (list )) @@ -763,15 +766,17 @@ ; Find value. (set! dv (map string->number sv)) - (if (equal? p_r "max")(set! dvm (apply max dv))) - (if (equal? p_r "min")(set! dvm (apply min dv))) + (if (equal? p_r "max") + (set! dvm (apply max dv))) + (if (equal? p_r "min") + (set! dvm (apply min dv))) ; Get the corresponding label. (set! n (- (length dv) 1)) (while (>= n 0) - (if (= dvm (list-ref dv n))(begin - (set! slm (list-ref sl n)) - (set! n 0))) + (if (= dvm (list-ref dv n)) + (begin (set! slm (list-ref sl n)) + (set! n 0))) (set! n (- n 1))) (set! res (list slm dvm)) @@ -908,10 +913,10 @@ ; - p_y1: qubit 1, control qubit of the cx gate where the ladder begins. ; - p_y2: qubit 2, target qubit of the cx gate where the ladder ends. ; - p_s: mode: -; - 1: descending ladder, control qubit on top (p_y1). -; - 2: ascending ladder, control qubit on top (p_y1). -; - 3: descending ladder, control qubit on bottom (p_y2). -; - 4: ascending ladder, control qubit on bottom (p_y2). +; - 1: descending ladder, control qubit on top (p_y1). +; - 2: ascending ladder, control qubit on top (p_y1). +; - 3: descending ladder, control qubit on bottom (p_y2). +; - 4: ascending ladder, control qubit on bottom (p_y2). ; (define (cx-ladder p_l1 p_y1 p_y2 p_s) (qcomg "cx-ladder" 0) @@ -955,8 +960,8 @@ ; - p_y1: qubit 1, lower registry number qubit where the ladder begins. ; - p_y2: qubit 2, higher registry number qubit where the ladder ends. ; - p_s: mode: -; - 1: descending ladder. -; - 2: ascending ladder. +; - 1: descending ladder. +; - 2: ascending ladder. ; (define (swap-fast-ladder p_l1 p_y1 p_y2 p_s) (qcomg "swap-fast-ladder" 0) @@ -1023,8 +1028,8 @@ ; - p_y1: qubit 1, lower registry qubit of the GHZ array. ; - p_y2: qubit 2, higher registry qubit of the GHZ array. ; - p_s1: mode: -; - 1: descending order. -; - 2: ascending order. +; - 1: descending order. +; - 2: ascending order. ; ; Remarks: ; - If p_s1 = 1, qubit p_y2 contains the non - Hadamard gate. @@ -1058,31 +1063,34 @@ (cond ((equal? p_s1 1)(set! s1 p_s1)) ((equal? p_s1 2)(set! s1 p_s1)) (else (set! s1 1))) - (cond ((> d 1)(begin (cond ((equal? s1 1)(begin (qcomg "ghzy ladder ascending" 0) - (g1y p_n1 p_l1 p_y1 (- p_y2 1)) - (g1 p_n2 p_l1 p_y2) - - ; cx ascending ladder. - (let loop ((i1 y2)) - (if (equal? i1 (+ p_y1 1)) - (cx p_l1 p_y1 p_l1 p_y2) - (begin (cx p_l1 (- i1 1) p_l1 p_y2) - (loop (- i1 1))))))) - ((equal? s1 2)(begin (qcomg "ghzy ladder descending" 0) - (g1 p_n2 p_l1 p_y1) - (g1y p_n1 p_l1 (+ p_y1 1) p_y2) - - ; cx descending ladder - (let loop ((i1 y1)) - (if (equal? i1 (- p_y2 1)) - (cx p_l1 p_y2 p_l1 p_y1) - (begin (cx p_l1 (+ i1 1) p_l1 p_y1) - (loop (+ i1 1))))))))) + (cond ((> d 1) + (begin (cond ((equal? s1 1) + (begin (qcomg "ghzy ladder ascending" 0) + (g1y p_n1 p_l1 p_y1 (- p_y2 1)) + (g1 p_n2 p_l1 p_y2) + + ; cx ascending ladder. + (let loop ((i1 y2)) + (if (equal? i1 (+ p_y1 1)) + (cx p_l1 p_y1 p_l1 p_y2) + (begin (cx p_l1 (- i1 1) p_l1 p_y2) + (loop (- i1 1))))))) + ((equal? s1 2) + (begin (qcomg "ghzy ladder descending" 0) + (g1 p_n2 p_l1 p_y1) + (g1y p_n1 p_l1 (+ p_y1 1) p_y2) + + ; cx descending ladder + (let loop ((i1 y1)) + (if (equal? i1 (- p_y2 1)) + (cx p_l1 p_y2 p_l1 p_y1) + (begin (cx p_l1 (+ i1 1) p_l1 p_y1) + (loop (+ i1 1))))))))) - ;Finish the structure. - (qcomg "ghzy ladder" 1) - (g1y p_n1 p_l1 p_y1 p_y2) - (g1y "barrier" p_l1 p_y1 p_y2))) + ;Finish the structure. + (qcomg "ghzy ladder" 1) + (g1y p_n1 p_l1 p_y1 p_y2) + (g1y "barrier" p_l1 p_y1 p_y2))) (qcomg "ghzy" 1))) diff --git a/g2q3.scm b/g2q3.scm index 014e5c6..5f49e11 100644 --- a/g2q3.scm +++ b/g2q3.scm @@ -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 @@ -127,8 +127,9 @@ (let ((res 0)) (let loop ((i p_qx)) (if (= i 0) - (begin (if(equal? p_clean "y")(system (strings-append (list "rm " p_ddir p_fname "_*") 0))) - res) + (begin (if (equal? p_clean "y") + (system (strings-append (list "rm " p_ddir p_fname "_*") 0))) + res) (begin (set! res (+ res (qcompile-and-run p_fname p_fnameo p_qver p_ddir p_qpu p_qf p_q p_c p_qn p_cn p_mc i p_v p_rf))) (loop (- i 1))))))) diff --git a/tests/test1.scm b/tests/test1.scm index 789e857..c341174 100644 --- a/tests/test1.scm +++ b/tests/test1.scm @@ -38,7 +38,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