forked from QuEST-Kit/QuEST
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathQuEST__cpu__internal_8h.html
5160 lines (4934 loc) · 569 KB
/
QuEST__cpu__internal_8h.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!-- HTML header for doxygen 1.8.8-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<!-- For Mobile Devices -->
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta name="generator" content="Doxygen 1.8.17"/>
<script type="text/javascript" src="https://code.jquery.com/jquery-2.1.1.min.js"></script>
<title>QuEST: QuEST_cpu_internal.h File Reference</title>
<!--<link href="tabs.css" rel="stylesheet" type="text/css"/>-->
<script type="text/javascript" src="dynsections.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
<link href="style.css" rel="stylesheet" type="text/css"/>
<link href='https://fonts.googleapis.com/css?family=Roboto+Slab' rel='stylesheet' type='text/css'>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
<link href="jquery.smartmenus.bootstrap.css" rel="stylesheet">
<script type="text/javascript" src="jquery.smartmenus.js"></script>
<!-- SmartMenus jQuery Bootstrap Addon -->
<script type="text/javascript" src="jquery.smartmenus.bootstrap.js"></script>
<!-- SmartMenus jQuery plugin -->
</head>
<body>
<nav class="navbar navbar-default" role="navigation">
<div class="container">
<div class="navbar-header">
<a class="navbar-brand"><img alt="Logo" src="logo.png"/></a>
<a class="navbar-brand"><b>QuEST</b> v3.2.0<br>The Quantum Exact Simulation Toolkit</a>
</div>
</div>
</nav>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div class="content" id="content">
<div class="container">
<div class="row">
<div class="col-sm-12 panel " style="padding-bottom: 15px;">
<div style="margin-bottom: 15px;">
<!-- end header part -->
<!-- Generated by Doxygen 1.8.17 -->
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&dn=gpl-2.0.txt GPL-v2 */
$(function() {
initMenu('',false,false,'search.php','Search');
});
/* @license-end */</script>
<div id="main-nav"></div>
<div id="nav-path" class="navpath">
<ul>
<li class="navelem"><a class="el" href="dir_d522931ffa1371640980b621734a4381.html">Users</a></li><li class="navelem"><a class="el" href="dir_70834f0dcd10de01d2e35ab402a2238e.html">tysonjones</a></li><li class="navelem"><a class="el" href="dir_1957401ef452be7528010ba0f4832a45.html">Desktop</a></li><li class="navelem"><a class="el" href="dir_dee4414d5d72b49a9429e079789ffd08.html">GithubRepos</a></li><li class="navelem"><a class="el" href="dir_a89b43d59316bb5045aa22bb53a67d29.html">QuEST</a></li><li class="navelem"><a class="el" href="dir_f1fe56bf5ef15ff22696c757278c6962.html">QuEST</a></li><li class="navelem"><a class="el" href="dir_757750313c878cfe3b7d1ade55b4b819.html">src</a></li><li class="navelem"><a class="el" href="dir_b42f528141150d9931abf34c4623dde5.html">CPU</a></li> </ul>
</div>
</div><!-- top -->
<div class="header">
<div class="summary">
<a href="#func-members">Functions</a> </div>
<div class="headertitle">
<div class="title">QuEST_cpu_internal.h File Reference</div> </div>
</div><!--header-->
<div class="contents">
<div class="textblock"><code>#include "<a class="el" href="QuEST__precision_8h_source.html">QuEST_precision.h</a>"</code><br />
</div>
<p><a href="QuEST__cpu__internal_8h_source.html">Go to the source code of this file.</a></p>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="func-members"></a>
Functions</h2></td></tr>
<tr class="memitem:afa58cf7cb98a25ab33621120c5c330d0"><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="QuEST__cpu__internal_8h.html#afa58cf7cb98a25ab33621120c5c330d0">densmatr_applyDiagonalOpLocal</a> (<a class="el" href="structQureg.html">Qureg</a> qureg, <a class="el" href="structDiagonalOp.html">DiagonalOp</a> op)</td></tr>
<tr class="separator:afa58cf7cb98a25ab33621120c5c330d0"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:aeb4453a2e609e5359d2995bccf6663ca"><td class="memItemLeft" align="right" valign="top"><a class="el" href="structComplex.html">Complex</a> </td><td class="memItemRight" valign="bottom"><a class="el" href="QuEST__cpu__internal_8h.html#aeb4453a2e609e5359d2995bccf6663ca">densmatr_calcExpecDiagonalOpLocal</a> (<a class="el" href="structQureg.html">Qureg</a> qureg, <a class="el" href="structDiagonalOp.html">DiagonalOp</a> op)</td></tr>
<tr class="separator:aeb4453a2e609e5359d2995bccf6663ca"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:a7772f97cb4d92a9825bf3b7c82c3230c"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> </td><td class="memItemRight" valign="bottom"><a class="el" href="QuEST__cpu__internal_8h.html#a7772f97cb4d92a9825bf3b7c82c3230c">densmatr_calcFidelityLocal</a> (<a class="el" href="structQureg.html">Qureg</a> qureg, <a class="el" href="structQureg.html">Qureg</a> pureState)</td></tr>
<tr class="memdesc:a7772f97cb4d92a9825bf3b7c82c3230c"><td class="mdescLeft"> </td><td class="mdescRight">computes a few dens-columns-worth of (vec^*T) dens * vec <a href="QuEST__cpu__internal_8h.html#a7772f97cb4d92a9825bf3b7c82c3230c">More...</a><br /></td></tr>
<tr class="separator:a7772f97cb4d92a9825bf3b7c82c3230c"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:a939897137596bb73ad7a028d0beaaa10"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> </td><td class="memItemRight" valign="bottom"><a class="el" href="QuEST__cpu__internal_8h.html#a939897137596bb73ad7a028d0beaaa10">densmatr_calcHilbertSchmidtDistanceSquaredLocal</a> (<a class="el" href="structQureg.html">Qureg</a> a, <a class="el" href="structQureg.html">Qureg</a> b)</td></tr>
<tr class="memdesc:a939897137596bb73ad7a028d0beaaa10"><td class="mdescLeft"> </td><td class="mdescRight">computes Tr((a-b) conjTrans(a-b)) = sum of abs values of (a-b) <a href="QuEST__cpu__internal_8h.html#a939897137596bb73ad7a028d0beaaa10">More...</a><br /></td></tr>
<tr class="separator:a939897137596bb73ad7a028d0beaaa10"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:a08392b1b27d10e3b8a8648a5afeaa629"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> </td><td class="memItemRight" valign="bottom"><a class="el" href="QuEST__cpu__internal_8h.html#a08392b1b27d10e3b8a8648a5afeaa629">densmatr_calcInnerProductLocal</a> (<a class="el" href="structQureg.html">Qureg</a> a, <a class="el" href="structQureg.html">Qureg</a> b)</td></tr>
<tr class="memdesc:a08392b1b27d10e3b8a8648a5afeaa629"><td class="mdescLeft"> </td><td class="mdescRight">computes Tr(conjTrans(a) b) = sum of (a_ij^* b_ij) <a href="QuEST__cpu__internal_8h.html#a08392b1b27d10e3b8a8648a5afeaa629">More...</a><br /></td></tr>
<tr class="separator:a08392b1b27d10e3b8a8648a5afeaa629"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:af910c7cf2b85bdc2c399cfe8dbfb8b9c"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> </td><td class="memItemRight" valign="bottom"><a class="el" href="QuEST__cpu__internal_8h.html#af910c7cf2b85bdc2c399cfe8dbfb8b9c">densmatr_calcPurityLocal</a> (<a class="el" href="structQureg.html">Qureg</a> qureg)</td></tr>
<tr class="separator:af910c7cf2b85bdc2c399cfe8dbfb8b9c"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:a8bea931504c90d9bd97e74645667804e"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> </td><td class="memItemRight" valign="bottom"><a class="el" href="QuEST__cpu__internal_8h.html#a8bea931504c90d9bd97e74645667804e">densmatr_findProbabilityOfZeroLocal</a> (<a class="el" href="structQureg.html">Qureg</a> qureg, int measureQubit)</td></tr>
<tr class="separator:a8bea931504c90d9bd97e74645667804e"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:a1b36518c8fbbc3a5084bb4ad1fb05ea5"><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="QuEST__cpu__internal_8h.html#a1b36518c8fbbc3a5084bb4ad1fb05ea5">densmatr_initPureStateLocal</a> (<a class="el" href="structQureg.html">Qureg</a> targetQureg, <a class="el" href="structQureg.html">Qureg</a> copyQureg)</td></tr>
<tr class="separator:a1b36518c8fbbc3a5084bb4ad1fb05ea5"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:a8d9c19a3424f0ad89bfbfd920d65301d"><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="QuEST__cpu__internal_8h.html#a8d9c19a3424f0ad89bfbfd920d65301d">densmatr_mixDampingDistributed</a> (<a class="el" href="structQureg.html">Qureg</a> qureg, int targetQubit, <a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> damping)</td></tr>
<tr class="separator:a8d9c19a3424f0ad89bfbfd920d65301d"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:ab124a3a9956046bf9c0e1e3ae9171f42"><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="QuEST__cpu__internal_8h.html#ab124a3a9956046bf9c0e1e3ae9171f42">densmatr_mixDampingLocal</a> (<a class="el" href="structQureg.html">Qureg</a> qureg, int targetQubit, <a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> damping)</td></tr>
<tr class="separator:ab124a3a9956046bf9c0e1e3ae9171f42"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:a88670d0e7cebe33f61c1dd98daa338b3"><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="QuEST__cpu__internal_8h.html#a88670d0e7cebe33f61c1dd98daa338b3">densmatr_mixDepolarisingDistributed</a> (<a class="el" href="structQureg.html">Qureg</a> qureg, int targetQubit, <a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> depolLevel)</td></tr>
<tr class="separator:a88670d0e7cebe33f61c1dd98daa338b3"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:ab750fb47da2fca9849c678c869e40e69"><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="QuEST__cpu__internal_8h.html#ab750fb47da2fca9849c678c869e40e69">densmatr_mixDepolarisingLocal</a> (<a class="el" href="structQureg.html">Qureg</a> qureg, int targetQubit, <a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> depolLevel)</td></tr>
<tr class="separator:ab750fb47da2fca9849c678c869e40e69"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:a2f76ec8f08e19bb8e1254aafb10e160e"><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="QuEST__cpu__internal_8h.html#a2f76ec8f08e19bb8e1254aafb10e160e">densmatr_mixTwoQubitDepolarisingDistributed</a> (<a class="el" href="structQureg.html">Qureg</a> qureg, int targetQubit, int qubit2, <a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> delta, <a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> gamma)</td></tr>
<tr class="separator:a2f76ec8f08e19bb8e1254aafb10e160e"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:a3510f01d4d15dcc545564eb84c668cad"><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="QuEST__cpu__internal_8h.html#a3510f01d4d15dcc545564eb84c668cad">densmatr_mixTwoQubitDepolarisingLocal</a> (<a class="el" href="structQureg.html">Qureg</a> qureg, int qubit1, int qubit2, <a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> delta, <a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> gamma)</td></tr>
<tr class="separator:a3510f01d4d15dcc545564eb84c668cad"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:ae90f82418e0aa67218d733dbbc681998"><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="QuEST__cpu__internal_8h.html#ae90f82418e0aa67218d733dbbc681998">densmatr_mixTwoQubitDepolarisingLocalPart1</a> (<a class="el" href="structQureg.html">Qureg</a> qureg, int qubit1, int qubit2, <a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> delta)</td></tr>
<tr class="separator:ae90f82418e0aa67218d733dbbc681998"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:acabdfbd3184d3ab3bded61e24142b800"><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="QuEST__cpu__internal_8h.html#acabdfbd3184d3ab3bded61e24142b800">densmatr_mixTwoQubitDepolarisingQ1LocalQ2DistributedPart3</a> (<a class="el" href="structQureg.html">Qureg</a> qureg, int targetQubit, int qubit2, <a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> delta, <a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> gamma)</td></tr>
<tr class="separator:acabdfbd3184d3ab3bded61e24142b800"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:a100463f6ec212c76a5fad99579000505"><td class="memItemLeft" align="right" valign="top">static int </td><td class="memItemRight" valign="bottom"><a class="el" href="QuEST__cpu__internal_8h.html#a100463f6ec212c76a5fad99579000505">extractBit</a> (const int locationOfBitFromRight, const long long int theEncodedNumber)</td></tr>
<tr class="separator:a100463f6ec212c76a5fad99579000505"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:a234f55b49a14dc4c58b1959effeb1b56"><td class="memItemLeft" align="right" valign="top">static long long int </td><td class="memItemRight" valign="bottom"><a class="el" href="QuEST__cpu__internal_8h.html#a234f55b49a14dc4c58b1959effeb1b56">flipBit</a> (const long long int number, const int bitInd)</td></tr>
<tr class="separator:a234f55b49a14dc4c58b1959effeb1b56"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:a8909226b5f0589d82b34af7f6bf2a339"><td class="memItemLeft" align="right" valign="top">static long long int </td><td class="memItemRight" valign="bottom"><a class="el" href="QuEST__cpu__internal_8h.html#a8909226b5f0589d82b34af7f6bf2a339">insertTwoZeroBits</a> (const long long int number, const int bit1, const int bit2)</td></tr>
<tr class="separator:a8909226b5f0589d82b34af7f6bf2a339"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:aa183d46d750769c42ff07ae1aaedc105"><td class="memItemLeft" align="right" valign="top">static long long int </td><td class="memItemRight" valign="bottom"><a class="el" href="QuEST__cpu__internal_8h.html#aa183d46d750769c42ff07ae1aaedc105">insertZeroBit</a> (const long long int number, const int index)</td></tr>
<tr class="separator:aa183d46d750769c42ff07ae1aaedc105"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:a0e4eb651e7cb309bcd664b89ac9a2242"><td class="memItemLeft" align="right" valign="top">static int </td><td class="memItemRight" valign="bottom"><a class="el" href="QuEST__cpu__internal_8h.html#a0e4eb651e7cb309bcd664b89ac9a2242">isOddParity</a> (const long long int number, const int qb1, const int qb2)</td></tr>
<tr class="separator:a0e4eb651e7cb309bcd664b89ac9a2242"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:ae94d012c3da6c84599e99f6afea81f5f"><td class="memItemLeft" align="right" valign="top">static int </td><td class="memItemRight" valign="bottom"><a class="el" href="QuEST__cpu__internal_8h.html#ae94d012c3da6c84599e99f6afea81f5f">maskContainsBit</a> (const long long int mask, const int bitInd)</td></tr>
<tr class="separator:ae94d012c3da6c84599e99f6afea81f5f"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:a16ccb485bcffb328bbd5b2af6977cead"><td class="memItemLeft" align="right" valign="top"><a class="el" href="structComplex.html">Complex</a> </td><td class="memItemRight" valign="bottom"><a class="el" href="QuEST__cpu__internal_8h.html#a16ccb485bcffb328bbd5b2af6977cead">statevec_calcExpecDiagonalOpLocal</a> (<a class="el" href="structQureg.html">Qureg</a> qureg, <a class="el" href="structDiagonalOp.html">DiagonalOp</a> op)</td></tr>
<tr class="separator:a16ccb485bcffb328bbd5b2af6977cead"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:a6fbb3b693f25dde1e9e3dc87dc1984f7"><td class="memItemLeft" align="right" valign="top"><a class="el" href="structComplex.html">Complex</a> </td><td class="memItemRight" valign="bottom"><a class="el" href="QuEST__cpu__internal_8h.html#a6fbb3b693f25dde1e9e3dc87dc1984f7">statevec_calcInnerProductLocal</a> (<a class="el" href="structQureg.html">Qureg</a> bra, <a class="el" href="structQureg.html">Qureg</a> ket)</td></tr>
<tr class="separator:a6fbb3b693f25dde1e9e3dc87dc1984f7"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:ad09bb76ad67581b03ab176832cca37cf"><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="QuEST__cpu__internal_8h.html#ad09bb76ad67581b03ab176832cca37cf">statevec_collapseToKnownProbOutcomeDistributedRenorm</a> (<a class="el" href="structQureg.html">Qureg</a> qureg, int measureQubit, <a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> totalProbability)</td></tr>
<tr class="memdesc:ad09bb76ad67581b03ab176832cca37cf"><td class="mdescLeft"> </td><td class="mdescRight">Renormalise parts of the state vector where measureQubit=0 or 1, based on the total probability of that qubit being in state 0 or 1. <a href="QuEST__cpu__internal_8h.html#ad09bb76ad67581b03ab176832cca37cf">More...</a><br /></td></tr>
<tr class="separator:ad09bb76ad67581b03ab176832cca37cf"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:ab02bce0ebbb8f624e8ced8b09b99cdef"><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="QuEST__cpu__internal_8h.html#ab02bce0ebbb8f624e8ced8b09b99cdef">statevec_collapseToKnownProbOutcomeLocal</a> (<a class="el" href="structQureg.html">Qureg</a> qureg, int measureQubit, int outcome, <a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> totalProbability)</td></tr>
<tr class="memdesc:ab02bce0ebbb8f624e8ced8b09b99cdef"><td class="mdescLeft"> </td><td class="mdescRight">Update the state vector to be consistent with measuring measureQubit=0 if outcome=0 and measureQubit=1 if outcome=1. <a href="QuEST__cpu__internal_8h.html#ab02bce0ebbb8f624e8ced8b09b99cdef">More...</a><br /></td></tr>
<tr class="separator:ab02bce0ebbb8f624e8ced8b09b99cdef"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:a7ea68e9132ed9db9c242353a33dba2f0"><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="QuEST__cpu__internal_8h.html#a7ea68e9132ed9db9c242353a33dba2f0">statevec_collapseToOutcomeDistributedSetZero</a> (<a class="el" href="structQureg.html">Qureg</a> qureg)</td></tr>
<tr class="memdesc:a7ea68e9132ed9db9c242353a33dba2f0"><td class="mdescLeft"> </td><td class="mdescRight">Set all amplitudes in one chunk to 0. <a href="QuEST__cpu__internal_8h.html#a7ea68e9132ed9db9c242353a33dba2f0">More...</a><br /></td></tr>
<tr class="separator:a7ea68e9132ed9db9c242353a33dba2f0"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:a0a7a35628b1c1eb47336deb9afda5b68"><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="QuEST__cpu__internal_8h.html#a0a7a35628b1c1eb47336deb9afda5b68">statevec_compactUnitaryDistributed</a> (<a class="el" href="structQureg.html">Qureg</a> qureg, <a class="el" href="structComplex.html">Complex</a> rot1, <a class="el" href="structComplex.html">Complex</a> rot2, ComplexArray stateVecUp, ComplexArray stateVecLo, ComplexArray stateVecOut)</td></tr>
<tr class="memdesc:a0a7a35628b1c1eb47336deb9afda5b68"><td class="mdescLeft"> </td><td class="mdescRight">Rotate a single qubit in the state vector of probability amplitudes, given two complex numbers alpha and beta, and a subset of the state vector with upper and lower block values stored seperately. <a href="QuEST__cpu__internal_8h.html#a0a7a35628b1c1eb47336deb9afda5b68">More...</a><br /></td></tr>
<tr class="separator:a0a7a35628b1c1eb47336deb9afda5b68"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:a5ddfdb22e4704b680d67d08d9e80835b"><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="QuEST__cpu__internal_8h.html#a5ddfdb22e4704b680d67d08d9e80835b">statevec_compactUnitaryLocal</a> (<a class="el" href="structQureg.html">Qureg</a> qureg, int targetQubit, <a class="el" href="structComplex.html">Complex</a> alpha, <a class="el" href="structComplex.html">Complex</a> beta)</td></tr>
<tr class="separator:a5ddfdb22e4704b680d67d08d9e80835b"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:a071baf8b6951d2a7d6529394b6f39364"><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="QuEST__cpu__internal_8h.html#a071baf8b6951d2a7d6529394b6f39364">statevec_controlledCompactUnitaryDistributed</a> (<a class="el" href="structQureg.html">Qureg</a> qureg, int controlQubit, <a class="el" href="structComplex.html">Complex</a> rot1, <a class="el" href="structComplex.html">Complex</a> rot2, ComplexArray stateVecUp, ComplexArray stateVecLo, ComplexArray stateVecOut)</td></tr>
<tr class="memdesc:a071baf8b6951d2a7d6529394b6f39364"><td class="mdescLeft"> </td><td class="mdescRight">Rotate a single qubit in the state vector of probability amplitudes, given two complex numbers alpha and beta and a subset of the state vector with upper and lower block values stored seperately. <a href="QuEST__cpu__internal_8h.html#a071baf8b6951d2a7d6529394b6f39364">More...</a><br /></td></tr>
<tr class="separator:a071baf8b6951d2a7d6529394b6f39364"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:a215e2d6f88dbecc0b408b3573b5e144f"><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="QuEST__cpu__internal_8h.html#a215e2d6f88dbecc0b408b3573b5e144f">statevec_controlledCompactUnitaryLocal</a> (<a class="el" href="structQureg.html">Qureg</a> qureg, int controlQubit, int targetQubit, <a class="el" href="structComplex.html">Complex</a> alpha, <a class="el" href="structComplex.html">Complex</a> beta)</td></tr>
<tr class="separator:a215e2d6f88dbecc0b408b3573b5e144f"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:a393da4c4bc582a757ca8406d8501aca0"><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="QuEST__cpu__internal_8h.html#a393da4c4bc582a757ca8406d8501aca0">statevec_controlledNotDistributed</a> (<a class="el" href="structQureg.html">Qureg</a> qureg, int controlQubit, ComplexArray stateVecIn, ComplexArray stateVecOut)</td></tr>
<tr class="memdesc:a393da4c4bc582a757ca8406d8501aca0"><td class="mdescLeft"> </td><td class="mdescRight">Rotate a single qubit by {{0,1},{1,0}. <a href="QuEST__cpu__internal_8h.html#a393da4c4bc582a757ca8406d8501aca0">More...</a><br /></td></tr>
<tr class="separator:a393da4c4bc582a757ca8406d8501aca0"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:ace1482ef82b83e7f926634a67b322fc4"><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="QuEST__cpu__internal_8h.html#ace1482ef82b83e7f926634a67b322fc4">statevec_controlledNotLocal</a> (<a class="el" href="structQureg.html">Qureg</a> qureg, int controlQubit, int targetQubit)</td></tr>
<tr class="separator:ace1482ef82b83e7f926634a67b322fc4"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:ae64f9630325b6f93c6e1e17b9918ecef"><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="QuEST__cpu__internal_8h.html#ae64f9630325b6f93c6e1e17b9918ecef">statevec_controlledPauliYDistributed</a> (<a class="el" href="structQureg.html">Qureg</a> qureg, int controlQubit, ComplexArray stateVecIn, ComplexArray stateVecOut, int conjFactor)</td></tr>
<tr class="separator:ae64f9630325b6f93c6e1e17b9918ecef"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:abc6383ac53124601e58922205b3cc484"><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="QuEST__cpu__internal_8h.html#abc6383ac53124601e58922205b3cc484">statevec_controlledPauliYLocal</a> (<a class="el" href="structQureg.html">Qureg</a> qureg, int controlQubit, int targetQubit, int conjFactor)</td></tr>
<tr class="separator:abc6383ac53124601e58922205b3cc484"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:a57368529b2a7e76fec423cbfe9980b22"><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="QuEST__cpu__internal_8h.html#a57368529b2a7e76fec423cbfe9980b22">statevec_controlledUnitaryDistributed</a> (<a class="el" href="structQureg.html">Qureg</a> qureg, int controlQubit, <a class="el" href="structComplex.html">Complex</a> rot1, <a class="el" href="structComplex.html">Complex</a> rot2, ComplexArray stateVecUp, ComplexArray stateVecLo, ComplexArray stateVecOut)</td></tr>
<tr class="memdesc:a57368529b2a7e76fec423cbfe9980b22"><td class="mdescLeft"> </td><td class="mdescRight">Rotate a single qubit in the state vector of probability amplitudes, given two complex numbers alpha and beta and a subset of the state vector with upper and lower block values stored seperately. <a href="QuEST__cpu__internal_8h.html#a57368529b2a7e76fec423cbfe9980b22">More...</a><br /></td></tr>
<tr class="separator:a57368529b2a7e76fec423cbfe9980b22"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:a903beb4f5d8753a964ce2dc5f9096a24"><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="QuEST__cpu__internal_8h.html#a903beb4f5d8753a964ce2dc5f9096a24">statevec_controlledUnitaryLocal</a> (<a class="el" href="structQureg.html">Qureg</a> qureg, int controlQubit, int targetQubit, <a class="el" href="structComplexMatrix2.html">ComplexMatrix2</a> u)</td></tr>
<tr class="separator:a903beb4f5d8753a964ce2dc5f9096a24"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:a430d98e35f1eae7f0815ac539057cf67"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> </td><td class="memItemRight" valign="bottom"><a class="el" href="QuEST__cpu__internal_8h.html#a430d98e35f1eae7f0815ac539057cf67">statevec_findProbabilityOfZeroDistributed</a> (<a class="el" href="structQureg.html">Qureg</a> qureg)</td></tr>
<tr class="memdesc:a430d98e35f1eae7f0815ac539057cf67"><td class="mdescLeft"> </td><td class="mdescRight">Measure the probability of a specified qubit being in the zero state across all amplitudes held in this chunk. <a href="QuEST__cpu__internal_8h.html#a430d98e35f1eae7f0815ac539057cf67">More...</a><br /></td></tr>
<tr class="separator:a430d98e35f1eae7f0815ac539057cf67"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:a8535bc15c2ff249ddddb3fde6eff1490"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> </td><td class="memItemRight" valign="bottom"><a class="el" href="QuEST__cpu__internal_8h.html#a8535bc15c2ff249ddddb3fde6eff1490">statevec_findProbabilityOfZeroLocal</a> (<a class="el" href="structQureg.html">Qureg</a> qureg, int measureQubit)</td></tr>
<tr class="memdesc:a8535bc15c2ff249ddddb3fde6eff1490"><td class="mdescLeft"> </td><td class="mdescRight">Measure the total probability of a specified qubit being in the zero state across all amplitudes in this chunk. <a href="QuEST__cpu__internal_8h.html#a8535bc15c2ff249ddddb3fde6eff1490">More...</a><br /></td></tr>
<tr class="separator:a8535bc15c2ff249ddddb3fde6eff1490"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:abea6570b95fdfa102511ccd1fcb30685"><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="QuEST__cpu__internal_8h.html#abea6570b95fdfa102511ccd1fcb30685">statevec_hadamardDistributed</a> (<a class="el" href="structQureg.html">Qureg</a> qureg, ComplexArray stateVecUp, ComplexArray stateVecLo, ComplexArray stateVecOut, int updateUpper)</td></tr>
<tr class="memdesc:abea6570b95fdfa102511ccd1fcb30685"><td class="mdescLeft"> </td><td class="mdescRight">Rotate a single qubit by {{1,1},{1,-1}}/sqrt2. <a href="QuEST__cpu__internal_8h.html#abea6570b95fdfa102511ccd1fcb30685">More...</a><br /></td></tr>
<tr class="separator:abea6570b95fdfa102511ccd1fcb30685"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:a86dbcc3db99294add9964741e19fbdab"><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="QuEST__cpu__internal_8h.html#a86dbcc3db99294add9964741e19fbdab">statevec_hadamardLocal</a> (<a class="el" href="structQureg.html">Qureg</a> qureg, int targetQubit)</td></tr>
<tr class="separator:a86dbcc3db99294add9964741e19fbdab"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:a0aedcccfa50c7aaa8b7fc4c14d7cdfb8"><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="QuEST__cpu__internal_8h.html#a0aedcccfa50c7aaa8b7fc4c14d7cdfb8">statevec_multiControlledMultiQubitUnitaryLocal</a> (<a class="el" href="structQureg.html">Qureg</a> qureg, long long int ctrlMask, int *targs, int numTargs, <a class="el" href="structComplexMatrixN.html">ComplexMatrixN</a> u)</td></tr>
<tr class="separator:a0aedcccfa50c7aaa8b7fc4c14d7cdfb8"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:af8236a00389137b5eff986a40577eaf3"><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="QuEST__cpu__internal_8h.html#af8236a00389137b5eff986a40577eaf3">statevec_multiControlledTwoQubitUnitaryLocal</a> (<a class="el" href="structQureg.html">Qureg</a> qureg, long long int ctrlMask, int q1, int q2, <a class="el" href="structComplexMatrix4.html">ComplexMatrix4</a> u)</td></tr>
<tr class="separator:af8236a00389137b5eff986a40577eaf3"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:ab58fe4be895283c2c4eb86ec9af5682e"><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="QuEST__cpu__internal_8h.html#ab58fe4be895283c2c4eb86ec9af5682e">statevec_multiControlledUnitaryDistributed</a> (<a class="el" href="structQureg.html">Qureg</a> qureg, int targetQubit, long long int ctrlQubitsMask, long long int ctrlFlipMask, <a class="el" href="structComplex.html">Complex</a> rot1, <a class="el" href="structComplex.html">Complex</a> rot2, ComplexArray stateVecUp, ComplexArray stateVecLo, ComplexArray stateVecOut)</td></tr>
<tr class="memdesc:ab58fe4be895283c2c4eb86ec9af5682e"><td class="mdescLeft"> </td><td class="mdescRight">Apply a unitary operation to a single qubit in the state vector of probability amplitudes, given a subset of the state vector with upper and lower block values stored seperately. <a href="QuEST__cpu__internal_8h.html#ab58fe4be895283c2c4eb86ec9af5682e">More...</a><br /></td></tr>
<tr class="separator:ab58fe4be895283c2c4eb86ec9af5682e"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:ab19f28e68330da68ea3caa2bdef32da9"><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="QuEST__cpu__internal_8h.html#ab19f28e68330da68ea3caa2bdef32da9">statevec_multiControlledUnitaryLocal</a> (<a class="el" href="structQureg.html">Qureg</a> qureg, int targetQubit, long long int ctrlQubitsMask, long long int ctrlFlipMask, <a class="el" href="structComplexMatrix2.html">ComplexMatrix2</a> u)</td></tr>
<tr class="separator:ab19f28e68330da68ea3caa2bdef32da9"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:a464efbd1d7ca5a7b25c83ada001955c2"><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="QuEST__cpu__internal_8h.html#a464efbd1d7ca5a7b25c83ada001955c2">statevec_pauliXDistributed</a> (<a class="el" href="structQureg.html">Qureg</a> qureg, ComplexArray stateVecIn, ComplexArray stateVecOut)</td></tr>
<tr class="memdesc:a464efbd1d7ca5a7b25c83ada001955c2"><td class="mdescLeft"> </td><td class="mdescRight">Rotate a single qubit by {{0,1},{1,0}. <a href="QuEST__cpu__internal_8h.html#a464efbd1d7ca5a7b25c83ada001955c2">More...</a><br /></td></tr>
<tr class="separator:a464efbd1d7ca5a7b25c83ada001955c2"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:aa987d1e0ba97da2ca540194356dd62de"><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="QuEST__cpu__internal_8h.html#aa987d1e0ba97da2ca540194356dd62de">statevec_pauliXLocal</a> (<a class="el" href="structQureg.html">Qureg</a> qureg, int targetQubit)</td></tr>
<tr class="separator:aa987d1e0ba97da2ca540194356dd62de"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:a0f562af6cb665a8a7a3f80e9449734d5"><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="QuEST__cpu__internal_8h.html#a0f562af6cb665a8a7a3f80e9449734d5">statevec_pauliYDistributed</a> (<a class="el" href="structQureg.html">Qureg</a> qureg, ComplexArray stateVecIn, ComplexArray stateVecOut, int updateUpper, int conjFac)</td></tr>
<tr class="memdesc:a0f562af6cb665a8a7a3f80e9449734d5"><td class="mdescLeft"> </td><td class="mdescRight">Rotate a single qubit by +-{{0,-i},{i,0}. <a href="QuEST__cpu__internal_8h.html#a0f562af6cb665a8a7a3f80e9449734d5">More...</a><br /></td></tr>
<tr class="separator:a0f562af6cb665a8a7a3f80e9449734d5"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:a45b0916c3e121837f214b64f7424e479"><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="QuEST__cpu__internal_8h.html#a45b0916c3e121837f214b64f7424e479">statevec_pauliYLocal</a> (<a class="el" href="structQureg.html">Qureg</a> qureg, int targetQubit, int conjFac)</td></tr>
<tr class="separator:a45b0916c3e121837f214b64f7424e479"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:abe74a5a9db8340e37b80fbc77338894d"><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="QuEST__cpu__internal_8h.html#abe74a5a9db8340e37b80fbc77338894d">statevec_swapQubitAmpsDistributed</a> (<a class="el" href="structQureg.html">Qureg</a> qureg, int pairRank, int qb1, int qb2)</td></tr>
<tr class="memdesc:abe74a5a9db8340e37b80fbc77338894d"><td class="mdescLeft"> </td><td class="mdescRight">qureg.pairStateVec contains the entire set of amplitudes of the paired node which includes the set of all amplitudes which need to be swapped between |..0..1..> and |..1..0..> <a href="QuEST__cpu__internal_8h.html#abe74a5a9db8340e37b80fbc77338894d">More...</a><br /></td></tr>
<tr class="separator:abe74a5a9db8340e37b80fbc77338894d"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:ab5b51a28caa8792a3f0c637409a694b0"><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="QuEST__cpu__internal_8h.html#ab5b51a28caa8792a3f0c637409a694b0">statevec_swapQubitAmpsLocal</a> (<a class="el" href="structQureg.html">Qureg</a> qureg, int qb1, int qb2)</td></tr>
<tr class="memdesc:ab5b51a28caa8792a3f0c637409a694b0"><td class="mdescLeft"> </td><td class="mdescRight">It is ensured that all amplitudes needing to be swapped are on this node. <a href="QuEST__cpu__internal_8h.html#ab5b51a28caa8792a3f0c637409a694b0">More...</a><br /></td></tr>
<tr class="separator:ab5b51a28caa8792a3f0c637409a694b0"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:a0ce2c2fd54df25495e99dc5b95bed4b2"><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="QuEST__cpu__internal_8h.html#a0ce2c2fd54df25495e99dc5b95bed4b2">statevec_unitaryDistributed</a> (<a class="el" href="structQureg.html">Qureg</a> qureg, <a class="el" href="structComplex.html">Complex</a> rot1, <a class="el" href="structComplex.html">Complex</a> rot2, ComplexArray stateVecUp, ComplexArray stateVecLo, ComplexArray stateVecOut)</td></tr>
<tr class="memdesc:a0ce2c2fd54df25495e99dc5b95bed4b2"><td class="mdescLeft"> </td><td class="mdescRight">Apply a unitary operation to a single qubit given a subset of the state vector with upper and lower block values stored seperately. <a href="QuEST__cpu__internal_8h.html#a0ce2c2fd54df25495e99dc5b95bed4b2">More...</a><br /></td></tr>
<tr class="separator:a0ce2c2fd54df25495e99dc5b95bed4b2"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:aafc398f8f479fcc066a2dea700235635"><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="QuEST__cpu__internal_8h.html#aafc398f8f479fcc066a2dea700235635">statevec_unitaryLocal</a> (<a class="el" href="structQureg.html">Qureg</a> qureg, int targetQubit, <a class="el" href="structComplexMatrix2.html">ComplexMatrix2</a> u)</td></tr>
<tr class="separator:aafc398f8f479fcc066a2dea700235635"><td class="memSeparator" colspan="2"> </td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<div class="textblock"><p>Internal functions used to implement the pure backend in ../QuEST_ops_pure.h. Do not call these functions directly. In general, qubits_cpu_local.c and qubits_cpu_mpi.c will implement the pure backend by choosing the correct function or combination of functions to use from those included here, which are defined in <a class="el" href="QuEST__cpu_8c.html">QuEST_cpu.c</a></p>
<dl class="section author"><dt>Author</dt><dd>Ania Brown </dd>
<dd>
Tyson Jones </dd>
<dd>
Balint Koczor </dd></dl>
<p class="definition">Definition in file <a class="el" href="QuEST__cpu__internal_8h_source.html">QuEST_cpu_internal.h</a>.</p>
</div><h2 class="groupheader">Function Documentation</h2>
<a id="afa58cf7cb98a25ab33621120c5c330d0"></a>
<h2 class="memtitle"><span class="permalink"><a href="#afa58cf7cb98a25ab33621120c5c330d0">◆ </a></span>densmatr_applyDiagonalOpLocal()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void densmatr_applyDiagonalOpLocal </td>
<td>(</td>
<td class="paramtype"><a class="el" href="structQureg.html">Qureg</a> </td>
<td class="paramname"><em>qureg</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype"><a class="el" href="structDiagonalOp.html">DiagonalOp</a> </td>
<td class="paramname"><em>op</em> </td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</div><div class="memdoc">
<p class="definition">Definition at line <a class="el" href="QuEST__cpu_8c_source.html#l03696">3696</a> of file <a class="el" href="QuEST__cpu_8c_source.html">QuEST_cpu.c</a>.</p>
<div class="fragment"><div class="line"><a name="l03696"></a><span class="lineno"> 3696</span>  {</div>
<div class="line"><a name="l03697"></a><span class="lineno"> 3697</span>  </div>
<div class="line"><a name="l03698"></a><span class="lineno"> 3698</span>  <span class="comment">/* ALL values of op are pre-loaded into qureg.pairStateVector (on every node).</span></div>
<div class="line"><a name="l03699"></a><span class="lineno"> 3699</span> <span class="comment"> * Furthermore, since it's gauranteed each node contains an integer number of </span></div>
<div class="line"><a name="l03700"></a><span class="lineno"> 3700</span> <span class="comment"> * columns of qureg (because op upperlimits the number of nodes; 1 per element),</span></div>
<div class="line"><a name="l03701"></a><span class="lineno"> 3701</span> <span class="comment"> * then we know iteration below begins at the 'top' of a column, and there is </span></div>
<div class="line"><a name="l03702"></a><span class="lineno"> 3702</span> <span class="comment"> * no offset for op (pairStateVector)</span></div>
<div class="line"><a name="l03703"></a><span class="lineno"> 3703</span> <span class="comment"> */</span></div>
<div class="line"><a name="l03704"></a><span class="lineno"> 3704</span>  </div>
<div class="line"><a name="l03705"></a><span class="lineno"> 3705</span>  <span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> numAmps = qureg.<a class="code" href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">numAmpsPerChunk</a>;</div>
<div class="line"><a name="l03706"></a><span class="lineno"> 3706</span>  <span class="keywordtype">int</span> opDim = (1 << op.<a class="code" href="structDiagonalOp.html#a5131eeb67aafb4c19ac98270c3266742">numQubits</a>);</div>
<div class="line"><a name="l03707"></a><span class="lineno"> 3707</span>  </div>
<div class="line"><a name="l03708"></a><span class="lineno"> 3708</span>  <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>* stateRe = qureg.<a class="code" href="structQureg.html#a441e4cacef6bd17adb9813c7442d42fe">stateVec</a>.real;</div>
<div class="line"><a name="l03709"></a><span class="lineno"> 3709</span>  <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>* stateIm = qureg.<a class="code" href="structQureg.html#a441e4cacef6bd17adb9813c7442d42fe">stateVec</a>.imag;</div>
<div class="line"><a name="l03710"></a><span class="lineno"> 3710</span>  <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>* opRe = qureg.<a class="code" href="structQureg.html#aba97773694870ef35e378c036f486bb7">pairStateVec</a>.real;</div>
<div class="line"><a name="l03711"></a><span class="lineno"> 3711</span>  <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>* opIm = qureg.<a class="code" href="structQureg.html#aba97773694870ef35e378c036f486bb7">pairStateVec</a>.imag;</div>
<div class="line"><a name="l03712"></a><span class="lineno"> 3712</span>  </div>
<div class="line"><a name="l03713"></a><span class="lineno"> 3713</span>  <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> a,b,c,d;</div>
<div class="line"><a name="l03714"></a><span class="lineno"> 3714</span>  <span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> index;</div>
<div class="line"><a name="l03715"></a><span class="lineno"> 3715</span>  </div>
<div class="line"><a name="l03716"></a><span class="lineno"> 3716</span> <span class="preprocessor"># ifdef _OPENMP</span></div>
<div class="line"><a name="l03717"></a><span class="lineno"> 3717</span> <span class="preprocessor"># pragma omp parallel \</span></div>
<div class="line"><a name="l03718"></a><span class="lineno"> 3718</span> <span class="preprocessor"> shared (stateRe,stateIm, opRe,opIm, numAmps,opDim) \</span></div>
<div class="line"><a name="l03719"></a><span class="lineno"> 3719</span> <span class="preprocessor"> private (index, a,b,c,d)</span></div>
<div class="line"><a name="l03720"></a><span class="lineno"> 3720</span> <span class="preprocessor"># endif </span></div>
<div class="line"><a name="l03721"></a><span class="lineno"> 3721</span>  {</div>
<div class="line"><a name="l03722"></a><span class="lineno"> 3722</span> <span class="preprocessor"># ifdef _OPENMP</span></div>
<div class="line"><a name="l03723"></a><span class="lineno"> 3723</span> <span class="preprocessor"># pragma omp for schedule (static)</span></div>
<div class="line"><a name="l03724"></a><span class="lineno"> 3724</span> <span class="preprocessor"># endif</span></div>
<div class="line"><a name="l03725"></a><span class="lineno"> 3725</span>  <span class="keywordflow">for</span> (index=0LL; index<numAmps; index++) {</div>
<div class="line"><a name="l03726"></a><span class="lineno"> 3726</span>  a = stateRe[index];</div>
<div class="line"><a name="l03727"></a><span class="lineno"> 3727</span>  b = stateIm[index];</div>
<div class="line"><a name="l03728"></a><span class="lineno"> 3728</span>  c = opRe[index % opDim];</div>
<div class="line"><a name="l03729"></a><span class="lineno"> 3729</span>  d = opIm[index % opDim];</div>
<div class="line"><a name="l03730"></a><span class="lineno"> 3730</span>  </div>
<div class="line"><a name="l03731"></a><span class="lineno"> 3731</span>  <span class="comment">// (a + b i)(c + d i) = (a c - b d) + i (a d + b c)</span></div>
<div class="line"><a name="l03732"></a><span class="lineno"> 3732</span>  stateRe[index] = a*c - b*d;</div>
<div class="line"><a name="l03733"></a><span class="lineno"> 3733</span>  stateIm[index] = a*d + b*c;</div>
<div class="line"><a name="l03734"></a><span class="lineno"> 3734</span>  }</div>
<div class="line"><a name="l03735"></a><span class="lineno"> 3735</span>  }</div>
<div class="line"><a name="l03736"></a><span class="lineno"> 3736</span> }</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST_8h_source.html#l00213">Qureg::numAmpsPerChunk</a>, <a class="el" href="QuEST_8h_source.html#l00181">DiagonalOp::numQubits</a>, <a class="el" href="QuEST_8h_source.html#l00224">Qureg::pairStateVec</a>, <a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>, and <a class="el" href="QuEST_8h_source.html#l00222">Qureg::stateVec</a>.</p>
<p class="reference">Referenced by <a class="el" href="QuEST__cpu__distributed_8c_source.html#l01517">densmatr_applyDiagonalOp()</a>.</p>
</div>
</div>
<a id="aeb4453a2e609e5359d2995bccf6663ca"></a>
<h2 class="memtitle"><span class="permalink"><a href="#aeb4453a2e609e5359d2995bccf6663ca">◆ </a></span>densmatr_calcExpecDiagonalOpLocal()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname"><a class="el" href="structComplex.html">Complex</a> densmatr_calcExpecDiagonalOpLocal </td>
<td>(</td>
<td class="paramtype"><a class="el" href="structQureg.html">Qureg</a> </td>
<td class="paramname"><em>qureg</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype"><a class="el" href="structDiagonalOp.html">DiagonalOp</a> </td>
<td class="paramname"><em>op</em> </td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</div><div class="memdoc">
<p class="definition">Definition at line <a class="el" href="QuEST__cpu_8c_source.html#l03781">3781</a> of file <a class="el" href="QuEST__cpu_8c_source.html">QuEST_cpu.c</a>.</p>
<div class="fragment"><div class="line"><a name="l03781"></a><span class="lineno"> 3781</span>  {</div>
<div class="line"><a name="l03782"></a><span class="lineno"> 3782</span>  </div>
<div class="line"><a name="l03783"></a><span class="lineno"> 3783</span>  <span class="comment">/* since for every 1 element in \p op, there exists a column in \p qureg, </span></div>
<div class="line"><a name="l03784"></a><span class="lineno"> 3784</span> <span class="comment"> * we know that the elements in \p op live on the same node as the </span></div>
<div class="line"><a name="l03785"></a><span class="lineno"> 3785</span> <span class="comment"> * corresponding diagonal elements of \p qureg. This means, the problem is </span></div>
<div class="line"><a name="l03786"></a><span class="lineno"> 3786</span> <span class="comment"> * embarrassingly parallelisable, and the code below works for both </span></div>
<div class="line"><a name="l03787"></a><span class="lineno"> 3787</span> <span class="comment"> * serial and distributed modes.</span></div>
<div class="line"><a name="l03788"></a><span class="lineno"> 3788</span> <span class="comment"> */</span></div>
<div class="line"><a name="l03789"></a><span class="lineno"> 3789</span>  </div>
<div class="line"><a name="l03790"></a><span class="lineno"> 3790</span>  <span class="comment">// computes first local index containing a diagonal element</span></div>
<div class="line"><a name="l03791"></a><span class="lineno"> 3791</span>  <span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> diagSpacing = 1LL + (1LL << qureg.<a class="code" href="structQureg.html#ad08dff5316b8937f4b2a1417591543dc">numQubitsRepresented</a>);</div>
<div class="line"><a name="l03792"></a><span class="lineno"> 3792</span>  <span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> numPrevDiags = (qureg.<a class="code" href="structQureg.html#ac2929e681d3d95591c18cf168dbbe4f0">chunkId</a>>0)? 1+(qureg.<a class="code" href="structQureg.html#ac2929e681d3d95591c18cf168dbbe4f0">chunkId</a>*qureg.<a class="code" href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">numAmpsPerChunk</a>)/diagSpacing : 0;</div>
<div class="line"><a name="l03793"></a><span class="lineno"> 3793</span>  <span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> globalIndNextDiag = diagSpacing * numPrevDiags;</div>
<div class="line"><a name="l03794"></a><span class="lineno"> 3794</span>  <span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> localIndNextDiag = globalIndNextDiag % qureg.<a class="code" href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">numAmpsPerChunk</a>;</div>
<div class="line"><a name="l03795"></a><span class="lineno"> 3795</span>  <span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> numAmps = qureg.<a class="code" href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">numAmpsPerChunk</a>;</div>
<div class="line"><a name="l03796"></a><span class="lineno"> 3796</span>  </div>
<div class="line"><a name="l03797"></a><span class="lineno"> 3797</span>  <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>* stateReal = qureg.<a class="code" href="structQureg.html#a441e4cacef6bd17adb9813c7442d42fe">stateVec</a>.real;</div>
<div class="line"><a name="l03798"></a><span class="lineno"> 3798</span>  <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>* stateImag = qureg.<a class="code" href="structQureg.html#a441e4cacef6bd17adb9813c7442d42fe">stateVec</a>.imag;</div>
<div class="line"><a name="l03799"></a><span class="lineno"> 3799</span>  <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>* opReal = op.<a class="code" href="structDiagonalOp.html#a1d66088bed235d524cd452b107694d5c">real</a>;</div>
<div class="line"><a name="l03800"></a><span class="lineno"> 3800</span>  <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>* opImag = op.<a class="code" href="structDiagonalOp.html#a85c3f52533efe831bbe40b9a48602388">imag</a>;</div>
<div class="line"><a name="l03801"></a><span class="lineno"> 3801</span>  </div>
<div class="line"><a name="l03802"></a><span class="lineno"> 3802</span>  <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> expecRe = 0;</div>
<div class="line"><a name="l03803"></a><span class="lineno"> 3803</span>  <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> expecIm = 0;</div>
<div class="line"><a name="l03804"></a><span class="lineno"> 3804</span>  </div>
<div class="line"><a name="l03805"></a><span class="lineno"> 3805</span>  <span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> stateInd;</div>
<div class="line"><a name="l03806"></a><span class="lineno"> 3806</span>  <span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> opInd;</div>
<div class="line"><a name="l03807"></a><span class="lineno"> 3807</span>  <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> matRe, matIm, opRe, opIm;</div>
<div class="line"><a name="l03808"></a><span class="lineno"> 3808</span>  </div>
<div class="line"><a name="l03809"></a><span class="lineno"> 3809</span>  <span class="comment">// visits every diagonal element with global index (2^n + 1)i for i in [0, 2^n-1]</span></div>
<div class="line"><a name="l03810"></a><span class="lineno"> 3810</span>  </div>
<div class="line"><a name="l03811"></a><span class="lineno"> 3811</span> <span class="preprocessor"># ifdef _OPENMP</span></div>
<div class="line"><a name="l03812"></a><span class="lineno"> 3812</span> <span class="preprocessor"># pragma omp parallel \</span></div>
<div class="line"><a name="l03813"></a><span class="lineno"> 3813</span> <span class="preprocessor"> shared (stateReal,stateImag, opReal,opImag, localIndNextDiag,diagSpacing,numAmps) \</span></div>
<div class="line"><a name="l03814"></a><span class="lineno"> 3814</span> <span class="preprocessor"> private (stateInd,opInd, matRe,matIm, opRe,opIm) \</span></div>
<div class="line"><a name="l03815"></a><span class="lineno"> 3815</span> <span class="preprocessor"> reduction ( +:expecRe, expecIm )</span></div>
<div class="line"><a name="l03816"></a><span class="lineno"> 3816</span> <span class="preprocessor"># endif </span></div>
<div class="line"><a name="l03817"></a><span class="lineno"> 3817</span>  {</div>
<div class="line"><a name="l03818"></a><span class="lineno"> 3818</span> <span class="preprocessor"># ifdef _OPENMP</span></div>
<div class="line"><a name="l03819"></a><span class="lineno"> 3819</span> <span class="preprocessor"># pragma omp for schedule (static)</span></div>
<div class="line"><a name="l03820"></a><span class="lineno"> 3820</span> <span class="preprocessor"># endif</span></div>
<div class="line"><a name="l03821"></a><span class="lineno"> 3821</span>  <span class="keywordflow">for</span> (stateInd=localIndNextDiag; stateInd < numAmps; stateInd += diagSpacing) {</div>
<div class="line"><a name="l03822"></a><span class="lineno"> 3822</span>  </div>
<div class="line"><a name="l03823"></a><span class="lineno"> 3823</span>  matRe = stateReal[stateInd];</div>
<div class="line"><a name="l03824"></a><span class="lineno"> 3824</span>  matIm = stateImag[stateInd];</div>
<div class="line"><a name="l03825"></a><span class="lineno"> 3825</span>  opInd = (stateInd - localIndNextDiag) / diagSpacing;</div>
<div class="line"><a name="l03826"></a><span class="lineno"> 3826</span>  opRe = opReal[opInd];</div>
<div class="line"><a name="l03827"></a><span class="lineno"> 3827</span>  opIm = opImag[opInd];</div>
<div class="line"><a name="l03828"></a><span class="lineno"> 3828</span>  </div>
<div class="line"><a name="l03829"></a><span class="lineno"> 3829</span>  <span class="comment">// (matRe + matIm i)(opRe + opIm i) = </span></div>
<div class="line"><a name="l03830"></a><span class="lineno"> 3830</span>  <span class="comment">// (matRe opRe - matIm opIm) + i (matRe opIm + matIm opRe)</span></div>
<div class="line"><a name="l03831"></a><span class="lineno"> 3831</span>  expecRe += matRe * opRe - matIm * opIm;</div>
<div class="line"><a name="l03832"></a><span class="lineno"> 3832</span>  expecIm += matRe * opIm + matIm * opRe;</div>
<div class="line"><a name="l03833"></a><span class="lineno"> 3833</span>  }</div>
<div class="line"><a name="l03834"></a><span class="lineno"> 3834</span>  }</div>
<div class="line"><a name="l03835"></a><span class="lineno"> 3835</span>  </div>
<div class="line"><a name="l03836"></a><span class="lineno"> 3836</span>  <a class="code" href="structComplex.html">Complex</a> expecVal;</div>
<div class="line"><a name="l03837"></a><span class="lineno"> 3837</span>  expecVal.<a class="code" href="structComplex.html#ab5b2e2eca02131fc74b289a83636cbe3">real</a> = expecRe;</div>
<div class="line"><a name="l03838"></a><span class="lineno"> 3838</span>  expecVal.<a class="code" href="structComplex.html#a84f5439aad0ef495efdd3b4c1c02d27e">imag</a> = expecIm;</div>
<div class="line"><a name="l03839"></a><span class="lineno"> 3839</span>  <span class="keywordflow">return</span> expecVal;</div>
<div class="line"><a name="l03840"></a><span class="lineno"> 3840</span> }</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST_8h_source.html#l00217">Qureg::chunkId</a>, <a class="el" href="QuEST_8h_source.html#l00106">Complex::imag</a>, <a class="el" href="QuEST_8h_source.html#l00191">DiagonalOp::imag</a>, <a class="el" href="QuEST_8h_source.html#l00213">Qureg::numAmpsPerChunk</a>, <a class="el" href="QuEST_8h_source.html#l00208">Qureg::numQubitsRepresented</a>, <a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>, <a class="el" href="QuEST_8h_source.html#l00105">Complex::real</a>, <a class="el" href="QuEST_8h_source.html#l00189">DiagonalOp::real</a>, and <a class="el" href="QuEST_8h_source.html#l00222">Qureg::stateVec</a>.</p>
<p class="reference">Referenced by <a class="el" href="QuEST__cpu__distributed_8c_source.html#l01541">densmatr_calcExpecDiagonalOp()</a>.</p>
</div>
</div>
<a id="a7772f97cb4d92a9825bf3b7c82c3230c"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a7772f97cb4d92a9825bf3b7c82c3230c">◆ </a></span>densmatr_calcFidelityLocal()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname"><a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> densmatr_calcFidelityLocal </td>
<td>(</td>
<td class="paramtype"><a class="el" href="structQureg.html">Qureg</a> </td>
<td class="paramname"><em>qureg</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype"><a class="el" href="structQureg.html">Qureg</a> </td>
<td class="paramname"><em>pureState</em> </td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</div><div class="memdoc">
<p>computes a few dens-columns-worth of (vec^*T) dens * vec </p>
<p class="definition">Definition at line <a class="el" href="QuEST__cpu_8c_source.html#l00990">990</a> of file <a class="el" href="QuEST__cpu_8c_source.html">QuEST_cpu.c</a>.</p>
<div class="fragment"><div class="line"><a name="l00990"></a><span class="lineno"> 990</span>  {</div>
<div class="line"><a name="l00991"></a><span class="lineno"> 991</span>  </div>
<div class="line"><a name="l00992"></a><span class="lineno"> 992</span>  <span class="comment">/* Here, elements of pureState are not accessed (instead grabbed from qureg.pair).</span></div>
<div class="line"><a name="l00993"></a><span class="lineno"> 993</span> <span class="comment"> * We only consult the attributes.</span></div>
<div class="line"><a name="l00994"></a><span class="lineno"> 994</span> <span class="comment"> *</span></div>
<div class="line"><a name="l00995"></a><span class="lineno"> 995</span> <span class="comment"> * qureg is a density matrix, and pureState is a statevector.</span></div>
<div class="line"><a name="l00996"></a><span class="lineno"> 996</span> <span class="comment"> * Every node contains as many columns of qureg as amps by pureState.</span></div>
<div class="line"><a name="l00997"></a><span class="lineno"> 997</span> <span class="comment"> * (each node contains an integer, exponent-of-2 number of whole columns of qureg)</span></div>
<div class="line"><a name="l00998"></a><span class="lineno"> 998</span> <span class="comment"> * Ergo, this node contains columns:</span></div>
<div class="line"><a name="l00999"></a><span class="lineno"> 999</span> <span class="comment"> * qureg.chunkID * pureState.numAmpsPerChunk to</span></div>
<div class="line"><a name="l01000"></a><span class="lineno"> 1000</span> <span class="comment"> * (qureg.chunkID + 1) * pureState.numAmpsPerChunk</span></div>
<div class="line"><a name="l01001"></a><span class="lineno"> 1001</span> <span class="comment"> *</span></div>
<div class="line"><a name="l01002"></a><span class="lineno"> 1002</span> <span class="comment"> * The first pureState.numAmpsTotal elements of qureg.pairStateVec are the</span></div>
<div class="line"><a name="l01003"></a><span class="lineno"> 1003</span> <span class="comment"> * entire pureState state-vector</span></div>
<div class="line"><a name="l01004"></a><span class="lineno"> 1004</span> <span class="comment"> */</span></div>
<div class="line"><a name="l01005"></a><span class="lineno"> 1005</span>  </div>
<div class="line"><a name="l01006"></a><span class="lineno"> 1006</span>  <span class="comment">// unpack everything for OPENMP</span></div>
<div class="line"><a name="l01007"></a><span class="lineno"> 1007</span>  <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>* vecRe = qureg.<a class="code" href="structQureg.html#aba97773694870ef35e378c036f486bb7">pairStateVec</a>.real;</div>
<div class="line"><a name="l01008"></a><span class="lineno"> 1008</span>  <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>* vecIm = qureg.<a class="code" href="structQureg.html#aba97773694870ef35e378c036f486bb7">pairStateVec</a>.imag;</div>
<div class="line"><a name="l01009"></a><span class="lineno"> 1009</span>  <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>* densRe = qureg.<a class="code" href="structQureg.html#a441e4cacef6bd17adb9813c7442d42fe">stateVec</a>.real;</div>
<div class="line"><a name="l01010"></a><span class="lineno"> 1010</span>  <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>* densIm = qureg.<a class="code" href="structQureg.html#a441e4cacef6bd17adb9813c7442d42fe">stateVec</a>.imag;</div>
<div class="line"><a name="l01011"></a><span class="lineno"> 1011</span>  </div>
<div class="line"><a name="l01012"></a><span class="lineno"> 1012</span>  <span class="keywordtype">int</span> row, col;</div>
<div class="line"><a name="l01013"></a><span class="lineno"> 1013</span>  <span class="keywordtype">int</span> dim = (int) pureState.<a class="code" href="structQureg.html#adef4935cac95763c29164cf99b144ed4">numAmpsTotal</a>; </div>
<div class="line"><a name="l01014"></a><span class="lineno"> 1014</span>  <span class="keywordtype">int</span> colsPerNode = (<span class="keywordtype">int</span>) pureState.<a class="code" href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">numAmpsPerChunk</a>;</div>
<div class="line"><a name="l01015"></a><span class="lineno"> 1015</span>  <span class="comment">// using only int, because density matrix has squared as many amps so its </span></div>
<div class="line"><a name="l01016"></a><span class="lineno"> 1016</span>  <span class="comment">// iteration would be impossible if the pureStates numAmpsTotal didn't fit into int</span></div>
<div class="line"><a name="l01017"></a><span class="lineno"> 1017</span>  </div>
<div class="line"><a name="l01018"></a><span class="lineno"> 1018</span>  <span class="comment">// starting GLOBAL column index of the qureg columns on this node</span></div>
<div class="line"><a name="l01019"></a><span class="lineno"> 1019</span>  <span class="keywordtype">int</span> startCol = (int) (qureg.<a class="code" href="structQureg.html#ac2929e681d3d95591c18cf168dbbe4f0">chunkId</a> * pureState.<a class="code" href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">numAmpsPerChunk</a>);</div>
<div class="line"><a name="l01020"></a><span class="lineno"> 1020</span>  </div>
<div class="line"><a name="l01021"></a><span class="lineno"> 1021</span>  <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> densElemRe, densElemIm;</div>
<div class="line"><a name="l01022"></a><span class="lineno"> 1022</span>  <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> prefacRe, prefacIm;</div>
<div class="line"><a name="l01023"></a><span class="lineno"> 1023</span>  <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> rowSumRe, rowSumIm;</div>
<div class="line"><a name="l01024"></a><span class="lineno"> 1024</span>  <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> vecElemRe, vecElemIm;</div>
<div class="line"><a name="l01025"></a><span class="lineno"> 1025</span>  </div>
<div class="line"><a name="l01026"></a><span class="lineno"> 1026</span>  <span class="comment">// quantity computed by this node</span></div>
<div class="line"><a name="l01027"></a><span class="lineno"> 1027</span>  <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> globalSumRe = 0; <span class="comment">// imag-component is assumed zero</span></div>
<div class="line"><a name="l01028"></a><span class="lineno"> 1028</span>  </div>
<div class="line"><a name="l01029"></a><span class="lineno"> 1029</span> <span class="preprocessor"># ifdef _OPENMP</span></div>
<div class="line"><a name="l01030"></a><span class="lineno"> 1030</span> <span class="preprocessor"># pragma omp parallel \</span></div>
<div class="line"><a name="l01031"></a><span class="lineno"> 1031</span> <span class="preprocessor"> shared (vecRe,vecIm,densRe,densIm, dim,colsPerNode,startCol) \</span></div>
<div class="line"><a name="l01032"></a><span class="lineno"> 1032</span> <span class="preprocessor"> private (row,col, prefacRe,prefacIm, rowSumRe,rowSumIm, densElemRe,densElemIm, vecElemRe,vecElemIm) \</span></div>
<div class="line"><a name="l01033"></a><span class="lineno"> 1033</span> <span class="preprocessor"> reduction ( +:globalSumRe )</span></div>
<div class="line"><a name="l01034"></a><span class="lineno"> 1034</span> <span class="preprocessor"># endif </span></div>
<div class="line"><a name="l01035"></a><span class="lineno"> 1035</span>  {</div>
<div class="line"><a name="l01036"></a><span class="lineno"> 1036</span> <span class="preprocessor"># ifdef _OPENMP</span></div>
<div class="line"><a name="l01037"></a><span class="lineno"> 1037</span> <span class="preprocessor"># pragma omp for schedule (static)</span></div>
<div class="line"><a name="l01038"></a><span class="lineno"> 1038</span> <span class="preprocessor"># endif</span></div>
<div class="line"><a name="l01039"></a><span class="lineno"> 1039</span>  <span class="comment">// indices of my GLOBAL row</span></div>
<div class="line"><a name="l01040"></a><span class="lineno"> 1040</span>  <span class="keywordflow">for</span> (row=0; row < dim; row++) {</div>
<div class="line"><a name="l01041"></a><span class="lineno"> 1041</span>  </div>
<div class="line"><a name="l01042"></a><span class="lineno"> 1042</span>  <span class="comment">// single element of conj(pureState)</span></div>
<div class="line"><a name="l01043"></a><span class="lineno"> 1043</span>  prefacRe = vecRe[row];</div>
<div class="line"><a name="l01044"></a><span class="lineno"> 1044</span>  prefacIm = - vecIm[row];</div>
<div class="line"><a name="l01045"></a><span class="lineno"> 1045</span>  </div>
<div class="line"><a name="l01046"></a><span class="lineno"> 1046</span>  rowSumRe = 0;</div>
<div class="line"><a name="l01047"></a><span class="lineno"> 1047</span>  rowSumIm = 0;</div>
<div class="line"><a name="l01048"></a><span class="lineno"> 1048</span>  </div>
<div class="line"><a name="l01049"></a><span class="lineno"> 1049</span>  <span class="comment">// indices of my LOCAL column</span></div>
<div class="line"><a name="l01050"></a><span class="lineno"> 1050</span>  <span class="keywordflow">for</span> (col=0; col < colsPerNode; col++) {</div>
<div class="line"><a name="l01051"></a><span class="lineno"> 1051</span>  </div>
<div class="line"><a name="l01052"></a><span class="lineno"> 1052</span>  <span class="comment">// my local density element</span></div>
<div class="line"><a name="l01053"></a><span class="lineno"> 1053</span>  densElemRe = densRe[row + dim*col];</div>
<div class="line"><a name="l01054"></a><span class="lineno"> 1054</span>  densElemIm = densIm[row + dim*col];</div>
<div class="line"><a name="l01055"></a><span class="lineno"> 1055</span>  </div>
<div class="line"><a name="l01056"></a><span class="lineno"> 1056</span>  <span class="comment">// state-vector element</span></div>
<div class="line"><a name="l01057"></a><span class="lineno"> 1057</span>  vecElemRe = vecRe[startCol + col];</div>
<div class="line"><a name="l01058"></a><span class="lineno"> 1058</span>  vecElemIm = vecIm[startCol + col];</div>
<div class="line"><a name="l01059"></a><span class="lineno"> 1059</span>  </div>
<div class="line"><a name="l01060"></a><span class="lineno"> 1060</span>  rowSumRe += densElemRe*vecElemRe - densElemIm*vecElemIm;</div>
<div class="line"><a name="l01061"></a><span class="lineno"> 1061</span>  rowSumIm += densElemRe*vecElemIm + densElemIm*vecElemRe;</div>
<div class="line"><a name="l01062"></a><span class="lineno"> 1062</span>  }</div>
<div class="line"><a name="l01063"></a><span class="lineno"> 1063</span>  </div>
<div class="line"><a name="l01064"></a><span class="lineno"> 1064</span>  globalSumRe += rowSumRe*prefacRe - rowSumIm*prefacIm; </div>
<div class="line"><a name="l01065"></a><span class="lineno"> 1065</span>  }</div>
<div class="line"><a name="l01066"></a><span class="lineno"> 1066</span>  }</div>
<div class="line"><a name="l01067"></a><span class="lineno"> 1067</span>  </div>
<div class="line"><a name="l01068"></a><span class="lineno"> 1068</span>  <span class="keywordflow">return</span> globalSumRe;</div>
<div class="line"><a name="l01069"></a><span class="lineno"> 1069</span> }</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST_8h_source.html#l00217">Qureg::chunkId</a>, <a class="el" href="QuEST_8h_source.html#l00213">Qureg::numAmpsPerChunk</a>, <a class="el" href="QuEST_8h_source.html#l00215">Qureg::numAmpsTotal</a>, <a class="el" href="QuEST_8h_source.html#l00224">Qureg::pairStateVec</a>, <a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>, and <a class="el" href="QuEST_8h_source.html#l00222">Qureg::stateVec</a>.</p>
<p class="reference">Referenced by <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00415">densmatr_calcFidelity()</a>.</p>
</div>
</div>
<a id="a939897137596bb73ad7a028d0beaaa10"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a939897137596bb73ad7a028d0beaaa10">◆ </a></span>densmatr_calcHilbertSchmidtDistanceSquaredLocal()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname"><a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> densmatr_calcHilbertSchmidtDistanceSquaredLocal </td>
<td>(</td>
<td class="paramtype"><a class="el" href="structQureg.html">Qureg</a> </td>
<td class="paramname"><em>a</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype"><a class="el" href="structQureg.html">Qureg</a> </td>
<td class="paramname"><em>b</em> </td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</div><div class="memdoc">
<p>computes Tr((a-b) conjTrans(a-b)) = sum of abs values of (a-b) </p>
<p class="definition">Definition at line <a class="el" href="QuEST__cpu_8c_source.html#l00923">923</a> of file <a class="el" href="QuEST__cpu_8c_source.html">QuEST_cpu.c</a>.</p>
<div class="fragment"><div class="line"><a name="l00923"></a><span class="lineno"> 923</span>  {</div>
<div class="line"><a name="l00924"></a><span class="lineno"> 924</span>  </div>
<div class="line"><a name="l00925"></a><span class="lineno"> 925</span>  <span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> index;</div>
<div class="line"><a name="l00926"></a><span class="lineno"> 926</span>  <span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> numAmps = a.<a class="code" href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">numAmpsPerChunk</a>;</div>
<div class="line"><a name="l00927"></a><span class="lineno"> 927</span>  </div>
<div class="line"><a name="l00928"></a><span class="lineno"> 928</span>  <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> *aRe = a.<a class="code" href="structQureg.html#a441e4cacef6bd17adb9813c7442d42fe">stateVec</a>.real;</div>
<div class="line"><a name="l00929"></a><span class="lineno"> 929</span>  <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> *aIm = a.<a class="code" href="structQureg.html#a441e4cacef6bd17adb9813c7442d42fe">stateVec</a>.imag;</div>
<div class="line"><a name="l00930"></a><span class="lineno"> 930</span>  <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> *bRe = b.<a class="code" href="structQureg.html#a441e4cacef6bd17adb9813c7442d42fe">stateVec</a>.real;</div>
<div class="line"><a name="l00931"></a><span class="lineno"> 931</span>  <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> *bIm = b.<a class="code" href="structQureg.html#a441e4cacef6bd17adb9813c7442d42fe">stateVec</a>.imag;</div>
<div class="line"><a name="l00932"></a><span class="lineno"> 932</span>  </div>
<div class="line"><a name="l00933"></a><span class="lineno"> 933</span>  <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> trace = 0;</div>
<div class="line"><a name="l00934"></a><span class="lineno"> 934</span>  <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> difRe, difIm;</div>
<div class="line"><a name="l00935"></a><span class="lineno"> 935</span>  </div>
<div class="line"><a name="l00936"></a><span class="lineno"> 936</span> <span class="preprocessor"># ifdef _OPENMP</span></div>
<div class="line"><a name="l00937"></a><span class="lineno"> 937</span> <span class="preprocessor"># pragma omp parallel \</span></div>
<div class="line"><a name="l00938"></a><span class="lineno"> 938</span> <span class="preprocessor"> shared (aRe,aIm, bRe,bIm, numAmps) \</span></div>
<div class="line"><a name="l00939"></a><span class="lineno"> 939</span> <span class="preprocessor"> private (index,difRe,difIm) \</span></div>
<div class="line"><a name="l00940"></a><span class="lineno"> 940</span> <span class="preprocessor"> reduction ( +:trace )</span></div>
<div class="line"><a name="l00941"></a><span class="lineno"> 941</span> <span class="preprocessor"># endif </span></div>
<div class="line"><a name="l00942"></a><span class="lineno"> 942</span>  {</div>
<div class="line"><a name="l00943"></a><span class="lineno"> 943</span> <span class="preprocessor"># ifdef _OPENMP</span></div>
<div class="line"><a name="l00944"></a><span class="lineno"> 944</span> <span class="preprocessor"># pragma omp for schedule (static)</span></div>
<div class="line"><a name="l00945"></a><span class="lineno"> 945</span> <span class="preprocessor"># endif</span></div>
<div class="line"><a name="l00946"></a><span class="lineno"> 946</span>  <span class="keywordflow">for</span> (index=0LL; index<numAmps; index++) {</div>
<div class="line"><a name="l00947"></a><span class="lineno"> 947</span>  </div>
<div class="line"><a name="l00948"></a><span class="lineno"> 948</span>  difRe = aRe[index] - bRe[index];</div>
<div class="line"><a name="l00949"></a><span class="lineno"> 949</span>  difIm = aIm[index] - bIm[index];</div>
<div class="line"><a name="l00950"></a><span class="lineno"> 950</span>  trace += difRe*difRe + difIm*difIm;</div>
<div class="line"><a name="l00951"></a><span class="lineno"> 951</span>  }</div>
<div class="line"><a name="l00952"></a><span class="lineno"> 952</span>  }</div>
<div class="line"><a name="l00953"></a><span class="lineno"> 953</span>  </div>
<div class="line"><a name="l00954"></a><span class="lineno"> 954</span>  <span class="keywordflow">return</span> trace;</div>
<div class="line"><a name="l00955"></a><span class="lineno"> 955</span> }</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST_8h_source.html#l00213">Qureg::numAmpsPerChunk</a>, <a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>, and <a class="el" href="QuEST_8h_source.html#l00222">Qureg::stateVec</a>.</p>
<p class="reference">Referenced by <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00430">densmatr_calcHilbertSchmidtDistance()</a>.</p>
</div>
</div>
<a id="a08392b1b27d10e3b8a8648a5afeaa629"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a08392b1b27d10e3b8a8648a5afeaa629">◆ </a></span>densmatr_calcInnerProductLocal()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname"><a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> densmatr_calcInnerProductLocal </td>
<td>(</td>
<td class="paramtype"><a class="el" href="structQureg.html">Qureg</a> </td>
<td class="paramname"><em>a</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype"><a class="el" href="structQureg.html">Qureg</a> </td>
<td class="paramname"><em>b</em> </td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</div><div class="memdoc">
<p>computes Tr(conjTrans(a) b) = sum of (a_ij^* b_ij) </p>
<p class="definition">Definition at line <a class="el" href="QuEST__cpu_8c_source.html#l00958">958</a> of file <a class="el" href="QuEST__cpu_8c_source.html">QuEST_cpu.c</a>.</p>
<div class="fragment"><div class="line"><a name="l00958"></a><span class="lineno"> 958</span>  {</div>
<div class="line"><a name="l00959"></a><span class="lineno"> 959</span>  </div>
<div class="line"><a name="l00960"></a><span class="lineno"> 960</span>  <span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> index;</div>
<div class="line"><a name="l00961"></a><span class="lineno"> 961</span>  <span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> numAmps = a.<a class="code" href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">numAmpsPerChunk</a>;</div>
<div class="line"><a name="l00962"></a><span class="lineno"> 962</span>  </div>
<div class="line"><a name="l00963"></a><span class="lineno"> 963</span>  <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> *aRe = a.<a class="code" href="structQureg.html#a441e4cacef6bd17adb9813c7442d42fe">stateVec</a>.real;</div>
<div class="line"><a name="l00964"></a><span class="lineno"> 964</span>  <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> *aIm = a.<a class="code" href="structQureg.html#a441e4cacef6bd17adb9813c7442d42fe">stateVec</a>.imag;</div>
<div class="line"><a name="l00965"></a><span class="lineno"> 965</span>  <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> *bRe = b.<a class="code" href="structQureg.html#a441e4cacef6bd17adb9813c7442d42fe">stateVec</a>.real;</div>
<div class="line"><a name="l00966"></a><span class="lineno"> 966</span>  <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> *bIm = b.<a class="code" href="structQureg.html#a441e4cacef6bd17adb9813c7442d42fe">stateVec</a>.imag;</div>
<div class="line"><a name="l00967"></a><span class="lineno"> 967</span>  </div>
<div class="line"><a name="l00968"></a><span class="lineno"> 968</span>  <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> trace = 0;</div>
<div class="line"><a name="l00969"></a><span class="lineno"> 969</span>  </div>
<div class="line"><a name="l00970"></a><span class="lineno"> 970</span> <span class="preprocessor"># ifdef _OPENMP</span></div>
<div class="line"><a name="l00971"></a><span class="lineno"> 971</span> <span class="preprocessor"># pragma omp parallel \</span></div>
<div class="line"><a name="l00972"></a><span class="lineno"> 972</span> <span class="preprocessor"> shared (aRe,aIm, bRe,bIm, numAmps) \</span></div>
<div class="line"><a name="l00973"></a><span class="lineno"> 973</span> <span class="preprocessor"> private (index) \</span></div>
<div class="line"><a name="l00974"></a><span class="lineno"> 974</span> <span class="preprocessor"> reduction ( +:trace )</span></div>
<div class="line"><a name="l00975"></a><span class="lineno"> 975</span> <span class="preprocessor"># endif </span></div>
<div class="line"><a name="l00976"></a><span class="lineno"> 976</span>  {</div>
<div class="line"><a name="l00977"></a><span class="lineno"> 977</span> <span class="preprocessor"># ifdef _OPENMP</span></div>
<div class="line"><a name="l00978"></a><span class="lineno"> 978</span> <span class="preprocessor"># pragma omp for schedule (static)</span></div>
<div class="line"><a name="l00979"></a><span class="lineno"> 979</span> <span class="preprocessor"># endif</span></div>
<div class="line"><a name="l00980"></a><span class="lineno"> 980</span>  <span class="keywordflow">for</span> (index=0LL; index<numAmps; index++) {</div>
<div class="line"><a name="l00981"></a><span class="lineno"> 981</span>  trace += aRe[index]*bRe[index] + aIm[index]*bIm[index];</div>
<div class="line"><a name="l00982"></a><span class="lineno"> 982</span>  }</div>
<div class="line"><a name="l00983"></a><span class="lineno"> 983</span>  }</div>
<div class="line"><a name="l00984"></a><span class="lineno"> 984</span>  </div>
<div class="line"><a name="l00985"></a><span class="lineno"> 985</span>  <span class="keywordflow">return</span> trace;</div>
<div class="line"><a name="l00986"></a><span class="lineno"> 986</span> }</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST_8h_source.html#l00213">Qureg::numAmpsPerChunk</a>, <a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>, and <a class="el" href="QuEST_8h_source.html#l00222">Qureg::stateVec</a>.</p>
<p class="reference">Referenced by <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00441">densmatr_calcInnerProduct()</a>.</p>
</div>
</div>
<a id="af910c7cf2b85bdc2c399cfe8dbfb8b9c"></a>
<h2 class="memtitle"><span class="permalink"><a href="#af910c7cf2b85bdc2c399cfe8dbfb8b9c">◆ </a></span>densmatr_calcPurityLocal()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname"><a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> densmatr_calcPurityLocal </td>
<td>(</td>
<td class="paramtype"><a class="el" href="structQureg.html">Qureg</a> </td>
<td class="paramname"><em>qureg</em></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<p class="definition">Definition at line <a class="el" href="QuEST__cpu_8c_source.html#l00861">861</a> of file <a class="el" href="QuEST__cpu_8c_source.html">QuEST_cpu.c</a>.</p>
<div class="fragment"><div class="line"><a name="l00861"></a><span class="lineno"> 861</span>  {</div>
<div class="line"><a name="l00862"></a><span class="lineno"> 862</span>  </div>
<div class="line"><a name="l00863"></a><span class="lineno"> 863</span>  <span class="comment">/* sum of qureg^2, which is sum_i |qureg[i]|^2 */</span></div>
<div class="line"><a name="l00864"></a><span class="lineno"> 864</span>  <span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> index;</div>
<div class="line"><a name="l00865"></a><span class="lineno"> 865</span>  <span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> numAmps = qureg.<a class="code" href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">numAmpsPerChunk</a>;</div>
<div class="line"><a name="l00866"></a><span class="lineno"> 866</span>  </div>
<div class="line"><a name="l00867"></a><span class="lineno"> 867</span>  <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> trace = 0;</div>
<div class="line"><a name="l00868"></a><span class="lineno"> 868</span>  <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> *vecRe = qureg.<a class="code" href="structQureg.html#a441e4cacef6bd17adb9813c7442d42fe">stateVec</a>.real;</div>
<div class="line"><a name="l00869"></a><span class="lineno"> 869</span>  <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> *vecIm = qureg.<a class="code" href="structQureg.html#a441e4cacef6bd17adb9813c7442d42fe">stateVec</a>.imag;</div>
<div class="line"><a name="l00870"></a><span class="lineno"> 870</span>  </div>
<div class="line"><a name="l00871"></a><span class="lineno"> 871</span> <span class="preprocessor"># ifdef _OPENMP</span></div>
<div class="line"><a name="l00872"></a><span class="lineno"> 872</span> <span class="preprocessor"># pragma omp parallel \</span></div>
<div class="line"><a name="l00873"></a><span class="lineno"> 873</span> <span class="preprocessor"> shared (vecRe, vecIm, numAmps) \</span></div>
<div class="line"><a name="l00874"></a><span class="lineno"> 874</span> <span class="preprocessor"> private (index) \</span></div>
<div class="line"><a name="l00875"></a><span class="lineno"> 875</span> <span class="preprocessor"> reduction ( +:trace )</span></div>
<div class="line"><a name="l00876"></a><span class="lineno"> 876</span> <span class="preprocessor"># endif </span></div>
<div class="line"><a name="l00877"></a><span class="lineno"> 877</span>  {</div>
<div class="line"><a name="l00878"></a><span class="lineno"> 878</span> <span class="preprocessor"># ifdef _OPENMP</span></div>
<div class="line"><a name="l00879"></a><span class="lineno"> 879</span> <span class="preprocessor"># pragma omp for schedule (static)</span></div>
<div class="line"><a name="l00880"></a><span class="lineno"> 880</span> <span class="preprocessor"># endif</span></div>
<div class="line"><a name="l00881"></a><span class="lineno"> 881</span>  <span class="keywordflow">for</span> (index=0LL; index<numAmps; index++) {</div>
<div class="line"><a name="l00882"></a><span class="lineno"> 882</span>  </div>
<div class="line"><a name="l00883"></a><span class="lineno"> 883</span>  trace += vecRe[index]*vecRe[index] + vecIm[index]*vecIm[index];</div>
<div class="line"><a name="l00884"></a><span class="lineno"> 884</span>  }</div>
<div class="line"><a name="l00885"></a><span class="lineno"> 885</span>  }</div>
<div class="line"><a name="l00886"></a><span class="lineno"> 886</span>  </div>
<div class="line"><a name="l00887"></a><span class="lineno"> 887</span>  <span class="keywordflow">return</span> trace;</div>
<div class="line"><a name="l00888"></a><span class="lineno"> 888</span> }</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST_8h_source.html#l00213">Qureg::numAmpsPerChunk</a>, <a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>, and <a class="el" href="QuEST_8h_source.html#l00222">Qureg::stateVec</a>.</p>
<p class="reference">Referenced by <a class="el" href="QuEST__cpu__distributed_8c_source.html#l01288">densmatr_calcPurity()</a>.</p>
</div>
</div>
<a id="a8bea931504c90d9bd97e74645667804e"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a8bea931504c90d9bd97e74645667804e">◆ </a></span>densmatr_findProbabilityOfZeroLocal()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname"><a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> densmatr_findProbabilityOfZeroLocal </td>
<td>(</td>
<td class="paramtype"><a class="el" href="structQureg.html">Qureg</a> </td>
<td class="paramname"><em>qureg</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int </td>
<td class="paramname"><em>measureQubit</em> </td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</div><div class="memdoc">
<p class="definition">Definition at line <a class="el" href="QuEST__cpu_8c_source.html#l03151">3151</a> of file <a class="el" href="QuEST__cpu_8c_source.html">QuEST_cpu.c</a>.</p>
<div class="fragment"><div class="line"><a name="l03151"></a><span class="lineno"> 3151</span>  {</div>
<div class="line"><a name="l03152"></a><span class="lineno"> 3152</span>  </div>
<div class="line"><a name="l03153"></a><span class="lineno"> 3153</span>  <span class="comment">// computes first local index containing a diagonal element</span></div>
<div class="line"><a name="l03154"></a><span class="lineno"> 3154</span>  <span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> localNumAmps = qureg.<a class="code" href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">numAmpsPerChunk</a>;</div>
<div class="line"><a name="l03155"></a><span class="lineno"> 3155</span>  <span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> densityDim = (1LL << qureg.<a class="code" href="structQureg.html#ad08dff5316b8937f4b2a1417591543dc">numQubitsRepresented</a>);</div>
<div class="line"><a name="l03156"></a><span class="lineno"> 3156</span>  <span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> diagSpacing = 1LL + densityDim;</div>
<div class="line"><a name="l03157"></a><span class="lineno"> 3157</span>  <span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> maxNumDiagsPerChunk = 1 + localNumAmps / diagSpacing;</div>
<div class="line"><a name="l03158"></a><span class="lineno"> 3158</span>  <span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> numPrevDiags = (qureg.<a class="code" href="structQureg.html#ac2929e681d3d95591c18cf168dbbe4f0">chunkId</a>>0)? 1+(qureg.<a class="code" href="structQureg.html#ac2929e681d3d95591c18cf168dbbe4f0">chunkId</a>*localNumAmps)/diagSpacing : 0;</div>
<div class="line"><a name="l03159"></a><span class="lineno"> 3159</span>  <span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> globalIndNextDiag = diagSpacing * numPrevDiags;</div>
<div class="line"><a name="l03160"></a><span class="lineno"> 3160</span>  <span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> localIndNextDiag = globalIndNextDiag % localNumAmps;</div>
<div class="line"><a name="l03161"></a><span class="lineno"> 3161</span>  </div>
<div class="line"><a name="l03162"></a><span class="lineno"> 3162</span>  <span class="comment">// computes how many diagonals are contained in this chunk</span></div>
<div class="line"><a name="l03163"></a><span class="lineno"> 3163</span>  <span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> numDiagsInThisChunk = maxNumDiagsPerChunk;</div>
<div class="line"><a name="l03164"></a><span class="lineno"> 3164</span>  <span class="keywordflow">if</span> (localIndNextDiag + (numDiagsInThisChunk-1)*diagSpacing >= localNumAmps)</div>
<div class="line"><a name="l03165"></a><span class="lineno"> 3165</span>  numDiagsInThisChunk -= 1;</div>
<div class="line"><a name="l03166"></a><span class="lineno"> 3166</span>  </div>
<div class="line"><a name="l03167"></a><span class="lineno"> 3167</span>  <span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> visitedDiags; <span class="comment">// number of visited diagonals in this chunk so far</span></div>
<div class="line"><a name="l03168"></a><span class="lineno"> 3168</span>  <span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> basisStateInd; <span class="comment">// current diagonal index being considered</span></div>
<div class="line"><a name="l03169"></a><span class="lineno"> 3169</span>  <span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> index; <span class="comment">// index in the local chunk</span></div>
<div class="line"><a name="l03170"></a><span class="lineno"> 3170</span>  </div>
<div class="line"><a name="l03171"></a><span class="lineno"> 3171</span>  <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> zeroProb = 0;</div>
<div class="line"><a name="l03172"></a><span class="lineno"> 3172</span>  <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> *stateVecReal = qureg.<a class="code" href="structQureg.html#a441e4cacef6bd17adb9813c7442d42fe">stateVec</a>.real;</div>
<div class="line"><a name="l03173"></a><span class="lineno"> 3173</span>  </div>
<div class="line"><a name="l03174"></a><span class="lineno"> 3174</span> <span class="preprocessor"># ifdef _OPENMP</span></div>
<div class="line"><a name="l03175"></a><span class="lineno"> 3175</span> <span class="preprocessor"># pragma omp parallel \</span></div>
<div class="line"><a name="l03176"></a><span class="lineno"> 3176</span> <span class="preprocessor"> shared (localIndNextDiag, numPrevDiags, diagSpacing, stateVecReal, numDiagsInThisChunk) \</span></div>
<div class="line"><a name="l03177"></a><span class="lineno"> 3177</span> <span class="preprocessor"> private (visitedDiags, basisStateInd, index) \</span></div>
<div class="line"><a name="l03178"></a><span class="lineno"> 3178</span> <span class="preprocessor"> reduction ( +:zeroProb )</span></div>
<div class="line"><a name="l03179"></a><span class="lineno"> 3179</span> <span class="preprocessor"># endif </span></div>
<div class="line"><a name="l03180"></a><span class="lineno"> 3180</span>  {</div>
<div class="line"><a name="l03181"></a><span class="lineno"> 3181</span> <span class="preprocessor"># ifdef _OPENMP</span></div>
<div class="line"><a name="l03182"></a><span class="lineno"> 3182</span> <span class="preprocessor"># pragma omp for schedule (static)</span></div>
<div class="line"><a name="l03183"></a><span class="lineno"> 3183</span> <span class="preprocessor"># endif</span></div>
<div class="line"><a name="l03184"></a><span class="lineno"> 3184</span>  <span class="comment">// sums the diagonal elems of the density matrix where measureQubit=0</span></div>
<div class="line"><a name="l03185"></a><span class="lineno"> 3185</span>  <span class="keywordflow">for</span> (visitedDiags = 0; visitedDiags < numDiagsInThisChunk; visitedDiags++) {</div>
<div class="line"><a name="l03186"></a><span class="lineno"> 3186</span>  </div>
<div class="line"><a name="l03187"></a><span class="lineno"> 3187</span>  basisStateInd = numPrevDiags + visitedDiags;</div>
<div class="line"><a name="l03188"></a><span class="lineno"> 3188</span>  index = localIndNextDiag + diagSpacing * visitedDiags;</div>
<div class="line"><a name="l03189"></a><span class="lineno"> 3189</span>  </div>
<div class="line"><a name="l03190"></a><span class="lineno"> 3190</span>  <span class="keywordflow">if</span> (<a class="code" href="QuEST__gpu_8cu.html#aec1852e1a8e70d3690919ce8ab551ba0">extractBit</a>(measureQubit, basisStateInd) == 0)</div>
<div class="line"><a name="l03191"></a><span class="lineno"> 3191</span>  zeroProb += stateVecReal[index]; <span class="comment">// assume imag[diagonls] ~ 0</span></div>
<div class="line"><a name="l03192"></a><span class="lineno"> 3192</span>  </div>
<div class="line"><a name="l03193"></a><span class="lineno"> 3193</span>  }</div>
<div class="line"><a name="l03194"></a><span class="lineno"> 3194</span>  }</div>
<div class="line"><a name="l03195"></a><span class="lineno"> 3195</span>  </div>
<div class="line"><a name="l03196"></a><span class="lineno"> 3196</span>  <span class="keywordflow">return</span> zeroProb;</div>
<div class="line"><a name="l03197"></a><span class="lineno"> 3197</span> }</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST_8h_source.html#l00217">Qureg::chunkId</a>, <a class="el" href="QuEST__gpu_8cu_source.html#l00082">extractBit()</a>, <a class="el" href="QuEST_8h_source.html#l00213">Qureg::numAmpsPerChunk</a>, <a class="el" href="QuEST_8h_source.html#l00208">Qureg::numQubitsRepresented</a>, <a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>, and <a class="el" href="QuEST_8h_source.html#l00222">Qureg::stateVec</a>.</p>
<p class="reference">Referenced by <a class="el" href="QuEST__cpu__distributed_8c_source.html#l01276">densmatr_calcProbOfOutcome()</a>.</p>
</div>
</div>
<a id="a1b36518c8fbbc3a5084bb4ad1fb05ea5"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a1b36518c8fbbc3a5084bb4ad1fb05ea5">◆ </a></span>densmatr_initPureStateLocal()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void densmatr_initPureStateLocal </td>
<td>(</td>
<td class="paramtype"><a class="el" href="structQureg.html">Qureg</a> </td>
<td class="paramname"><em>targetQureg</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype"><a class="el" href="structQureg.html">Qureg</a> </td>
<td class="paramname"><em>copyQureg</em> </td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</div><div class="memdoc">
<p class="definition">Definition at line <a class="el" href="QuEST__cpu_8c_source.html#l01184">1184</a> of file <a class="el" href="QuEST__cpu_8c_source.html">QuEST_cpu.c</a>.</p>
<div class="fragment"><div class="line"><a name="l01184"></a><span class="lineno"> 1184</span>  {</div>
<div class="line"><a name="l01185"></a><span class="lineno"> 1185</span>  </div>
<div class="line"><a name="l01186"></a><span class="lineno"> 1186</span>  <span class="comment">/* copyQureg amps aren't explicitly used - they're accessed through targetQureg.pair,</span></div>
<div class="line"><a name="l01187"></a><span class="lineno"> 1187</span> <span class="comment"> * which contains the full pure statevector.</span></div>
<div class="line"><a name="l01188"></a><span class="lineno"> 1188</span> <span class="comment"> * targetQureg has as many columns on node as copyQureg has amps</span></div>
<div class="line"><a name="l01189"></a><span class="lineno"> 1189</span> <span class="comment"> */</span></div>
<div class="line"><a name="l01190"></a><span class="lineno"> 1190</span>  </div>
<div class="line"><a name="l01191"></a><span class="lineno"> 1191</span>  <span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> colOffset = targetQureg.<a class="code" href="structQureg.html#ac2929e681d3d95591c18cf168dbbe4f0">chunkId</a> * copyQureg.<a class="code" href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">numAmpsPerChunk</a>;</div>
<div class="line"><a name="l01192"></a><span class="lineno"> 1192</span>  <span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> colsPerNode = copyQureg.<a class="code" href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">numAmpsPerChunk</a>;</div>
<div class="line"><a name="l01193"></a><span class="lineno"> 1193</span>  <span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> rowsPerNode = copyQureg.<a class="code" href="structQureg.html#adef4935cac95763c29164cf99b144ed4">numAmpsTotal</a>;</div>
<div class="line"><a name="l01194"></a><span class="lineno"> 1194</span>  </div>
<div class="line"><a name="l01195"></a><span class="lineno"> 1195</span>  <span class="comment">// unpack vars for OpenMP</span></div>
<div class="line"><a name="l01196"></a><span class="lineno"> 1196</span>  <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>* vecRe = targetQureg.<a class="code" href="structQureg.html#aba97773694870ef35e378c036f486bb7">pairStateVec</a>.real;</div>
<div class="line"><a name="l01197"></a><span class="lineno"> 1197</span>  <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>* vecIm = targetQureg.<a class="code" href="structQureg.html#aba97773694870ef35e378c036f486bb7">pairStateVec</a>.imag;</div>
<div class="line"><a name="l01198"></a><span class="lineno"> 1198</span>  <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>* densRe = targetQureg.<a class="code" href="structQureg.html#a441e4cacef6bd17adb9813c7442d42fe">stateVec</a>.real;</div>
<div class="line"><a name="l01199"></a><span class="lineno"> 1199</span>  <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>* densIm = targetQureg.<a class="code" href="structQureg.html#a441e4cacef6bd17adb9813c7442d42fe">stateVec</a>.imag;</div>
<div class="line"><a name="l01200"></a><span class="lineno"> 1200</span>  </div>
<div class="line"><a name="l01201"></a><span class="lineno"> 1201</span>  <span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> col, row, index;</div>
<div class="line"><a name="l01202"></a><span class="lineno"> 1202</span>  </div>
<div class="line"><a name="l01203"></a><span class="lineno"> 1203</span>  <span class="comment">// a_i conj(a_j) |i><j|</span></div>
<div class="line"><a name="l01204"></a><span class="lineno"> 1204</span>  <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> ketRe, ketIm, braRe, braIm;</div>
<div class="line"><a name="l01205"></a><span class="lineno"> 1205</span>  </div>
<div class="line"><a name="l01206"></a><span class="lineno"> 1206</span> <span class="preprocessor"># ifdef _OPENMP</span></div>
<div class="line"><a name="l01207"></a><span class="lineno"> 1207</span> <span class="preprocessor"># pragma omp parallel \</span></div>
<div class="line"><a name="l01208"></a><span class="lineno"> 1208</span> <span class="preprocessor"> default (none) \</span></div>
<div class="line"><a name="l01209"></a><span class="lineno"> 1209</span> <span class="preprocessor"> shared (colOffset, colsPerNode,rowsPerNode, vecRe,vecIm,densRe,densIm) \</span></div>
<div class="line"><a name="l01210"></a><span class="lineno"> 1210</span> <span class="preprocessor"> private (col,row, ketRe,ketIm,braRe,braIm, index) </span></div>
<div class="line"><a name="l01211"></a><span class="lineno"> 1211</span> <span class="preprocessor"># endif</span></div>
<div class="line"><a name="l01212"></a><span class="lineno"> 1212</span>  {</div>
<div class="line"><a name="l01213"></a><span class="lineno"> 1213</span> <span class="preprocessor"># ifdef _OPENMP</span></div>
<div class="line"><a name="l01214"></a><span class="lineno"> 1214</span> <span class="preprocessor"># pragma omp for schedule (static)</span></div>
<div class="line"><a name="l01215"></a><span class="lineno"> 1215</span> <span class="preprocessor"># endif</span></div>
<div class="line"><a name="l01216"></a><span class="lineno"> 1216</span>  <span class="comment">// local column</span></div>
<div class="line"><a name="l01217"></a><span class="lineno"> 1217</span>  <span class="keywordflow">for</span> (col=0; col < colsPerNode; col++) {</div>
<div class="line"><a name="l01218"></a><span class="lineno"> 1218</span>  </div>
<div class="line"><a name="l01219"></a><span class="lineno"> 1219</span>  <span class="comment">// global row</span></div>
<div class="line"><a name="l01220"></a><span class="lineno"> 1220</span>  <span class="keywordflow">for</span> (row=0; row < rowsPerNode; row++) {</div>
<div class="line"><a name="l01221"></a><span class="lineno"> 1221</span>  </div>
<div class="line"><a name="l01222"></a><span class="lineno"> 1222</span>  <span class="comment">// get pure state amps</span></div>
<div class="line"><a name="l01223"></a><span class="lineno"> 1223</span>  ketRe = vecRe[row];</div>
<div class="line"><a name="l01224"></a><span class="lineno"> 1224</span>  ketIm = vecIm[row];</div>
<div class="line"><a name="l01225"></a><span class="lineno"> 1225</span>  braRe = vecRe[col + colOffset];</div>
<div class="line"><a name="l01226"></a><span class="lineno"> 1226</span>  braIm = - vecIm[col + colOffset]; <span class="comment">// minus for conjugation</span></div>
<div class="line"><a name="l01227"></a><span class="lineno"> 1227</span>  </div>
<div class="line"><a name="l01228"></a><span class="lineno"> 1228</span>  <span class="comment">// update density matrix</span></div>
<div class="line"><a name="l01229"></a><span class="lineno"> 1229</span>  index = row + col*rowsPerNode; <span class="comment">// local ind</span></div>
<div class="line"><a name="l01230"></a><span class="lineno"> 1230</span>  densRe[index] = ketRe*braRe - ketIm*braIm;</div>
<div class="line"><a name="l01231"></a><span class="lineno"> 1231</span>  densIm[index] = ketRe*braIm + ketIm*braRe;</div>
<div class="line"><a name="l01232"></a><span class="lineno"> 1232</span>  }</div>
<div class="line"><a name="l01233"></a><span class="lineno"> 1233</span>  }</div>
<div class="line"><a name="l01234"></a><span class="lineno"> 1234</span>  }</div>
<div class="line"><a name="l01235"></a><span class="lineno"> 1235</span> }</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST_8h_source.html#l00217">Qureg::chunkId</a>, <a class="el" href="QuEST_8h_source.html#l00213">Qureg::numAmpsPerChunk</a>, <a class="el" href="QuEST_8h_source.html#l00215">Qureg::numAmpsTotal</a>, <a class="el" href="QuEST_8h_source.html#l00224">Qureg::pairStateVec</a>, <a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>, and <a class="el" href="QuEST_8h_source.html#l00222">Qureg::stateVec</a>.</p>
<p class="reference">Referenced by <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00452">densmatr_initPureState()</a>.</p>
</div>
</div>
<a id="a8d9c19a3424f0ad89bfbfd920d65301d"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a8d9c19a3424f0ad89bfbfd920d65301d">◆ </a></span>densmatr_mixDampingDistributed()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void densmatr_mixDampingDistributed </td>
<td>(</td>
<td class="paramtype"><a class="el" href="structQureg.html">Qureg</a> </td>
<td class="paramname"><em>qureg</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int </td>
<td class="paramname"><em>targetQubit</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype"><a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> </td>
<td class="paramname"><em>damping</em> </td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</div><div class="memdoc">
<p class="definition">Definition at line <a class="el" href="QuEST__cpu_8c_source.html#l00300">300</a> of file <a class="el" href="QuEST__cpu_8c_source.html">QuEST_cpu.c</a>.</p>
<div class="fragment"><div class="line"><a name="l00300"></a><span class="lineno"> 300</span>  {</div>
<div class="line"><a name="l00301"></a><span class="lineno"> 301</span>  <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> retain=1-damping;</div>
<div class="line"><a name="l00302"></a><span class="lineno"> 302</span>  <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> dephase=sqrt(1-damping);</div>
<div class="line"><a name="l00303"></a><span class="lineno"> 303</span>  </div>
<div class="line"><a name="l00304"></a><span class="lineno"> 304</span>  <span class="comment">// multiply the off-diagonal (|0><1| and |1><0|) terms by sqrt(1-damping)</span></div>
<div class="line"><a name="l00305"></a><span class="lineno"> 305</span>  <a class="code" href="QuEST__cpu_8c.html#a717a0448066831cb5b392bcf2e1d0529">densmatr_oneQubitDegradeOffDiagonal</a>(qureg, targetQubit, dephase);</div>
<div class="line"><a name="l00306"></a><span class="lineno"> 306</span>  </div>
<div class="line"><a name="l00307"></a><span class="lineno"> 307</span>  <span class="comment">// below, we modify the diagonals terms which require |1><1| to |0><0| communication</span></div>
<div class="line"><a name="l00308"></a><span class="lineno"> 308</span>  </div>
<div class="line"><a name="l00309"></a><span class="lineno"> 309</span>  <span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> sizeInnerBlock, sizeInnerHalfBlock;</div>
<div class="line"><a name="l00310"></a><span class="lineno"> 310</span>  <span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> sizeOuterColumn, sizeOuterHalfColumn;</div>
<div class="line"><a name="l00311"></a><span class="lineno"> 311</span>  <span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> thisInnerBlock, <span class="comment">// current block</span></div>
<div class="line"><a name="l00312"></a><span class="lineno"> 312</span>  thisOuterColumn, <span class="comment">// current column in density matrix</span></div>
<div class="line"><a name="l00313"></a><span class="lineno"> 313</span>  thisIndex, <span class="comment">// current index in (density matrix representation) state vector</span></div>
<div class="line"><a name="l00314"></a><span class="lineno"> 314</span>  thisIndexInOuterColumn,</div>
<div class="line"><a name="l00315"></a><span class="lineno"> 315</span>  thisIndexInInnerBlock; </div>
<div class="line"><a name="l00316"></a><span class="lineno"> 316</span>  <span class="keywordtype">int</span> outerBit; </div>
<div class="line"><a name="l00317"></a><span class="lineno"> 317</span>  <span class="keywordtype">int</span> stateBit;</div>
<div class="line"><a name="l00318"></a><span class="lineno"> 318</span>  </div>
<div class="line"><a name="l00319"></a><span class="lineno"> 319</span>  <span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> thisTask; </div>
<div class="line"><a name="l00320"></a><span class="lineno"> 320</span>  <span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> numTasks=qureg.<a class="code" href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">numAmpsPerChunk</a>>>1;</div>
<div class="line"><a name="l00321"></a><span class="lineno"> 321</span>  </div>
<div class="line"><a name="l00322"></a><span class="lineno"> 322</span>  <span class="comment">// set dimensions</span></div>
<div class="line"><a name="l00323"></a><span class="lineno"> 323</span>  sizeInnerHalfBlock = 1LL << targetQubit; </div>
<div class="line"><a name="l00324"></a><span class="lineno"> 324</span>  sizeInnerBlock = 2LL * sizeInnerHalfBlock; </div>
<div class="line"><a name="l00325"></a><span class="lineno"> 325</span>  sizeOuterColumn = 1LL << qureg.<a class="code" href="structQureg.html#ad08dff5316b8937f4b2a1417591543dc">numQubitsRepresented</a>;</div>
<div class="line"><a name="l00326"></a><span class="lineno"> 326</span>  sizeOuterHalfColumn = sizeOuterColumn >> 1;</div>
<div class="line"><a name="l00327"></a><span class="lineno"> 327</span>  </div>
<div class="line"><a name="l00328"></a><span class="lineno"> 328</span> <span class="preprocessor"># ifdef _OPENMP</span></div>
<div class="line"><a name="l00329"></a><span class="lineno"> 329</span> <span class="preprocessor"># pragma omp parallel \</span></div>
<div class="line"><a name="l00330"></a><span class="lineno"> 330</span> <span class="preprocessor"> default (none) \</span></div>
<div class="line"><a name="l00331"></a><span class="lineno"> 331</span> <span class="preprocessor"> shared (sizeInnerBlock,sizeInnerHalfBlock,sizeOuterColumn,sizeOuterHalfColumn, \</span></div>
<div class="line"><a name="l00332"></a><span class="lineno"> 332</span> <span class="preprocessor"> qureg,damping, retain, dephase, numTasks,targetQubit) \</span></div>
<div class="line"><a name="l00333"></a><span class="lineno"> 333</span> <span class="preprocessor"> private (thisTask,thisInnerBlock,thisOuterColumn,thisIndex,thisIndexInOuterColumn, \</span></div>
<div class="line"><a name="l00334"></a><span class="lineno"> 334</span> <span class="preprocessor"> thisIndexInInnerBlock,outerBit, stateBit)</span></div>
<div class="line"><a name="l00335"></a><span class="lineno"> 335</span> <span class="preprocessor"># endif</span></div>
<div class="line"><a name="l00336"></a><span class="lineno"> 336</span>  {</div>
<div class="line"><a name="l00337"></a><span class="lineno"> 337</span> <span class="preprocessor"># ifdef _OPENMP</span></div>
<div class="line"><a name="l00338"></a><span class="lineno"> 338</span> <span class="preprocessor"># pragma omp for schedule (static)</span></div>
<div class="line"><a name="l00339"></a><span class="lineno"> 339</span> <span class="preprocessor"># endif</span></div>
<div class="line"><a name="l00340"></a><span class="lineno"> 340</span>  <span class="comment">// thisTask iterates over half the elements in this process' chunk of the density matrix</span></div>
<div class="line"><a name="l00341"></a><span class="lineno"> 341</span>  <span class="comment">// treat this as iterating over all columns, then iterating over half the values</span></div>
<div class="line"><a name="l00342"></a><span class="lineno"> 342</span>  <span class="comment">// within one column.</span></div>
<div class="line"><a name="l00343"></a><span class="lineno"> 343</span>  <span class="comment">// If this function has been called, this process' chunk contains half an </span></div>
<div class="line"><a name="l00344"></a><span class="lineno"> 344</span>  <span class="comment">// outer block or less</span></div>
<div class="line"><a name="l00345"></a><span class="lineno"> 345</span>  <span class="keywordflow">for</span> (thisTask=0; thisTask<numTasks; thisTask++) {</div>
<div class="line"><a name="l00346"></a><span class="lineno"> 346</span>  <span class="comment">// we want to process all columns in the density matrix,</span></div>
<div class="line"><a name="l00347"></a><span class="lineno"> 347</span>  <span class="comment">// updating the values for half of each column (one half of each inner block)</span></div>
<div class="line"><a name="l00348"></a><span class="lineno"> 348</span>  thisOuterColumn = thisTask / sizeOuterHalfColumn;</div>
<div class="line"><a name="l00349"></a><span class="lineno"> 349</span>  thisIndexInOuterColumn = thisTask&(sizeOuterHalfColumn-1); <span class="comment">// thisTask % sizeOuterHalfColumn</span></div>
<div class="line"><a name="l00350"></a><span class="lineno"> 350</span>  thisInnerBlock = thisIndexInOuterColumn/sizeInnerHalfBlock;</div>
<div class="line"><a name="l00351"></a><span class="lineno"> 351</span>  <span class="comment">// get index in state vector corresponding to upper inner block</span></div>
<div class="line"><a name="l00352"></a><span class="lineno"> 352</span>  thisIndexInInnerBlock = thisTask&(sizeInnerHalfBlock-1); <span class="comment">// thisTask % sizeInnerHalfBlock</span></div>
<div class="line"><a name="l00353"></a><span class="lineno"> 353</span>  thisIndex = thisOuterColumn*sizeOuterColumn + thisInnerBlock*sizeInnerBlock </div>
<div class="line"><a name="l00354"></a><span class="lineno"> 354</span>  + thisIndexInInnerBlock;</div>
<div class="line"><a name="l00355"></a><span class="lineno"> 355</span>  <span class="comment">// check if we are in the upper or lower half of an outer block</span></div>
<div class="line"><a name="l00356"></a><span class="lineno"> 356</span>  outerBit = <a class="code" href="QuEST__gpu_8cu.html#aec1852e1a8e70d3690919ce8ab551ba0">extractBit</a>(targetQubit, (thisIndex+qureg.<a class="code" href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">numAmpsPerChunk</a>*qureg.<a class="code" href="structQureg.html#ac2929e681d3d95591c18cf168dbbe4f0">chunkId</a>)>>qureg.<a class="code" href="structQureg.html#ad08dff5316b8937f4b2a1417591543dc">numQubitsRepresented</a>);</div>
<div class="line"><a name="l00357"></a><span class="lineno"> 357</span>  <span class="comment">// if we are in the lower half of an outer block, shift to be in the lower half</span></div>
<div class="line"><a name="l00358"></a><span class="lineno"> 358</span>  <span class="comment">// of the inner block as well (we want to dephase |0><0| and |1><1| only)</span></div>
<div class="line"><a name="l00359"></a><span class="lineno"> 359</span>  thisIndex += outerBit*(sizeInnerHalfBlock);</div>
<div class="line"><a name="l00360"></a><span class="lineno"> 360</span>  </div>
<div class="line"><a name="l00361"></a><span class="lineno"> 361</span>  <span class="comment">// NOTE: at this point thisIndex should be the index of the element we want to </span></div>
<div class="line"><a name="l00362"></a><span class="lineno"> 362</span>  <span class="comment">// dephase in the chunk of the state vector on this process, in the </span></div>
<div class="line"><a name="l00363"></a><span class="lineno"> 363</span>  <span class="comment">// density matrix representation. </span></div>
<div class="line"><a name="l00364"></a><span class="lineno"> 364</span>  <span class="comment">// thisTask is the index of the pair element in pairStateVec</span></div>
<div class="line"><a name="l00365"></a><span class="lineno"> 365</span>  </div>
<div class="line"><a name="l00366"></a><span class="lineno"> 366</span>  <span class="comment">// Extract state bit, is 0 if thisIndex corresponds to a state with 0 in the target qubit</span></div>
<div class="line"><a name="l00367"></a><span class="lineno"> 367</span>  <span class="comment">// and is 1 if thisIndex corresponds to a state with 1 in the target qubit</span></div>
<div class="line"><a name="l00368"></a><span class="lineno"> 368</span>  stateBit = <a class="code" href="QuEST__gpu_8cu.html#aec1852e1a8e70d3690919ce8ab551ba0">extractBit</a>(targetQubit, (thisIndex+qureg.<a class="code" href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">numAmpsPerChunk</a>*qureg.<a class="code" href="structQureg.html#ac2929e681d3d95591c18cf168dbbe4f0">chunkId</a>));</div>
<div class="line"><a name="l00369"></a><span class="lineno"> 369</span>  </div>
<div class="line"><a name="l00370"></a><span class="lineno"> 370</span>  <span class="comment">// state[thisIndex] = (1-depolLevel)*state[thisIndex] + depolLevel*(state[thisIndex]</span></div>
<div class="line"><a name="l00371"></a><span class="lineno"> 371</span>  <span class="comment">// + pair[thisTask])/2</span></div>
<div class="line"><a name="l00372"></a><span class="lineno"> 372</span>  <span class="keywordflow">if</span>(stateBit == 0){</div>
<div class="line"><a name="l00373"></a><span class="lineno"> 373</span>  qureg.<a class="code" href="structQureg.html#a441e4cacef6bd17adb9813c7442d42fe">stateVec</a>.real[thisIndex] = qureg.<a class="code" href="structQureg.html#a441e4cacef6bd17adb9813c7442d42fe">stateVec</a>.real[thisIndex] +</div>
<div class="line"><a name="l00374"></a><span class="lineno"> 374</span>  damping*( qureg.<a class="code" href="structQureg.html#aba97773694870ef35e378c036f486bb7">pairStateVec</a>.real[thisTask]);</div>
<div class="line"><a name="l00375"></a><span class="lineno"> 375</span>  </div>
<div class="line"><a name="l00376"></a><span class="lineno"> 376</span>  qureg.<a class="code" href="structQureg.html#a441e4cacef6bd17adb9813c7442d42fe">stateVec</a>.imag[thisIndex] = qureg.<a class="code" href="structQureg.html#a441e4cacef6bd17adb9813c7442d42fe">stateVec</a>.imag[thisIndex] +</div>
<div class="line"><a name="l00377"></a><span class="lineno"> 377</span>  damping*( qureg.<a class="code" href="structQureg.html#aba97773694870ef35e378c036f486bb7">pairStateVec</a>.imag[thisTask]);</div>
<div class="line"><a name="l00378"></a><span class="lineno"> 378</span>  } <span class="keywordflow">else</span>{</div>
<div class="line"><a name="l00379"></a><span class="lineno"> 379</span>  qureg.<a class="code" href="structQureg.html#a441e4cacef6bd17adb9813c7442d42fe">stateVec</a>.real[thisIndex] = retain*qureg.<a class="code" href="structQureg.html#a441e4cacef6bd17adb9813c7442d42fe">stateVec</a>.real[thisIndex];</div>
<div class="line"><a name="l00380"></a><span class="lineno"> 380</span>  </div>
<div class="line"><a name="l00381"></a><span class="lineno"> 381</span>  qureg.<a class="code" href="structQureg.html#a441e4cacef6bd17adb9813c7442d42fe">stateVec</a>.imag[thisIndex] = retain*qureg.<a class="code" href="structQureg.html#a441e4cacef6bd17adb9813c7442d42fe">stateVec</a>.imag[thisIndex];</div>
<div class="line"><a name="l00382"></a><span class="lineno"> 382</span>  }</div>
<div class="line"><a name="l00383"></a><span class="lineno"> 383</span>  } </div>
<div class="line"><a name="l00384"></a><span class="lineno"> 384</span>  } </div>
<div class="line"><a name="l00385"></a><span class="lineno"> 385</span> }</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST_8h_source.html#l00217">Qureg::chunkId</a>, <a class="el" href="QuEST__cpu_8c_source.html#l00048">densmatr_oneQubitDegradeOffDiagonal()</a>, <a class="el" href="QuEST__gpu_8cu_source.html#l00082">extractBit()</a>, <a class="el" href="QuEST_8h_source.html#l00213">Qureg::numAmpsPerChunk</a>, <a class="el" href="QuEST_8h_source.html#l00208">Qureg::numQubitsRepresented</a>, <a class="el" href="QuEST_8h_source.html#l00224">Qureg::pairStateVec</a>, <a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>, and <a class="el" href="QuEST_8h_source.html#l00222">Qureg::stateVec</a>.</p>
<p class="reference">Referenced by <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00725">densmatr_mixDamping()</a>.</p>
</div>
</div>
<a id="ab124a3a9956046bf9c0e1e3ae9171f42"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ab124a3a9956046bf9c0e1e3ae9171f42">◆ </a></span>densmatr_mixDampingLocal()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void densmatr_mixDampingLocal </td>
<td>(</td>
<td class="paramtype"><a class="el" href="structQureg.html">Qureg</a> </td>
<td class="paramname"><em>qureg</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int </td>
<td class="paramname"><em>targetQubit</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype"><a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> </td>
<td class="paramname"><em>damping</em> </td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</div><div class="memdoc">