The Quantum Exact Simulation Toolkit v4.3.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/** Applies a one-qubit dephasing channel upon the density matrix @p qureg,
33 * where @p prob is the probability of a @f$ \hat{Z} @f$ error upon the
34 * @p target qubit.
35 *
36 * This is also known as a phase-flip channel.
37 *
38 * @formulae
39 *
40 * Let @f$ \dmrho = @f$ @p qureg, @f$ p = @f$ @p prob and @f$ t = @f$ @p target.
41 *
42 * This function effects
43 * @f[
44 \dmrho
45 \;\rightarrow\;
46 (1 - p) \, \dmrho
47 \,+\,
48 p \, \hat{Z}_t \,\dmrho\, \hat{Z}_t.
49 * @f]
50 *
51 * This is a physically valid operation (is completely positive and trace preserving)
52 * when @f$ 0 \le p \le 1 @f$, and is a meaningful noise channel (i.e. induces mixing)
53 * for @f$ 0 < p \le 1/2 @f$.
54 *
55 * @constraints
56 *
57 * - Parameter @p prob must be a valid probability and ergo satisfy @f$ 0 \le p \le 1 @f$
58 * unless validation is disabled via setQuESTValidationOff(), which permits quasi-probability
59 * channels with, for example, negative probabilities.
60 * - The maximum permitted error probability is @f$ p = 1/2 @f$ (unless validation is disabled)
61 * at which the qubit becomes completely "dephased", and the off-diagonal "coherences" become zero.
62 * - With validation disabled, the channel remains CPTP for @f$ 1/2 \le p \le 1 @f$.
63 *
64 * @equivalences
65 *
66 * This function is equivalent to (but much faster than):
67 * - mixPaulis() with a zero probability for the @f$\hat{X}@f$ and @f$\hat{Y}@f$ components.
68 * ```
69 mixPaulis(qureg, target, 0, 0, prob);
70 * ```
71 * - mixKrausMap() with (scaled) @f$\hat{\id}@f$ and @f$\hat{Z}@f$ Kraus operators.
72 * ```
73 qreal a = sqrt(1-prob);
74 qreal b = sqrt(prob);
75
76 KrausMap map = createInlineKrausMap(1, 2, {
77 {{a,0},{0, a}}, // a * I
78 {{b,0},{0,-b}} // b * Z
79 });
80
81 mixKrausMap(qureg, &target, 1, map);
82 * ```
83 * - mixQureg() with a duplicated Qureg modified under applyPauliZ().
84 * ```
85 Qureg clone = createCloneQureg(qureg);
86 applyPauliZ(clone);
87 mixQureg(qureg, other, prob);
88 * ```
89 *
90 * @notyetvalidated
91 *
92 * @param[in,out] qureg the density matrix to modify.
93 * @param[in] target the index of the target qubit.
94 * @param[in] prob the probability of any error.
95 * @throws @validationerror
96 * - if @p qureg is not initialised.
97 * - if @p qureg is not a density matrix (unless @p prob is 0).
98 * - if @p target is an invalid qubit index.
99 * - if @p prob < 0, or @p prob > 1/2.
100 * @see
101 * - mixTwoQubitDephasing()
102 * - mixDepolarising()
103 * - mixPaulis()
104 * @author Tyson Jones
105 */
106void mixDephasing(Qureg qureg, int target, qreal prob);
107
108
109/** Applies a two-qubit dephasing channel upon the density matrix @p qureg,
110 * where @p prob is the probability of a @f$ \hat{Z} @f$ error upon either
111 * or both of qubits @p target1 and @p target2, which are interchangeable.
112 *
113 * @formulae
114 *
115 * Let @f$ \dmrho = @f$ @p qureg, @f$ p = @f$ @p prob, @f$ t_1 = @f$ @p target1 and @f$ t_2 = @f$ @p target2.
116 *
117 * This function effects
118 * @f[
119 \dmrho
120 \;\rightarrow\;
121 (1 - p) \, \dmrho
122 \,+\,
123 \frac{p}{3} \left(
124 \hat{Z}_{t_1} \dmrho \hat{Z}_{t_1}
125 \,+\,
126 \hat{Z}_{t_2} \dmrho \hat{Z}_{t_2}
127 \,+\,
128 \hat{Z}_{t_1} \hat{Z}_{t_2} \dmrho \hat{Z}_{t_1} \hat{Z}_{t_2}
129 \right).
130 * @f]
131 *
132 * This is a physically valid operation (is completely positive and trace preserving)
133 * when @f$ 0 \le p \le 1 @f$, and is a meaningful noise channel (i.e. induces mixing)
134 * for @f$ 0 < p \le 3/4 @f$.
135 *
136 * @constraints
137 *
138 * - Parameter @p prob must be a valid probability and ergo satisfy @f$ 0 \le p \le 1 @f$
139 * unless validation is disabled via setQuESTValidationOff(), which permits quasi-probability
140 * channels with, for example, negative probabilities.
141 * - The maximum permitted error probability is @f$ p = 3/4 @f$ (unless validation is disabled),
142 * at which the channel is "maximum strength" and the off-diagonal "coherences" of the two qubits
143 * become zero.
144 * - With validation disabled, the channel remains CPTP for @f$ 3/4 \le p \le 1 @f$.
145 *
146 * @equivalences
147 *
148 * This function is equivalent to (but much faster than):
149 * - mixKrausMap() with (scaled) @f$\hat{\id}\otimes\hat{\id}@f$, @f$\hat{\id}\otimes\hat{Z}@f$,
150 * @f$\hat{Z}\otimes\hat{\id}@f$ and @f$\hat{Z}\otimes\hat{Z}@f$ Kraus operators.
151 * ```
152 qreal a = sqrt(1-prob);
153 qreal b = sqrt(prob/3);
154
155 KrausMap map = createInlineKrausMap(2, 4, {
156 {{a,0,0,0},{0, a,0,0},{0,0, a,0},{0,0,0, a}}, // a * II
157 {{b,0,0,0},{0,-b,0,0},{0,0, b,0},{0,0,0,-b}}, // b * IZ
158 {{b,0,0,0},{0, b,0,0},{0,0,-b,0},{0,0,0,-b}}, // b * ZI
159 {{b,0,0,0},{0,-b,0,0},{0,0,-b,0},{0,0,0, b}} // b * ZZ
160 });
161
162 int targets[] = {target1, target2};
163 mixKrausMap(qureg, targets, 2, map);
164 * ```
165 *
166 * @notyetvalidated
167 *
168 * @param[in,out] qureg the density matrix to modify.
169 * @param[in] target1 the index of the first target qubit.
170 * @param[in] target2 the index of the second target qubit.
171 * @param[in] prob the probability of any error.
172 * @throws @validationerror
173 * - if @p qureg is not initialised.
174 * - if @p qureg is not a density matrix (unless @p prob is 0).
175 * - if @p target1 or @p target2 is an invalid qubit index, or are the same.
176 * - if @p prob < 0, or @p prob > 3/4.
177 * @see
178 * - createDensityQureg()
179 * - mixDephasing()
180 * - mixDepolarising()
181 * - mixPaulis()
182 * @author Tyson Jones
183 */
184void mixTwoQubitDephasing(Qureg qureg, int target1, int target2, qreal prob);
185
186
187/** Applies a one-qubit homogeneous depolarising channel upon the density matrix @p qureg,
188 * where @p prob is the probability of any error upon the @p target qubit.
189 *
190 * @formulae
191 *
192 * Let @f$ \dmrho = @f$ @p qureg, @f$ p = @f$ @p prob and @f$ t = @f$ @p target.
193 *
194 * This function effects
195 * @f[
196 \dmrho \;\rightarrow\;
197 (1 - p) \, \dmrho \,+\, \frac{p}{3} \left(
198 \hat{X}_t \dmrho \hat{X}_t \,+\,
199 \hat{Y}_t \dmrho \hat{Y}_t \,+\,
200 \hat{Z}_t \dmrho \hat{Z}_t
201 \right).
202 * @f]
203 *
204 * This is a physically valid operation (is completely positive and trace preserving)
205 * when @f$ 0 \le p \le 1 @f$, and is a meaningful noise channel (i.e. induces mixing)
206 * for @f$ 0 < p \le 3/4 @f$.
207 *
208 * @constraints
209 *
210 * - Parameter @p prob must be a valid probability and ergo satisfy @f$ 0 \le p \le 1 @f$
211 * unless validation is disabled via setQuESTValidationOff(), which permits quasi-probability
212 * channels with, for example, negative probabilities.
213 * - The maximum permitted error probability is @f$ p = 3/4 @f$ (unless validation is disabled),
214 * at which the channel is maximum strength, and the qubit enters the maximally mixed state.
215 * - With validation disabled, the channel remains CPTP for @f$ 3/4 \le p \le 1 @f$.
216 *
217 * @equivalences
218 *
219 * This function is equivalent to (but much faster than):
220 * - mixPaulis() with a uniform probability.
221 * ```
222 mixPaulis(qureg, target, prob/3, prob/3, prob/3);
223 * ```
224 * - mixKrausMap() with (scaled) @f$\hat{\id}@f$, @f$\hat{X}@f$, @f$\hat{Y}@f$ and @f$\hat{Z}@f$ Kraus operators.
225 * ```
226 qreal a = sqrt(1-prob);
227 qreal b = sqrt(prob/3);
228
229 KrausMap map = createInlineKrausMap(1, 4, {
230 {{a,0},{0, a}}, // a * I
231 {{0,b},{b, 0}}, // b * X
232 {{b,0},{0,-b}}, // b * Z
233 {{0,-1i*b},{1i*b,0}}, // b * Y
234 });
235
236 mixKrausMap(qureg, &target, 1, map);
237 * ```
238 *
239 * @notyetvalidated
240 *
241 * @param[in,out] qureg the density matrix to modify.
242 * @param[in] target the index of the target qubit.
243 * @param[in] prob the probability of any error.
244 * @throws @validationerror
245 * - if @p qureg is not initialised.
246 * - if @p qureg is not a density matrix (unless @p prob is 0).
247 * - if @p target is an invalid qubit index.
248 * - if @p prob < 0, or @p prob > 3/4.
249 * @see
250 * - mixTwoQubitDepolarising()
251 * - mixDephasing()
252 * - mixPaulis()
253 * @author Tyson Jones
254 */
255void mixDepolarising(Qureg qureg, int target, qreal prob);
256
257
258/** Applies a two-qubit homogeneous depolarising channel upon the density matrix @p qureg,
259 * where @p prob is the probability of any error upon either
260 * or both of qubits @p target1 and @p target2, which are interchangeable.
261 *
262 * @formulae
263 *
264 * Let @f$ \dmrho = @f$ @p qureg, @f$ p = @f$ @p prob, @f$ t_1 = @f$ @p target1 and @f$ t_2 = @f$ @p target2.
265 *
266 * This function effects:
267 * @f[
268 \dmrho \; \rightarrow \;
269 (1 - p) \dmrho
270 +
271 \frac{p}{15} \left(
272 \sum_{\hat{\sigma} \in \{\hat{\id},\hat{X},\hat{Y},\hat{Z}\}}
273 \sum_{\hat{\sigma}' \in \{\hat{\id},\hat{X},\hat{Y},\hat{Z}\}}
274 \hat{\sigma}_{t_1} \hat{\sigma}_{t_2}'
275 \; \dmrho \;
276 \hat{\sigma}_{t_1} \hat{\sigma}_{t_2}'
277 \right)
278 - \frac{p}{15} \hat{\id}_{t_1} \hat{\id}_{t_2} \dmrho \hat{\id}_{t_1} \hat{\id}_{t_2},
279 * @f]
280 *
281 * or verbosely:
282 *
283 * @f[
284 \dmrho \; \rightarrow \;
285 (1 - p) \, \rho + \frac{p}{15} \;
286 \left(
287 \begin{gathered}
288 \hat{X}_{t_1} \, \rho \, \hat{X}_{t_1} +
289 \hat{Y}_{t_1} \, \rho \, \hat{Y}_{t_1} +
290 \hat{Z}_{t_1} \, \rho \, \hat{Z}_{t_1} +
291 \\
292 \hat{X}_{t_2} \, \rho \, \hat{X}_{t_2} +
293 \hat{Y}_{t_2} \, \rho \, \hat{Y}_{t_2} +
294 \hat{Z}_{t_2} \, \rho \, \hat{Z}_{t_2} +
295 \\
296 \hat{X}_{t_1} \hat{X}_{t_2} \, \rho \, \hat{X}_{t_1} \hat{X}_{t_2} +
297 \hat{Y}_{t_1} \hat{Y}_{t_2} \, \rho \, \hat{Y}_{t_1} \hat{Y}_{t_2} +
298 \hat{Z}_{t_1} \hat{Z}_{t_2} \, \rho \, \hat{Z}_{t_1} \hat{Z}_{t_2} +
299 \\
300 \hat{X}_{t_1} \hat{Y}_{t_2} \, \rho \, \hat{X}_{t_1} \hat{Y}_{t_2} +
301 \hat{Y}_{t_1} \hat{Z}_{t_2} \, \rho \, \hat{Y}_{t_1} \hat{Z}_{t_2} +
302 \hat{Z}_{t_1} \hat{X}_{t_2} \, \rho \, \hat{Z}_{t_1} \hat{X}_{t_2} +
303 \\
304 \hat{X}_{t_1} \hat{Z}_{t_2} \, \rho \, \hat{X}_{t_1} \hat{Z}_{t_2} +
305 \hat{Y}_{t_1} \hat{X}_{t_2} \, \rho \, \hat{Y}_{t_1} \hat{X}_{t_2} +
306 \hat{Z}_{t_1} \hat{Y}_{t_2} \, \rho \, \hat{Z}_{t_1} \hat{Y}_{t_2}
307 \end{gathered}
308 \right).
309 * @f]
310 *
311 * This is a physically valid operation (is completely positive and trace preserving)
312 * when @f$ 0 \le p \le 1 @f$, and is a meaningful noise channel (i.e. induces mixing)
313 * for @f$ 0 < p \le 15/16 @f$.
314 *
315 * @constraints
316 *
317 * - Parameter @p prob must be a valid probability and ergo satisfy @f$ 0 \le p \le 1 @f$
318 * unless validation is disabled via setQuESTValidationOff(), which permits quasi-probability
319 * channels with, for example, negative probabilities.
320 * - The maximum permitted error probability is @f$ p = 15/16 @f$ (unless validation is disabled),
321 * at which the channel is maximum strength, and the target qubits become maximally mixed.
322 * - With validation disabled, the channel remains CPTP for @f$ 15/16 \le p \le 1 @f$.
323 *
324 * @equivalences
325 *
326 * This function is equivalent to (but much faster than):
327 * - mixKrausMap() with Kraus operators containing every possible tensor product
328 * of two Pauli matrices, all scaled by @f$ (p/15)^{1/2} @f$, _except_ for
329 * @f$ \hat{\id} \otimes \hat{\id} @f$ which is scaled by @f$ (1-16p/15)^{1/2} @f$.
330 *
331 * @notyetvalidated
332 *
333 * @param[in,out] qureg the density matrix to modify.
334 * @param[in] target1 the index of the first target qubit.
335 * @param[in] target2 the index of the second target qubit.
336 * @param[in] prob the probability of any error.
337 * @throws @validationerror
338 * - if @p qureg is not initialised.
339 * - if @p qureg is not a density matrix (unless @p prob is 0).
340 * - if @p target1 or @p target2 is an invalid qubit index, or are the same.
341 * - if @p prob < 0, or @p prob > 15/16.
342 * @see
343 * - createDensityQureg()
344 * - mixTwoQubitDephasing()
345 * @author Tyson Jones
346 */
347void mixTwoQubitDepolarising(Qureg qureg, int target1, int target2, qreal prob);
348
349
350/** Applies a one-qubit amplitude damping channel upon the density matrix @p qureg,
351 * where @p prob is the probability of the @p target qubit relaxing to the zero state.
352 *
353 * @formulae
354 *
355 * Let @f$ \dmrho = @f$ @p qureg, @f$ p = @f$ @p prob and @f$ t = @f$ @p target.
356 *
357 * This function effects
358 * @f[
359 \dmrho \; \rightarrow \;
360 \hat{K}_t^{(1)} \dmrho \, {\hat{K}_t^{(1)}}^\dagger
361 \,+\,
362 \hat{K}_t^{(2)} \dmrho \, {\hat{K}_t^{(2)}}^\dagger
363 * @f]
364 * where @f$ \hat{K}^{(1)} @f$ and @f$ \hat{K}^{(2)} @f$ are one-qubit Kraus operators
365 * @f[
366 \hat{K}^{(1)} = \begin{pmatrix} 1 & 0 \\ 0 & \sqrt{1-p} \end{pmatrix},
367 \;\;
368 \hat{K}^{(2)} = \begin{pmatrix} 0 & \sqrt{p} \\ 0 & 0 \end{pmatrix}.
369 * @f]
370 *
371 * This is a physically valid operation (the channel is completely positive and trace
372 * preserving) for @f$ 0 \le p \le 1 @f$. Note however that it may actually reduce
373 * mixing and increase purity, depending on @f$ p @f$ and the qubit's initial state.
374 *
375 * @constraints
376 *
377 * - Parameter @p prob must be a valid probability and ergo satisfy @f$ 0 \le p \le 1 @f$.
378 * Beware that disabling validation with setQuESTValidationOff() and passing @p prob
379 * outside this domain will result in mathematically erroneous results; amplitudes which
380 * are erroneously zero, or @c NaN, as output by @c sqrt().
381 *
382 * @equivalences
383 *
384 * This function is equivalent to (but much faster than):
385 * - mixKrausMap() with the above Kraus operators.
386 * ```
387 KrausMap map = createInlineKrausMap(1, 2, {
388 {{1,0},{0,sqrt(1-prob)}}, // K1
389 {{0,sqrt(p)},{0,0}} // K2
390 });
391
392 mixKrausMap(qureg, &target, 1, map);
393 * ```
394 *
395 * @notyetvalidated
396 *
397 * @param[in,out] qureg the density matrix to modify.
398 * @param[in] target the index of the target qubit.
399 * @param[in] prob the probability of relaxing to zero.
400 * @throws @validationerror
401 * - if @p qureg is not initialised.
402 * - if @p qureg is not a density matrix (unless @p prob is 0).
403 * - if @p target is an invalid qubit index.
404 * - if @p prob < 0 or @p prob > 1.
405 * @see
406 * - mixKrausMap()
407 * @author Tyson Jones
408 */
409void mixDamping(Qureg qureg, int target, qreal prob);
410
411
412/** Applies a one-qubit inhomogeneous Pauli channel upon the density matrix @p qureg.
413 *
414 * This is a generalisation of mixDepolarising(), permitting inhomogeneous error probabilities.
415 *
416 * @formulae
417 *
418 * Let @f$ \dmrho = @f$ @p qureg, @f$ t = @f$ @p target, and
419 * @f$ p_x = @f$ @p probX, @f$ p_y = @f$ @p probY, @f$ p_z = @f$ @p probZ.
420 *
421 * This function effects
422 * @f[
423 \dmrho \;\rightarrow\;
424 (1 - p) \, \dmrho
425 \,+\,
426 p_x \, \hat{X}_t \dmrho \hat{X}_t
427 \,+\,
428 p_y \, \hat{Y}_t \dmrho \hat{Y}_t
429 \,+\,
430 p_z \, \hat{Z}_t \dmrho \hat{Z}_t.
431 * @f]
432 *
433 * This operation is physically valid (completely positive and trace preserving) when each
434 * probability is valid (@f$ 0 \le p_i \le 1 @f$), and together satisfy
435 * @f[
436 * p_x + p_y + p_z \le 1.
437 * @f]
438 * The operation is a meaningful noise channel (decreases purity) when the probabilities are
439 * below that which induces maximal mixing; when the probability of no error is greater than
440 * (or equal to) the probability of any error.
441 * @f[
442 * 1 - (p_x + p_y + p_z) \ge \max(p_x, p_y, p_z).
443 * @f]
444 *
445 * @constraints
446 *
447 * - Each of @p probX, @p probY, and @p probZ must be a valid probability, i.e. @f$ 0 \le p_i \le 1 @f$,
448 * and the probability of no error (one minus their sum) must also be valid. This particular validation
449 * is insensitive to the validation epsilon as controlled with setQuESTValidationEpsilon(), but can instead
450 * be relaxed with setQuESTValidationOff(), to effect channels which are not completely-positive and
451 * trace-preserving, such as quasi-probability channels.
452 * - The channel strength must not exceed that which induces maximal mixing (unless validation is disabled),
453 * whereby the probability of any particular error equals that of no error, as discussed above.
454 *
455 * @equivalences
456 *
457 * This function is equivalent to (but much faster than):
458 * - mixKrausMap() with (scaled) @f$\hat{\id}@f$, @f$\hat{X}@f$, @f$\hat{Y}@f$ and @f$\hat{Z}@f$ Kraus operators.
459 * ```
460 qreal a = sqrt(1-probX-probY-probZ);
461 qreal b = sqrt(probX);
462 qreal c = sqrt(probY);
463 qreal d = sqrt(probZ);
464
465 KrausMap map = createInlineKrausMap(1, 4, {
466 {{a,0},{0, a}}, // a * I
467 {{0,b},{b, 0}}, // b * X
468 {{d,0},{0,-d}}, // d * Z
469 {{0,-1i*c},{1i*c,0}}, // c * Y
470 });
471
472 mixKrausMap(qureg, &target, 1, map);
473 * ```
474 *
475 * @notyetvalidated
476 *
477 * @param[in,out] qureg the density matrix to modify.
478 * @param[in] target the index of the target qubit.
479 * @param[in] probX the probability of an X operator upon @p target.
480 * @param[in] probY the probability of an Y operator upon @p target.
481 * @param[in] probZ the probability of an Z operator upon @p target.
482 * @throws @validationerror
483 * - if @p qureg is not initialised.
484 * - if @p qureg is not a density matrix (unless @p probX = @p probY = @p probZ = 0).
485 * - if @p target is an invalid qubit index.
486 * - if any probability is invalid (below zero or above one).
487 * - if the probability of any error exceeds that of no error.
488 * @see
489 * - mixDephasing()
490 * - mixDepolarising()
491 * - mixKrausMap
492 * @author Tyson Jones
493 */
494void mixPaulis(Qureg qureg, int target, qreal probX, qreal probY, qreal probZ);
495
496
497/** Modifies the density matrix @p qureg to the mixture of itself and the density matrix or
498 * statevector @p other.
499 *
500 * @formulae
501 *
502 * Let @f$ \dmrho_1 = @f$ @p qureg and @f$ p = @f$ @p prob.
503 *
504 * - When @p other is a density matrix @f$ \dmrho_2 @f$, this function effects
505 * @f[
506 \dmrho_1 \;\rightarrow \;
507 (1 - p) \, \dmrho_1
508 \,+\,
509 p \, \dmrho_2.
510 * @f]
511 * - When @p other is a statevector @f$ \ket{\psi_2} @f$, this function effects
512 * @f[
513 \dmrho_1 \;\rightarrow \;
514 (1 - p) \, \dmrho_1
515 \,+\,
516 p \, \ketbra{\psi_2}{\psi_2}.
517 * @f]
518 *
519 * @constraints
520 *
521 * - Parameter @p prob must be a valid probability, satisfying @f$ 0 \le p \le 1 @f$,
522 * though can be relaxed to any real scalar by disabling validation with
523 * setQuESTValidationOff().
524 * - @p qureg and @p other must contain the same number of qubits.
525 * - If @p other is a density matrix, it must be identically distributed to @p qureg
526 * (although the parallelisation backends, like multithreading and GPU acceleration, are
527 * permitted to differ).
528 * - If @p other is a statevector and @p qureg is not distributed, neither too must @p other.
529 *
530 * @notyetvalidated
531 *
532 * @param[in,out] qureg the density matrix to modify.
533 * @param[in] other the density matrix or statevector to mix into @p qureg.
534 * @param[in] prob the coefficient of @p other in the mixture.
535 * @throws @validationerror
536 * - if @p qureg is not initialised.
537 * - if @p qureg is not a density matrix.
538 * - if @p qureg and @p other contain a different number of qubits.
539 * - if @p prob is not a valid probability.
540 * - if @p other is a density matrix which is differently distributed to @p qureg.
541 * - if @p other is a distributed statevector, but @p qureg is not distributed.
542 * @see
543 * - mixKrausMap()
544 * @author Tyson Jones
545 */
546void mixQureg(Qureg qureg, Qureg other, qreal prob);
547
548
549/** Applies a general, any-size channel described as a Kraus map upon the density matrix @p qureg.
550 *
551 * @formulae
552 *
553 * Let @f$ \dmrho = @f$ @p qureg, @f$ \vec{t} = @f$ @p targets and @f$ \hat{K}^{(i)} @f$
554 * denote the @f$i@f$-th Kraus operator in @p map.
555 *
556 * This function effects
557 * @f[
558 \dmrho \; \rightarrow \;
559 \sum\limits_i
560 \hat{K}_{\vec{t}}^{(i)} \dmrho \, {\hat{K}_{\vec{t}}^{(i)}}^\dagger.
561 * @f]
562 *
563 * The channel is completely positive and trace preserving (CPTP) when the Kraus operators satisfy
564 * @f[
565 \sum\limits_i {\hat{K}_{\vec{t}}^{(i)}}^\dagger \hat{K}_{\vec{t}}^{(i)} = \mathbb{1}.
566 * @f]
567 *
568 * @constraints
569 *
570 * - The number of channel targets @p numTargets must agree with the size of the Kraus map.
571 * - The channel must be approximately CPTP, such that difference between
572 * @f$ \sum\limits_i {\hat{K}_{\vec{t}}^{(i)}}^\dagger \hat{K}_{\vec{t}}^{(i)} @f$ and
573 * @f$ \mathbb{1} @f$ has no element of absolute value greater than the validation
574 * epsilon @f$ \valeps @f$. This can be adjusted with setQuESTValidationEpsilon(), and
575 * relaxed entirely by setting @f$ \valeps = 0 @f$.
576 * - When @p qureg is distributed, each node must contain at least @c pow(2,2*numTargets)
577 * many amplitudes, to ensure sufficient communication buffers are allocated.
578 *
579 * @equivalences
580 *
581 * This function calls mixSuperOp(), passing the corresponding superoperator of @p map, which has the form
582 * @f[
583 \hat{S} = \sum\limits_i {\hat{K}_{\vec{t}}^{(i)}}^* \otimes \hat{K}_{\vec{t}}^{(i)}.
584 * @f]
585 *
586 * @notyetvalidated
587 *
588 * @param[in,out] qureg the density matrix to modify.
589 * @param[in] targets the list of target qubit indices.
590 * @param[in] numTargets the length of @p targets
591 * @param[in] map a compatible-sized KrausMap.
592 * @throws @validationerror
593 * - if @p qureg is not initialised.
594 * - if @p qureg is not a density matrix.
595 * - if @p targets contains a duplicate or invalid qubit index.
596 * - if @p numTargets is less than one, or exceeds the size of @p qureg.
597 * - if @p map is not initialised.
598 * - if @p map contains a different number of qubits than @p numTargets.
599 * - if @p map is not CPTP.
600 * - if @p qureg is distributed and @p numTargets exceeds the number of
601 * qubits in @p qureg minus half log-2 of the number of processes.
602 * @see
603 * - createKrausMap()
604 * - [createInlineKrausMap()](https://quest-kit.github.io/QuEST/group__channels__create.html#gae9c49a6443896ef590ff1e4cfaa4912b)
605 * - setKrausMap()
606 * @author Tyson Jones
607 */
608void mixKrausMap(Qureg qureg, int* targets, int numTargets, KrausMap map);
609
610
611/** Applies a superoperator upon the linearised density matrix @p qureg, where @p targets
612 * span the ket space.
613 *
614 * @formulae
615 *
616 * Let @f$ \dmrho = @f$ @p qureg contain @f$N@f$ qubits, with amplitudes @f$ \alpha_{ij} @f$.
617 * @f[
618 \dmrho = \sum\limits_i^{2^N} \sum\limits_j^{2^N} \alpha_{ij} \ket{i}\bra{j}.
619 * @f]
620 * Internally, this matrix of dimension @f$ 2^N \times 2^N @f$ is stored in a vectorised
621 * form @f$ \ket{\rho} @f$ of dimension @f$ 2^{2N} \times 1 @f$, which concatenates the columns
622 * of @f$ \dmrho @f$.
623 * @f[
624 \begin{aligned}
625 \ket{\rho} &= \sum\limits_i^{2^N} \sum\limits_j^{2^N} \alpha_{ij} \ket{j} \ket{i} \\
626 &= \sum\limits_k^{2^{2N}} \beta_k \ket{k}
627 \end{aligned}
628 * @f]
629 * This resembles an unnormalised statevector of twice as many qubits as @f$ \dmrho @f$, whereby
630 * operators are left- and right-multiplied as
631 * @f[
632 \ket{ \hat{A} \, \rho \, \hat{B} } = \hat{B}^T\otimes \hat{A} \ket{\rho}.
633 * @f]
634 *
635 * Let @f$ \vec{t} = @f$ @p targets, @f$ n = @f$ @p numTargets, and let @f$ \hat{S} = @f$ superop.
636 * The @f$n@f$-qubit superoperator @f$\hat{S}@f$ is a @f$ 2^{2n} \times 2^{2n} @f$ complex matrix
637 * which operates upon both the ket and bra partitions of the linearised density matrix @f$\ket{\rho}@f$.
638 *
639 * The targets @f$\vec{t}@f$ are treated as the ket qubits, specified in order of increasing
640 * significance, where the first qubit corresponds to the rightmost partition of the matrix
641 * @f$\hat{S}@f$. Concretely, let @f$\vec{t}+N@f$ notate the list of indices obtained by adding @f$N@f$
642 * to every element of @f$\vec{t}@f$, and let @f$(\vec{t} \cup \vec{t}+N)@f$ the result of concatenating
643 * this new list with @f$\vec{t}@f$. Then, this function effects
644 * @f[
645 \ket{\rho} \rightarrow \hat{S}_{(\vec{t} \cup \vec{t}+N)} \ket{\rho},
646 * @f]
647 * which is mathematically identical to left-applying the @f$2n@f$-qubit matrix @f$\hat{S}@f$ upon a
648 * @f$2N@f$-qubit statevector @f$\ket{\rho}@f$.
649 *
650 * See mixKrausMap() for an example of the construction of @f$\hat{S}@f$.
651 *
652 * @constraints
653 *
654 * - There is no requirement nor validation that @p superop is CPTP, and so is permitted to
655 * break state normalisation and interpretability.
656 * - The number of targets must agree with the number of qubits upon which @p superop acts.
657 * - When @p qureg is distributed, each node must contain at least @c pow(2,2*numTargets)
658 * many amplitudes, to ensure sufficient communication buffers are allocated.
659 *
660 * @equivalences
661 *
662 * This function is equivalent to calling leftapplyCompMatr() upon @p qureg, having prepared
663 * @p superop as a CompMatr, and passing a target list prepared as @f$(\vec{t} \cup \vec{t}+N)@f$ above.
664 *
665 * @notyetvalidated
666 *
667 * @param[in,out] qureg the density matrix to modify.
668 * @param[in] targets the list of target qubit indices.
669 * @param[in] numTargets the length of @p targets
670 * @param[in] superop a compatible-sized SuperOp.
671 * @throws @validationerror
672 * - if @p qureg is not initialised.
673 * - if @p qureg is not a density matrix.
674 * - if @p targets contains a duplicate or invalid qubit index.
675 * - if @p numTargets is less than one, or exceeds the size of @p qureg.
676 * - if @p superop is not initialised, or not sync'ed (e.g. via syncSuperOp()).
677 * - if @p superop contains a different number of qubits than @p numTargets.
678 * - if @p qureg is distributed and @p numTargets exceeds the number of
679 * qubits in @p qureg minus half log-2 of the number of processes.
680 * @see
681 * - createSuperOp()
682 * - createInlineSuperOp()
683 * - setSuperOp()
684 * - mixKrausMap()
685 * @author Tyson Jones
686 */
687void mixSuperOp(Qureg qureg, int* targets, int numTargets, SuperOp superop);
688
689
690// end de-mangler
691#ifdef __cplusplus
692}
693#endif
694
695
696
697/*
698 * C++ OVERLOADS
699 *
700 * which are only accessible to C++ binaries, and accept
701 * arguments more natural to C++ (e.g. std::vector). These
702 * are included in the file-wide doxygen group (no subgroups).
703 */
704
705#ifdef __cplusplus
706
707#include <vector>
708
709/// @notyettested
710/// @notyetdoced
711/// @notyetvalidated
712/// @cppvectoroverload
713/// @see mixKrausMap()
714void mixKrausMap(Qureg qureg, std::vector<int> targets, KrausMap map);
715
716/// @notyettested
717/// @notyetdoced
718/// @notyetvalidated
719/// @cppvectoroverload
720/// @see mixSuperOp()
721void mixSuperOp(Qureg qureg, std::vector<int> targets, SuperOp superop);
722
723#endif // __cplusplus
724
725
726
727#endif // DECOHERENCE_H
728
729/** @} */ // (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