The Quantum Exact Simulation Toolkit v4.0.0
Loading...
Searching...
No Matches
decoherence.h
1/** @file
2 * API signatures for effecting decohering channels upon Quregs
3 * which are instantiated as density matrices.
4 *
5 * @author Tyson Jones
6 *
7 * @defgroup decoherence Decoherence
8 * @ingroup api
9 * @brief Functions for effecting decoherence channels upon density matrices.
10 * @{
11 */
12
13#ifndef DECOHERENCE_H
14#define DECOHERENCE_H
15
16#include "quest/include/types.h"
17#include "quest/include/qureg.h"
18#include "quest/include/channels.h"
19
20
21
22/*
23 * C AND C++ AGNOSTIC FUNCTIONS
24 */
25
26// enable invocation by both C and C++ binaries
27#ifdef __cplusplus
28extern "C" {
29#endif
30
31
32/** @notdoced
33 *
34 * @formulae
35 * Let @f$ \dmrho = @f$ @p qureg, @f$ p = @f$ @p prob and @f$ t = @f$ @p target.
36 *
37 * This function effects
38 * @f[
39 \dmrho
40 \;\rightarrow\;
41 (1 - p) \, \dmrho
42 \,+\,
43 p \, \hat{Z}_t \,\dmrho\, \hat{Z}_t.
44 * @f]
45 *
46 * @equivalences
47 * This function is equivalent to (but much faster than):
48 * - mixPaulis() with a zero probability for the @f$\hat{X}@f$ and @f$\hat{Y}@f$ components.
49 * ```
50 mixPaulis(qureg, target, 0, 0, prob);
51 * ```
52 * - mixKrausMap() with (scaled) @f$\hat{\id}@f$ and @f$\hat{Z}@f$ Kraus operators.
53 * ```
54 qreal a = sqrt(1-prob);
55 qreal b = sqrt(prob);
56
57 KrausMap map = createInlineKrausMap(1, 2, {
58 {{a,0},{0, a}}, // a * I
59 {{b,0},{0,-b}} // b * Z
60 });
61
62 mixKrausMap(qureg, &target, 1, map);
63 * ```
64 * - mixQureg() with a duplicated Qureg modified under applyPauliZ().
65 * ```
66 Qureg clone = createCloneQureg(qureg);
67 applyPauliZ(clone);
68 mixQureg(qureg, other, prob);
69 * ```
70 *
71 * @notvalidated
72 */
73void mixDephasing(Qureg qureg, int target, qreal prob);
74
75
76/** @notdoced
77 *
78 * @formulae
79 * Let @f$ \dmrho = @f$ @p qureg, @f$ p = @f$ @p prob, @f$ t_1 = @f$ @p target1 and @f$ t_2 = @f$ @p target2.
80 *
81 * This function effects
82 * @f[
83 \dmrho
84 \;\rightarrow\;
85 (1 - p) \, \dmrho
86 \,+\,
87 \frac{p}{3} \left(
88 \hat{Z}_{t_1} \dmrho \hat{Z}_{t_1}
89 \,+\,
90 \hat{Z}_{t_1} \dmrho \hat{Z}_{t_1}
91 \,+\,
92 \hat{Z}_{t_1} \hat{Z}_{t_2} \dmrho \hat{Z}_{t_1} \hat{Z}_{t_2}
93 \right).
94 * @f]
95 *
96 * @equivalences
97 * This function is equivalent to (but much faster than):
98 * - mixKrausMap() with (scaled) @f$\hat{\id}\otimes\hat{\id}@f$, @f$\hat{\id}\otimes\hat{Z}@f$,
99 * @f$\hat{Z}\otimes\hat{\id}@f$ and @f$\hat{Z}\otimes\hat{Z}@f$ Kraus operators.
100 * ```
101 qreal a = sqrt(1-prob);
102 qreal b = sqrt(prob/3);
103
104 KrausMap map = createInlineKrausMap(2, 4, {
105 {{a,0,0,0},{0, a,0,0},{0,0, a,0},{0,0,0, a}}, // a * II
106 {{b,0,0,0},{0,-b,0,0},{0,0, b,0},{0,0,0,-b}}, // b * IZ
107 {{b,0,0,0},{0, b,0,0},{0,0,-b,0},{0,0,0,-b}}, // b * ZI
108 {{b,0,0,0},{0,-b,0,0},{0,0,-b,0},{0,0,0, b}} // b * ZZ
109 });
110
111 int targets[] = {target1, target2};
112 mixKrausMap(qureg, targets, 2, map);
113 * ```
114 *
115 * @notvalidated
116 */
117void mixTwoQubitDephasing(Qureg qureg, int target1, int target2, qreal prob);
118
119
120/** @notdoced
121 *
122 * @formulae
123 * Let @f$ \dmrho = @f$ @p qureg, @f$ p = @f$ @p prob and @f$ t = @f$ @p target.
124 *
125 * This function effects
126 * @f[
127 \dmrho \;\rightarrow\;
128 (1 - p) \, \dmrho \,+\, \frac{p}{3} \left(
129 \hat{X}_t \dmrho \hat{X}_t \,+\,
130 \hat{Y}_t \dmrho \hat{Y}_t \,+\,
131 \hat{Z}_t \dmrho \hat{Z}_t
132 \right).
133 * @f]
134 *
135 * @equivalences
136 * This function is equivalent to (but much faster than):
137 * - mixPaulis() with a uniform probability.
138 * ```
139 mixPaulis(qureg, target, prob/3, prob/3, prob/3);
140 * ```
141 * - mixKrausMap() with (scaled) @f$\hat{\id}@f$, @f$\hat{X}@f$, @f$\hat{Y}@f$ and @f$\hat{Z}@f$ Kraus operators.
142 * ```
143 qreal a = sqrt(1-prob);
144 qreal b = sqrt(prob/3);
145
146 KrausMap map = createInlineKrausMap(1, 4, {
147 {{a,0},{0, a}}, // a * I
148 {{0,b},{b, 0}}, // b * X
149 {{b,0},{0,-b}} // b * Z
150 {{0,-1i*b},{1i*b,0}}, // b * Y
151 });
152
153 mixKrausMap(qureg, &target, 1, map);
154 * ```
155 *
156 * @notvalidated
157 */
158void mixDepolarising(Qureg qureg, int target, qreal prob);
159
160
161/** @notdoced
162 *
163 * @formulae
164 * Let @f$ \dmrho = @f$ @p qureg, @f$ p = @f$ @p prob, @f$ t_1 = @f$ @p target1 and @f$ t_2 = @f$ @p target2.
165 *
166 * This function effects:
167 * @f[
168 \dmrho \; \rightarrow \;
169 (1 - p) \dmrho
170 +
171 \frac{p}{15} \left(
172 \sum_{\hat{\sigma} \in \{\hat{\id},\hat{X},\hat{Y},\hat{Z}\}}
173 \sum_{\hat{\sigma}' \in \{\hat{\id},\hat{X},\hat{Y},\hat{Z}\}}
174 \hat{\sigma}_{t_1} \hat{\sigma}_{t_2}'
175 \; \dmrho \;
176 \hat{\sigma}_{t_1} \hat{\sigma}_{t_2}'
177 \right)
178 - \frac{p}{15} \hat{\id}_{t_1} \hat{\id}_{t_2} \dmrho \hat{\id}_{t_1} \hat{\id}_{t_2},
179 * @f]
180 *
181 * or verbosely:
182 *
183 * @f[
184 \dmrho \; \rightarrow \;
185 (1 - p) \, \rho + \frac{p}{15} \;
186 \left(
187 \begin{gathered}
188 \hat{X}_{t_1} \, \rho \, \hat{X}_{t_1} +
189 \hat{Y}_{t_1} \, \rho \, \hat{Y}_{t_1} +
190 \hat{Z}_{t_1} \, \rho \, \hat{Z}_{t_1} +
191 \\
192 \hat{X}_{t_2} \, \rho \, \hat{X}_{t_2} +
193 \hat{Y}_{t_2} \, \rho \, \hat{Y}_{t_2} +
194 \hat{Z}_{t_2} \, \rho \, \hat{Z}_{t_2} +
195 \\
196 \hat{X}_{t_1} \hat{X}_{t_2} \, \rho \, \hat{X}_{t_1} \hat{X}_{t_2} +
197 \hat{Y}_{t_1} \hat{Y}_{t_2} \, \rho \, \hat{Y}_{t_1} \hat{Y}_{t_2} +
198 \hat{Z}_{t_1} \hat{Z}_{t_2} \, \rho \, \hat{Z}_{t_1} \hat{Z}_{t_2} +
199 \\
200 \hat{X}_{t_1} \hat{Y}_{t_2} \, \rho \, \hat{X}_{t_1} \hat{Y}_{t_2} +
201 \hat{Y}_{t_1} \hat{Z}_{t_2} \, \rho \, \hat{Y}_{t_1} \hat{Z}_{t_2} +
202 \hat{Z}_{t_1} \hat{X}_{t_2} \, \rho \, \hat{Z}_{t_1} \hat{X}_{t_2} +
203 \\
204 \hat{X}_{t_1} \hat{Z}_{t_2} \, \rho \, \hat{X}_{t_1} \hat{Z}_{t_2} +
205 \hat{Y}_{t_1} \hat{X}_{t_2} \, \rho \, \hat{Y}_{t_1} \hat{Z}_{t_2} +
206 \hat{Z}_{t_1} \hat{Y}_{t_2} \, \rho \, \hat{Z}_{t_1} \hat{Y}_{t_2}
207 \end{gathered}
208 \right).
209 * @f]
210 *
211 * @equivalences
212 * This function is equivalent to (but much faster than):
213 * - mixKrausMap() with Kraus operators containing every possible tensor product
214 * of two Pauli matrices, all scaled by @f$ (p/15)^{1/2} @f$, _except_ for
215 * @f$ \hat{\id} \otimes \hat{\id} @f$ which is scaled by @f$ (1-16p/15)^{1/2} @f$.
216 *
217 * @notvalidated
218 */
219void mixTwoQubitDepolarising(Qureg qureg, int target1, int target2, qreal prob);
220
221
222/** @notdoced
223 *
224 * @formulae
225 * Let @f$ \dmrho = @f$ @p qureg, @f$ p = @f$ @p prob and @f$ t = @f$ @p target.
226 *
227 * This function effects
228 * @f[
229 \dmrho \; \rightarrow \;
230 \hat{K}_t^{(1)} \dmrho \, {\hat{K}_t^{(2)}}^\dagger
231 \,+\,
232 \hat{K}_t^{(2)} \dmrho \, {\hat{K}_t^{(2)}}^\dagger
233 * @f]
234 * where @f$ \hat{K}^{(1)} @f$ and @f$ \hat{K}^{(2)} @f$ are one-qubit Kraus operators
235 * @f[
236 \hat{K}^{(1)} = \begin{pmatrix} 1 & 0 \\ 0 & \sqrt{1-p} \end{pmatrix},
237 \;\;
238 \hat{K}^{(1)} = \begin{pmatrix} 0 & \sqrt{p} \\ 0 & 0 \end{pmatrix}.
239 * @f]
240 *
241 * @equivalences
242 * This function is equivalent to (but much faster than):
243 * - mixKrausMap() with the above Kraus operators.
244 * ```
245 KrausMap map = createInlineKrausMap(1, 2, {
246 {{1,0},{0,sqrt(1-prob)}}, // K1
247 {{0,sqrt(p)},{0,0}} // K2
248 });
249
250 mixKrausMap(qureg, &target, 1, map);
251 * ```
252 *
253 * @notvalidated
254 */
255void mixDamping(Qureg qureg, int target, qreal prob);
256
257
258/** @notdoced
259 *
260 * @formulae
261 * Let @f$ \dmrho = @f$ @p qureg, @f$ t = @f$ @p target, and
262 * @f$ p_x = @f$ @p probX, @f$ p_y = @f$ @p probY, @f$ p_z = @f$ @p probZ.
263 *
264 * This function effects
265 * @f[
266 \dmrho \;\rightarrow\;
267 (1 - p) \, \dmrho
268 \,+\,
269 p_x \, \hat{X}_t \dmrho \hat{X}_t
270 \,+\,
271 p_y \, \hat{Y}_t \dmrho \hat{Y}_t
272 \,+\,
273 p_z \, \hat{Z}_t \dmrho \hat{Z}_t.
274 * @f]
275 *
276 * @equivalences
277 * This function is equivalent to (but much faster than):
278 * - mixKrausMap() with (scaled) @f$\hat{\id}@f$, @f$\hat{X}@f$, @f$\hat{Y}@f$ and @f$\hat{Z}@f$ Kraus operators.
279 * ```
280 qreal a = sqrt(1-probX-probY-probZ);
281 qreal b = sqrt(probX);
282 qreal c = sqrt(probY);
283 qreal d = sqrt(probZ);
284
285 KrausMap map = createInlineKrausMap(1, 4, {
286 {{a,0},{0, a}}, // a * I
287 {{0,b},{b, 0}}, // b * X
288 {{d,0},{0,-d}} // d * Z
289 {{0,-1i*c},{1i*c,0}}, // c * Y
290 });
291
292 mixKrausMap(qureg, &target, 1, map);
293 * ```
294 *
295 * @notvalidated
296 */
297void mixPaulis(Qureg qureg, int target, qreal probX, qreal probY, qreal probZ);
298
299
300/** @notdoced
301 *
302 * @formulae
303 * Let @f$ \dmrho_1 = @f$ @p qureg, @f$ \dmrho_2 = @f$ @p other and @f$ p = @f$ @p prob.
304 *
305 * This function effects
306 * @f[
307 \dmrho_1 \;\rightarrow \;
308 (1 - p) \, \dmrho_1
309 \,+\,
310 p \, \dmrho_2.
311 * @f]
312 *
313 * @notvalidated
314 */
315void mixQureg(Qureg qureg, Qureg other, qreal prob);
316
317
318/** @notdoced
319 *
320 * @formulae
321 * Let @f$ \dmrho = @f$ @p qureg, @f$ \vec{t} = @f$ @p targets and @f$ \hat{K}^{(i)} @f$
322 * denote the @f$i@f$-th Kraus operator in @p map.
323 *
324 * This function effects
325 * @f[
326 \dmrho \; \rightarrow \;
327 \sum\limits_i
328 \hat{K}_{\vec{t}}^{(i)} \dmrho \, {\hat{K}_{\vec{t}}^{(i)}}^\dagger
329 * @f]
330 *
331 * @notvalidated
332 */
333void mixKrausMap(Qureg qureg, int* targets, int numTargets, KrausMap map);
334
335
336/// @notdoced
337/// @notvalidated
338void mixSuperOp(Qureg qureg, int* targets, int numTargets, SuperOp superop);
339
340
341// end de-mangler
342#ifdef __cplusplus
343}
344#endif
345
346
347
348/*
349 * C++ OVERLOADS
350 *
351 * which are only accessible to C++ binaries, and accept
352 * arguments more natural to C++ (e.g. std::vector). These
353 * are included in the file-wide doxygen group (no subgroups).
354 */
355
356#ifdef __cplusplus
357
358#include <vector>
359
360/// @nottested
361/// @notdoced
362/// @notvalidated
363/// @cpponly
364void mixKrausMap(Qureg qureg, std::vector<int> targets, KrausMap map);
365
366/// @nottested
367/// @notdoced
368/// @notvalidated
369/// @cpponly
370void mixSuperOp(Qureg qureg, std::vector<int> targets, SuperOp superop);
371
372#endif // __cplusplus
373
374
375
376#endif // DECOHERENCE_H
377
378/** @} */ // (end file-wide doxygen defgroup)
void mixQureg(Qureg qureg, Qureg other, qreal prob)
void mixPaulis(Qureg qureg, int target, qreal probX, qreal probY, qreal probZ)
void mixKrausMap(Qureg qureg, int *targets, int numTargets, KrausMap map)
void mixSuperOp(Qureg qureg, int *targets, int numTargets, SuperOp superop)
void mixTwoQubitDephasing(Qureg qureg, int target1, int target2, qreal prob)
void mixTwoQubitDepolarising(Qureg qureg, int target1, int target2, qreal prob)
void mixDamping(Qureg qureg, int target, qreal prob)
void mixDephasing(Qureg qureg, int target, qreal prob)
void mixDepolarising(Qureg qureg, int target, qreal prob)
Definition qureg.h:49