The Quantum Exact Simulation Toolkit v4.1.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 @validationerror
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 @validationerror
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/** @notyetdoced
173 *
174 * Applies a singly-controlled one-qubit dense unitary @p matrix to the specified
175 * @p target qubit of @p qureg.
176 *
177 * @diagram
178 * @dot
179digraph {
180 rankdir=LR;
181 node [fontsize=10, fontname="Menlo"];
182 edge [dir=none];
183
184 topWireL [shape=plaintext, label="control"];
185 topWireR [shape=plaintext, label=""];
186 ctrl [shape=circle, label="", width=.12, style=filled, fillcolor=black];
187
188 topWireL -> ctrl -> topWireR;
189
190 botWireL [shape=plaintext, label="target"];
191 botWireR [shape=plaintext, label=""];
192 gate [shape=box, label="matrix"];
193
194 botWireL -> gate -> botWireR;
195 ctrl -> gate;
196
197 {rank=same; topWireL; botWireL};
198 {rank=same; ctrl; gate};
199 {rank=same; topWireR; botWireR};
200}
201 * @enddot
202 *
203 * @see
204 * - applyCompMatr1()
205 */
206void applyControlledCompMatr1(Qureg qureg, int control, int target, CompMatr1 matrix);
207
208
209/** @notyetdoced
210 *
211 * Applies a multiply-controlled one-qubit dense unitary @p matrix to the specified
212 * @p target qubit of @p qureg.
213 *
214 * @diagram
215 * @dot
216digraph {
217 rankdir=LR;
218 node [fontsize=10, fontname="Menlo"];
219 edge [dir=none];
220
221 trailingCtrl [shape=plaintext, label="..."];
222
223 topWireL [shape=plaintext, label="controls[1]"];
224 topWireR [shape=plaintext, label=""];
225 topCtrl [shape=circle, label="", width=.12, style=filled, fillcolor=black];
226
227 topWireL -> topCtrl -> topWireR;
228
229 midWireL [shape=plaintext, label="controls[0]"];
230 midWireR [shape=plaintext, label=""];
231 midCtrl [shape=circle, label="", width=.12, style=filled, fillcolor=black];
232
233 midWireL -> midCtrl -> midWireR;
234
235 botWireL [shape=plaintext, label="target"];
236 botWireR [shape=plaintext, label=""];
237 gate [shape=box, label="matrix"];
238
239 botWireL -> gate -> botWireR;
240 trailingCtrl -> topCtrl -> midCtrl -> gate;
241
242 {rank=same; topWireL; midWireL; botWireL};
243 {rank=same; trailingCtrl; topCtrl; midCtrl; gate};
244 {rank=same; topWireR; midWireR; botWireR};
245}
246 * @enddot
247 *
248 * @see
249 * - applyCompMatr1()
250 */
251void applyMultiControlledCompMatr1(Qureg qureg, int* controls, int numControls, int target, CompMatr1 matrix);
252
253
254/** @notyetdoced
255 *
256 * Applies an arbitrarily-controlled one-qubit dense unitary @p matrix to the specified
257 * @p target qubit of @p qureg, conditioned upon the @p controls being in the given @p states.
258 *
259 * @diagram
260 * @dot
261digraph {
262 rankdir=LR;
263 node [fontsize=10, fontname="Menlo"];
264 edge [dir=none];
265
266 trailingCtrl [shape=plaintext, label="..."];
267
268 topWireL [shape=plaintext, label="controls[1]"];
269 topWireR [shape=plaintext, label=""];
270 topCtrl [shape=circle, label="", width=.12, style=filled, fillcolor=black];
271
272 topWireL -> topCtrl -> topWireR;
273
274 midWireL [shape=plaintext, label="controls[0]"];
275 midWireR [shape=plaintext, label=""];
276 midCtrl [shape=circle, label="", width=.12, style=filled, fillcolor=white];
277
278 midWireL -> midCtrl -> midWireR;
279
280 botWireL [shape=plaintext, label="target"];
281 botWireR [shape=plaintext, label=""];
282 gate [shape=box, label="matrix"];
283
284 botWireL -> gate -> botWireR;
285 trailingCtrl -> topCtrl -> midCtrl -> gate;
286
287 {rank=same; topWireL; midWireL; botWireL};
288 {rank=same; trailingCtrl; topCtrl; midCtrl; gate};
289 {rank=same; topWireR; midWireR; botWireR};
290}
291 * @enddot
292 *
293 * @see
294 * - applyCompMatr1()
295 */
296void applyMultiStateControlledCompMatr1(Qureg qureg, int* controls, int* states, int numControls, int target, CompMatr1 matrix);
297
298
299// end de-mangler
300#ifdef __cplusplus
301}
302#endif
303
304#ifdef __cplusplus
305
306
307/// @notyettested
308/// @notyetvalidated
309/// @notyetdoced
310/// @cppvectoroverload
311/// @see applyMultiControlledCompMatr1()
312void applyMultiControlledCompMatr1(Qureg qureg, std::vector<int> controls, int target, CompMatr1 matrix);
313
314
315/// @notyettested
316/// @notyetvalidated
317/// @notyetdoced
318/// @cppvectoroverload
319/// @see applyMultiStateControlledCompMatr1()
320void applyMultiStateControlledCompMatr1(Qureg qureg, std::vector<int> controls, std::vector<int> states, int target, CompMatr1 matrix);
321
322
323#endif // __cplusplus
324
325/** @} */
326
327
328
329/**
330 * @defgroup op_compmatr2 CompMatr2
331 * @brief Functions for applying general two-qubit dense matrices, as CompMatr2.
332 * @{
333 */
334
335
336#ifdef __cplusplus
337extern "C" {
338#endif
339
340
341/// @notyetdoced
342/// @see
343/// - applyCompMatr2()
344/// - multiplyCompMatr1()
345void multiplyCompMatr2(Qureg qureg, int target1, int target2, CompMatr2 matr);
346
347
348/** @notyetdoced
349 *
350 * Applies a general two-qubit dense unitary @p matrix to qubits @p target1 and
351 * @p target2 (treated as increasing significance) of @p qureg.
352 *
353 * @diagram
354 * @dot
355digraph {
356 layout=neato;
357 rankdir=LR;
358 node [fontsize=10, fontname="Menlo"];
359 edge [dir=none];
360
361 topWireL [shape=plaintext, pos="0,0!", label="target2"];
362 topWireR [shape=plaintext, pos="2.5,0!", label=""];
363
364 botWireL [shape=plaintext, pos="0,.5!", label="target1"];
365 botWireR [shape=plaintext, pos="2.5,.5!", label=""];
366
367 gate [shape=rectangle, label="matrix", style=filled, fillcolor=white, height=1, pos="1.25,.25!"];
368
369 topWireL -> topWireR;
370 botWireL -> botWireR;
371}
372 * @enddot
373 *
374 * @see
375 * - applyCompMatr1()
376 */
377void applyCompMatr2(Qureg qureg, int target1, int target2, CompMatr2 matrix);
378
379
380/** @notyetdoced
381 *
382 * Applies a singly-controlled two-qubit dense unitary @p matrix to qubits
383 * @p target1 and @p target2 (treated as increasing significance) of @p qureg.
384 *
385 * @diagram
386 * @dot
387digraph {
388 layout=neato;
389 rankdir=LR;
390 node [fontsize=10, fontname="Menlo"];
391 edge [dir=none];
392
393 topWireL [shape=plaintext, pos="0,1!", label="control"];
394 topWireR [shape=plaintext, pos="2.5,1!", label=""];
395
396 midWireL [shape=plaintext, pos="0,0.5!", label="target2"];
397 midWireR [shape=plaintext, pos="2.5,0.5!", label=""];
398
399 botWireL [shape=plaintext, pos="0,0!", label="target1"];
400 botWireR [shape=plaintext, pos="2.5,0!", label=""];
401
402 gate [shape=rectangle, label="matrix", style=filled, fillcolor=white, height=1, pos="1.25,0.25!"];
403 ctrl [shape=circle, label="", width=.12, style=filled, fillcolor=black, pos="1.25,1!"];
404
405 topWireL -> ctrl -> topWireR;
406 midWireL -> midWireR;
407 botWireL -> botWireR;
408 ctrl -> gate;
409}
410 * @enddot
411 *
412 * @see
413 * - applyCompMatr2()
414 */
415void applyControlledCompMatr2(Qureg qureg, int control, int target1, int target2, CompMatr2 matr);
416
417
418/** @notyetdoced
419 *
420 * Applies a multiply-controlled two-qubit dense unitary @p matrix to qubits
421 * @p target1 and @p target2 (treated as increasing significance) of @p qureg.
422 *
423 * @diagram
424 * @dot
425digraph {
426 layout=neato;
427 rankdir=LR;
428 node [fontsize=10, fontname="Menlo"];
429 edge [dir=none];
430
431 tippytopWireL [shape=plaintext, pos="0,1.5!", label="controls[1]"];
432 tippytopWireR [shape=plaintext, pos="2.5,1.5!", label=""];
433
434 topWireL [shape=plaintext, pos="0,1!", label="controls[0]"];
435 topWireR [shape=plaintext, pos="2.5,1!", label=""];
436
437 midWireL [shape=plaintext, pos="0,0.5!", label="target2"];
438 midWireR [shape=plaintext, pos="2.5,0.5!", label=""];
439
440 botWireL [shape=plaintext, pos="0,0!", label="target1"];
441 botWireR [shape=plaintext, pos="2.5,0!", label=""];
442
443 gate [shape=rectangle, label="matrix", style=filled, fillcolor=white, height=1, pos="1.25,0.25!"];
444 ctrl1 [shape=circle, label="", width=.12, style=filled, fillcolor=black, pos="1.25,1!"];
445 ctrl2 [shape=circle, label="", width=.12, style=filled, fillcolor=black, pos="1.25,1.5!"];
446 trailingCtrl [shape=plaintext, label="...", pos="1.25,2!"];
447
448 tippytopWireL -> ctrl2 -> tippytopWireR;
449 topWireL -> ctrl1 -> topWireR;
450 midWireL -> midWireR;
451 botWireL -> botWireR;
452 trailingCtrl -> ctrl2 -> ctrl1 -> gate;
453}
454 * @enddot
455 *
456 * @see
457 * - applyCompMatr2()
458 */
459void applyMultiControlledCompMatr2(Qureg qureg, int* controls, int numControls, int target1, int target2, CompMatr2 matr);
460
461
462/** @notyetdoced
463 *
464 * Applies an arbitrarily-controlled two-qubit dense unitary @p matrix to qubits
465 * @p target1 and @p target2 (treated as increasing significance) of @p qureg,
466 * conditioned upon the @p controls being in the given @p states.
467 *
468 * @diagram
469 * @dot
470digraph {
471 layout=neato;
472 rankdir=LR;
473 node [fontsize=10, fontname="Menlo"];
474 edge [dir=none];
475
476 tippytopWireL [shape=plaintext, pos="0,1.5!", label="controls[1]"];
477 tippytopWireR [shape=plaintext, pos="2.5,1.5!", label=""];
478
479 topWireL [shape=plaintext, pos="0,1!", label="controls[0]"];
480 topWireR [shape=plaintext, pos="2.5,1!", label=""];
481
482 midWireL [shape=plaintext, pos="0,0.5!", label="target2"];
483 midWireR [shape=plaintext, pos="2.5,0.5!", label=""];
484
485 botWireL [shape=plaintext, pos="0,0!", label="target1"];
486 botWireR [shape=plaintext, pos="2.5,0!", label=""];
487
488 gate [shape=rectangle, label="matrix", style=filled, fillcolor=white, height=1, pos="1.25,0.25!"];
489 ctrl1 [shape=circle, label="", width=.12, style=filled, fillcolor=white, pos="1.25,1!"];
490 ctrl2 [shape=circle, label="", width=.12, style=filled, fillcolor=black, pos="1.25,1.5!"];
491 trailingCtrl [shape=plaintext, label="...", pos="1.25,2!"];
492
493 tippytopWireL -> ctrl2 -> tippytopWireR;
494 topWireL -> ctrl1 -> topWireR;
495 midWireL -> midWireR;
496 botWireL -> botWireR;
497 trailingCtrl -> ctrl2 -> ctrl1 -> gate;
498}
499 * @enddot
500 *
501 * @see
502 * - applyCompMatr2()
503 * - applyMultiStateControlledCompMatr1()
504 */
505void applyMultiStateControlledCompMatr2(Qureg qureg, int* controls, int* states, int numControls, int target1, int target2, CompMatr2 matr);
506
507
508// end de-mangler
509#ifdef __cplusplus
510}
511#endif
512
513#ifdef __cplusplus
514
515
516/// @notyettested
517/// @notyetvalidated
518/// @notyetdoced
519/// @cppvectoroverload
520/// @see applyMultiControlledCompMatr2()
521void applyMultiControlledCompMatr2(Qureg qureg, std::vector<int> controls, int target1, int target2, CompMatr2 matr);
522
523
524/// @notyettested
525/// @notyetvalidated
526/// @notyetdoced
527/// @cppvectoroverload
528/// @see applyMultiStateControlledCompMatr2()
529void applyMultiStateControlledCompMatr2(Qureg qureg, std::vector<int> controls, std::vector<int> states, int numControls, int target1, int target2, CompMatr2 matr);
530
531
532#endif // __cplusplus
533
534/** @} */
535
536
537
538/**
539 * @defgroup op_compmatr CompMatr
540 * @brief Functions for applying general many-target dense matrices, as CompMatr.
541 * @{
542 */
543
544
545#ifdef __cplusplus
546extern "C" {
547#endif
548
549
550/** @notyetdoced
551 *
552 * @see
553 * - applyCompMatr()
554 * - multiplyCompMatr1()
555 */
556void multiplyCompMatr(Qureg qureg, int* targets, int numTargets, CompMatr matrix);
557
558
559/** @notyetdoced
560 *
561 * @formulae
562 *
563 * Let @f$ M = @f$ @p matrix.
564 * The qubits within @p targets are treated to be ordered least to most significant with respect
565 * to @f$ M @f$. That is, if @f$ M @f$ was hypothetically separable single-qubit matrices
566 * @f[
567 M \equiv A \otimes B \otimes C \otimes \dots
568 * @f]
569 * then this function would effect
570 * @f[
571 \hat{M}_{\text{targets}} \equiv A_{\text{targets}[0]} B_{\text{targets}[1]} C_{\text{targets}[2]} \dots
572 * @f]
573 *
574 * @see
575 * - applyCompMatr1()
576 */
577void applyCompMatr(Qureg qureg, int* targets, int numTargets, CompMatr matr);
578
579
580/// @notyetdoced
581/// @see
582/// - applyControlledCompMatr1()
583void applyControlledCompMatr(Qureg qureg, int control, int* targets, int numTargets, CompMatr matr);
584
585
586/// @notyetdoced
587/// @see
588/// - applyMultiControlledCompMatr1()
589void applyMultiControlledCompMatr(Qureg qureg, int* controls, int numControls, int* targets, int numTargets, CompMatr matr);
590
591
592/// @notyetdoced
593/// @see
594/// - applyMultiStateControlledCompMatr1()
595void applyMultiStateControlledCompMatr(Qureg qureg, int* controls, int* states, int numControls, int* targets, int numTargets, CompMatr matr);
596
597
598// end de-mangler
599#ifdef __cplusplus
600}
601#endif
602
603#ifdef __cplusplus
604
605
606/// @notyettested
607/// @notyetvalidated
608/// @notyetdoced
609/// @cppvectoroverload
610/// @see multiplyCompMatr()
611void multiplyCompMatr(Qureg qureg, std::vector<int> targets, CompMatr matr);
612
613
614/// @notyettested
615/// @notyetvalidated
616/// @notyetdoced
617/// @cppvectoroverload
618/// @see applyCompMatr()
619void applyCompMatr(Qureg qureg, std::vector<int> targets, CompMatr matr);
620
621
622/// @notyettested
623/// @notyetvalidated
624/// @notyetdoced
625/// @cppvectoroverload
626/// @see applyControlledCompMatr()
627void applyControlledCompMatr(Qureg qureg, int control, std::vector<int> targets, CompMatr matr);
628
629
630/// @notyettested
631/// @notyetvalidated
632/// @notyetdoced
633/// @cppvectoroverload
634/// @see applyMultiControlledCompMatr()
635void applyMultiControlledCompMatr(Qureg qureg, std::vector<int> controls, std::vector<int> targets, CompMatr matr);
636
637
638/// @notyettested
639/// @notyetvalidated
640/// @notyetdoced
641/// @cppvectoroverload
642/// @see applyMultiStateControlledCompMatr()
643void applyMultiStateControlledCompMatr(Qureg qureg, std::vector<int> controls, std::vector<int> states, std::vector<int> targets, CompMatr matr);
644
645
646#endif // __cplusplus
647
648/** @} */
649
650
651
652/**
653 * @defgroup op_diagmatr1 DiagMatr1
654 * @brief Functions for applying general one-qubit diagonal matrices, as DiagMatr1.
655 * @{
656 */
657
658
659#ifdef __cplusplus
660extern "C" {
661#endif
662
663
664/// @notyetdoced
665/// @see multiplyCompMatr1()
666void multiplyDiagMatr1(Qureg qureg, int target, DiagMatr1 matr);
667
668
669/// @notyetdoced
670/// @see applyCompMatr1()
671void applyDiagMatr1(Qureg qureg, int target, DiagMatr1 matr);
672
673
674/// @notyetdoced
675/// @see applyControlledCompMatr1()
676void applyControlledDiagMatr1(Qureg qureg, int control, int target, DiagMatr1 matr);
677
678
679/// @notyetdoced
680/// @see applyMultiControlledCompMatr1()
681void applyMultiControlledDiagMatr1(Qureg qureg, int* controls, int numControls, int target, DiagMatr1 matr);
682
683
684/// @notyetdoced
685/// @see applyMultiStateControlledCompMatr1()
686void applyMultiStateControlledDiagMatr1(Qureg qureg, int* controls, int* states, int numControls, int target, DiagMatr1 matr);
687
688
689// end de-mangler
690#ifdef __cplusplus
691}
692#endif
693
694#ifdef __cplusplus
695
696
697/// @notyettested
698/// @notyetvalidated
699/// @notyetdoced
700/// @cppvectoroverload
701/// @see applyMultiControlledDiagMatr1()
702void applyMultiControlledDiagMatr1(Qureg qureg, std::vector<int> controls, int target, DiagMatr1 matr);
703
704
705/// @notyettested
706/// @notyetvalidated
707/// @notyetdoced
708/// @cppvectoroverload
709/// @see applyMultiStateControlledDiagMatr1()
710void applyMultiStateControlledDiagMatr1(Qureg qureg, std::vector<int> controls, std::vector<int> states, int target, DiagMatr1 matr);
711
712
713#endif // __cplusplus
714
715/** @} */
716
717
718
719/**
720 * @defgroup op_diagmatr2 DiagMatr2
721 * @brief Functions for applying general two-qubit diagonal matrices, as DiagMatr2.
722 * @{
723 */
724
725
726#ifdef __cplusplus
727extern "C" {
728#endif
729
730
731/// @notyetdoced
732/// @see multiplyCompMatr1()
733void multiplyDiagMatr2(Qureg qureg, int target1, int target2, DiagMatr2 matr);
734
735
736/// @notyetdoced
737/// @see applyCompMatr1()
738void applyDiagMatr2(Qureg qureg, int target1, int target2, DiagMatr2 matr);
739
740
741/// @notyetdoced
742/// @see applyControlledCompMatr1()
743void applyControlledDiagMatr2(Qureg qureg, int control, int target1, int target2, DiagMatr2 matr);
744
745
746/// @notyetdoced
747/// @see applyMultiControlledCompMatr1()
748void applyMultiControlledDiagMatr2(Qureg qureg, int* controls, int numControls, int target1, int target2, DiagMatr2 matr);
749
750
751/// @notyetdoced
752/// @see applyMultiStateControlledCompMatr1()
753void applyMultiStateControlledDiagMatr2(Qureg qureg, int* controls, int* states, int numControls, int target1, int target2, DiagMatr2 matr);
754
755
756// end de-mangler
757#ifdef __cplusplus
758}
759#endif
760
761#ifdef __cplusplus
762
763
764/// @notyettested
765/// @notyetvalidated
766/// @notyetdoced
767/// @cppvectoroverload
768/// @see applyMultiControlledDiagMatr2()
769void applyMultiControlledDiagMatr2(Qureg qureg, std::vector<int> controls, int target1, int target2, DiagMatr2 matr);
770
771
772/// @notyettested
773/// @notyetvalidated
774/// @notyetdoced
775/// @cppvectoroverload
776/// @see applyMultiStateControlledDiagMatr2()
777void applyMultiStateControlledDiagMatr2(Qureg qureg, std::vector<int> controls, std::vector<int> states, int target1, int target2, DiagMatr2 matr);
778
779
780#endif // __cplusplus
781
782/** @} */
783
784
785
786/**
787 * @defgroup op_diagmatr DiagMatr
788 * @brief Functions for applying general many-qubit diagonal matrices, as DiagMatr.
789 * @{
790 */
791
792
793#ifdef __cplusplus
794extern "C" {
795#endif
796
797
798/// @notyetdoced
799/// @see multiplyCompMatr1()
800void multiplyDiagMatr(Qureg qureg, int* targets, int numTargets, DiagMatr matrix);
801
802
803/// @notyetdoced
804/// @see applyCompMatr1()
805void applyDiagMatr(Qureg qureg, int* targets, int numTargets, DiagMatr matrix);
806
807
808/// @notyetdoced
809/// @see applyControlledCompMatr1()
810void applyControlledDiagMatr(Qureg qureg, int control, int* targets, int numTargets, DiagMatr matrix);
811
812
813/// @notyetdoced
814/// @see applyMultiControlledCompMatr1()
815void applyMultiControlledDiagMatr(Qureg qureg, int* controls, int numControls, int* targets, int numTargets, DiagMatr matrix);
816
817
818/// @notyetdoced
819/// @see applyMultiStateControlledCompMatr1()
820void applyMultiStateControlledDiagMatr(Qureg qureg, int* controls, int* states, int numControls, int* targets, int numTargets, DiagMatr matrix);
821
822
823/// @notyetdoced
824/// @see
825/// - multiplyCompMatr1()
826/// - applyDiagMatrPower()
827void multiplyDiagMatrPower(Qureg qureg, int* targets, int numTargets, DiagMatr matrix, qcomp exponent);
828
829
830/** @notyetdoced
831 *
832 * @formulae
833 *
834 * This function is equivalent to applyDiagMatr() except that @p matrix is raised to the given @p exponent.
835 */
836void applyDiagMatrPower(Qureg qureg, int* targets, int numTargets, DiagMatr matrix, qcomp exponent);
837
838
839/// @notyetdoced
840/// @see
841/// - applyDiagMatrPower()
842/// - applyControlledCompMatr1()
843void applyControlledDiagMatrPower(Qureg qureg, int control, int* targets, int numTargets, DiagMatr matrix, qcomp exponent);
844
845
846/// @notyetdoced
847/// @see
848/// - applyDiagMatrPower()
849/// - applyMultiControlledCompMatr1()
850void applyMultiControlledDiagMatrPower(Qureg qureg, int* controls, int numControls, int* targets, int numTargets, DiagMatr matrix, qcomp exponent);
851
852
853/// @notyetdoced
854/// @see
855/// - applyDiagMatrPower()
856/// - applyMultiStateControlledCompMatr1()
857void applyMultiStateControlledDiagMatrPower(Qureg qureg, int* controls, int* states, int numControls, int* targets, int numTargets, DiagMatr matrix, qcomp exponent);
858
859
860// end de-mangler
861#ifdef __cplusplus
862}
863#endif
864
865#ifdef __cplusplus
866
867
868/// @notyettested
869/// @notyetvalidated
870/// @notyetdoced
871/// @cppvectoroverload
872/// @see multiplyDiagMatr()
873void multiplyDiagMatr(Qureg qureg, std::vector<int> targets, DiagMatr matrix);
874
875
876/// @notyettested
877/// @notyetvalidated
878/// @notyetdoced
879/// @cppvectoroverload
880/// @see applyDiagMatr()
881void applyDiagMatr(Qureg qureg, std::vector<int> targets, DiagMatr matrix);
882
883
884/// @notyettested
885/// @notyetvalidated
886/// @notyetdoced
887/// @cppvectoroverload
888/// @see applyControlledDiagMatr()
889void applyControlledDiagMatr(Qureg qureg, int control, std::vector<int> targets, DiagMatr matrix);
890
891
892/// @notyettested
893/// @notyetvalidated
894/// @notyetdoced
895/// @cppvectoroverload
896/// @see applyMultiControlledDiagMatr()
897void applyMultiControlledDiagMatr(Qureg qureg, std::vector<int> controls, std::vector<int> targets, DiagMatr matrix);
898
899
900/// @notyettested
901/// @notyetvalidated
902/// @notyetdoced
903/// @cppvectoroverload
904/// @see applyMultiStateControlledDiagMatr()
905void applyMultiStateControlledDiagMatr(Qureg qureg, std::vector<int> controls, std::vector<int> states, std::vector<int> targets, DiagMatr matrix);
906
907
908/// @notyettested
909/// @notyetvalidated
910/// @notyetdoced
911/// @cppvectoroverload
912/// @see multiplyDiagMatrPower()
913void multiplyDiagMatrPower(Qureg qureg, std::vector<int> targets, DiagMatr matrix, qcomp exponent);
914
915
916/// @notyettested
917/// @notyetvalidated
918/// @notyetdoced
919/// @cppvectoroverload
920/// @see applyDiagMatrPower()
921void applyDiagMatrPower(Qureg qureg, std::vector<int> targets, DiagMatr matrix, qcomp exponent);
922
923
924/// @notyettested
925/// @notyetvalidated
926/// @notyetdoced
927/// @cppvectoroverload
928/// @see applyControlledDiagMatrPower()
929void applyControlledDiagMatrPower(Qureg qureg, int control, std::vector<int> targets, DiagMatr matrix, qcomp exponent);
930
931
932/// @notyettested
933/// @notyetvalidated
934/// @notyetdoced
935/// @cppvectoroverload
936/// @see applyMultiControlledDiagMatrPower()
937void applyMultiControlledDiagMatrPower(Qureg qureg, std::vector<int> controls, std::vector<int> targets, DiagMatr matrix, qcomp exponent);
938
939
940/// @notyettested
941/// @notyetvalidated
942/// @notyetdoced
943/// @cppvectoroverload
944/// @see applyMultiStateControlledDiagMatrPower()
945void applyMultiStateControlledDiagMatrPower(Qureg qureg, std::vector<int> controls, std::vector<int> states, std::vector<int> targets, DiagMatr matrix, qcomp exponent);
946
947
948#endif // __cplusplus
949
950/** @} */
951
952
953
954/**
955 * @defgroup op_fullstatediagmatr FullStateDiagMatr
956 * @brief Functions for applying general all-qubit diagonal matrices, as FullStateDiagMatr.
957 * @{
958 */
959
960
961#ifdef __cplusplus
962extern "C" {
963#endif
964
965
966/// @notyetdoced
967/// @notyetvalidated
968/// @see
969/// - multiplyCompMatr1
971
972
973/// @notyetdoced
974/// @notyetvalidated
975/// @see
976/// - multiplyCompMatr1
977/// - applyDiagMatrPower
978void multiplyFullStateDiagMatrPower(Qureg qureg, FullStateDiagMatr matrix, qcomp exponent);
979
980
981/// @notyetdoced
982/// @notyetvalidated
984
985
986/// @notyetdoced
987/// @notyetvalidated
988/// @see
989/// - applyDiagMatrPower
990void applyFullStateDiagMatrPower(Qureg qureg, FullStateDiagMatr matrix, qcomp exponent);
991
992
993// end de-mangler
994#ifdef __cplusplus
995}
996#endif
997
998
999/** @} */
1000
1001
1002
1003/**
1004 * @defgroup op_fixed Fixed
1005 * @brief Functions for applying the one-qubit S, T and Hadamard gates.
1006 * @{
1007 */
1008
1009
1010#ifdef __cplusplus
1011extern "C" {
1012#endif
1013
1014
1015/// @notyetdoced
1016void applyS(Qureg qureg, int target);
1017
1018
1019/// @notyetdoced
1020void applyControlledS(Qureg qureg, int control, int target);
1021
1022
1023/// @notyetdoced
1024void applyMultiControlledS(Qureg qureg, int* controls, int numControls, int target);
1025
1026
1027/// @notyetdoced
1028/// @see applyMultiStateControlledCompMatr1()
1029void applyMultiStateControlledS(Qureg qureg, int* controls, int* states, int numControls, int target);
1030
1031
1032/// @notyetdoced
1033void applyT(Qureg qureg, int target);
1034
1035
1036/// @notyetdoced
1037void applyControlledT(Qureg qureg, int control, int target);
1038
1039
1040/// @notyetdoced
1041void applyMultiControlledT(Qureg qureg, int* controls, int numControls, int target);
1042
1043
1044/// @notyetdoced
1045/// @see applyMultiStateControlledCompMatr1()
1046void applyMultiStateControlledT(Qureg qureg, int* controls, int* states, int numControls, int target);
1047
1048
1049/// @notyetdoced
1050void applyHadamard(Qureg qureg, int target);
1051
1052
1053/// @notyetdoced
1054void applyControlledHadamard(Qureg qureg, int control, int target);
1055
1056
1057/// @notyetdoced
1058void applyMultiControlledHadamard(Qureg qureg, int* controls, int numControls, int target);
1059
1060
1061/// @notyetdoced
1062/// @see applyMultiStateControlledCompMatr1()
1063void applyMultiStateControlledHadamard(Qureg qureg, int* controls, int* states, int numControls, int target);
1064
1065
1066// end de-mangler
1067#ifdef __cplusplus
1068}
1069#endif
1070
1071#ifdef __cplusplus
1072
1073
1074/// @notyettested
1075/// @notyetvalidated
1076/// @notyetdoced
1077/// @cppvectoroverload
1078/// @see applyMultiControlledS()
1079void applyMultiControlledS(Qureg qureg, std::vector<int> controls, int target);
1080
1081
1082/// @notyettested
1083/// @notyetvalidated
1084/// @notyetdoced
1085/// @cppvectoroverload
1086/// @see applyMultiStateControlledS()
1087void applyMultiStateControlledS(Qureg qureg, std::vector<int> controls, std::vector<int> states, int target);
1088
1089
1090/// @notyettested
1091/// @notyetvalidated
1092/// @notyetdoced
1093/// @cppvectoroverload
1094/// @see applyMultiControlledT()
1095void applyMultiControlledT(Qureg qureg, std::vector<int> controls, int target);
1096
1097
1098/// @notyettested
1099/// @notyetvalidated
1100/// @notyetdoced
1101/// @cppvectoroverload
1102/// @see applyMultiStateControlledT()
1103void applyMultiStateControlledT(Qureg qureg, std::vector<int> controls, std::vector<int> states, int target);
1104
1105
1106/// @notyettested
1107/// @notyetvalidated
1108/// @notyetdoced
1109/// @cppvectoroverload
1110/// @see applyMultiControlledHadamard()
1111void applyMultiControlledHadamard(Qureg qureg, std::vector<int> controls, int target);
1112
1113
1114/// @notyettested
1115/// @notyetvalidated
1116/// @notyetdoced
1117/// @cppvectoroverload
1118/// @see applyMultiStateControlledHadamard()
1119void applyMultiStateControlledHadamard(Qureg qureg, std::vector<int> controls, std::vector<int> states, int target);
1120
1121
1122#endif // __cplusplus
1123
1124/** @} */
1125
1126
1127
1128/**
1129 * @defgroup op_swap Swap
1130 * @brief Functions for applying the two-qubit SWAP and related gates.
1131 * @{
1132 */
1133
1134
1135#ifdef __cplusplus
1136extern "C" {
1137#endif
1138
1139
1140/// @notyetdoced
1141/// @see multiplyCompMatr1()
1142void multiplySwap(Qureg qureg, int qubit1, int qubit2);
1143
1144
1145/** Applies a SWAP gate between @p qubit1 and @p qubit2 of @p qureg.
1146 *
1147 * @diagram
1148 * @dot
1149digraph {
1150 rankdir=LR;
1151 layout=neato;
1152 node [fontsize=10, fontname="Menlo"];
1153 edge [dir=none];
1154
1155 topWireL [shape=plaintext, label="qubit2", pos="0,.5!"];
1156 topWireM [shape=point, label="", width=0, pos=".75,.5!"];
1157 topWireR [shape=plaintext, label="", pos="1.5,.5!"];
1158
1159 botWireL [shape=plaintext, label="qubit1", pos="0,0!"];
1160 botWireM [shape=point, label="", width=0, pos=".75,0!"];
1161 botWireR [shape=plaintext, label="", pos="1.5,0!"];
1162
1163 topWireL -> topWireR;
1164 botWireL -> botWireR;
1165 botWireM -> topWireM;
1166
1167 topX [shape=plaintext, label="✕", pos=".75,.5!", fontsize=15];
1168 botX [shape=plaintext, label="✕", pos=".75,0!", fontsize=15];
1169}
1170 * @enddot
1171 *
1172 * @notyetdoced
1173 */
1174void applySwap(Qureg qureg, int qubit1, int qubit2);
1175
1176
1177/// @notyetdoced
1178void applyControlledSwap(Qureg qureg, int control, int qubit1, int qubit2);
1179
1180
1181/// @notyetdoced
1182void applyMultiControlledSwap(Qureg qureg, int* controls, int numControls, int qubit1, int qubit2);
1183
1184
1185/// @notyetdoced
1186/// @see applyMultiStateControlledCompMatr1()
1187void applyMultiStateControlledSwap(Qureg qureg, int* controls, int* states, int numControls, int qubit1, int qubit2);
1188
1189
1190/// @notyetdoced
1191void applySqrtSwap(Qureg qureg, int qubit1, int qubit2);
1192
1193
1194/// @notyetdoced
1195void applyControlledSqrtSwap(Qureg qureg, int control, int qubit1, int qubit2);
1196
1197
1198/// @notyetdoced
1199void applyMultiControlledSqrtSwap(Qureg qureg, int* controls, int numControls, int qubit1, int qubit2);
1200
1201
1202/// @notyetdoced
1203/// @see applyMultiStateControlledCompMatr1()
1204void applyMultiStateControlledSqrtSwap(Qureg qureg, int* controls, int* states, int numControls, int qubit1, int qubit2);
1205
1206
1207// end de-mangler
1208#ifdef __cplusplus
1209}
1210#endif
1211
1212#ifdef __cplusplus
1213
1214
1215/// @notyettested
1216/// @notyetvalidated
1217/// @notyetdoced
1218/// @cppvectoroverload
1219/// @see applyMultiControlledSwap()
1220void applyMultiControlledSwap(Qureg qureg, std::vector<int> controls, int qubit1, int qubit2);
1221
1222
1223/// @notyettested
1224/// @notyetvalidated
1225/// @notyetdoced
1226/// @cppvectoroverload
1227/// @see applyMultiStateControlledSwap()
1228void applyMultiStateControlledSwap(Qureg qureg, std::vector<int> controls, std::vector<int> states, int qubit1, int qubit2);
1229
1230
1231/// @notyettested
1232/// @notyetvalidated
1233/// @notyetdoced
1234/// @cppvectoroverload
1235/// @see applyMultiControlledSqrtSwap()
1236void applyMultiControlledSqrtSwap(Qureg qureg, std::vector<int> controls, int qubit1, int qubit2);
1237
1238
1239/// @notyettested
1240/// @notyetvalidated
1241/// @notyetdoced
1242/// @cppvectoroverload
1243/// @see applyMultiStateControlledSqrtSwap()
1244void applyMultiStateControlledSqrtSwap(Qureg qureg, std::vector<int> controls, std::vector<int> states, int numControls, int qubit1, int qubit2);
1245
1246
1247#endif // __cplusplus
1248
1249/** @} */
1250
1251
1252
1253/**
1254 * @defgroup op_pauli Pauli
1255 * @brief Functions for applying the individual one-qubit Pauli operators.
1256 * @{
1257 */
1258
1259
1260#ifdef __cplusplus
1261extern "C" {
1262#endif
1263
1264
1265/// @notyetdoced
1266/// @see multiplyCompMatr1()
1267void multiplyPauliX(Qureg qureg, int target);
1268
1269
1270/// @notyetdoced
1271/// @see multiplyCompMatr1()
1272void multiplyPauliY(Qureg qureg, int target);
1273
1274
1275/// @notyetdoced
1276/// @see multiplyCompMatr1()
1277void multiplyPauliZ(Qureg qureg, int target);
1278
1279
1280/// @notyetdoced
1281void applyPauliX(Qureg qureg, int target);
1282
1283
1284/// @notyetdoced
1285void applyPauliY(Qureg qureg, int target);
1286
1287
1288/// @notyetdoced
1289void applyPauliZ(Qureg qureg, int target);
1290
1291
1292/// @notyetdoced
1293void applyControlledPauliX(Qureg qureg, int control, int target);
1294
1295
1296/// @notyetdoced
1297void applyControlledPauliY(Qureg qureg, int control, int target);
1298
1299
1300/// @notyetdoced
1301void applyControlledPauliZ(Qureg qureg, int control, int target);
1302
1303
1304/// @notyetdoced
1305void applyMultiControlledPauliX(Qureg qureg, int* controls, int numControls, int target);
1306
1307
1308/// @notyetdoced
1309void applyMultiControlledPauliY(Qureg qureg, int* controls, int numControls, int target);
1310
1311
1312/// @notyetdoced
1313void applyMultiControlledPauliZ(Qureg qureg, int* controls, int numControls, int target);
1314
1315
1316/// @notyetdoced
1317/// @see applyMultiStateControlledCompMatr1()
1318void applyMultiStateControlledPauliX(Qureg qureg, int* controls, int* states, int numControls, int target);
1319
1320
1321/// @notyetdoced
1322/// @see applyMultiStateControlledCompMatr1()
1323void applyMultiStateControlledPauliY(Qureg qureg, int* controls, int* states, int numControls, int target);
1324
1325
1326/// @notyetdoced
1327/// @see applyMultiStateControlledCompMatr1()
1328void applyMultiStateControlledPauliZ(Qureg qureg, int* controls, int* states, int numControls, int target);
1329
1330
1331// end de-mangler
1332#ifdef __cplusplus
1333}
1334#endif
1335
1336#ifdef __cplusplus
1337
1338
1339/// @notyettested
1340/// @notyetvalidated
1341/// @notyetdoced
1342/// @cppvectoroverload
1343/// @see applyMultiControlledPauliX()
1344void applyMultiControlledPauliX(Qureg qureg, std::vector<int> controls, int target);
1345
1346
1347/// @notyettested
1348/// @notyetvalidated
1349/// @notyetdoced
1350/// @cppvectoroverload
1351/// @see applyMultiControlledPauliY()
1352void applyMultiControlledPauliY(Qureg qureg, std::vector<int> controls, int target);
1353
1354
1355/// @notyettested
1356/// @notyetvalidated
1357/// @notyetdoced
1358/// @cppvectoroverload
1359/// @see applyMultiControlledPauliZ()
1360void applyMultiControlledPauliZ(Qureg qureg, std::vector<int> controls, int target);
1361
1362
1363/// @notyettested
1364/// @notyetvalidated
1365/// @notyetdoced
1366/// @cppvectoroverload
1367/// @see applyMultiStateControlledPauliX()
1368void applyMultiStateControlledPauliX(Qureg qureg, std::vector<int> controls, std::vector<int> states, int target);
1369
1370
1371/// @notyettested
1372/// @notyetvalidated
1373/// @notyetdoced
1374/// @cppvectoroverload
1375/// @see applyMultiStateControlledPauliY()
1376void applyMultiStateControlledPauliY(Qureg qureg, std::vector<int> controls, std::vector<int> states, int target);
1377
1378
1379/// @notyettested
1380/// @notyetvalidated
1381/// @notyetdoced
1382/// @cppvectoroverload
1383/// @see applyMultiStateControlledPauliZ()
1384void applyMultiStateControlledPauliZ(Qureg qureg, std::vector<int> controls, std::vector<int> states, int target);
1385
1386
1387#endif // __cplusplus
1388
1389/** @} */
1390
1391
1392
1393/**
1394 * @defgroup op_paulistr PauliStr
1395 * @brief Functions for applying a tensor product of Pauli operators, as a PauliStr
1396 * @{
1397 */
1398
1399
1400#ifdef __cplusplus
1401extern "C" {
1402#endif
1403
1404
1405/// @notyetdoced
1406/// @see multiplyCompMatr1()
1407void multiplyPauliStr(Qureg qureg, PauliStr str);
1408
1409
1410/// @notyetdoced
1411void applyPauliStr(Qureg qureg, PauliStr str);
1412
1413
1414/// @notyetdoced
1415void applyControlledPauliStr(Qureg qureg, int control, PauliStr str);
1416
1417
1418/// @notyetdoced
1419void applyMultiControlledPauliStr(Qureg qureg, int* controls, int numControls, PauliStr str);
1420
1421
1422/// @notyetdoced
1423/// @see applyMultiStateControlledCompMatr1()
1424void applyMultiStateControlledPauliStr(Qureg qureg, int* controls, int* states, int numControls, PauliStr str);
1425
1426
1427// end de-mangler
1428#ifdef __cplusplus
1429}
1430#endif
1431
1432#ifdef __cplusplus
1433
1434
1435/// @notyettested
1436/// @notyetvalidated
1437/// @notyetdoced
1438/// @cppvectoroverload
1439/// @see applyMultiControlledPauliStr()
1440void applyMultiControlledPauliStr(Qureg qureg, std::vector<int> controls, PauliStr str);
1441
1442
1443/// @notyettested
1444/// @notyetvalidated
1445/// @notyetdoced
1446/// @cppvectoroverload
1447/// @see applyMultiStateControlledPauliStr()
1448void applyMultiStateControlledPauliStr(Qureg qureg, std::vector<int> controls, std::vector<int> states, PauliStr str);
1449
1450
1451#endif // __cplusplus
1452
1453/** @} */
1454
1455
1456
1457/**
1458 * @defgroup op_rotation Rotations
1459 * @brief Functions for applying one-qubit rotations around Pauli and arbitrary axis.
1460 * @{
1461 */
1462
1463
1464#ifdef __cplusplus
1465extern "C" {
1466#endif
1467
1468
1469/** @notyetdoced
1470 *
1471 * @formulae
1472 *
1473 * Let @f$ \theta = @f$ @p angle.
1474 * This function effects unitary
1475 * @f[
1476 \hat{R}_{x}(\theta)
1477 =
1478 \exp \left(
1479 - \iu \frac{\theta}{2}
1480 \hat{\sigma}_x
1481 \right)
1482 * @f]
1483 * upon the @p target qubit, where @f$ \hat{\sigma}_x @f$ is the Pauli X matrix.
1484 *
1485 * @equivalences
1486 * - This function is entirely equivalent to calling applyPauliGadget() with a single-site PauliStr.
1487 * ```
1488 applyPauliGadget(qureg, getInlinePauliStr("X", {target}), angle);
1489 * ```
1490 * - This function is faster than, but otherwise equivalent to, invoking applyRotateAroundAxis()
1491 * with an axis vector equal to the X-axis.
1492 * ```
1493 applyRotateAroundAxis(qureg, target, qreal angle, 1,0,0);
1494 * ```
1495 * - This function is faster than, but otherwise equivalent to, effecting @f$ \hat{R}_{x}(\theta) @f$ as a CompMatr1.
1496 * ```
1497 qcomp c = cos(angle/2);
1498 qcomp s = sin(angle/2) * (-1.i);
1499 CompMatr1 matr = getInlineCompMatr1({{c, s}, {s, c}});
1500 applyCompMatr1(qureg, target, matr);
1501 * ```
1502 * - Passing @p angle=0 is equivalent to effecting the identity, leaving the state unchanged.
1503 */
1504void applyRotateX(Qureg qureg, int target, qreal angle);
1505
1506
1507/** @notyetdoced
1508 *
1509 * @formulae
1510 *
1511 * Let @f$ \theta = @f$ @p angle.
1512 * This function effects unitary
1513 * @f[
1514 \hat{R}_{y}(\theta)
1515 =
1516 \exp \left(
1517 - \iu \frac{\theta}{2}
1518 \hat{\sigma}_y
1519 \right)
1520 * @f]
1521 * upon the @p target qubit, where @f$ \hat{\sigma}_y @f$ is the Pauli Y matrix.
1522 *
1523 * @equivalences
1524 * - This function is entirely equivalent to calling applyPauliGadget() with a single-site PauliStr.
1525 * ```
1526 applyPauliGadget(qureg, getInlinePauliStr("Y", {target}), angle);
1527 * ```
1528 * - This function is faster than, but otherwise equivalent to, invoking applyRotateAroundAxis()
1529 * with an axis vector equal to the Y-axis.
1530 * ```
1531 applyRotateAroundAxis(qureg, target, qreal angle, 0,1,0);
1532 * ```
1533 * - This function is faster than, but otherwise equivalent to, effecting @f$ \hat{R}_{y}(\theta) @f$ as a CompMatr1.
1534 * ```
1535 qcomp c = cos(angle/2);
1536 qcomp s = sin(angle/2);
1537 CompMatr1 matr = getInlineCompMatr1({{c, -s}, {s, c}});
1538 applyCompMatr1(qureg, target, matr);
1539 * ```
1540 * - Passing @p angle=0 is equivalent to effecting the identity, leaving the state unchanged.
1541 */
1542void applyRotateY(Qureg qureg, int target, qreal angle);
1543
1544
1545/** @notyetdoced
1546 *
1547 * @formulae
1548 *
1549 * Let @f$ \theta = @f$ @p angle.
1550 * This function effects unitary
1551 * @f[
1552 \hat{R}_{z}(\theta)
1553 =
1554 \exp \left(
1555 - \iu \frac{\theta}{2}
1556 \hat{\sigma}_z
1557 \right)
1558 * @f]
1559 * upon the @p target qubit, where @f$ \hat{\sigma}_z @f$ is the Pauli Z matrix.
1560 *
1561 * @equivalences
1562 * - This function is entirely equivalent to calling applyPauliGadget() with a single-site PauliStr.
1563 * ```
1564 applyPauliGadget(qureg, getInlinePauliStr("Z", {target}), angle);
1565 * ```
1566 * - This function is faster than, but otherwise equivalent to, invoking applyRotateAroundAxis()
1567 * with an axis vector equal to the Z-axis.
1568 * ```
1569 applyRotateAroundAxis(qureg, target, qreal angle, 0,0,1);
1570 * ```
1571 * - This function is faster than, but otherwise equivalent to, effecting @f$ \hat{R}_{z}(\theta) @f$ as a DiagMatr1.
1572 * ```
1573 qcomp a = cexp(- angle / 2 * 1.i);
1574 qcomp b = cexp( angle / 2 * 1.i);
1575 DiagMatr1 matr = getInlineDiagMatr1({a, b});
1576 applyDiagMatr1(qureg, target, matr);
1577 * ```
1578 * - Passing @p angle=0 is equivalent to effecting the identity, leaving the state unchanged.
1579 */
1580void applyRotateZ(Qureg qureg, int target, qreal angle);
1581
1582
1583/// @notyetdoced
1584void applyControlledRotateX(Qureg qureg, int control, int target, qreal angle);
1585
1586
1587/// @notyetdoced
1588void applyControlledRotateY(Qureg qureg, int control, int target, qreal angle);
1589
1590
1591/// @notyetdoced
1592void applyControlledRotateZ(Qureg qureg, int control, int target, qreal angle);
1593
1594
1595/// @notyetdoced
1596void applyMultiControlledRotateX(Qureg qureg, int* controls, int numControls, int target, qreal angle);
1597
1598
1599/// @notyetdoced
1600void applyMultiControlledRotateY(Qureg qureg, int* controls, int numControls, int target, qreal angle);
1601
1602
1603/// @notyetdoced
1604void applyMultiControlledRotateZ(Qureg qureg, int* controls, int numControls, int target, qreal angle);
1605
1606
1607/// @notyetdoced
1608/// @see
1609/// - applyRotateX()
1610/// - applyMultiStateControlledCompMatr1()
1611void applyMultiStateControlledRotateX(Qureg qureg, int* controls, int* states, int numControls, int target, qreal angle);
1612
1613
1614/// @notyetdoced
1615/// @see
1616/// - applyRotateY()
1617/// - applyMultiStateControlledCompMatr1()
1618void applyMultiStateControlledRotateY(Qureg qureg, int* controls, int* states, int numControls, int target, qreal angle);
1619
1620
1621/// @notyetdoced
1622/// @see
1623/// - applyRotateZ()
1624/// - applyMultiStateControlledCompMatr1()
1625void applyMultiStateControlledRotateZ(Qureg qureg, int* controls, int* states, int numControls, int target, qreal angle);
1626
1627
1628/** @notyetdoced
1629 *
1630 * @formulae
1631 *
1632 * Let @f$ \theta = @f$ @p angle and @f$ \vec{n} = ( @f$ @p axisX, @p axisY, @p axisZ @f$ ) @f$,
1633 * with corresponding unit vector @f$ \bar{n} @f$.
1634 * Further, let @f$ \vec{\sigma} = (\hat{\sigma}_x, \hat{\sigma}_y, \hat{\sigma}_z) @f$ denote a vector of the Pauli matrices.
1635 *
1636 * This function effects unitary
1637 * @f[
1638 \hat{R}_{\bar{n}}(\theta)
1639 =
1640 \exp \left(
1641 - \iu \frac{\theta}{2}
1642 \bar{n} \cdot \vec{\sigma}
1643 \right)
1644 * @f]
1645 * upon the target qubit. Explicitly,
1646 * @f[
1647 \hat{R}_{\bar{n}}(\theta)
1648 \equiv
1649 \begin{pmatrix}
1650 \cos\left( \frac{\theta}{2} \right) - \iu \, \bar{n}_z \sin\left( \frac{\theta}{2} \right)
1651 &
1652 - \, (\bar{n}_y + \bar{n}_x \, \iu ) \sin\left( \frac{\theta}{2} \right)
1653 \\
1654 (\bar{n}_y - \bar{n}_x \, \iu ) \sin\left( \frac{\theta}{2} \right)
1655 &
1656 \cos\left( \frac{\theta}{2} \right) + \iu \, \bar{n}_z \sin\left( \frac{\theta}{2} \right)
1657 \end{pmatrix}
1658 * @f]
1659 * where
1660 * @f[
1661 \bar{n}_i
1662 =
1663 \frac{\vec{n}_i}{\| \vec{n} \|_2}
1664 =
1665 \frac{\vec{n}_i}{ \sqrt{ {\vec{n}_x}^2 + {\vec{n}_y}^2 + {\vec{n}_z}^2 } }.
1666 * @f]
1667 *
1668 * @equivalences
1669 * - Assuming @f$ \| \vec{n} \|_2 \ne 0 @f$, this function is agnostic to the normalisation
1670 * of the axis vector.
1671 * ```
1672 applyRotateAroundAxis(qureg, target, angle, x, y, z);
1673 applyRotateAroundAxis(qureg, target, angle, 5*x,5*y,5*z); // equivalent
1674 * ```
1675 * - This function is entirely equivalent to preparing @f$ \hat{R}_{\bar{n}}(\theta) @f$
1676 * as a CompMatr1 and effecting it upon the state via applyCompMatr1().
1677 * - This function is both more accurate and efficient than equivalently instantiating a
1678 * three-term PauliStrSum @f$ \hat{H} = \bar{n} \cdot \vec{\sigma}@f$ and effecting
1679 * @f$ \exp \left(\iu \alpha \hat{H} \right) @f$ via applyTrotterizedPauliStrSumGadget()
1680 * with @f$ \alpha = - \theta/2 @f$ and very many repetitions.
1681 * - Passing @p angle=0 is equivalent to effecting the identity, leaving the state unchanged.
1682 */
1683void applyRotateAroundAxis(Qureg qureg, int target, qreal angle, qreal axisX, qreal axisY, qreal axisZ);
1684
1685
1686/// @notyetdoced
1687void applyControlledRotateAroundAxis(Qureg qureg, int ctrl, int targ, qreal angle, qreal axisX, qreal axisY, qreal axisZ);
1688
1689
1690/// @notyetdoced
1691void applyMultiControlledRotateAroundAxis(Qureg qureg, int* ctrls, int numCtrls, int targ, qreal angle, qreal axisX, qreal axisY, qreal axisZ);
1692
1693
1694/// @notyetdoced
1695/// @see
1696/// - applyRotateAroundAxis()
1697/// - applyMultiStateControlledCompMatr1()
1698void applyMultiStateControlledRotateAroundAxis(Qureg qureg, int* ctrls, int* states, int numCtrls, int targ, qreal angle, qreal axisX, qreal axisY, qreal axisZ);
1699
1700
1701// end de-mangler
1702#ifdef __cplusplus
1703}
1704#endif
1705
1706#ifdef __cplusplus
1707
1708
1709/// @notyettested
1710/// @notyetvalidated
1711/// @notyetdoced
1712/// @cppvectoroverload
1713/// @see applyMultiControlledRotateX()
1714void applyMultiControlledRotateX(Qureg qureg, std::vector<int> controls, int target, qreal angle);
1715
1716
1717/// @notyettested
1718/// @notyetvalidated
1719/// @notyetdoced
1720/// @cppvectoroverload
1721/// @see applyMultiControlledRotateY()
1722void applyMultiControlledRotateY(Qureg qureg, std::vector<int> controls, int target, qreal angle);
1723
1724
1725/// @notyettested
1726/// @notyetvalidated
1727/// @notyetdoced
1728/// @cppvectoroverload
1729/// @see applyMultiControlledRotateZ()
1730void applyMultiControlledRotateZ(Qureg qureg, std::vector<int> controls, int target, qreal angle);
1731
1732
1733/// @notyettested
1734/// @notyetvalidated
1735/// @notyetdoced
1736/// @cppvectoroverload
1737/// @see applyMultiStateControlledRotateX()
1738void applyMultiStateControlledRotateX(Qureg qureg, std::vector<int> controls, std::vector<int> states, int target, qreal angle);
1739
1740
1741/// @notyettested
1742/// @notyetvalidated
1743/// @notyetdoced
1744/// @cppvectoroverload
1745/// @see applyMultiStateControlledRotateY()
1746void applyMultiStateControlledRotateY(Qureg qureg, std::vector<int> controls, std::vector<int> states, int target, qreal angle);
1747
1748
1749/// @notyettested
1750/// @notyetvalidated
1751/// @notyetdoced
1752/// @cppvectoroverload
1753/// @see applyMultiStateControlledRotateZ()
1754void applyMultiStateControlledRotateZ(Qureg qureg, std::vector<int> controls, std::vector<int> states, int target, qreal angle);
1755
1756
1757/// @notyettested
1758/// @notyetvalidated
1759/// @notyetdoced
1760/// @cppvectoroverload
1761/// @see applyMultiControlledRotateAroundAxis()
1762void applyMultiControlledRotateAroundAxis(Qureg qureg, std::vector<int> ctrls, int targ, qreal angle, qreal axisX, qreal axisY, qreal axisZ);
1763
1764
1765/// @notyettested
1766/// @notyetvalidated
1767/// @notyetdoced
1768/// @cppvectoroverload
1769/// @see applyMultiStateControlledRotateAroundAxis()
1770void applyMultiStateControlledRotateAroundAxis(Qureg qureg, std::vector<int> ctrls, std::vector<int> states, int targ, qreal angle, qreal axisX, qreal axisY, qreal axisZ);
1771
1772
1773#endif // __cplusplus
1774
1775/** @} */
1776
1777
1778
1779/**
1780 * @defgroup op_pauligadget Pauli gadgets
1781 * @brief Functions for applying many-qubit rotations around arbitrary PauliStr.
1782 * @{
1783 */
1784
1785
1786#ifdef __cplusplus
1787extern "C" {
1788#endif
1789
1790
1791/// @notyetdoced
1792/// @see
1793/// - multiplyCompMatr1()
1794/// - applyPauliGadget()
1795void multiplyPauliGadget(Qureg qureg, PauliStr str, qreal angle);
1796
1797
1798/** @notyetdoced
1799 *
1800 * @formulae
1801 * Let @f$ \hat{\sigma} = @f$ @p str and @f$ \theta = @f$ @p angle.
1802 *
1803 * This function effects unitary
1804 * @f[
1805 R_{\hat{\sigma}}(\theta) = \exp \left( - \iu \, \frac{\theta}{2} \, \hat{\sigma} \right),
1806 * @f]
1807 * which affects only the qubits for which @f$ \hat{\sigma} @f$ is not the identity
1808 * Pauli. As such, this effects a multi-qubit rotation around an arbitrary Pauli string.
1809 *
1810 * @equivalences
1811 * - Because @f$ R_{\hat{\sigma}}(\theta) @f$ satisfies
1812 * @f[
1813 R_{\hat{\sigma}}(\theta) \equiv
1814 \cos\left( \frac{\theta}{2} \right) \, \id
1815 - \iu \sin\left( \frac{\theta}{2} \right) \, \hat{\sigma},
1816 * @f]
1817 * this function is equivalent to (but much faster than) effecting @f$ \hat{\sigma} @f$
1818 * upon a clone which is subsequently superposed.
1819 * ```
1820 // prepare |temp> = str |qureg>
1821 Qureg temp = createCloneQureg(qureg);
1822 applyPauliStr(temp, str);
1823
1824 // set |qureg> = cos(theta/2) |qureg> - i sin(theta/2) str |qureg>
1825 setQuregToSuperposition(cos(theta/2), qureg, - 1.0i * sin(theta/2), temp, 0, temp);
1826 * ```
1827 * - When @p str contains only @f$ \hat{Z} @f$ or @f$ \id @f$ Paulis, this function will
1828 * automatically invoke applyPhaseGadget() which leverages an optimised implementation.
1829 * - When @p str contains only @f$ \id @f$ Paulis, this function merely effects a change
1830 * of global phase upon statevectors of @f$ -\theta/2 @f$, leaving density matrices
1831 * unchanged.
1832 * ```
1833 qcomp factor = cexp(- theta / 2 * 1.i);
1834 setQuregToSuperposition(factor, qureg, 0,qureg,0,qureg);
1835 * ```
1836 *
1837 * @myexample
1838 * ```
1839 Qureg qureg = createQureg(10);
1840 qreal theta = 3.14;
1841
1842 // verbosely
1843 int numPaulis = 4;
1844 char* paulis = "XYIZ";
1845 int targets[] = {0,1,5,7};
1846 PauliStr str = getPauliStr(paulis, targets, numPaulis);
1847 applyPauliGadget(qureg, str, angle);
1848
1849 // concisely
1850 applyPauliGadget(qureg, getInlinePauliStr("XYZ",{0,1,7}), theta);
1851 * ```
1852 * - Passing @p angle=0 is equivalent to effecting the identity, leaving the state unchanged.
1853 */
1854void applyPauliGadget(Qureg qureg, PauliStr str, qreal angle);
1855
1856
1857/// @notyetdoced
1858void applyControlledPauliGadget(Qureg qureg, int control, PauliStr str, qreal angle);
1859
1860
1861/// @notyetdoced
1862void applyMultiControlledPauliGadget(Qureg qureg, int* controls, int numControls, PauliStr str, qreal angle);
1863
1864
1865/// @notyetdoced
1866/// @see
1867/// - applyPauliGadget()
1868/// - applyMultiStateControlledCompMatr1()
1869void applyMultiStateControlledPauliGadget(Qureg qureg, int* controls, int* states, int numControls, PauliStr str, qreal angle);
1870
1871
1872// end de-mangler
1873#ifdef __cplusplus
1874}
1875#endif
1876
1877#ifdef __cplusplus
1878
1879
1880/// @notyettested
1881/// @notyetvalidated
1882/// @notyetdoced
1883/// @cppvectoroverload
1884/// @see applyMultiControlledPauliGadget()
1885void applyMultiControlledPauliGadget(Qureg qureg, std::vector<int> controls, PauliStr str, qreal angle);
1886
1887
1888/// @notyettested
1889/// @notyetvalidated
1890/// @notyetdoced
1891/// @cppvectoroverload
1892/// @see applyMultiStateControlledPauliGadget()
1893void applyMultiStateControlledPauliGadget(Qureg qureg, std::vector<int> controls, std::vector<int> states, PauliStr str, qreal angle);
1894
1895
1896#endif // __cplusplus
1897
1898/** @} */
1899
1900
1901
1902/**
1903 * @defgroup op_phasegadget Phase gates
1904 * @brief Functions for applying many-qubit rotations around Pauli Z axis, and phase flips and shifts.
1905 * @{
1906 */
1907
1908
1909#ifdef __cplusplus
1910extern "C" {
1911#endif
1912
1913
1914/// @notyetdoced
1915/// @see
1916/// - multiplyCompMatr1()
1917/// - applyPhaseGadget
1918void multiplyPhaseGadget(Qureg qureg, int* targets, int numTargets, qreal angle);
1919
1920
1921/** @notyetdoced
1922 *
1923 * @formulae
1924 *
1925 * Let @f$ \vec{t} = @f$ @p targets and @f$ \theta = @f$ @p angle.
1926 *
1927 * This function effects diagonal unitary
1928 * @f[
1929 R_{\hat{Z}}(\theta) = \exp \left( - \iu \, \frac{\theta}{2} \, \bigotimes_{t \,\in\, \vec{t}} \hat{Z}_t \right).
1930 * @f]
1931 *
1932 * @equivalences
1933 * - This function is equivalent to calling applyPauliGadget() with a PauliStr containing only @f$ \hat{Z} @f$ and @f$ \id @f$.
1934 * This latter function will actually automatically invoke applyPhaseGadget() which has an optimised implementation.
1935 * - This function is equivalent to, albeit much faster than, preparing a DiagMatr with @f$ \pm 1 @f$ elements (depending upon
1936 * the parity of the targeted set bits) and effecting it with applyDiagMatr().
1937 * - Passing @p angle=0 is equivalent to effecting the identity, leaving the state unchanged.
1938 */
1939void applyPhaseGadget(Qureg qureg, int* targets, int numTargets, qreal angle);
1940
1941
1942/// @notyetdoced
1943void applyControlledPhaseGadget(Qureg qureg, int control, int* targets, int numTargets, qreal angle);
1944
1945
1946/// @notyetdoced
1947void applyMultiControlledPhaseGadget(Qureg qureg, int* controls, int numControls, int* targets, int numTargets, qreal angle);
1948
1949
1950/// @notyetdoced
1951/// @see
1952/// - applyPhaseGadget()
1953/// - applyMultiStateControlledCompMatr1()
1954void applyMultiStateControlledPhaseGadget(Qureg qureg, int* controls, int* states, int numControls, int* targets, int numTargets, qreal angle);
1955
1956
1957/** @notyetdoced
1958 *
1959 * This function is a mere alias of applyPauliZ(), meaningfully differing only for many targets.
1960 */
1961void applyPhaseFlip(Qureg qureg, int target);
1962
1963
1964/** @notyetdoced
1965 *
1966 * @formulae
1967 *
1968 * Let @f$ \theta = @f$ @p angle. This function effects diagonal unitary
1969 *
1970 * @f[
1971 \hat{U}(\theta) = \begin{pmatrix} 1 & 0 \\ 0 & e^{\iu \theta} \end{pmatrix}
1972 * @f]
1973 * upon the @p target qubit.
1974 *
1975 * @equivalences
1976 * - This function is equivalent to, albeit much faster than, a Z-axis rotation with
1977 * an adjustment to the global phase (which is redundant upon density matrices).
1978 * @f[
1979 * \hat{U}(\theta) \equiv \hat{R}_z(\theta) \cdot e^{\iu \frac{\theta}{2}} \hat{\id}
1980 * @f]
1981 * ```
1982 applyRotateZ(qureg, target, angle);
1983 applyPauliGadget(qureg, getPauliStr("I"), angle); // global phase
1984 * ```
1985 * - Passing @p angle=0 is equivalent to effecting the identity, leaving the state unchanged.
1986 */
1987void applyPhaseShift(Qureg qureg, int target, qreal angle);
1988
1989
1990/** @notyetdoced
1991 *
1992 * Applies a two-qubit phase flip upon qubits @p target1 and @p target2 of @p qureg.
1993 *
1994 * @formulae
1995 *
1996 * This function flips the sign of all computational basis states for which
1997 * the targeted qubits are in state @f$ \ket{1}\ket{1} @f$. This is equivalent
1998 * to the diagonal unitary
1999 *
2000 * @f[
2001 \hat{U}(\theta) = \begin{pmatrix} 1 \\ & 1 \\ & & 1 \\ & & & -1 \end{pmatrix},
2002 * @f]
2003 * effected upon the target qubits.
2004 *
2005 * @diagram
2006 * @dot
2007digraph {
2008 rankdir=LR;
2009 layout=neato;
2010 node [fontsize=10, fontname="Menlo"];
2011 edge [dir=none];
2012
2013 topWireL [shape=plaintext, label="target1", pos="0,.5!"];
2014 topWireM [shape=point, label="", width=.1, pos=".75,.5!"]
2015 topWireR [shape=plaintext, label="", pos="1.5,.5!"];
2016
2017 botWireL [shape=plaintext, label="target2", pos="0,0!"];
2018 botWireM [shape=point, label="", width=.1, pos=".75,0!"];
2019 botWireR [shape=plaintext, label="", pos="1.5,0!"];
2020
2021 topWireL -> topWireR;
2022 botWireL -> botWireR;
2023 botWireM -> topWireM;
2024}
2025 * @enddot
2026 *
2027 * @equivalences
2028 * - The target qubits are interchangeable, ergo
2029 * ```
2030 applyTwoQubitPhaseFlip(qureg, target1, target2);
2031 applyTwoQubitPhaseFlip(qureg, target2, target1); // equivalent
2032 * ```
2033 * - This function is entirely equivalent to a controlled Pauli-Z unitary (or a hypothetical
2034 * controlled variant of applyPhaseFlip()) with either target qubit substituted for the control qubit.
2035 * ```
2036 applyControlledPauliZ(qureg, target1, target2);
2037 * ```
2038 * - This function is faster and more accurate than, but otherwise equivalent to, a two-qubit phase shift
2039 * with angle @f$ = \pi @f$.
2040 * ```
2041 applyTwoQubitPhaseShift(qureg, target1, target2, 3.141592653); // approx equiv
2042 * ```
2043 */
2044void applyTwoQubitPhaseFlip(Qureg qureg, int target1, int target2);
2045
2046
2047/** @notyetdoced
2048 *
2049 * Applies a two-qubit phase shift upon qubits @p target1 and @p target2 of @p qureg.
2050 *
2051 * @formulae
2052 *
2053 * Let @f$ \theta = @f$ @p angle.
2054 * This function multiplies factor @f$ e^{\iu \theta} @f$ upon all computational basis states
2055 * for which the targeted qubits are in state @f$ \ket{1}\ket{1} @f$. This is equivalent
2056 * to the diagonal unitary
2057 *
2058 * @f[
2059 \hat{U}(\theta) = \begin{pmatrix} 1 \\ & 1 \\ & & 1 \\ & & & e^{\iu \theta} \end{pmatrix},
2060 * @f]
2061 * effected upon the target qubits.
2062 *
2063 * @diagram
2064 * @dot
2065digraph {
2066 rankdir=LR;
2067 layout=neato;
2068 node [fontsize=10, fontname="Menlo"];
2069 edge [dir=none];
2070
2071 topWireL [shape=plaintext, label="target1", pos="0,.5!"];
2072 topWireM [shape=point, label="", width=.1, pos=".75,.5!"]
2073 topWireR [shape=plaintext, label="", pos="1.5,.5!"];
2074
2075 botWireL [shape=plaintext, label="target2", pos="0,0!"];
2076 botWireM [shape=point, label="", width=.1, pos=".75,0!"];
2077 botWireR [shape=plaintext, label="", pos="1.5,0!"];
2078
2079 topWireL -> topWireR;
2080 botWireL -> botWireR;
2081 botWireM -> topWireM;
2082
2083 angle [shape=plaintext, label="θ", pos=".85,-.2!"];
2084}
2085 * @enddot
2086 *
2087 * @equivalences
2088 * - The target qubits are interchangeable, ergo
2089 * ```
2090 applyTwoQubitPhaseShift(qureg, target1, target2, angle);
2091 applyTwoQubitPhaseShift(qureg, target2, target1, angle); // equivalent
2092 * ```
2093 * - This function is equivalent to a controlled variant of applyPhaseShift(), treating
2094 * either target qubit as the control qubit.
2095 * - This function generalises applyTwoQubitPhaseFlip() to arbitrary changes in phase.
2096 * - Passing @p angle=0 is equivalent to effecting the identity, leaving the state unchanged.
2097 */
2098void applyTwoQubitPhaseShift(Qureg qureg, int target1, int target2, qreal angle);
2099
2100
2101/** @notyetdoced
2102 *
2103 * @formulae
2104 *
2105 * This function flips the sign of all computational basis states for which
2106 * the targeted qubits are all in state @f$ \ket{1} @f$. This is equivalent
2107 * to the diagonal unitary
2108 * @f[
2109 \hat{U}(\theta) = \begin{pmatrix} 1 \\ & \ddots \\ & & 1 \\ & & & -1 \end{pmatrix},
2110 * @f]
2111 * effected upon the target qubits.
2112 *
2113 * @equivalences
2114 * - The ordering of @p targets has no affect on the effected operation.
2115 * - This function is entirely equivalent to a multi-controlled Pauli-Z unitary (or a hypothetical
2116 * many-controlled variant of applyPhaseFlip()) with all but one arbitrary target qubit becoming
2117 * control qubits.
2118 * ```
2119 applyMultiControlledPauliZ(qureg, targets, numTargets-1, targets[0]);
2120 * ```
2121 * - This function is faster and more accurate than, but otherwise equivalent to, a multi-qubit phase shift
2122 * with angle @f$ = \pi @f$.
2123 * ```
2124 applyMultiQubitPhaseShift(qureg, targets, numTargets, 3.141592653); // approx equiv
2125 * ```
2126 */
2127void applyMultiQubitPhaseFlip(Qureg qureg, int* targets, int numTargets);
2128
2129
2130/** @notyetdoced
2131 *
2132 * @formulae
2133 *
2134 * Let @f$ \theta = @f$ @p angle.
2135 * This function multiplies factor @f$ e^{\iu \theta} @f$ upon all computational basis states
2136 * for which all targeted qubits are in state @f$ \ket{1} @f$. This is equivalent
2137 * to the diagonal unitary
2138 * @f[
2139 \hat{U}(\theta) = \begin{pmatrix} 1 \\ & \ddots \\ & & 1 \\ & & & e^{\iu \theta} \end{pmatrix},
2140 * @f]
2141 * effected upon the target qubits.
2142 *
2143 * @diagram
2144 * @dot
2145digraph {
2146 rankdir=LR;
2147 layout=neato;
2148 node [fontsize=10, fontname="Menlo"];
2149 edge [dir=none];
2150
2151 topWireL [shape=plaintext, label="target1", pos="0,.5!"];
2152 topWireM [shape=point, label="", width=.1, pos=".75,.5!"]
2153 topWireR [shape=plaintext, label="", pos="1.5,.5!"];
2154
2155 botWireL [shape=plaintext, label="target2", pos="0,0!"];
2156 botWireM [shape=point, label="", width=.1, pos=".75,0!"];
2157 botWireR [shape=plaintext, label="", pos="1.5,0!"];
2158
2159 topWireL -> topWireR;
2160 botWireL -> botWireR;
2161 botWireM -> topWireM;
2162
2163 angle [shape=plaintext, label="θ", pos=".85,-.2!"];
2164}
2165 * @enddot
2166 *
2167 * @equivalences
2168 * - The ordering of @p targets has no affect on the effected operation.
2169 * - This function is equivalent to a multi-controlled variant of applyPhaseShift(), treating all
2170 * but one arbitrary target qubit as control qubits.
2171 * - This function generalises applyMultiQubitPhaseFlip() to arbitrary changes in phase.
2172 * - Passing @p angle=0 is equivalent to effecting the identity, leaving the state unchanged.
2173 */
2174void applyMultiQubitPhaseShift(Qureg qureg, int* targets, int numTargets, qreal angle);
2175
2176
2177// end de-mangler
2178#ifdef __cplusplus
2179}
2180#endif
2181
2182#ifdef __cplusplus
2183
2184
2185/// @notyettested
2186/// @notyetvalidated
2187/// @notyetdoced
2188/// @cppvectoroverload
2189/// @see multiplyPhaseGadget()
2190void multiplyPhaseGadget(Qureg qureg, std::vector<int> targets, qreal angle);
2191
2192
2193/// @notyettested
2194/// @notyetvalidated
2195/// @notyetdoced
2196/// @cppvectoroverload
2197/// @see applyPhaseGadget()
2198void applyPhaseGadget(Qureg qureg, std::vector<int> targets, qreal angle);
2199
2200
2201/// @notyettested
2202/// @notyetvalidated
2203/// @notyetdoced
2204/// @cppvectoroverload
2205/// @see applyControlledPhaseGadget()
2206void applyControlledPhaseGadget(Qureg qureg, int control, std::vector<int> targets, qreal angle);
2207
2208
2209/// @notyettested
2210/// @notyetvalidated
2211/// @notyetdoced
2212/// @cppvectoroverload
2213/// @see applyMultiControlledPhaseGadget()
2214void applyMultiControlledPhaseGadget(Qureg qureg, std::vector<int> controls, std::vector<int> targets, qreal angle);
2215
2216
2217/// @notyettested
2218/// @notyetvalidated
2219/// @notyetdoced
2220/// @cppvectoroverload
2221/// @see applyMultiStateControlledPhaseGadget()
2222void applyMultiStateControlledPhaseGadget(Qureg qureg, std::vector<int> controls, std::vector<int> states, std::vector<int> targets, qreal angle);
2223
2224
2225/// @notyettested
2226/// @notyetvalidated
2227/// @notyetdoced
2228/// @cppvectoroverload
2229/// @see applyMultiQubitPhaseFlip()
2230void applyMultiQubitPhaseFlip(Qureg qureg, std::vector<int> targets);
2231
2232
2233/// @notyettested
2234/// @notyetvalidated
2235/// @notyetdoced
2236/// @cppvectoroverload
2237/// @see applyMultiQubitPhaseShift()
2238void applyMultiQubitPhaseShift(Qureg qureg, std::vector<int> targets, qreal angle);
2239
2240
2241#endif // __cplusplus
2242
2243/** @} */
2244
2245
2246
2247/**
2248 * @defgroup op_paulistrsum PauliStrSum
2249 * @brief Functions for applying, exponentiating or Trotterising a weigthed sum of Pauli tensors.
2250 * @{
2251 */
2252
2253
2254#ifdef __cplusplus
2255extern "C" {
2256#endif
2257
2258
2259/// @notyetdoced
2260/// @notyetvalidated
2261/// @see multiplyCompMatr1()
2262void multiplyPauliStrSum(Qureg qureg, PauliStrSum sum, Qureg workspace);
2263
2264
2265/** @notyetdoced
2266 * @notyettested
2267 *
2268 * @formulae
2269 *
2270 * Let @f$ \hat{H} = @f$ @p sum and @f$ \theta = @f$ @p angle. This function approximates the action of
2271 * @f[
2272 \exp \left(\iu \, \theta \, \hat{H} \right)
2273 * @f]
2274 * via a Trotter-Suzuki decomposition of the specified @p order and number of repetitions (@p reps).
2275 *
2276 *
2277 * To be precise, let @f$ r = @f$ @p reps and assume @p sum is composed of
2278 * @f$ T @f$-many terms of the form
2279 * @f[
2280 \hat{H} = \sum\limits_j^T c_j \, \hat{\sigma}_j
2281 * @f]
2282 * where @f$ c_j @f$ is the (necessarily real) coefficient of the @f$ j @f$-th PauliStr @f$ \hat{\sigma}_j @f$.
2283 *
2284 * - When @p order=1, this function performs first-order Trotterisation, whereby
2285 * @f[
2286 \exp(\iu \, \theta \, \hat{H} )
2287 \approx
2288 \prod\limits^{r}
2289 \prod\limits_{j=1}^{T}
2290 \exp \left( \iu \, \frac{\theta \, c_j}{r} \, \hat\sigma_j \right).
2291 * @f]
2292 * - When @p order=2, this function performs the lowest order "symmetrized" Suzuki decomposition, whereby
2293 * @f[
2294 \exp(\iu \, \theta \, \hat{H} )
2295 \approx
2296 \prod\limits^{r} \left[
2297 \prod\limits_{j=1}^{T} \exp \left( \iu \frac{\theta \, c_j}{2 \, r} \hat\sigma_j \right)
2298 \prod\limits_{j=T}^{1} \exp \left( \iu \frac{\theta \, c_j}{2 \, r} \hat\sigma_j \right)
2299 \right].
2300 * @f]
2301 * - Greater, even values of @p order (denoted by symbol @f$ n @f$) invoke higher-order symmetrized decompositions
2302 * @f$ S[\theta,n,r] @f$. Letting @f$ p = \left( 4 - 4^{1/(n-1)} \right)^{-1} @f$, these satisfy
2303 * @f{align*}
2304 S[\theta, n, 1] &=
2305 \left( \prod\limits^2 S[p \, \theta, n-2, 1] \right)
2306 S[ (1-4p)\,\theta, n-2, 1]
2307 \left( \prod\limits^2 S[p \, \theta, n-2, 1] \right),
2308 \\
2309 S[\theta, n, r] &=
2310 \prod\limits^{r} S\left[\frac{\theta}{r}, n, 1\right].
2311 * @f}
2312 *
2313 * > These formulations are taken from 'Finding Exponential Product Formulas
2314 * > of Higher Orders', Naomichi Hatano and Masuo Suzuki (2005) (<a href="https://arxiv.org/abs/math-ph/0506007">arXiv</a>).
2315 */
2316void applyTrotterizedPauliStrSumGadget(Qureg qureg, PauliStrSum sum, qreal angle, int order, int reps);
2317
2318
2319// end de-mangler
2320#ifdef __cplusplus
2321}
2322#endif
2323
2324
2325/** @} */
2326
2327
2328
2329/**
2330 * @defgroup op_nots Many-not gates
2331 * @brief Functions for effecting many-qubit NOT gates
2332 * @{
2333 */
2334
2335
2336#ifdef __cplusplus
2337extern "C" {
2338#endif
2339
2340
2341/// @notyetdoced
2342/// @see multiplyCompMatr1()
2343void multiplyMultiQubitNot(Qureg qureg, int* targets, int numTargets);
2344
2345
2346/// @notyetdoced
2347void applyMultiQubitNot(Qureg qureg, int* targets, int numTargets);
2348
2349
2350/// @notyetdoced
2351void applyControlledMultiQubitNot(Qureg qureg, int control, int* targets, int numTargets);
2352
2353
2354/// @notyetdoced
2355void applyMultiControlledMultiQubitNot(Qureg qureg, int* controls, int numControls, int* targets, int numTargets);
2356
2357
2358/// @notyetdoced
2359/// @see
2360/// - applyMultiStateControlledCompMatr1()
2361void applyMultiStateControlledMultiQubitNot(Qureg qureg, int* controls, int* states, int numControls, int* targets, int numTargets);
2362
2363
2364// end de-mangler
2365#ifdef __cplusplus
2366}
2367#endif
2368
2369#ifdef __cplusplus
2370
2371
2372/// @notyettested
2373/// @notyetvalidated
2374/// @notyetdoced
2375/// @cppvectoroverload
2376/// @see multiplyMultiQubitNot()
2377void multiplyMultiQubitNot(Qureg qureg, std::vector<int> targets);
2378
2379
2380/// @notyettested
2381/// @notyetvalidated
2382/// @notyetdoced
2383/// @cppvectoroverload
2384/// @see applyMultiQubitNot()
2385void applyMultiQubitNot(Qureg qureg, std::vector<int> targets);
2386
2387
2388/// @notyettested
2389/// @notyetvalidated
2390/// @notyetdoced
2391/// @cppvectoroverload
2392/// @see applyControlledMultiQubitNot()
2393void applyControlledMultiQubitNot(Qureg qureg, int control, std::vector<int> targets);
2394
2395
2396/// @notyettested
2397/// @notyetvalidated
2398/// @notyetdoced
2399/// @cppvectoroverload
2400/// @see applyMultiControlledMultiQubitNot()
2401void applyMultiControlledMultiQubitNot(Qureg qureg, std::vector<int> controls, std::vector<int> targets);
2402
2403
2404/// @notyettested
2405/// @notyetvalidated
2406/// @notyetdoced
2407/// @cppvectoroverload
2408/// @see applyMultiStateControlledMultiQubitNot()
2409void applyMultiStateControlledMultiQubitNot(Qureg qureg, std::vector<int> controls, std::vector<int> states, std::vector<int> targets);
2410
2411
2412#endif // __cplusplus
2413
2414/** @} */
2415
2416
2417
2418/**
2419 * @defgroup op_measurement Measurements
2420 * @brief Functions for effecting destructive measurements.
2421 * @{
2422 */
2423
2424
2425#ifdef __cplusplus
2426extern "C" {
2427#endif
2428
2429
2430/// @notyetdoced
2431/// @notyetvalidated
2432int applyQubitMeasurement(Qureg qureg, int target);
2433
2434
2435/// @notyetdoced
2436/// @notyetvalidated
2437int applyQubitMeasurementAndGetProb(Qureg qureg, int target, qreal* probability);
2438
2439
2440/// @notyetdoced
2441/// @notyetvalidated
2442qreal applyForcedQubitMeasurement(Qureg qureg, int target, int outcome);
2443
2444
2445/// @notyetdoced
2446/// @notyetvalidated
2447qindex applyMultiQubitMeasurement(Qureg qureg, int* qubits, int numQubits);
2448
2449
2450/// @notyetdoced
2451/// @notyetvalidated
2452qindex applyMultiQubitMeasurementAndGetProb(Qureg qureg, int* qubits, int numQubits, qreal* probability);
2453
2454
2455/// @notyetdoced
2456/// @notyetvalidated
2457qreal applyForcedMultiQubitMeasurement(Qureg qureg, int* qubits, int* outcomes, int numQubits);
2458
2459
2460// end de-mangler
2461#ifdef __cplusplus
2462}
2463#endif
2464
2465#ifdef __cplusplus
2466
2467
2468/// @notyettested
2469/// @notyetvalidated
2470/// @notyetdoced
2471/// @cppvectoroverload
2472/// @see applyMultiQubitMeasurementAndGetProb()
2473qindex applyMultiQubitMeasurementAndGetProb(Qureg qureg, std::vector<int> qubits, qreal* probability);
2474
2475
2476/// @notyettested
2477/// @notyetvalidated
2478/// @notyetdoced
2479/// @cppvectoroverload
2480/// @see applyForcedMultiQubitMeasurement()
2481qreal applyForcedMultiQubitMeasurement(Qureg qureg, std::vector<int> qubits, std::vector<int> outcomes);
2482
2483
2484#endif // __cplusplus
2485
2486/** @} */
2487
2488
2489
2490/**
2491 * @defgroup op_projectors Projectors
2492 * @brief Functions for effecting projectors which break the state normalisation.
2493 * @{
2494 */
2495
2496
2497#ifdef __cplusplus
2498extern "C" {
2499#endif
2500
2501
2502/// @notyetdoced
2503/// @notyetvalidated
2504void applyQubitProjector(Qureg qureg, int target, int outcome);
2505
2506
2507/// @notyetdoced
2508/// @notyetvalidated
2509void applyMultiQubitProjector(Qureg qureg, int* qubits, int* outcomes, int numQubits);
2510
2511
2512// end de-mangler
2513#ifdef __cplusplus
2514}
2515#endif
2516
2517#ifdef __cplusplus
2518
2519
2520/// @notyettested
2521/// @notyetvalidated
2522/// @notyetdoced
2523/// @cppvectoroverload
2524/// @see applyMultiQubitProjector()
2525void applyMultiQubitProjector(Qureg qureg, std::vector<int> qubits, std::vector<int> outcomes);
2526
2527
2528#endif // __cplusplus
2529
2530/** @} */
2531
2532
2533
2534/**
2535 * @defgroup op_qft QFT
2536 * @brief Functions for applying the Quantum Fourier Transform.
2537 * @{
2538 */
2539
2540
2541#ifdef __cplusplus
2542extern "C" {
2543#endif
2544
2545
2546/// @notyetdoced
2547/// @notyetvalidated
2548void applyQuantumFourierTransform(Qureg qureg, int* targets, int numTargets);
2549
2550
2551/// @notyetdoced
2552/// @notyetvalidated
2554
2555
2556// end de-mangler
2557#ifdef __cplusplus
2558}
2559#endif
2560
2561#ifdef __cplusplus
2562
2563
2564/// @notyettested
2565/// @notyetvalidated
2566/// @notyetdoced
2567/// @cppvectoroverload
2568/// @see applyQuantumFourierTransform()
2569void applyQuantumFourierTransform(Qureg qureg, std::vector<int> targets);
2570
2571
2572#endif // __cplusplus
2573
2574/** @} */
2575
2576
2577
2578#endif // OPERATIONS_H
2579
2580/** @} */ // (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 matrix)
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 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 applyRotateAroundAxis(Qureg qureg, int target, qreal angle, qreal axisX, qreal axisY, qreal axisZ)
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