-
Notifications
You must be signed in to change notification settings - Fork 1
/
grsp17.scm
279 lines (243 loc) · 6.12 KB
/
grsp17.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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
;; =========================================================================
;;
;; grsp17.scm
;;
;; Quantum information theory functions.
;;
;; =========================================================================
;;
;; Copyright (C) 2021 - 2024 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.
;;
;; Sources:
;;
;; See code of functions used and their respective source files for more
;; credits and references.
;;
;; - [1] Quantum computing (2022) Wikipedia. Wikimedia Foundation. Available
;; at: https://en.wikipedia.org/wiki/Quantum_computing
;; (Accessed: December 11, 2022).
;; - [2] Quantum Volume (2022) Wikipedia. Wikimedia Foundation. Available
;; at: https://en.wikipedia.org/wiki/Quantum_volume
;; (Accessed: December 11, 2022).
;; - [3] Bra–Ket Notation (2022) Wikipedia. Wikimedia Foundation. Available
;; at: https://en.wikipedia.org/wiki/Bra%E2%80%93ket_notation
;; (Accessed: December 12, 2022).
;; - [4] W State (2022) Wikipedia. Wikimedia Foundation. Available at:
;; https://en.wikipedia.org/wiki/W_state (Accessed: December 13, 2022).
;; - [5] Greenberger–Horne–zeilinger state (2022) Wikipedia. Wikimedia
;; Foundation. Available at:
;; https://en.wikipedia.org/wiki/Greenberger%E2%80%93Horne%E2%80%93Zeilinger_state
;; (Accessed: December 13, 2022).
;; - [6] List of mathematical symbols by subject (2022) Wikipedia. Wikimedia
;; Foundation. Available at:
;; https://en.wikipedia.org/wiki/List_of_mathematical_symbols_by_subject
;; (Accessed: December 15, 2022).
;; - [7] Multipartite entanglement (2022) Wikipedia. Wikimedia Foundation.
;; Available at: https://en.wikipedia.org/wiki/Multipartite_entanglement
;; (Accessed: December 16, 2022).
;; - [8] Many-worlds interpretation (2022) Wikipedia. Wikimedia Foundation.
;; Available at: https://en.wikipedia.org/wiki/Many-worlds_interpretation
;; (Accessed: January 6, 2023).
;; - [9] Mathematical universe hypothesis (2023) Wikipedia. Available at:
;; https://en.wikipedia.org/wiki/Mathematical_universe_hypothesis
;; (Accessed: 31 July 2023).
(define-module (grsp grsp17)
#:use-module (grsp grsp0)
#:use-module (grsp grsp1)
#:use-module (grsp grsp2)
#:use-module (grsp grsp3)
#:use-module (grsp grsp5)
#:export (grsp-qit-depth
grsp-qit-volume
grsp-qit-eeff1
grsp-qit-bra
grsp-qit-ket
grsp-qit-ghz
grsp-qit-w))
;;;; grsp-qit-depth - Circuit depth. Number of operations possible before
;; decoherence.
;;
;; Keywords:
;;
;; - quantum, circuit, depth, errors, tolerance
;;
;; Parameters:
;;
;; - p_n1: number of qubits.
;; - p_n2: effective error rate (average error rate of a two-qubit gate).
;;
;; Notes:
;;
;; - Results are in this case approximate.
;;
;; Output:
;;
;; - Numeric.
;;
;; Sources:
;;
;; - [2].
;;
(define (grsp-qit-depth p_n1 p_n2)
(let ((res1 0))
(set! res1 (/ 1 (* p_n1 p_n2)))
res1))
;;;; grsp-qit-volume - Quantum volume.
;;
;; Keywords:
;;
;; - quantum, circuit, volume, performance, capacity, power
;;
;; Parameters:
;;
;; - p_n1: number of qubits.
;; - p_n2: depth.
;;
;; Output:
;;
;; - Numeric.
;;
;; Sources:
;;
;; - [2].
;;
(define (grsp-qit-volume p_n1 p_n2)
(let ((res1 0))
(set! res1 (* p_n1 p_n2))
res1))
;;;; grsp-qit-eeff1 - Effective error rate; average mean error rate of a
;; two - qubit gate.
;;
;; Keywords:
;;
;; - quantum, circuit, volume, performance, errors
;;
;; Parameters:
;;
;; - p_a1: sample matrix.
;;
;; Output:
;;
;; - Numeric.
;;
;; Sources:
;;
;; - [2].
;;
(define (grsp-qit-eeff1 p_a1)
(let ((res1 0))
(set! res1 (grsp-mean1 p_a1))
res1))
;;;; grsp-qit-bra - Expresses p_a1 as a bra (row vector) following Dirac
;; notation.
;;
;; Keywords:
;;
;; - quantum, matrices, dirac, bra, ket, dirac
;;
;; Parameters:
;;
;; - p_a1: row vector (bra).
;;
;; Output:
;;
;; - Matrix.
;;
(define (grsp-quit-bra p_a1)
(let ((res1 0))
(set! res1 (grsp-matrix-cpy p_a1))
(cond ((> (grsp-matrix-wlongest p_a1) 0)
(set! res1 (grsp-matrix-transpose p_a1))))
res1))
;;;; grsp-qit-ket - Expresses p_a1 as a ket (column vector) following Dirac
;; notation.
;;
;; Keywords:
;;
;; - quantum, matrices, dirac, bra, ket
;;
;; Parameters:
;;
;; - p_a1: col vector (bra).
;;
;; Output:
;;
;; - Matrix.
;;
(define (grsp-quit-ket p_a1)
(let ((res1 0))
(set! res1 (grsp-matrix-cpy p_a1))
(cond ((< (grsp-matrix-wlongest p_a1) 0)
(set! res1 (grsp-matrix-transpose p_a1))))
res1))
;;;; grsp-qit-ghz - Generalized GHZ state.
;;
;; Keywords:
;;
;; - quantum, matrices, dirac, bra, ket, state
;;
;; Parameters:
;;
;; - p_l1: list of ket subsystems.
;;
;; Output:
;;
;; - numeric.
;;
;; Sources:
;;
;; - [5].
;;
(define (grsp-qit-ghz p_l1)
(let ((res1 0)
(n1 (/ 1 (sqrt 2))))
;; Kronecker product.
(set! res1 (grsp-matrix-opmml "#(*)" p_l1))
;; Scalar product.
(set! res1 (grsp-matrix-opsc "#*" res1 n1))
res1))
;;;; grsp-qit-w - Generalized W state.
;;
;; Keywords:
;;
;; - quantum, matrices, dirac, bra, ket, state
;;
;; Parameters:
;;
;; - p_l1: list of ket subsystems.
;;
;; Output:
;;
;; - Numeric.
;;
;; Sources:
;;
;; - [5].
;;
(define (grsp-qit-w p_l1)
(let ((res1 0)
(n1 (/ 1 (length p_l1))))
;; Kronecker product.
(set! res1 (grsp-matrix-opmml "#(*)" p_l1))
;; Scalar product.
(set! res1 (grsp-matrix-opsc "#*" res1 n1))
res1))