-
Notifications
You must be signed in to change notification settings - Fork 2
/
g2q4.scm
87 lines (79 loc) · 2.38 KB
/
g2q4.scm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
;; =============================================================================
;;
;; q2q4.scm
;;
;; Useful algorithms and functions.
;;
;; =============================================================================
;;
;; Copyright (C) 2018 - 2022 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
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;;
;; This program is distributed in the hope that it will be useful, but
;; WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
;; or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
;; License for more details.
;;
;; You should have received a copy of the GNU Lesser General Public License
;; along with this program. If not, see <https://www.gnu.org/licenses/>.
;;
;; =============================================================================
;;;; General notes:
;;
;; - Read sources for limitations on function parameters.
;; - Read at least the general notes of all scm files in this library before
;; use. Consider these files as your main documentation for g2q.
;;
;; Sources:
;;
;; - [1] Roell, J., 2018. Demystifying Quantum Gates — One Qubit At A Time.
;; [online] Medium. Available at:
;; https://towardsdatascience.com/demystifying-quantum-gates-one-qubit-at-a-time-54404ed80640
;; [Accessed 25 April 2020].
(define-module (g2q g2q4)
#:use-module (g2q g2q0)
#:use-module (g2q g2q1)
#:use-module (g2q g2q2)
#:use-module (g2q g2q3)
#:use-module (grsp grsp0)
#:use-module (grsp grsp1)
#:export (qrand1))
;; qrand1 - 4 x 1 universal random quantum circuit.
;;
;; Keywords:
;;
;; -
;;
;; Parameters:
;;
;; - p_r1: string, quantum register name.
;; - p_y1: numeric, qubit number.
;;
;; Sources:
;;
;; - [1][g2q2.[6]].
;;
(define (qrand1 p_r1 p_y1)
(let ((y1 p_y1)
(y2 (+ p_y1 1))
(y3 (+ p_y1 2))
(y4 (+ p_y1 3)))
(qcomg "qrand1" 0)
(g1y "h" p_r1 y1 y4)
(cz p_r1 y2 p_r1 y3)
(g1y "t" p_r1 y2 y3)
(cz p_r1 y1 p_r1 y2)
(cz p_r1 y3 p_r1 y4)
(g1 "t" p_r1 y1)
(g1 "y" p_r1 y2)
(g1 "x" p_r1 y3)
(g1 "t" p_r1 y4)
(cz p_r1 y2 p_r1 y3)
(g1 "x" p_r1 y2)
(g1 "t" p_r1 y3)
(cz p_r1 y1 p_r1 y2)
(qcomg "qrand1" 1)))