The Quantum Exact Simulation Toolkit v4.0.0
Loading...
Searching...
No Matches
operations.h
1/** @file
2 * API signatures for effecting operators (such as gates and unitaries)
3 * upon Quregs which are instantiated as either statevectors or
4 * density matrices. This excludes decoherence channels which are
5 * instead exposed in decoherence.h
6 *
7 * @author Tyson Jones
8 *
9 * @defgroup operations Operations
10 * @ingroup api
11 * @brief Functions for effecting operators upon Quregs.
12 * @{
13 */
14
15#ifndef OPERATIONS_H
16#define OPERATIONS_H
17
18#include "quest/include/qureg.h"
19#include "quest/include/paulis.h"
20#include "quest/include/matrices.h"
21#include "quest/include/channels.h"
22
23#ifdef __cplusplus
24 #include <vector>
25#endif
26
27
28
29/*
30 * unlike some other headers, we here intermix the C and C++-only
31 * signatures, grouping them semantically & by their doc groups
32 */
33
34
35
36/**
37 * @defgroup op_compmatr1 CompMatr1
38 * @brief Functions for applying general one-qubit dense matrices, as CompMatr1.
39 * @{
40 */
41
42
43#ifdef __cplusplus
44extern "C" {
45#endif
46
47
48/** Multiplies a general one-qubit dense @p matrix upon the specified @p target
49 * qubit of @p qureg.
50 *
51 * @formulae
52 * Let @f$ \hat{M} = @f$ @p matrix and @f$ t = @f$ @p target, and notate
53 * @f$\hat{M}_t@f$ as per applyCompMatr1(). Unlike applyCompMatr1() however,
54 * this function only ever left-multiplies @p matrix upon @p qureg, regardless
55 * of whether it is a statevector or density matrix.
56 *
57 * Explicitly,
58 * - When @p qureg is a statevector @f$ \svpsi @f$, this function effects
59 * @f[
60 \svpsi \rightarrow \hat{M}_t \, \svpsi.
61 * @f]
62 * - When @p qureg is a density matrix @f$\dmrho@f$, this function effects
63 * @f[
64 \dmrho \rightarrow \hat{M}_t \, \dmrho.
65 * @f]
66 *
67 * There are no additional constraints like unitarity.
68 *
69 * @myexample
70 * ```
71 Qureg qureg = createDensityQureg(5);
72
73 CompMatr1 matrix = getInlineCompMatr1({
74 {0.1, 0.2},
75 {0.3i, 0.4i}
76 });
77
78 multiplyCompMatr1(qureg, 2, matrix);
79 * ```
80 *
81 * @param[in,out] qureg the state to modify.
82 * @param[in] target the index of the target qubit.
83 * @param[in] matrix the Z-basis matrix to multiply.
84 * @throws invalidQuESTInputError()
85 * - if @p qureg or @p matrix are uninitialised.
86 * - if @p target is an invalid qubit index.
87 * @see
88 * - getCompMatr1()
89 * - getInlineCompMatr1()
90 * - applyCompMatr1()
91 * - applyQubitProjector()
92 * - multiplyCompMatr()
93 * @author Tyson Jones
94 */
95void multiplyCompMatr1(Qureg qureg, int target, CompMatr1 matrix);
96
97
98/** Applies a general one-qubit dense unitary @p matrix to the specified @p target
99 * qubit of @p qureg.
100 *
101 * @diagram
102 * @dot
103digraph {
104 rankdir=LR;
105 node [fontsize=10, fontname="Menlo"];
106 edge [dir=none];
107
108 wireL [shape=plaintext, label="target"];
109 wireR [shape=plaintext, label=""];
110 gate [shape=box, label="matrix"];
111
112 wireL -> gate -> wireR
113}
114 * @enddot
115 *
116 * @formulae
117 * Let @f$ \hat{U} = @f$ @p matrix, @f$ t = @f$ @p target, and let @f$\hat{U}_t@f$
118 * notate operating @f$\hat{U}@f$ upon the @f$ t @f$-th qubit among@f$ N @f$, i.e.
119 * @f[
120 \hat{U}_t \equiv \id^{N-t} \otimes \hat{U} \otimes \id^{t-1}.
121 * @f]
122 * Then,
123 * - When @p qureg is a statevector @f$ \svpsi @f$, this function effects
124 * @f[
125 \svpsi \rightarrow \hat{U}_t \, \svpsi.
126 * @f]
127 * - When @p qureg is a density matrix @f$\dmrho@f$, this function effects
128 * @f[
129 \dmrho \rightarrow \hat{U}_t \, \dmrho \, {\hat{U}_t}^\dagger.
130 * @f]
131 *
132 * @constraints
133 * - Unitarity of @f$ \hat{U} = @f$ @p matrix requires that
134 * @f$ \hat{U} \hat{U}^\dagger = \id @f$. Validation will check that @p matrix is
135 * approximately unitarity via
136 * @f[
137 \max\limits_{ij} \Big|\left(\hat{U} \hat{U}^\dagger - \id\right)_{ij}\Big|^2 \le \valeps
138 * @f]
139 * where the validation epsilon @f$ \valeps @f$ can be adjusted with setValidationEpsilon().
140 *
141 * @myexample
142 * ```
143 Qureg qureg = createQureg(5);
144
145 CompMatr1 matrix = getInlineCompMatr1({
146 {-1i/sqrt(2), 1i/sqrt(2)},
147 {(1i-1)/2, (1i-1)/2}
148 });
149
150 applyCompMatr1(qureg, 2, matrix);
151 * ```
152 *
153 * @param[in,out] qureg the state to modify.
154 * @param[in] target the index of the target qubit.
155 * @param[in] matrix the Z-basis unitary matrix to effect.
156 * @throws invalidQuESTInputError()
157 * - if @p qureg or @p matrix are uninitialised.
158 * - if @p matrix is not approximately unitary.
159 * - if @p target is an invalid qubit index.
160 * @see
161 * - getCompMatr1()
162 * - getInlineCompMatr1()
163 * - multiplyCompMatr1()
164 * - applyControlledCompMatr1()
165 * - applyCompMatr2()
166 * - applyCompMatr()
167 * @author Tyson Jones
168 */
169void applyCompMatr1(Qureg qureg, int target, CompMatr1 matrix);
170
171
172/** Applies a singly-controlled one-qubit dense unitary @p matrix to the specified
173 * @p target qubit of @p qureg.
174 *
175 * @diagram
176 * @dot
177digraph {
178 rankdir=LR;
179 node [fontsize=10, fontname="Menlo"];
180 edge [dir=none];
181
182 topWireL [shape=plaintext, label="control"];
183 topWireR [shape=plaintext, label=""];
184 ctrl [shape=circle, label="", width=.12, style=filled, fillcolor=black];
185
186 topWireL -> ctrl -> topWireR;
187
188 botWireL [shape=plaintext, label="target"];
189 botWireR [shape=plaintext, label=""];
190 gate [shape=box, label="matrix"];
191
192 botWireL -> gate -> botWireR;
193 ctrl -> gate;
194
195 {rank=same; topWireL; botWireL};
196 {rank=same; ctrl; gate};
197 {rank=same; topWireR; botWireR};
198}
199 * @enddot
200 *
201 * @notdoced
202 */
203void applyControlledCompMatr1(Qureg qureg, int control, int target, CompMatr1 matrix);
204
205
206/** Applies a multiply-controlled one-qubit dense unitary @p matrix to the specified
207 * @p target qubit of @p qureg.
208 *
209 * @diagram
210 * @dot
211digraph {
212 rankdir=LR;
213 node [fontsize=10, fontname="Menlo"];
214 edge [dir=none];
215
216 trailingCtrl [shape=plaintext, label="..."];
217
218 topWireL [shape=plaintext, label="controls[1]"];
219 topWireR [shape=plaintext, label=""];
220 topCtrl [shape=circle, label="", width=.12, style=filled, fillcolor=black];
221
222 topWireL -> topCtrl -> topWireR;
223
224 midWireL [shape=plaintext, label="controls[0]"];
225 midWireR [shape=plaintext, label=""];
226 midCtrl [shape=circle, label="", width=.12, style=filled, fillcolor=black];
227
228 midWireL -> midCtrl -> midWireR;
229
230 botWireL [shape=plaintext, label="target"];
231 botWireR [shape=plaintext, label=""];
232 gate [shape=box, label="matrix"];
233
234 botWireL -> gate -> botWireR;
235 trailingCtrl -> topCtrl -> midCtrl -> gate;
236
237 {rank=same; topWireL; midWireL; botWireL};
238 {rank=same; trailingCtrl; topCtrl; midCtrl; gate};
239 {rank=same; topWireR; midWireR; botWireR};
240}
241 * @enddot
242 *
243 * @notdoced
244 */
245void applyMultiControlledCompMatr1(Qureg qureg, int* controls, int numControls, int target, CompMatr1 matrix);
246
247
248/** Applies an arbitrarily-controlled one-qubit dense unitary @p matrix to the specified
249 * @p target qubit of @p qureg, conditioned upon the @p controls being in the given @p states.
250 *
251 * @diagram
252 * @dot
253digraph {
254 rankdir=LR;
255 node [fontsize=10, fontname="Menlo"];
256 edge [dir=none];
257
258 trailingCtrl [shape=plaintext, label="..."];
259
260 topWireL [shape=plaintext, label="controls[1]"];
261 topWireR [shape=plaintext, label=""];
262 topCtrl [shape=circle, label="", width=.12, style=filled, fillcolor=black];
263
264 topWireL -> topCtrl -> topWireR;
265
266 midWireL [shape=plaintext, label="controls[0]"];
267 midWireR [shape=plaintext, label=""];
268 midCtrl [shape=circle, label="", width=.12, style=filled, fillcolor=white];
269
270 midWireL -> midCtrl -> midWireR;
271
272 botWireL [shape=plaintext, label="target"];
273 botWireR [shape=plaintext, label=""];
274 gate [shape=box, label="matrix"];
275
276 botWireL -> gate -> botWireR;
277 trailingCtrl -> topCtrl -> midCtrl -> gate;
278
279 {rank=same; topWireL; midWireL; botWireL};
280 {rank=same; trailingCtrl; topCtrl; midCtrl; gate};
281 {rank=same; topWireR; midWireR; botWireR};
282}
283 * @enddot
284 *
285 * @notdoced
286 */
287void applyMultiStateControlledCompMatr1(Qureg qureg, int* controls, int* states, int numControls, int target, CompMatr1 matrix);
288
289
290// end de-mangler
291#ifdef __cplusplus
292}
293#endif
294
295#ifdef __cplusplus
296
297
298/// @nottested
299/// @notvalidated
300/// @notdoced
301/// @cpponly
302void applyMultiControlledCompMatr1(Qureg qureg, std::vector<int> controls, int target, CompMatr1 matrix);
303
304
305/// @nottested
306/// @notvalidated
307/// @notdoced
308/// @cpponly
309void applyMultiStateControlledCompMatr1(Qureg qureg, std::vector<int> controls, std::vector<int> states, int target, CompMatr1 matrix);
310
311
312#endif // __cplusplus
313
314/** @} */
315
316
317
318/**
319 * @defgroup op_compmatr2 CompMatr2
320 * @brief Functions for applying general two-qubit dense matrices, as CompMatr2.
321 * @{
322 */
323
324
325#ifdef __cplusplus
326extern "C" {
327#endif
328
329
330/// @notdoced
331void multiplyCompMatr2(Qureg qureg, int target1, int target2, CompMatr2 matr);
332
333
334/** Applies a general two-qubit dense unitary @p matrix to qubits @p target1 and
335 * @p target2 (treated as increasing significance) of @p qureg.
336 *
337 * @diagram
338 * @dot
339digraph {
340 layout=neato;
341 rankdir=LR;
342 node [fontsize=10, fontname="Menlo"];
343 edge [dir=none];
344
345 topWireL [shape=plaintext, pos="0,0!", label="target2"];
346 topWireR [shape=plaintext, pos="2.5,0!", label=""];
347
348 botWireL [shape=plaintext, pos="0,.5!", label="target1"];
349 botWireR [shape=plaintext, pos="2.5,.5!", label=""];
350
351 gate [shape=rectangle, label="matrix", style=filled, fillcolor=white, height=1, pos="1.25,.25!"];
352
353 topWireL -> topWireR;
354 botWireL -> botWireR;
355}
356 * @enddot
357 *
358 * @notdoced
359 */
360void applyCompMatr2(Qureg qureg, int target1, int target2, CompMatr2 matrix);
361
362
363/** Applies a singly-controlled two-qubit dense unitary @p matrix to qubits
364 * @p target1 and @p target2 (treated as increasing significance) of @p qureg.
365 *
366 * @diagram
367 * @dot
368digraph {
369 layout=neato;
370 rankdir=LR;
371 node [fontsize=10, fontname="Menlo"];
372 edge [dir=none];
373
374 topWireL [shape=plaintext, pos="0,1!", label="control"];
375 topWireR [shape=plaintext, pos="2.5,1!", label=""];
376
377 midWireL [shape=plaintext, pos="0,0.5!", label="target2"];
378 midWireR [shape=plaintext, pos="2.5,0.5!", label=""];
379
380 botWireL [shape=plaintext, pos="0,0!", label="target1"];
381 botWireR [shape=plaintext, pos="2.5,0!", label=""];
382
383 gate [shape=rectangle, label="matrix", style=filled, fillcolor=white, height=1, pos="1.25,0.25!"];
384 ctrl [shape=circle, label="", width=.12, style=filled, fillcolor=black, pos="1.25,1!"];
385
386 topWireL -> ctrl -> topWireR;
387 midWireL -> midWireR;
388 botWireL -> botWireR;
389 ctrl -> gate;
390}
391 * @enddot
392 *
393 * @notdoced
394 */
395void applyControlledCompMatr2(Qureg qureg, int control, int target1, int target2, CompMatr2 matr);
396
397
398/** Applies a multiply-controlled two-qubit dense unitary @p matrix to qubits
399 * @p target1 and @p target2 (treated as increasing significance) of @p qureg.
400 *
401 * @diagram
402 * @dot
403digraph {
404 layout=neato;
405 rankdir=LR;
406 node [fontsize=10, fontname="Menlo"];
407 edge [dir=none];
408
409 tippytopWireL [shape=plaintext, pos="0,1.5!", label="controls[1]"];
410 tippytopWireR [shape=plaintext, pos="2.5,1.5!", label=""];
411
412 topWireL [shape=plaintext, pos="0,1!", label="controls[0]"];
413 topWireR [shape=plaintext, pos="2.5,1!", label=""];
414
415 midWireL [shape=plaintext, pos="0,0.5!", label="target2"];
416 midWireR [shape=plaintext, pos="2.5,0.5!", label=""];
417
418 botWireL [shape=plaintext, pos="0,0!", label="target1"];
419 botWireR [shape=plaintext, pos="2.5,0!", label=""];
420
421 gate [shape=rectangle, label="matrix", style=filled, fillcolor=white, height=1, pos="1.25,0.25!"];
422 ctrl1 [shape=circle, label="", width=.12, style=filled, fillcolor=black, pos="1.25,1!"];
423 ctrl2 [shape=circle, label="", width=.12, style=filled, fillcolor=black, pos="1.25,1.5!"];
424 trailingCtrl [shape=plaintext, label="...", pos="1.25,2!"];
425
426 tippytopWireL -> ctrl2 -> tippytopWireR;
427 topWireL -> ctrl1 -> topWireR;
428 midWireL -> midWireR;
429 botWireL -> botWireR;
430 trailingCtrl -> ctrl2 -> ctrl1 -> gate;
431}
432 * @enddot
433 *
434 * @notdoced
435 */
436void applyMultiControlledCompMatr2(Qureg qureg, int* controls, int numControls, int target1, int target2, CompMatr2 matr);
437
438
439/** Applies an arbitrarily-controlled two-qubit dense unitary @p matrix to qubits
440 * @p target1 and @p target2 (treated as increasing significance) of @p qureg,
441 * conditioned upon the @p controls being in the given @p states.
442 *
443 * @diagram
444 * @dot
445digraph {
446 layout=neato;
447 rankdir=LR;
448 node [fontsize=10, fontname="Menlo"];
449 edge [dir=none];
450
451 tippytopWireL [shape=plaintext, pos="0,1.5!", label="controls[1]"];
452 tippytopWireR [shape=plaintext, pos="2.5,1.5!", label=""];
453
454 topWireL [shape=plaintext, pos="0,1!", label="controls[0]"];
455 topWireR [shape=plaintext, pos="2.5,1!", label=""];
456
457 midWireL [shape=plaintext, pos="0,0.5!", label="target2"];
458 midWireR [shape=plaintext, pos="2.5,0.5!", label=""];
459
460 botWireL [shape=plaintext, pos="0,0!", label="target1"];
461 botWireR [shape=plaintext, pos="2.5,0!", label=""];
462
463 gate [shape=rectangle, label="matrix", style=filled, fillcolor=white, height=1, pos="1.25,0.25!"];
464 ctrl1 [shape=circle, label="", width=.12, style=filled, fillcolor=white, pos="1.25,1!"];
465 ctrl2 [shape=circle, label="", width=.12, style=filled, fillcolor=black, pos="1.25,1.5!"];
466 trailingCtrl [shape=plaintext, label="...", pos="1.25,2!"];
467
468 tippytopWireL -> ctrl2 -> tippytopWireR;
469 topWireL -> ctrl1 -> topWireR;
470 midWireL -> midWireR;
471 botWireL -> botWireR;
472 trailingCtrl -> ctrl2 -> ctrl1 -> gate;
473}
474 * @enddot
475 *
476 * @notdoced
477 */
478void applyMultiStateControlledCompMatr2(Qureg qureg, int* controls, int* states, int numControls, int target1, int target2, CompMatr2 matr);
479
480
481// end de-mangler
482#ifdef __cplusplus
483}
484#endif
485
486#ifdef __cplusplus
487
488
489/// @nottested
490/// @notvalidated
491/// @notdoced
492/// @cpponly
493void applyMultiControlledCompMatr2(Qureg qureg, std::vector<int> controls, int target1, int target2, CompMatr2 matr);
494
495
496/// @nottested
497/// @notvalidated
498/// @notdoced
499/// @cpponly
500void applyMultiStateControlledCompMatr2(Qureg qureg, std::vector<int> controls, std::vector<int> states, int numControls, int target1, int target2, CompMatr2 matr);
501
502
503#endif // __cplusplus
504
505/** @} */
506
507
508
509/**
510 * @defgroup op_compmatr CompMatr
511 * @brief Functions for applying general many-target dense matrices, as CompMatr.
512 * @{
513 */
514
515
516#ifdef __cplusplus
517extern "C" {
518#endif
519
520
521/// @notdoced
522void multiplyCompMatr(Qureg qureg, int* targets, int numTargets, CompMatr matr);
523
524
525/// @notdoced
526void applyCompMatr(Qureg qureg, int* targets, int numTargets, CompMatr matr);
527
528
529/// @notdoced
530void applyControlledCompMatr(Qureg qureg, int control, int* targets, int numTargets, CompMatr matr);
531
532
533/// @notdoced
534void applyMultiControlledCompMatr(Qureg qureg, int* controls, int numControls, int* targets, int numTargets, CompMatr matr);
535
536
537/// @notdoced
538void applyMultiStateControlledCompMatr(Qureg qureg, int* controls, int* states, int numControls, int* targets, int numTargets, CompMatr matr);
539
540
541// end de-mangler
542#ifdef __cplusplus
543}
544#endif
545
546#ifdef __cplusplus
547
548
549/// @nottested
550/// @notvalidated
551/// @notdoced
552/// @cpponly
553void multiplyCompMatr(Qureg qureg, std::vector<int> targets, CompMatr matr);
554
555
556/// @nottested
557/// @notvalidated
558/// @notdoced
559/// @cpponly
560void applyCompMatr(Qureg qureg, std::vector<int> targets, CompMatr matr);
561
562
563/// @nottested
564/// @notvalidated
565/// @notdoced
566/// @cpponly
567void applyControlledCompMatr(Qureg qureg, int control, std::vector<int> targets, CompMatr matr);
568
569
570/// @nottested
571/// @notvalidated
572/// @notdoced
573/// @cpponly
574void applyMultiControlledCompMatr(Qureg qureg, std::vector<int> controls, std::vector<int> targets, CompMatr matr);
575
576
577/// @nottested
578/// @notvalidated
579/// @notdoced
580/// @cpponly
581void applyMultiStateControlledCompMatr(Qureg qureg, std::vector<int> controls, std::vector<int> states, std::vector<int> targets, CompMatr matr);
582
583
584#endif // __cplusplus
585
586/** @} */
587
588
589
590/**
591 * @defgroup op_diagmatr1 DiagMatr1
592 * @brief Functions for applying general one-qubit diagonal matrices, as DiagMatr1.
593 * @{
594 */
595
596
597#ifdef __cplusplus
598extern "C" {
599#endif
600
601
602/// @notdoced
603void multiplyDiagMatr1(Qureg qureg, int target, DiagMatr1 matr);
604
605
606/// @notdoced
607void applyDiagMatr1(Qureg qureg, int target, DiagMatr1 matr);
608
609
610/// @notdoced
611void applyControlledDiagMatr1(Qureg qureg, int control, int target, DiagMatr1 matr);
612
613
614/// @notdoced
615void applyMultiControlledDiagMatr1(Qureg qureg, int* controls, int numControls, int target, DiagMatr1 matr);
616
617
618/// @notdoced
619void applyMultiStateControlledDiagMatr1(Qureg qureg, int* controls, int* states, int numControls, int target, DiagMatr1 matr);
620
621
622// end de-mangler
623#ifdef __cplusplus
624}
625#endif
626
627#ifdef __cplusplus
628
629
630/// @nottested
631/// @notvalidated
632/// @notdoced
633/// @cpponly
634void applyMultiControlledDiagMatr1(Qureg qureg, std::vector<int> controls, int target, DiagMatr1 matr);
635
636
637/// @nottested
638/// @notvalidated
639/// @notdoced
640/// @cpponly
641void applyMultiStateControlledDiagMatr1(Qureg qureg, std::vector<int> controls, std::vector<int> states, int target, DiagMatr1 matr);
642
643
644#endif // __cplusplus
645
646/** @} */
647
648
649
650/**
651 * @defgroup op_diagmatr2 DiagMatr2
652 * @brief Functions for applying general two-qubit diagonal matrices, as DiagMatr2.
653 * @{
654 */
655
656
657#ifdef __cplusplus
658extern "C" {
659#endif
660
661
662/// @notdoced
663void multiplyDiagMatr2(Qureg qureg, int target1, int target2, DiagMatr2 matr);
664
665
666/// @notdoced
667void applyDiagMatr2(Qureg qureg, int target1, int target2, DiagMatr2 matr);
668
669
670/// @notdoced
671void applyControlledDiagMatr2(Qureg qureg, int control, int target1, int target2, DiagMatr2 matr);
672
673
674/// @notdoced
675void applyMultiControlledDiagMatr2(Qureg qureg, int* controls, int numControls, int target1, int target2, DiagMatr2 matr);
676
677
678/// @notdoced
679void applyMultiStateControlledDiagMatr2(Qureg qureg, int* controls, int* states, int numControls, int target1, int target2, DiagMatr2 matr);
680
681
682// end de-mangler
683#ifdef __cplusplus
684}
685#endif
686
687#ifdef __cplusplus
688
689
690/// @nottested
691/// @notvalidated
692/// @notdoced
693/// @cpponly
694void applyMultiControlledDiagMatr2(Qureg qureg, std::vector<int> controls, int target1, int target2, DiagMatr2 matr);
695
696
697/// @nottested
698/// @notvalidated
699/// @notdoced
700/// @cpponly
701void applyMultiStateControlledDiagMatr2(Qureg qureg, std::vector<int> controls, std::vector<int> states, int target1, int target2, DiagMatr2 matr);
702
703
704#endif // __cplusplus
705
706/** @} */
707
708
709
710/**
711 * @defgroup op_diagmatr DiagMatr
712 * @brief Functions for applying general many-qubit diagonal matrices, as DiagMatr.
713 * @{
714 */
715
716
717#ifdef __cplusplus
718extern "C" {
719#endif
720
721
722/// @notdoced
723void multiplyDiagMatr(Qureg qureg, int* targets, int numTargets, DiagMatr matrix);
724
725
726/// @notdoced
727void applyDiagMatr(Qureg qureg, int* targets, int numTargets, DiagMatr matrix);
728
729
730/// @notdoced
731void applyControlledDiagMatr(Qureg qureg, int control, int* targets, int numTargets, DiagMatr matrix);
732
733
734/// @notdoced
735void applyMultiControlledDiagMatr(Qureg qureg, int* controls, int numControls, int* targets, int numTargets, DiagMatr matrix);
736
737
738/// @notdoced
739void applyMultiStateControlledDiagMatr(Qureg qureg, int* controls, int* states, int numControls, int* targets, int numTargets, DiagMatr matrix);
740
741
742/// @notdoced
743void multiplyDiagMatrPower(Qureg qureg, int* targets, int numTargets, DiagMatr matrix, qcomp exponent);
744
745
746/// @notdoced
747void applyDiagMatrPower(Qureg qureg, int* targets, int numTargets, DiagMatr matrix, qcomp exponent);
748
749
750/// @notdoced
751void applyControlledDiagMatrPower(Qureg qureg, int control, int* targets, int numTargets, DiagMatr matrix, qcomp exponent);
752
753
754/// @notdoced
755void applyMultiControlledDiagMatrPower(Qureg qureg, int* controls, int numControls, int* targets, int numTargets, DiagMatr matrix, qcomp exponent);
756
757
758/// @notdoced
759void applyMultiStateControlledDiagMatrPower(Qureg qureg, int* controls, int* states, int numControls, int* targets, int numTargets, DiagMatr matrix, qcomp exponent);
760
761
762// end de-mangler
763#ifdef __cplusplus
764}
765#endif
766
767#ifdef __cplusplus
768
769
770/// @nottested
771/// @notvalidated
772/// @notdoced
773/// @cpponly
774void multiplyDiagMatr(Qureg qureg, std::vector<int> targets, DiagMatr matrix);
775
776
777/// @nottested
778/// @notvalidated
779/// @notdoced
780/// @cpponly
781void applyDiagMatr(Qureg qureg, std::vector<int> targets, DiagMatr matrix);
782
783
784/// @nottested
785/// @notvalidated
786/// @notdoced
787/// @cpponly
788void applyControlledDiagMatr(Qureg qureg, int control, std::vector<int> targets, DiagMatr matrix);
789
790
791/// @nottested
792/// @notvalidated
793/// @notdoced
794/// @cpponly
795void applyMultiControlledDiagMatr(Qureg qureg, std::vector<int> controls, std::vector<int> targets, DiagMatr matrix);
796
797
798/// @nottested
799/// @notvalidated
800/// @notdoced
801/// @cpponly
802void applyMultiStateControlledDiagMatr(Qureg qureg, std::vector<int> controls, std::vector<int> states, std::vector<int> targets, DiagMatr matrix);
803
804
805/// @nottested
806/// @notvalidated
807/// @notdoced
808/// @cpponly
809void multiplyDiagMatrPower(Qureg qureg, std::vector<int> targets, DiagMatr matrix, qcomp exponent);
810
811
812/// @nottested
813/// @notvalidated
814/// @notdoced
815/// @cpponly
816void applyDiagMatrPower(Qureg qureg, std::vector<int> targets, DiagMatr matrix, qcomp exponent);
817
818
819/// @nottested
820/// @notvalidated
821/// @notdoced
822/// @cpponly
823void applyControlledDiagMatrPower(Qureg qureg, int control, std::vector<int> targets, DiagMatr matrix, qcomp exponent);
824
825
826/// @nottested
827/// @notvalidated
828/// @notdoced
829/// @cpponly
830void applyMultiControlledDiagMatrPower(Qureg qureg, std::vector<int> controls, std::vector<int> targets, DiagMatr matrix, qcomp exponent);
831
832
833/// @nottested
834/// @notvalidated
835/// @notdoced
836/// @cpponly
837void applyMultiStateControlledDiagMatrPower(Qureg qureg, std::vector<int> controls, std::vector<int> states, std::vector<int> targets, DiagMatr matrix, qcomp exponent);
838
839
840#endif // __cplusplus
841
842/** @} */
843
844
845
846/**
847 * @defgroup op_fullstatediagmatr FullStateDiagMatr
848 * @brief Functions for applying general all-qubit diagonal matrices, as FullStateDiagMatr.
849 * @{
850 */
851
852
853#ifdef __cplusplus
854extern "C" {
855#endif
856
857
858/// @notdoced
859/// @notvalidated
861
862
863/// @notdoced
864/// @notvalidated
865void multiplyFullStateDiagMatrPower(Qureg qureg, FullStateDiagMatr matrix, qcomp exponent);
866
867
868/// @notdoced
869/// @notvalidated
871
872
873/// @notdoced
874/// @notvalidated
875void applyFullStateDiagMatrPower(Qureg qureg, FullStateDiagMatr matrix, qcomp exponent);
876
877
878// end de-mangler
879#ifdef __cplusplus
880}
881#endif
882
883
884/** @} */
885
886
887
888/**
889 * @defgroup op_fixed Fixed
890 * @brief Functions for applying the one-qubit S, T and Hadamard gates.
891 * @{
892 */
893
894
895#ifdef __cplusplus
896extern "C" {
897#endif
898
899
900/// @notdoced
901void applyS(Qureg qureg, int target);
902
903
904/// @notdoced
905void applyControlledS(Qureg qureg, int control, int target);
906
907
908/// @notdoced
909void applyMultiControlledS(Qureg qureg, int* controls, int numControls, int target);
910
911
912/// @notdoced
913void applyMultiStateControlledS(Qureg qureg, int* controls, int* states, int numControls, int target);
914
915
916/// @notdoced
917void applyT(Qureg qureg, int target);
918
919
920/// @notdoced
921void applyControlledT(Qureg qureg, int control, int target);
922
923
924/// @notdoced
925void applyMultiControlledT(Qureg qureg, int* controls, int numControls, int target);
926
927
928/// @notdoced
929void applyMultiStateControlledT(Qureg qureg, int* controls, int* states, int numControls, int target);
930
931
932/// @notdoced
933void applyHadamard(Qureg qureg, int target);
934
935
936/// @notdoced
937void applyControlledHadamard(Qureg qureg, int control, int target);
938
939
940/// @notdoced
941void applyMultiControlledHadamard(Qureg qureg, int* controls, int numControls, int target);
942
943
944/// @notdoced
945void applyMultiStateControlledHadamard(Qureg qureg, int* controls, int* states, int numControls, int target);
946
947
948// end de-mangler
949#ifdef __cplusplus
950}
951#endif
952
953#ifdef __cplusplus
954
955
956/// @nottested
957/// @notvalidated
958/// @notdoced
959/// @cpponly
960void applyMultiControlledS(Qureg qureg, std::vector<int> controls, int target);
961
962
963/// @nottested
964/// @notvalidated
965/// @notdoced
966/// @cpponly
967void applyMultiStateControlledS(Qureg qureg, std::vector<int> controls, std::vector<int> states, int target);
968
969
970/// @nottested
971/// @notvalidated
972/// @notdoced
973/// @cpponly
974void applyMultiControlledT(Qureg qureg, std::vector<int> controls, int target);
975
976
977/// @nottested
978/// @notvalidated
979/// @notdoced
980/// @cpponly
981void applyMultiStateControlledT(Qureg qureg, std::vector<int> controls, std::vector<int> states, int target);
982
983
984/// @nottested
985/// @notvalidated
986/// @notdoced
987/// @cpponly
988void applyMultiControlledHadamard(Qureg qureg, std::vector<int> controls, int target);
989
990
991/// @nottested
992/// @notvalidated
993/// @notdoced
994/// @cpponly
995void applyMultiStateControlledHadamard(Qureg qureg, std::vector<int> controls, std::vector<int> states, int target);
996
997
998#endif // __cplusplus
999
1000/** @} */
1001
1002
1003
1004/**
1005 * @defgroup op_swap Swap
1006 * @brief Functions for applying the two-qubit SWAP and related gates.
1007 * @{
1008 */
1009
1010
1011#ifdef __cplusplus
1012extern "C" {
1013#endif
1014
1015
1016/// @notdoced
1017void multiplySwap(Qureg qureg, int qubit1, int qubit2);
1018
1019
1020/** Applies a SWAP gate between @p qubit1 and @p qubit2 of @p qureg.
1021 *
1022 * @diagram
1023 * @dot
1024digraph {
1025 rankdir=LR;
1026 layout=neato;
1027 node [fontsize=10, fontname="Menlo"];
1028 edge [dir=none];
1029
1030 topWireL [shape=plaintext, label="qubit2", pos="0,.5!"];
1031 topWireM [shape=point, label="", width=0, pos=".75,.5!"];
1032 topWireR [shape=plaintext, label="", pos="1.5,.5!"];
1033
1034 botWireL [shape=plaintext, label="qubit1", pos="0,0!"];
1035 botWireM [shape=point, label="", width=0, pos=".75,0!"];
1036 botWireR [shape=plaintext, label="", pos="1.5,0!"];
1037
1038 topWireL -> topWireR;
1039 botWireL -> botWireR;
1040 botWireM -> topWireM;
1041
1042 topX [shape=plaintext, label="✕", pos=".75,.5!", fontsize=15];
1043 botX [shape=plaintext, label="✕", pos=".75,0!", fontsize=15];
1044}
1045 * @enddot
1046 *
1047 * @notdoced
1048 */
1049void applySwap(Qureg qureg, int qubit1, int qubit2);
1050
1051
1052/// @notdoced
1053void applyControlledSwap(Qureg qureg, int control, int qubit1, int qubit2);
1054
1055
1056/// @notdoced
1057void applyMultiControlledSwap(Qureg qureg, int* controls, int numControls, int qubit1, int qubit2);
1058
1059
1060/// @notdoced
1061void applyMultiStateControlledSwap(Qureg qureg, int* controls, int* states, int numControls, int qubit1, int qubit2);
1062
1063
1064/// @notdoced
1065void applySqrtSwap(Qureg qureg, int qubit1, int qubit2);
1066
1067
1068/// @notdoced
1069void applyControlledSqrtSwap(Qureg qureg, int control, int qubit1, int qubit2);
1070
1071
1072/// @notdoced
1073void applyMultiControlledSqrtSwap(Qureg qureg, int* controls, int numControls, int qubit1, int qubit2);
1074
1075
1076/// @notdoced
1077void applyMultiStateControlledSqrtSwap(Qureg qureg, int* controls, int* states, int numControls, int qubit1, int qubit2);
1078
1079
1080// end de-mangler
1081#ifdef __cplusplus
1082}
1083#endif
1084
1085#ifdef __cplusplus
1086
1087
1088/// @nottested
1089/// @notvalidated
1090/// @notdoced
1091/// @cpponly
1092void applyMultiControlledSwap(Qureg qureg, std::vector<int> controls, int qubit1, int qubit2);
1093
1094
1095/// @nottested
1096/// @notvalidated
1097/// @notdoced
1098/// @cpponly
1099void applyMultiStateControlledSwap(Qureg qureg, std::vector<int> controls, std::vector<int> states, int qubit1, int qubit2);
1100
1101
1102/// @nottested
1103/// @notvalidated
1104/// @notdoced
1105/// @cpponly
1106void applyMultiControlledSqrtSwap(Qureg qureg, std::vector<int> controls, int qubit1, int qubit2);
1107
1108
1109/// @nottested
1110/// @notvalidated
1111/// @notdoced
1112/// @cpponly
1113void applyMultiStateControlledSqrtSwap(Qureg qureg, std::vector<int> controls, std::vector<int> states, int numControls, int qubit1, int qubit2);
1114
1115
1116#endif // __cplusplus
1117
1118/** @} */
1119
1120
1121
1122/**
1123 * @defgroup op_pauli Pauli
1124 * @brief Functions for applying the individual one-qubit Pauli operators.
1125 * @{
1126 */
1127
1128
1129#ifdef __cplusplus
1130extern "C" {
1131#endif
1132
1133
1134/// @notdoced
1135void multiplyPauliX(Qureg qureg, int target);
1136
1137
1138/// @notdoced
1139void multiplyPauliY(Qureg qureg, int target);
1140
1141
1142/// @notdoced
1143void multiplyPauliZ(Qureg qureg, int target);
1144
1145
1146/// @notdoced
1147void applyPauliX(Qureg qureg, int target);
1148
1149
1150/// @notdoced
1151void applyPauliY(Qureg qureg, int target);
1152
1153
1154/// @notdoced
1155void applyPauliZ(Qureg qureg, int target);
1156
1157
1158/// @notdoced
1159void applyControlledPauliX(Qureg qureg, int control, int target);
1160
1161
1162/// @notdoced
1163void applyControlledPauliY(Qureg qureg, int control, int target);
1164
1165
1166/// @notdoced
1167void applyControlledPauliZ(Qureg qureg, int control, int target);
1168
1169
1170/// @notdoced
1171void applyMultiControlledPauliX(Qureg qureg, int* controls, int numControls, int target);
1172
1173
1174/// @notdoced
1175void applyMultiControlledPauliY(Qureg qureg, int* controls, int numControls, int target);
1176
1177
1178/// @notdoced
1179void applyMultiControlledPauliZ(Qureg qureg, int* controls, int numControls, int target);
1180
1181
1182/// @notdoced
1183void applyMultiStateControlledPauliX(Qureg qureg, int* controls, int* states, int numControls, int target);
1184
1185
1186/// @notdoced
1187void applyMultiStateControlledPauliY(Qureg qureg, int* controls, int* states, int numControls, int target);
1188
1189
1190/// @notdoced
1191void applyMultiStateControlledPauliZ(Qureg qureg, int* controls, int* states, int numControls, int target);
1192
1193
1194// end de-mangler
1195#ifdef __cplusplus
1196}
1197#endif
1198
1199#ifdef __cplusplus
1200
1201
1202/// @nottested
1203/// @notvalidated
1204/// @notdoced
1205/// @cpponly
1206void applyMultiControlledPauliX(Qureg qureg, std::vector<int> controls, int target);
1207
1208
1209/// @nottested
1210/// @notvalidated
1211/// @notdoced
1212/// @cpponly
1213void applyMultiControlledPauliY(Qureg qureg, std::vector<int> controls, int target);
1214
1215
1216/// @nottested
1217/// @notvalidated
1218/// @notdoced
1219/// @cpponly
1220void applyMultiControlledPauliZ(Qureg qureg, std::vector<int> controls, int target);
1221
1222
1223/// @nottested
1224/// @notvalidated
1225/// @notdoced
1226/// @cpponly
1227void applyMultiStateControlledPauliX(Qureg qureg, std::vector<int> controls, std::vector<int> states, int target);
1228
1229
1230/// @nottested
1231/// @notvalidated
1232/// @notdoced
1233/// @cpponly
1234void applyMultiStateControlledPauliY(Qureg qureg, std::vector<int> controls, std::vector<int> states, int target);
1235
1236
1237/// @nottested
1238/// @notvalidated
1239/// @notdoced
1240/// @cpponly
1241void applyMultiStateControlledPauliZ(Qureg qureg, std::vector<int> controls, std::vector<int> states, int target);
1242
1243
1244#endif // __cplusplus
1245
1246/** @} */
1247
1248
1249
1250/**
1251 * @defgroup op_paulistr PauliStr
1252 * @brief Functions for applying a tensor product of Pauli operators, as a PauliStr
1253 * @{
1254 */
1255
1256
1257#ifdef __cplusplus
1258extern "C" {
1259#endif
1260
1261
1262/// @notdoced
1263void multiplyPauliStr(Qureg qureg, PauliStr str);
1264
1265
1266/// @notdoced
1267void applyPauliStr(Qureg qureg, PauliStr str);
1268
1269
1270/// @notdoced
1271void applyControlledPauliStr(Qureg qureg, int control, PauliStr str);
1272
1273
1274/// @notdoced
1275void applyMultiControlledPauliStr(Qureg qureg, int* controls, int numControls, PauliStr str);
1276
1277
1278/// @notdoced
1279void applyMultiStateControlledPauliStr(Qureg qureg, int* controls, int* states, int numControls, PauliStr str);
1280
1281
1282// end de-mangler
1283#ifdef __cplusplus
1284}
1285#endif
1286
1287#ifdef __cplusplus
1288
1289
1290/// @nottested
1291/// @notvalidated
1292/// @notdoced
1293/// @cpponly
1294void applyMultiControlledPauliStr(Qureg qureg, std::vector<int> controls, PauliStr str);
1295
1296
1297/// @nottested
1298/// @notvalidated
1299/// @notdoced
1300/// @cpponly
1301void applyMultiStateControlledPauliStr(Qureg qureg, std::vector<int> controls, std::vector<int> states, PauliStr str);
1302
1303
1304#endif // __cplusplus
1305
1306/** @} */
1307
1308
1309
1310/**
1311 * @defgroup op_rotation Rotations
1312 * @brief Functions for applying one-qubit rotations around Pauli and arbitrary axis.
1313 * @{
1314 */
1315
1316
1317#ifdef __cplusplus
1318extern "C" {
1319#endif
1320
1321
1322/// @notdoced
1323void applyRotateX(Qureg qureg, int target, qreal angle);
1324
1325
1326/// @notdoced
1327void applyRotateY(Qureg qureg, int target, qreal angle);
1328
1329
1330/// @notdoced
1331void applyRotateZ(Qureg qureg, int target, qreal angle);
1332
1333
1334/// @notdoced
1335void applyControlledRotateX(Qureg qureg, int control, int target, qreal angle);
1336
1337
1338/// @notdoced
1339void applyControlledRotateY(Qureg qureg, int control, int target, qreal angle);
1340
1341
1342/// @notdoced
1343void applyControlledRotateZ(Qureg qureg, int control, int target, qreal angle);
1344
1345
1346/// @notdoced
1347void applyMultiControlledRotateX(Qureg qureg, int* controls, int numControls, int target, qreal angle);
1348
1349
1350/// @notdoced
1351void applyMultiControlledRotateY(Qureg qureg, int* controls, int numControls, int target, qreal angle);
1352
1353
1354/// @notdoced
1355void applyMultiControlledRotateZ(Qureg qureg, int* controls, int numControls, int target, qreal angle);
1356
1357
1358/// @notdoced
1359void applyMultiStateControlledRotateX(Qureg qureg, int* controls, int* states, int numControls, int target, qreal angle);
1360
1361
1362/// @notdoced
1363void applyMultiStateControlledRotateY(Qureg qureg, int* controls, int* states, int numControls, int target, qreal angle);
1364
1365
1366/// @notdoced
1367void applyMultiStateControlledRotateZ(Qureg qureg, int* controls, int* states, int numControls, int target, qreal angle);
1368
1369
1370/// @notdoced
1371void applyRotateAroundAxis(Qureg qureg, int targ, qreal angle, qreal axisX, qreal axisY, qreal axisZ);
1372
1373
1374/// @notdoced
1375void applyControlledRotateAroundAxis(Qureg qureg, int ctrl, int targ, qreal angle, qreal axisX, qreal axisY, qreal axisZ);
1376
1377
1378/// @notdoced
1379void applyMultiControlledRotateAroundAxis(Qureg qureg, int* ctrls, int numCtrls, int targ, qreal angle, qreal axisX, qreal axisY, qreal axisZ);
1380
1381
1382/// @notdoced
1383void applyMultiStateControlledRotateAroundAxis(Qureg qureg, int* ctrls, int* states, int numCtrls, int targ, qreal angle, qreal axisX, qreal axisY, qreal axisZ);
1384
1385
1386// end de-mangler
1387#ifdef __cplusplus
1388}
1389#endif
1390
1391#ifdef __cplusplus
1392
1393
1394/// @nottested
1395/// @notvalidated
1396/// @notdoced
1397/// @cpponly
1398void applyMultiControlledRotateX(Qureg qureg, std::vector<int> controls, int target, qreal angle);
1399
1400
1401/// @nottested
1402/// @notvalidated
1403/// @notdoced
1404/// @cpponly
1405void applyMultiControlledRotateY(Qureg qureg, std::vector<int> controls, int target, qreal angle);
1406
1407
1408/// @nottested
1409/// @notvalidated
1410/// @notdoced
1411/// @cpponly
1412void applyMultiControlledRotateZ(Qureg qureg, std::vector<int> controls, int target, qreal angle);
1413
1414
1415/// @nottested
1416/// @notvalidated
1417/// @notdoced
1418/// @cpponly
1419void applyMultiStateControlledRotateX(Qureg qureg, std::vector<int> controls, std::vector<int> states, int target, qreal angle);
1420
1421
1422/// @nottested
1423/// @notvalidated
1424/// @notdoced
1425/// @cpponly
1426void applyMultiStateControlledRotateY(Qureg qureg, std::vector<int> controls, std::vector<int> states, int target, qreal angle);
1427
1428
1429/// @nottested
1430/// @notvalidated
1431/// @notdoced
1432/// @cpponly
1433void applyMultiStateControlledRotateZ(Qureg qureg, std::vector<int> controls, std::vector<int> states, int target, qreal angle);
1434
1435
1436/// @nottested
1437/// @notvalidated
1438/// @notdoced
1439/// @cpponly
1440void applyMultiControlledRotateAroundAxis(Qureg qureg, std::vector<int> ctrls, int targ, qreal angle, qreal axisX, qreal axisY, qreal axisZ);
1441
1442
1443/// @nottested
1444/// @notvalidated
1445/// @notdoced
1446/// @cpponly
1447void applyMultiStateControlledRotateAroundAxis(Qureg qureg, std::vector<int> ctrls, std::vector<int> states, int targ, qreal angle, qreal axisX, qreal axisY, qreal axisZ);
1448
1449
1450#endif // __cplusplus
1451
1452/** @} */
1453
1454
1455
1456/**
1457 * @defgroup op_pauligadget Pauli gadgets
1458 * @brief Functions for applying many-qubit rotations around arbitrary PauliStr.
1459 * @{
1460 */
1461
1462
1463#ifdef __cplusplus
1464extern "C" {
1465#endif
1466
1467
1468/// @notdoced
1469void multiplyPauliGadget(Qureg qureg, PauliStr str, qreal angle);
1470
1471
1472/// @notdoced
1473void applyPauliGadget(Qureg qureg, PauliStr str, qreal angle);
1474
1475
1476/// @notdoced
1477void applyControlledPauliGadget(Qureg qureg, int control, PauliStr str, qreal angle);
1478
1479
1480/// @notdoced
1481void applyMultiControlledPauliGadget(Qureg qureg, int* controls, int numControls, PauliStr str, qreal angle);
1482
1483
1484/// @notdoced
1485void applyMultiStateControlledPauliGadget(Qureg qureg, int* controls, int* states, int numControls, PauliStr str, qreal angle);
1486
1487
1488// end de-mangler
1489#ifdef __cplusplus
1490}
1491#endif
1492
1493#ifdef __cplusplus
1494
1495
1496/// @nottested
1497/// @notvalidated
1498/// @notdoced
1499/// @cpponly
1500void applyMultiControlledPauliGadget(Qureg qureg, std::vector<int> controls, PauliStr str, qreal angle);
1501
1502
1503/// @nottested
1504/// @notvalidated
1505/// @notdoced
1506/// @cpponly
1507void applyMultiStateControlledPauliGadget(Qureg qureg, std::vector<int> controls, std::vector<int> states, PauliStr str, qreal angle);
1508
1509
1510#endif // __cplusplus
1511
1512/** @} */
1513
1514
1515
1516/**
1517 * @defgroup op_phasegadget Phase gates
1518 * @brief Functions for applying many-qubit rotations around Pauli Z axis, and phase flips and shifts.
1519 * @{
1520 */
1521
1522
1523#ifdef __cplusplus
1524extern "C" {
1525#endif
1526
1527
1528/// @notdoced
1529void multiplyPhaseGadget(Qureg qureg, int* targets, int numTargets, qreal angle);
1530
1531
1532/// @notdoced
1533void applyPhaseGadget(Qureg qureg, int* targets, int numTargets, qreal angle);
1534
1535
1536/// @notdoced
1537void applyControlledPhaseGadget(Qureg qureg, int control, int* targets, int numTargets, qreal angle);
1538
1539
1540/// @notdoced
1541void applyMultiControlledPhaseGadget(Qureg qureg, int* controls, int numControls, int* targets, int numTargets, qreal angle);
1542
1543
1544/// @notdoced
1545void applyMultiStateControlledPhaseGadget(Qureg qureg, int* controls, int* states, int numControls, int* targets, int numTargets, qreal angle);
1546
1547
1548/// @notdoced
1549void applyPhaseFlip(Qureg qureg, int target);
1550
1551
1552/// @notdoced
1553void applyPhaseShift(Qureg qureg, int target, qreal angle);
1554
1555
1556/** Applies a two-qubit phase flip upon @p qubit1 and @p qubit2 of @p qureg.
1557 *
1558 * @diagram
1559 * @dot
1560digraph {
1561 rankdir=LR;
1562 layout=neato;
1563 node [fontsize=10, fontname="Menlo"];
1564 edge [dir=none];
1565
1566 topWireL [shape=plaintext, label="target1", pos="0,.5!"];
1567 topWireM [shape=point, label="", width=.1, pos=".75,.5!"]
1568 topWireR [shape=plaintext, label="", pos="1.5,.5!"];
1569
1570 botWireL [shape=plaintext, label="target2", pos="0,0!"];
1571 botWireM [shape=point, label="", width=.1, pos=".75,0!"];
1572 botWireR [shape=plaintext, label="", pos="1.5,0!"];
1573
1574 topWireL -> topWireR;
1575 botWireL -> botWireR;
1576 botWireM -> topWireM;
1577}
1578 * @enddot
1579 *
1580 * @notdoced
1581 */
1582void applyTwoQubitPhaseFlip( Qureg qureg, int target1, int target2);
1583
1584
1585/** Applies a two-qubit phase flip upon @p qubit1 and @p qubit2 of @p qureg.
1586 *
1587 * @diagram
1588 * @dot
1589digraph {
1590 rankdir=LR;
1591 layout=neato;
1592 node [fontsize=10, fontname="Menlo"];
1593 edge [dir=none];
1594
1595 topWireL [shape=plaintext, label="target1", pos="0,.5!"];
1596 topWireM [shape=point, label="", width=.1, pos=".75,.5!"]
1597 topWireR [shape=plaintext, label="", pos="1.5,.5!"];
1598
1599 botWireL [shape=plaintext, label="target2", pos="0,0!"];
1600 botWireM [shape=point, label="", width=.1, pos=".75,0!"];
1601 botWireR [shape=plaintext, label="", pos="1.5,0!"];
1602
1603 topWireL -> topWireR;
1604 botWireL -> botWireR;
1605 botWireM -> topWireM;
1606
1607 angle [shape=plaintext, label="θ", pos=".85,-.2!"];
1608}
1609 * @enddot
1610 *
1611 * @notdoced
1612 */
1613void applyTwoQubitPhaseShift(Qureg qureg, int target1, int target2, qreal angle);
1614
1615
1616/// @notdoced
1617void applyMultiQubitPhaseFlip(Qureg qureg, int* targets, int numTargets);
1618
1619
1620/// @notdoced
1621void applyMultiQubitPhaseShift(Qureg qureg, int* targets, int numTargets, qreal angle);
1622
1623
1624// end de-mangler
1625#ifdef __cplusplus
1626}
1627#endif
1628
1629#ifdef __cplusplus
1630
1631
1632/// @nottested
1633/// @notvalidated
1634/// @notdoced
1635/// @cpponly
1636void multiplyPhaseGadget(Qureg qureg, std::vector<int> targets, qreal angle);
1637
1638
1639/// @nottested
1640/// @notvalidated
1641/// @notdoced
1642/// @cpponly
1643void applyPhaseGadget(Qureg qureg, std::vector<int> targets, qreal angle);
1644
1645
1646/// @nottested
1647/// @notvalidated
1648/// @notdoced
1649/// @cpponly
1650void applyControlledPhaseGadget(Qureg qureg, int control, std::vector<int> targets, qreal angle);
1651
1652
1653/// @nottested
1654/// @notvalidated
1655/// @notdoced
1656/// @cpponly
1657void applyMultiControlledPhaseGadget(Qureg qureg, std::vector<int> controls, std::vector<int> targets, qreal angle);
1658
1659
1660/// @nottested
1661/// @notvalidated
1662/// @notdoced
1663/// @cpponly
1664void applyMultiStateControlledPhaseGadget(Qureg qureg, std::vector<int> controls, std::vector<int> states, std::vector<int> targets, qreal angle);
1665
1666
1667/// @nottested
1668/// @notvalidated
1669/// @notdoced
1670/// @cpponly
1671void applyMultiQubitPhaseFlip(Qureg qureg, std::vector<int> targets);
1672
1673
1674/// @nottested
1675/// @notvalidated
1676/// @notdoced
1677/// @cpponly
1678void applyMultiQubitPhaseShift(Qureg qureg, std::vector<int> targets, qreal angle);
1679
1680
1681#endif // __cplusplus
1682
1683/** @} */
1684
1685
1686
1687/**
1688 * @defgroup op_paulistrsum PauliStrSum
1689 * @brief Functions for applying, exponentiating or Trotterising a weigthed sum of Pauli tensors.
1690 * @{
1691 */
1692
1693
1694#ifdef __cplusplus
1695extern "C" {
1696#endif
1697
1698
1699/// @notdoced
1700/// @notvalidated
1701void multiplyPauliStrSum(Qureg qureg, PauliStrSum sum, Qureg workspace);
1702
1703
1704/// @notdoced
1705/// @nottested
1706void applyTrotterizedPauliStrSumGadget(Qureg qureg, PauliStrSum sum, qreal angle, int order, int reps);
1707
1708
1709// end de-mangler
1710#ifdef __cplusplus
1711}
1712#endif
1713
1714
1715/** @} */
1716
1717
1718
1719/**
1720 * @defgroup op_nots Many-not gates
1721 * @brief Functions for effecting many-qubit NOT gates
1722 * @{
1723 */
1724
1725
1726#ifdef __cplusplus
1727extern "C" {
1728#endif
1729
1730
1731/// @notdoced
1732void multiplyMultiQubitNot(Qureg qureg, int* targets, int numTargets);
1733
1734
1735/// @notdoced
1736void applyMultiQubitNot(Qureg qureg, int* targets, int numTargets);
1737
1738
1739/// @notdoced
1740void applyControlledMultiQubitNot(Qureg qureg, int control, int* targets, int numTargets);
1741
1742
1743/// @notdoced
1744void applyMultiControlledMultiQubitNot(Qureg qureg, int* controls, int numControls, int* targets, int numTargets);
1745
1746
1747/// @notdoced
1748void applyMultiStateControlledMultiQubitNot(Qureg qureg, int* controls, int* states, int numControls, int* targets, int numTargets);
1749
1750
1751// end de-mangler
1752#ifdef __cplusplus
1753}
1754#endif
1755
1756#ifdef __cplusplus
1757
1758
1759/// @nottested
1760/// @notvalidated
1761/// @notdoced
1762/// @cpponly
1763void multiplyMultiQubitNot(Qureg qureg, std::vector<int> targets);
1764
1765
1766/// @nottested
1767/// @notvalidated
1768/// @notdoced
1769/// @cpponly
1770void applyMultiQubitNot(Qureg qureg, std::vector<int> targets);
1771
1772
1773/// @nottested
1774/// @notvalidated
1775/// @notdoced
1776/// @cpponly
1777void applyControlledMultiQubitNot(Qureg qureg, int control, std::vector<int> targets);
1778
1779
1780/// @nottested
1781/// @notvalidated
1782/// @notdoced
1783/// @cpponly
1784void applyMultiControlledMultiQubitNot(Qureg qureg, std::vector<int> controls, std::vector<int> targets);
1785
1786
1787/// @nottested
1788/// @notvalidated
1789/// @notdoced
1790/// @cpponly
1791void applyMultiStateControlledMultiQubitNot(Qureg qureg, std::vector<int> controls, std::vector<int> states, std::vector<int> targets);
1792
1793
1794#endif // __cplusplus
1795
1796/** @} */
1797
1798
1799
1800/**
1801 * @defgroup op_measurement Measurements
1802 * @brief Functions for effecting destructive measurements.
1803 * @{
1804 */
1805
1806
1807#ifdef __cplusplus
1808extern "C" {
1809#endif
1810
1811
1812/// @notdoced
1813/// @notvalidated
1814int applyQubitMeasurement(Qureg qureg, int target);
1815
1816
1817/// @notdoced
1818/// @notvalidated
1819int applyQubitMeasurementAndGetProb(Qureg qureg, int target, qreal* probability);
1820
1821
1822/// @notdoced
1823/// @notvalidated
1824qreal applyForcedQubitMeasurement(Qureg qureg, int target, int outcome);
1825
1826
1827/// @notdoced
1828/// @notvalidated
1829qindex applyMultiQubitMeasurement(Qureg qureg, int* qubits, int numQubits);
1830
1831
1832/// @notdoced
1833/// @notvalidated
1834qindex applyMultiQubitMeasurementAndGetProb(Qureg qureg, int* qubits, int numQubits, qreal* probability);
1835
1836
1837/// @notdoced
1838/// @notvalidated
1839qreal applyForcedMultiQubitMeasurement(Qureg qureg, int* qubits, int* outcomes, int numQubits);
1840
1841
1842// end de-mangler
1843#ifdef __cplusplus
1844}
1845#endif
1846
1847#ifdef __cplusplus
1848
1849
1850/// @nottested
1851/// @notvalidated
1852/// @notdoced
1853/// @cpponly
1854qindex applyMultiQubitMeasurementAndGetProb(Qureg qureg, std::vector<int> qubits, qreal* probability);
1855
1856
1857/// @nottested
1858/// @notvalidated
1859/// @notdoced
1860/// @cpponly
1861qreal applyForcedMultiQubitMeasurement(Qureg qureg, std::vector<int> qubits, std::vector<int> outcomes);
1862
1863
1864#endif // __cplusplus
1865
1866/** @} */
1867
1868
1869
1870/**
1871 * @defgroup op_projectors Projectors
1872 * @brief Functions for effecting projectors which break the state normalisation.
1873 * @{
1874 */
1875
1876
1877#ifdef __cplusplus
1878extern "C" {
1879#endif
1880
1881
1882/// @notdoced
1883/// @notvalidated
1884void applyQubitProjector(Qureg qureg, int target, int outcome);
1885
1886
1887/// @notdoced
1888/// @notvalidated
1889void applyMultiQubitProjector(Qureg qureg, int* qubits, int* outcomes, int numQubits);
1890
1891
1892// end de-mangler
1893#ifdef __cplusplus
1894}
1895#endif
1896
1897#ifdef __cplusplus
1898
1899
1900/// @nottested
1901/// @notvalidated
1902/// @notdoced
1903/// @cpponly
1904void applyMultiQubitProjector(Qureg qureg, std::vector<int> qubits, std::vector<int> outcomes);
1905
1906
1907#endif // __cplusplus
1908
1909/** @} */
1910
1911
1912
1913/**
1914 * @defgroup op_qft QFT
1915 * @brief Functions for applying the Quantum Fourier Transform.
1916 * @{
1917 */
1918
1919
1920#ifdef __cplusplus
1921extern "C" {
1922#endif
1923
1924
1925/// @notdoced
1926/// @notvalidated
1927void applyQuantumFourierTransform(Qureg qureg, int* targets, int numTargets);
1928
1929
1930/// @notdoced
1931/// @notvalidated
1933
1934
1935// end de-mangler
1936#ifdef __cplusplus
1937}
1938#endif
1939
1940#ifdef __cplusplus
1941
1942
1943/// @nottested
1944/// @notvalidated
1945/// @notdoced
1946/// @cpponly
1947void applyQuantumFourierTransform(Qureg qureg, std::vector<int> targets);
1948
1949
1950#endif // __cplusplus
1951
1952/** @} */
1953
1954
1955
1956#endif // OPERATIONS_H
1957
1958/** @} */ // (end file-wide doxygen defgroup)
void applyCompMatr1(Qureg qureg, int target, CompMatr1 matrix)
void multiplyCompMatr1(Qureg qureg, int target, CompMatr1 matrix)
void applyMultiControlledCompMatr1(Qureg qureg, int *controls, int numControls, int target, CompMatr1 matrix)
void applyControlledCompMatr1(Qureg qureg, int control, int target, CompMatr1 matrix)
void applyMultiStateControlledCompMatr1(Qureg qureg, int *controls, int *states, int numControls, int target, CompMatr1 matrix)
void applyMultiStateControlledCompMatr2(Qureg qureg, int *controls, int *states, int numControls, int target1, int target2, CompMatr2 matr)
void multiplyCompMatr2(Qureg qureg, int target1, int target2, CompMatr2 matr)
void applyMultiControlledCompMatr2(Qureg qureg, int *controls, int numControls, int target1, int target2, CompMatr2 matr)
void applyCompMatr2(Qureg qureg, int target1, int target2, CompMatr2 matrix)
void applyControlledCompMatr2(Qureg qureg, int control, int target1, int target2, CompMatr2 matr)
void applyMultiStateControlledCompMatr(Qureg qureg, int *controls, int *states, int numControls, int *targets, int numTargets, CompMatr matr)
void multiplyCompMatr(Qureg qureg, int *targets, int numTargets, CompMatr matr)
void applyMultiControlledCompMatr(Qureg qureg, int *controls, int numControls, int *targets, int numTargets, CompMatr matr)
void applyControlledCompMatr(Qureg qureg, int control, int *targets, int numTargets, CompMatr matr)
void applyCompMatr(Qureg qureg, int *targets, int numTargets, CompMatr matr)
void applyControlledDiagMatr1(Qureg qureg, int control, int target, DiagMatr1 matr)
void multiplyDiagMatr1(Qureg qureg, int target, DiagMatr1 matr)
void applyDiagMatr1(Qureg qureg, int target, DiagMatr1 matr)
void applyMultiStateControlledDiagMatr1(Qureg qureg, int *controls, int *states, int numControls, int target, DiagMatr1 matr)
void applyMultiControlledDiagMatr1(Qureg qureg, int *controls, int numControls, int target, DiagMatr1 matr)
void applyMultiStateControlledDiagMatr2(Qureg qureg, int *controls, int *states, int numControls, int target1, int target2, DiagMatr2 matr)
void applyMultiControlledDiagMatr2(Qureg qureg, int *controls, int numControls, int target1, int target2, DiagMatr2 matr)
void applyDiagMatr2(Qureg qureg, int target1, int target2, DiagMatr2 matr)
void applyControlledDiagMatr2(Qureg qureg, int control, int target1, int target2, DiagMatr2 matr)
void multiplyDiagMatr2(Qureg qureg, int target1, int target2, DiagMatr2 matr)
void multiplyDiagMatr(Qureg qureg, int *targets, int numTargets, DiagMatr matrix)
void multiplyDiagMatrPower(Qureg qureg, int *targets, int numTargets, DiagMatr matrix, qcomp exponent)
void applyDiagMatr(Qureg qureg, int *targets, int numTargets, DiagMatr matrix)
void applyMultiControlledDiagMatrPower(Qureg qureg, int *controls, int numControls, int *targets, int numTargets, DiagMatr matrix, qcomp exponent)
void applyMultiStateControlledDiagMatrPower(Qureg qureg, int *controls, int *states, int numControls, int *targets, int numTargets, DiagMatr matrix, qcomp exponent)
void applyDiagMatrPower(Qureg qureg, int *targets, int numTargets, DiagMatr matrix, qcomp exponent)
void applyControlledDiagMatr(Qureg qureg, int control, int *targets, int numTargets, DiagMatr matrix)
void applyMultiControlledDiagMatr(Qureg qureg, int *controls, int numControls, int *targets, int numTargets, DiagMatr matrix)
void applyControlledDiagMatrPower(Qureg qureg, int control, int *targets, int numTargets, DiagMatr matrix, qcomp exponent)
void applyMultiStateControlledDiagMatr(Qureg qureg, int *controls, int *states, int numControls, int *targets, int numTargets, DiagMatr matrix)
void applyControlledT(Qureg qureg, int control, int target)
void applyControlledS(Qureg qureg, int control, int target)
void applyMultiStateControlledHadamard(Qureg qureg, int *controls, int *states, int numControls, int target)
void applyMultiControlledHadamard(Qureg qureg, int *controls, int numControls, int target)
void applyS(Qureg qureg, int target)
void applyMultiControlledT(Qureg qureg, int *controls, int numControls, int target)
void applyMultiControlledS(Qureg qureg, int *controls, int numControls, int target)
void applyT(Qureg qureg, int target)
void applyMultiStateControlledS(Qureg qureg, int *controls, int *states, int numControls, int target)
void applyHadamard(Qureg qureg, int target)
void applyControlledHadamard(Qureg qureg, int control, int target)
void applyMultiStateControlledT(Qureg qureg, int *controls, int *states, int numControls, int target)
void applyFullStateDiagMatr(Qureg qureg, FullStateDiagMatr matrix)
void multiplyFullStateDiagMatrPower(Qureg qureg, FullStateDiagMatr matrix, qcomp exponent)
void applyFullStateDiagMatrPower(Qureg qureg, FullStateDiagMatr matrix, qcomp exponent)
void multiplyFullStateDiagMatr(Qureg qureg, FullStateDiagMatr matrix)
qreal applyForcedQubitMeasurement(Qureg qureg, int target, int outcome)
qindex applyMultiQubitMeasurement(Qureg qureg, int *qubits, int numQubits)
int applyQubitMeasurement(Qureg qureg, int target)
qreal applyForcedMultiQubitMeasurement(Qureg qureg, int *qubits, int *outcomes, int numQubits)
qindex applyMultiQubitMeasurementAndGetProb(Qureg qureg, int *qubits, int numQubits, qreal *probability)
int applyQubitMeasurementAndGetProb(Qureg qureg, int target, qreal *probability)
void applyMultiStateControlledMultiQubitNot(Qureg qureg, int *controls, int *states, int numControls, int *targets, int numTargets)
void multiplyMultiQubitNot(Qureg qureg, int *targets, int numTargets)
void applyMultiControlledMultiQubitNot(Qureg qureg, int *controls, int numControls, int *targets, int numTargets)
void applyMultiQubitNot(Qureg qureg, int *targets, int numTargets)
void applyControlledMultiQubitNot(Qureg qureg, int control, int *targets, int numTargets)
void applyMultiControlledPauliZ(Qureg qureg, int *controls, int numControls, int target)
void applyPauliX(Qureg qureg, int target)
void multiplyPauliY(Qureg qureg, int target)
void applyControlledPauliX(Qureg qureg, int control, int target)
void applyMultiStateControlledPauliY(Qureg qureg, int *controls, int *states, int numControls, int target)
void applyMultiControlledPauliY(Qureg qureg, int *controls, int numControls, int target)
void applyControlledPauliZ(Qureg qureg, int control, int target)
void applyMultiControlledPauliX(Qureg qureg, int *controls, int numControls, int target)
void multiplyPauliX(Qureg qureg, int target)
void applyPauliZ(Qureg qureg, int target)
void multiplyPauliZ(Qureg qureg, int target)
void applyMultiStateControlledPauliZ(Qureg qureg, int *controls, int *states, int numControls, int target)
void applyPauliY(Qureg qureg, int target)
void applyControlledPauliY(Qureg qureg, int control, int target)
void applyMultiStateControlledPauliX(Qureg qureg, int *controls, int *states, int numControls, int target)
void applyMultiControlledPauliGadget(Qureg qureg, int *controls, int numControls, PauliStr str, qreal angle)
void multiplyPauliGadget(Qureg qureg, PauliStr str, qreal angle)
void applyControlledPauliGadget(Qureg qureg, int control, PauliStr str, qreal angle)
void applyMultiStateControlledPauliGadget(Qureg qureg, int *controls, int *states, int numControls, PauliStr str, qreal angle)
void applyPauliGadget(Qureg qureg, PauliStr str, qreal angle)
void applyMultiControlledPauliStr(Qureg qureg, int *controls, int numControls, PauliStr str)
void multiplyPauliStr(Qureg qureg, PauliStr str)
void applyPauliStr(Qureg qureg, PauliStr str)
void applyMultiStateControlledPauliStr(Qureg qureg, int *controls, int *states, int numControls, PauliStr str)
void applyControlledPauliStr(Qureg qureg, int control, PauliStr str)
void multiplyPauliStrSum(Qureg qureg, PauliStrSum sum, Qureg workspace)
void applyTrotterizedPauliStrSumGadget(Qureg qureg, PauliStrSum sum, qreal angle, int order, int reps)
void applyControlledPhaseGadget(Qureg qureg, int control, int *targets, int numTargets, qreal angle)
void applyMultiControlledPhaseGadget(Qureg qureg, int *controls, int numControls, int *targets, int numTargets, qreal angle)
void applyMultiQubitPhaseShift(Qureg qureg, int *targets, int numTargets, qreal angle)
void applyTwoQubitPhaseShift(Qureg qureg, int target1, int target2, qreal angle)
void applyTwoQubitPhaseFlip(Qureg qureg, int target1, int target2)
void applyMultiStateControlledPhaseGadget(Qureg qureg, int *controls, int *states, int numControls, int *targets, int numTargets, qreal angle)
void applyPhaseShift(Qureg qureg, int target, qreal angle)
void applyPhaseFlip(Qureg qureg, int target)
void multiplyPhaseGadget(Qureg qureg, int *targets, int numTargets, qreal angle)
void applyMultiQubitPhaseFlip(Qureg qureg, int *targets, int numTargets)
void applyPhaseGadget(Qureg qureg, int *targets, int numTargets, qreal angle)
void applyMultiQubitProjector(Qureg qureg, int *qubits, int *outcomes, int numQubits)
void applyQubitProjector(Qureg qureg, int target, int outcome)
void applyFullQuantumFourierTransform(Qureg qureg)
void applyQuantumFourierTransform(Qureg qureg, int *targets, int numTargets)
void applyMultiStateControlledRotateY(Qureg qureg, int *controls, int *states, int numControls, int target, qreal angle)
void applyControlledRotateZ(Qureg qureg, int control, int target, qreal angle)
void applyMultiControlledRotateX(Qureg qureg, int *controls, int numControls, int target, qreal angle)
void applyMultiStateControlledRotateX(Qureg qureg, int *controls, int *states, int numControls, int target, qreal angle)
void applyMultiControlledRotateZ(Qureg qureg, int *controls, int numControls, int target, qreal angle)
void applyRotateAroundAxis(Qureg qureg, int targ, qreal angle, qreal axisX, qreal axisY, qreal axisZ)
void applyMultiStateControlledRotateZ(Qureg qureg, int *controls, int *states, int numControls, int target, qreal angle)
void applyRotateZ(Qureg qureg, int target, qreal angle)
void applyMultiStateControlledRotateAroundAxis(Qureg qureg, int *ctrls, int *states, int numCtrls, int targ, qreal angle, qreal axisX, qreal axisY, qreal axisZ)
void applyControlledRotateX(Qureg qureg, int control, int target, qreal angle)
void applyRotateY(Qureg qureg, int target, qreal angle)
void applyRotateX(Qureg qureg, int target, qreal angle)
void applyMultiControlledRotateAroundAxis(Qureg qureg, int *ctrls, int numCtrls, int targ, qreal angle, qreal axisX, qreal axisY, qreal axisZ)
void applyMultiControlledRotateY(Qureg qureg, int *controls, int numControls, int target, qreal angle)
void applyControlledRotateAroundAxis(Qureg qureg, int ctrl, int targ, qreal angle, qreal axisX, qreal axisY, qreal axisZ)
void applyControlledRotateY(Qureg qureg, int control, int target, qreal angle)
void applyMultiControlledSwap(Qureg qureg, int *controls, int numControls, int qubit1, int qubit2)
void applyControlledSwap(Qureg qureg, int control, int qubit1, int qubit2)
void applyMultiStateControlledSwap(Qureg qureg, int *controls, int *states, int numControls, int qubit1, int qubit2)
void applySwap(Qureg qureg, int qubit1, int qubit2)
void applyControlledSqrtSwap(Qureg qureg, int control, int qubit1, int qubit2)
void multiplySwap(Qureg qureg, int qubit1, int qubit2)
void applySqrtSwap(Qureg qureg, int qubit1, int qubit2)
void applyMultiControlledSqrtSwap(Qureg qureg, int *controls, int numControls, int qubit1, int qubit2)
void applyMultiStateControlledSqrtSwap(Qureg qureg, int *controls, int *states, int numControls, int qubit1, int qubit2)
Definition qureg.h:49