The Quantum Exact Simulation Toolkit v4.1.0
Loading...
Searching...
No Matches
channels.h
1/** @file
2 * Data structures for representing arbitrary channels as
3 * superoperators and Kraus maps, including their constructors,
4 * getters, setters and reporters. Note the functions to
5 * actually simulate these channels are exposed in decoherence.h
6 *
7 * Like matrices.h, this file makes extensive use of macros to
8 * overload struct initialisers for user convenience. All macros
9 * herein expand to single-line definitions for safety. Some
10 * intendedly private functions are necessarily exposed here to
11 * the user, and are prefixed with an underscore.
12 *
13 * Design nuances:
14 * - SuperOp is a separate, independent data-structure from KrausMap
15 * which is never assumed/validated to be CPTP. This is because the
16 * runtime assessment of CPTP of an arbitrary superoperator is expensive,
17 * requiring diagonalisation.
18 * - KrausMap contains an internal SuperOp instance which it uses to
19 * simulate the channel, which is re-populated whenever the constituent
20 * Kraus operators of the map are changed by the user.
21 * - KrausMap maintains an explicit list of Kraus operators, even though
22 * only the single resulting superoperator is used for simulation. This is
23 * so that CPTP validation can be efficiently performed at any time, and so
24 * that KrausMap reporting can display the individual quadratically-smaller
25 * Kraus operators, for user clarity. This is an insignificant memory waste.
26 * - KrausMap must know the number of constituent Kraus operators upfront, in
27 * order to allocate their memory. It is not possible to specify fewer Kraus
28 * operators later when initialising the KrausMap, because tracking a "number
29 * of Kraus operators" independently of the "maximum number of Kraus operators"
30 * is smelly and over-engineered. Changing operators requires a new KrausMap.
31 * - There are no fixed-size stack-memory versions of KrausMap and SuperOp,
32 * unlike their matrix counterparts which have (e.g.) CompMatr1. This is
33 * because fixed-size KrausMap creation involves populating the superoperator
34 * (and in GPU settings, copying to GPU memory) which may be an astonishingly
35 * large overhead, and expensive to copy between function stacks.
36 *
37 * @author Tyson Jones
38 * @author Richard Meister (aided in design)
39 * @author Erich Essmann (aided in design)
40 *
41 * @defgroup channels Channels
42 * @ingroup api
43 * @brief Data structures for representing arbitrary channels as Kraus maps and superoperators.
44 * @{
45 */
46
47#ifndef CHANNELS_H
48#define CHANNELS_H
49
50#include "quest/include/types.h"
51
52// C++ gets vector initialiser overloads, whereas C gets a macro
53#ifdef __cplusplus
54 #include <vector>
55#endif
56
57
58
59/*
60 * unlike some other headers, we here intermix the C and C++-only
61 * signatures, grouping them semantically & by their doc groups
62 */
63
64
65
66/**
67 * @defgroup channels_structs Structs
68 * @brief Data structures for representing decoherence channels.
69 * @{
70 */
71
72
73/// @notyetdoced
74typedef struct {
75
76 int numQubits;
77 qindex numRows;
78
79 // 2D CPU memory, which users can manually overwrite like cpuElems[i][j],
80 // but which actually merely aliases the 1D cpuElemsFlat below
81 qcomp** cpuElems;
82
83 // row-major flattened elements of cpuElems, always allocated
84 qcomp* cpuElemsFlat;
85
86 // row-major flattened elems in GPU memory, allocated
87 // only and always in GPU-enabled QuEST environments
88 qcomp* gpuElemsFlat;
89
90 // whether the user has ever synchronised memory to the GPU, which is performed automatically
91 // when calling functions like setCompMatr(), but which requires manual invocation with
92 // syncCompMatr() after manual modification of the cpuElem. Note this can only indicate whether
93 // the matrix has EVER been synced; it cannot be used to detect whether manual modifications
94 // made after an initial sync have been re-synched. This is a heap pointer to remain mutable.
95 int* wasGpuSynced;
96
97} SuperOp;
98
99
100/// @notyetdoced
101typedef struct {
102
103 int numQubits;
104
105 // representation of the map as a collection of Kraus operators, kept exclusively
106 // in CPU memory, and used only for CPTP validation and reporting the map
107 int numMatrices;
108 qindex numRows;
109 qcomp*** matrices;
110
111 // representation of the map as a single superoperator, used for simulation
112 SuperOp superop;
113
114 // CPTP-ness is determined at validation; 0 or 1, or -1 to indicate unknown. The flag is
115 // stored in heap so even copies of structs are mutable, but pointer itself is immutable.
116 int* isApproxCPTP;
117
118} KrausMap;
119
120
121// we define no fixed-size versions (e.g. KrausMap1/2), unlike we did for CompMatr1/2
122// and DiagMatr1/2. This is because the 2-qubit superoperator is 256 elements big, and
123// seems inadvisably large to be passing-by-copy through the QuEST backend layers, and
124// would need explicit GPU memory allocation at each invocation of mixKrausMap2() (it
125// exceeds the max number of CUDA kernel args). Furthermore, repeatedly calling
126// createKrausMap2() would repeatedly invoke ~256*16 flops to compute te superoperator,
127// which may be an user-astonishing overhead (more astonishing than the API asymmetry).
128// Finally, computing the fixed-size superoperators must be in the header (to avoid
129// the issues of qcmop interoperability, just like for getCompMatr1) and could not call
130// an inner function which wouldn't be user-exposed; so we would end up redefining the
131// superoperator calculation THREE times!
132
133
134/** @} */
135
136
137
138// we define the remaining doc groups in advance, since their signatures are
139// more naturally grouped in an implementation-specific way below. Note the
140// above structs were not doc'd this way (which would be more consistent)
141// because it inexplicably causes Doxygen to duplicate their section at the
142// top-level under Channels (rather than under Structs). Bizarre! The order
143// of declaration below will match the order shown in the html doc.
144/**
145 * @defgroup channels_create Constructors
146 * @brief Functions for creating channel data structures.
147 *
148 * @defgroup channels_destroy Destructors
149 * @brief Functions for destroying existing channel data structures.
150 *
151 * @defgroup channels_reporters Reporters
152 * @brief Functions for printing channels.
153 *
154 * @defgroup channels_setters Setters
155 * @brief Functions for overwriting the elements of channels.
156 *
157 * @defgroup channels_sync Synchronisation
158 * @brief Functions for overwriting a channel's GPU (VRAM) memory with its CPU (RAM) contents.
159 * @details These functions are only necessary when the user wishes to manually modify the
160 * elements of a channel (in lieu of using the @ref channels_setters "Setters"), to
161 * thereafter synchronise the changes to the GPU copy of the channel. These functions
162 * have no effect when running without GPU-acceleration, but remain legal and harmless
163 * to call (to achieve platform agnosticism).
164 */
165
166
167
168/*
169 * BASIC FUNCTIONS
170 */
171
172
173// de-mangle so below are directly callable by C and C++ binary
174#ifdef __cplusplus
175extern "C" {
176#endif
177
178
179 /** @ingroup channels_create
180 * @notyetdoced
181 *
182 * @see
183 * - createInlineKrausMap
184 * - createSuperOp()
185 * - setKrausMap()
186 * - setInlineKrausMap
187 * - [C](https://github.com/QuEST-Kit/QuEST/blob/devel/examples/isolated/initialising_krausmaps.c) or
188 * [C++](https://github.com/QuEST-Kit/QuEST/blob/devel/examples/isolated/initialising_krausmaps.cpp) examples
189 */
190 KrausMap createKrausMap(int numQubits, int numOperators);
191
192
193 /** @ingroup channels_sync
194 * @notyetdoced
195 *
196 * @see
197 * - setKrausMap()
198 * - [C](https://github.com/QuEST-Kit/QuEST/blob/devel/examples/isolated/initialising_krausmaps.c) or
199 * [C++](https://github.com/QuEST-Kit/QuEST/blob/devel/examples/isolated/initialising_krausmaps.cpp) examples
200 */
201 void syncKrausMap(KrausMap map);
202
203
204 /// @ingroup channels_destroy
205 /// @notyetdoced
206 void destroyKrausMap(KrausMap map);
207
208
209 /// @ingroup channels_reporters
210 /// @notyetdoced
211 /// @notyettested
212 void reportKrausMap(KrausMap map);
213
214
215 /** @ingroup channels_create
216 * @notyetdoced
217 *
218 * @see
219 * - createInlineSuperOp()
220 * - createKrausMap()
221 * - setSuperOp()
222 * - setInlineSuperOp()
223 * - [C](https://github.com/QuEST-Kit/QuEST/blob/devel/examples/isolated/initialising_superoperators.c) or
224 * [C++](https://github.com/QuEST-Kit/QuEST/blob/devel/examples/isolated/initialising_superoperators.cpp) examples
225 */
226 SuperOp createSuperOp(int numQubits);
227
228
229 /** @ingroup channels_sync
230 * @notyetdoced
231 *
232 * @see
233 * - setSuperOp()
234 * - [C](https://github.com/QuEST-Kit/QuEST/blob/devel/examples/isolated/initialising_superoperators.c) or
235 * [C++](https://github.com/QuEST-Kit/QuEST/blob/devel/examples/isolated/initialising_superoperators.cpp) examples
236 */
237 void syncSuperOp(SuperOp op);
238
239
240 /// @ingroup channels_destroy
241 /// @notyetdoced
242 void destroySuperOp(SuperOp op);
243
244
245 /// @ingroup channels_reporters
246 /// @notyetdoced
247 /// @notyettested
248 void reportSuperOp(SuperOp op);
249
250
251#ifdef __cplusplus
252}
253#endif
254
255
256
257/*
258 * POINTER INITIALISERS
259 *
260 * which permit users to pass heap and stack pointers in both C and C++, e.g.
261 * - qcomp** ptr = malloc(...); setSuperOp(m, ptr);
262 * - qcomp* ptrs[16]; setSuperOp(m, ptrs);
263 * - qcomp*** ptr = malloc(...); setKrausMap(m, ptr);
264 */
265
266
267// de-mangle so below are directly callable by C and C++ binary
268#ifdef __cplusplus
269extern "C" {
270#endif
271
272
273 /** @ingroup channels_setters
274 * @notyetdoced
275 *
276 * @see
277 * - setInlineKrausMap()
278 * - syncKrausMap()
279 * - [C](https://github.com/QuEST-Kit/QuEST/blob/devel/examples/isolated/initialising_krausmaps.c) or
280 * [C++](https://github.com/QuEST-Kit/QuEST/blob/devel/examples/isolated/initialising_krausmaps.cpp) examples
281 */
282 void setKrausMap(KrausMap map, qcomp*** matrices);
283
284
285 /** @ingroup channels_setters
286 * @notyetdoced
287 *
288 * @see
289 * - setInlineSuperOp()
290 * - syncSuperOp()
291 * - [C](https://github.com/QuEST-Kit/QuEST/blob/devel/examples/isolated/initialising_superoperators.c) or
292 * [C++](https://github.com/QuEST-Kit/QuEST/blob/devel/examples/isolated/initialising_superoperators.cpp) examples
293 */
294 void setSuperOp(SuperOp op, qcomp** matrix);
295
296
297#ifdef __cplusplus
298}
299#endif
300
301
302
303/*
304 * ARRAY, VECTOR, MATRIX INITIALISERS
305 *
306 * which define additional overloads for arrays, VLAs, vectors and vector initialisation lists.
307 * They permit C users to additionally call e.g.
308 * - qcomp arr[16][16]; setSuperOp(m, arr);
309 * - int n=16; qcomp arr[n][n]; setSuperOp(m, arr);
310 * - setKrausMap(m, (qcomp[5][16][16]) {{{...}}});
311 * - inline temporary VLA remains impossible even in C99, however
312 * and C++ users gain overloads:
313 * - int n=8; std::vector vec(n); setSuperOp(m, vec);
314 * - setKrausMap(m, {{{...}}} );
315 * An unintended but harmless side-effect is the exposure of functions setKrausMapFromArr(),
316 * setSuperOpFromArr(), validate_setCompMatrFromArr() and validate_setSuperOpFromArr to the user.
317 */
318
319
320#if defined(__cplusplus)
321
322 // C++ overloads to accept vectors, which also enables vector initialiser literals
323
324
325 /** @ingroup channels_setters
326 * @notyetdoced
327 * @cpponly
328 *
329 * @see
330 * - setInlineKrausMap()
331 * - [C++](https://github.com/QuEST-Kit/QuEST/blob/devel/examples/isolated/initialising_krausmaps.cpp) examples
332 */
333 void setKrausMap(KrausMap map, std::vector<std::vector<std::vector<qcomp>>> matrices);
334
335
336 /** @ingroup channels_setters
337 * @notyetdoced
338 * @cpponly
339 *
340 * @see
341 * - setInlineSuperOp()
342 * - [C++](https://github.com/QuEST-Kit/QuEST/blob/devel/examples/isolated/initialising_superoperators.cpp) examples
343 */
344 void setSuperOp(SuperOp op, std::vector<std::vector<qcomp>> matrix);
345
346
347 // C++ cannot accept VLAs so does not define 2D array overloads
348
349#elif !defined(_MSC_VER)
350
351 // C first defines bespoke functions which accept C99 VLAs, which we have to define here in
352 // the header becauses the C++ source cannot use VLA, nor should we pass a 2D qcomp array
353 // directly between C and C++ binaries (due to limited interoperability)
354
355
356 // C must validate the struct fields before accessing passed 2D arrays to avoid seg-faults
357 /// @private
358 extern void _validateParamsToSetKrausMapFromArr(KrausMap map);
359 /// @private
360 extern void _validateParamsToSetSuperOpFromArr(SuperOp op);
361
362
363 /// @private
364 static inline void _setKrausMapFromArr(KrausMap map, qcomp matrices[map.numMatrices][map.numRows][map.numRows]) {
365 _validateParamsToSetKrausMapFromArr(map);
366
367 // create stack space for 2D collection of pointers, one to each input row
368 qcomp* rows[map.numMatrices][map.numRows];
369 qcomp** ptrs[map.numMatrices];
370
371 // copy decayed array pointers into stack
372 for (int n=0; n<map.numMatrices; n++) {
373 for (qindex r=0; r<map.numRows; r++)
374 rows[n][r] = matrices[n][r];
375 ptrs[n] = rows[n];
376 }
377
378 setKrausMap(map, ptrs); // validation gauranteed to pass
379 }
380
381 /// @private
382 static inline void _setSuperOpFromArr(SuperOp op, qcomp matrix[op.numRows][op.numRows]) {
383 _validateParamsToSetSuperOpFromArr(op);
384
385 // create stack space for pointers, one for each input row
386 qcomp* ptrs[op.numRows];
387
388 // copy decayed array pointers into stack
389 for (qindex r=0; r<op.numRows; r++)
390 ptrs[r] = matrix[r];
391
392 setSuperOp(op, ptrs); // validation gauranteed to pass
393 }
394
395
396 // C then overloads setKrausMap() to call the above VLA when given arrays, using C11 Generics.
397 // See the doc of getCompMatr1() in matrices.h for an explanation of Generic, and its nuances.
398
399 /// @neverdoced
400 #define setKrausMap(map, ...) \
401 _Generic((__VA_ARGS__), \
402 qcomp*** : setKrausMap, \
403 default : _setKrausMapFromArr \
404 )((map), (__VA_ARGS__))
405
406 /// @neverdoced
407 #define setSuperOp(op, ...) \
408 _Generic((__VA_ARGS__), \
409 qcomp** : setSuperOp, \
410 default : _setSuperOpFromArr \
411 )((op), (__VA_ARGS__))
412
413 // spoofing macros as functions
414 #if 0
415
416
417 /** @ingroup channels_setters
418 * @notyetdoced
419 * @conly
420 * @macrodoc
421 *
422 * @see
423 * - setInlineKrausMap()
424 * - [C](https://github.com/QuEST-Kit/QuEST/blob/devel/examples/isolated/initialising_krausmaps.c) examples
425 */
426 void setKrausMap(KrausMap map, qcomp matrices[map.numMatrices][map.numRows][map.numRows]);
427
428
429 /** @ingroup channels_setters
430 * @notyetdoced
431 * @conly
432 * @macrodoc
433 *
434 * @see
435 * - setInlineSuperOp()
436 * - [C](https://github.com/QuEST-Kit/QuEST/blob/devel/examples/isolated/initialising_superoperators.c) examples
437 */
438 void setSuperOp(SuperOp op, qcomp matrix[op.numRows][op.numRows]);
439
440
441 #endif
442
443
444#else
445
446 // MSVC's C11 does not support C99 VLAs, so there is no way to support _setKrausMapFromArr(),
447 // and ergo no need for setKrausMap() or setSuperOp() wrappers. This sadly means MSVC C users
448 // can only use the existing functions which accept qcomp*** and qcomp** respectively.
449
450#endif
451
452
453
454/*
455 * LITERAL INITIALISERS
456 *
457 * which enable C users to give inline 2D and 3D array literals without having to use the
458 * VLA compound literal syntax. We expose these macros to C++ too for API consistency,
459 * although C++'s vector overloads achieve the same thing.
460 *
461 * These empower C and C++ users to call
462 * - setInlineSuperOp(m, 1, {{...}});
463 * - setInlineKrausMap(m, 2, 16, {{{...}}});
464 */
465
466
467#if defined(__cplusplus)
468
469 // C++ redirects to vector overloads, passing initialiser lists. The args like 'numQb'
470 // and 'numOps' are superfluous, but needed for consistency with the C API, so we additionally
471 // validate that they match the struct dimensions (which requires validating the structs).
472
473
474 /** @ingroup channels_setters
475 * @notyetdoced
476 * @cpponly
477 *
478 * @see
479 * - setKrausMap()
480 * - syncKrausMap()
481 * - [C++](https://github.com/QuEST-Kit/QuEST/blob/devel/examples/isolated/initialising_krausmaps.cpp) examples
482 */
483 void setInlineKrausMap(KrausMap map, int numQb, int numOps, std::vector<std::vector<std::vector<qcomp>>> matrices);
484
485
486 /** @ingroup channels_setters
487 * @notyetdoced
488 * @cpponly
489 *
490 * @see
491 * - setSuperOp()
492 * - syncSuperOp()
493 * - [C++](https://github.com/QuEST-Kit/QuEST/blob/devel/examples/isolated/initialising_superoperators.cpp) examples
494 */
495 void setInlineSuperOp(SuperOp op, int numQb, std::vector<std::vector<qcomp>> matrix);
496
497
498#elif !defined(_MSC_VER)
499
500 // C defines macros which add compound literal syntax so that the user's passed lists
501 // become compile-time-sized temporary arrays. C99 does not permit inline-initialised
502 // VLAs, so we cannot have the macro expand to add (qcomp[matr.numRows][matr.numRows])
503 // in order to preclude passing 'numQb'. We ergo accept and validate 'numQb' macro param.
504 // We define private inner-functions of a macro, in lieu of writing multiline macros
505 // using do-while, just to better emulate a function call for users - e.g. they
506 // can wrap the macro invocations with another function call, etc.
507
508
509 // C validators check 'numQb' and 'numOps' are consistent with the struct, but cannot check the user's passed literal sizes
510 /// @private
511 extern void _validateParamsToSetInlineKrausMap(KrausMap map, int numQb, int numOps);
512 /// @private
513 extern void _validateParamsToSetInlineSuperOp(SuperOp op, int numQb);
514
515
516 /// @private
517 static inline void _setInlineKrausMap(KrausMap map, int numQb, int numOps, qcomp elems[numOps][1<<numQb][1<<numQb]) {
518 _validateParamsToSetInlineKrausMap(map, numQb, numOps);
519 _setKrausMapFromArr(map, elems);
520 }
521
522 /// @private
523 static inline void _setInlineSuperOp(SuperOp op, int numQb, qcomp elems[1<<(2*numQb)][1<<(2*numQb)] ) {
524 _validateParamsToSetInlineSuperOp(op, numQb);
525 _setSuperOpFromArr(op, elems);
526 }
527
528
529 /// @neverdoced
530 #define setInlineKrausMap(map, numQb, numOps, ...) \
531 _setInlineKrausMap((map), (numQb), (numOps), (qcomp[(numOps)][1<<(numQb)][1<<(numQb)]) __VA_ARGS__)
532
533 /// @neverdoced
534 #define setInlineSuperOp(matr, numQb, ...) \
535 _setInlineSuperOp((matr), (numQb), (qcomp[1<<(2*(numQb))][1<<(2*(numQb))]) __VA_ARGS__)
536
537 // spoofing macros as functions
538 #if 0
539
540
541 /** @ingroup channels_setters
542 * @notyetdoced
543 * @macrodoc
544 *
545 * @see
546 * - setKrausMap()
547 * - syncKrausMap()
548 * - [C](https://github.com/QuEST-Kit/QuEST/blob/devel/examples/isolated/initialising_krausmaps.c) examples
549 */
550 void setInlineKrausMap(KrausMap map, int numQb, int numOps, {{{ matrices }}});
551
552
553 /** @ingroup channels_setters
554 * @notyetdoced
555 * @macrodoc
556 *
557 * @see
558 * - setSuperOp()
559 * - syncSuperOp()
560 * - [C](https://github.com/QuEST-Kit/QuEST/blob/devel/examples/isolated/initialising_superoperators.c) examples
561 */
562 void setInlineSuperOp(SuperOp op, int numQb, {{ matrix }});
563
564
565 #endif
566
567#else
568
569 // MSVC's C11 does not support C99 VLA, so the inner *FromArr() functions have not
570 // been defined, and ergo we cannot define setInlineKrausMap() nor setInlineSuperOp()
571
572#endif
573
574
575
576/*
577 * LITERAL CREATORS
578 *
579 * which combine creators and the inline initialisation functions, so that
580 * both C and C++ users can call e.g.
581 * - SuperOp op = createInlineSuperOp(2, {{...}});
582 */
583
584
585#if defined(__cplusplus)
586
587 // C++ accepts vector initialiser lists
588
589
590 /** @ingroup channels_create
591 * @notyetdoced
592 * @cpponly
593 *
594 * @see
595 * - createKrausMap()
596 * - setKrausMap()
597 * - syncKrausMap()
598 * - [C++](https://github.com/QuEST-Kit/QuEST/blob/devel/examples/isolated/initialising_krausmaps.cpp) examples
599 */
600 KrausMap createInlineKrausMap(int numQubits, int numOperators, std::vector<std::vector<std::vector<qcomp>>> matrices);
601
602
603 /** @ingroup channels_create
604 * @notyetdoced
605 * @cpponly
606 *
607 * @see
608 * - createSuperOp()
609 * - setSuperOp()
610 * - syncSuperOp()
611 * - [C++](https://github.com/QuEST-Kit/QuEST/blob/devel/examples/isolated/initialising_superoperators.cpp) examples
612 */
613 SuperOp createInlineSuperOp(int numQubits, std::vector<std::vector<qcomp>> matrix);
614
615
616#elif !defined(_MSC_VER)
617
618 // C defines macros which add compound literal syntax so that the user's passed lists
619 // become compile-time-sized temporary arrays. We use bespoke validation so that the
620 // error messages reflect the name of the macro, rather than the inner called functions.
621 // We define a private inner function per macro, in lieu of writing multiline macros
622 // using do-while, just to better emulate a function call for users - e.g. they
623 // can wrap the macro invocation with another function call.
624
625
626 /// @private
627 extern void _validateParamsToCreateInlineKrausMap(int numQb, int numOps);
628 /// @private
629 extern void _validateParamsToCreateInlineSuperOp(int numQb);
630
631
632 /// @private
633 static inline KrausMap _createInlineKrausMap(int numQb, int numOps, qcomp matrices[numOps][1<<numQb][1<<numQb]) {
634 _validateParamsToCreateInlineKrausMap(numQb, numOps);
635 KrausMap out = createKrausMap(numQb, numOps); // malloc failures will report 'createKrausMap', rather than 'inline' version. Alas!
636 _setKrausMapFromArr(out, matrices);
637 return out;
638 }
639
640 /// @private
641 static inline SuperOp _createInlineSuperOp(int numQb, qcomp matrix[1<<numQb][1<<numQb]) {
642 _validateParamsToCreateInlineSuperOp(numQb);
643 SuperOp out = createSuperOp(numQb); // malloc failures will report 'createSuperOp', rather than 'inline' version. Alas!
644 _setSuperOpFromArr(out, matrix);
645 return out;
646 }
647
648
649 /// @neverdoced
650 #define createInlineKrausMap(numQb, numOps, ...) \
651 _createInlineKrausMap((numQb), (numOps), (qcomp[(numOps)][1<<(numQb)][1<<(numQb)]) __VA_ARGS__)
652
653 /// @neverdoced
654 #define createInlineSuperOp(numQb, ...) \
655 _createInlineSuperOp((numQb), (qcomp[1<<(2*(numQb))][1<<(2*(numQb))]) __VA_ARGS__)
656
657 // spoofing macros as functions
658 #if 0
659
660
661 /** @ingroup channels_create
662 * @notyetdoced
663 * @macrodoc
664 *
665 * @see
666 * - createKrausMap()
667 * - setKrausMap()
668 * - syncKrausMap()
669 * - [C](https://github.com/QuEST-Kit/QuEST/blob/devel/examples/isolated/initialising_krausmaps.c) examples
670 */
671 KrausMap createInlineKrausMap(int numQb, int numOps, {{{ matrices }}});
672
673
674 /** @ingroup channels_create
675 * @notyetdoced
676 * @macrodoc
677 *
678 * @see
679 * - createSuperOp()
680 * - setSuperOp()
681 * - syncSuperOp()
682 * - [C](https://github.com/QuEST-Kit/QuEST/blob/devel/examples/isolated/initialising_superoperators.c) examples
683 */
684 SuperOp createInlineSuperOp(int numQb, {{ matrix }});
685
686
687 #endif
688
689#else
690
691 // MSVC's C11 does not support C99 VLA, so none of the necessary inner functions are defined,
692 // and ergo Windows C users cannot use createInlineKrausMap() nor createInlineSuperOp(). Tragic!
693
694#endif
695
696
697
698#endif // CHANNELS_H
699
700/** @} */ // (end file-wide doxygen defgroup)
KrausMap createInlineKrausMap(int numQubits, int numOperators, std::vector< std::vector< std::vector< qcomp > > > matrices)
SuperOp createInlineSuperOp(int numQubits, std::vector< std::vector< qcomp > > matrix)
KrausMap createKrausMap(int numQubits, int numOperators)
Definition channels.cpp:176
SuperOp createSuperOp(int numQubits)
Definition channels.cpp:162
void destroySuperOp(SuperOp op)
Definition channels.cpp:203
void destroyKrausMap(KrausMap map)
Definition channels.cpp:210
void reportKrausMap(KrausMap map)
Definition channels.cpp:467
void reportSuperOp(SuperOp op)
Definition channels.cpp:447
void setInlineSuperOp(SuperOp op, int numQb, std::vector< std::vector< qcomp > > matrix)
void setInlineKrausMap(KrausMap map, int numQb, int numOps, std::vector< std::vector< std::vector< qcomp > > > matrices)
void setSuperOp(SuperOp op, qcomp **matrix)
Definition channels.cpp:271
void setKrausMap(KrausMap map, qcomp ***matrices)
Definition channels.cpp:309
void syncSuperOp(SuperOp op)
Definition channels.cpp:223
void syncKrausMap(KrausMap map)
Definition channels.cpp:236