quest_bind 0.3.7

Wrapper around the Quantum Exact Simulation Toolkit (QuEST)
Documentation
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
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
<!-- 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: Operators</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.4.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&amp;dn=gpl-2.0.txt GPL-v2 */
$(function() {
  initMenu('',false,false,'search.php','Search');
});
/* @license-end */</script>
<div id="main-nav"></div>
</div><!-- top -->
<div class="header">
  <div class="summary">
<a href="#func-members">Functions</a>  </div>
  <div class="headertitle">
<div class="title">Operators</div>  </div>
</div><!--header-->
<div class="contents">

<p>Non-physical operators which may be non-unitary, non-norm-preserving, even non-Hermitian.  
<a href="#details">More...</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:gad2e953390342cd361cfb4064d47715e6"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__operator.html#gad2e953390342cd361cfb4064d47715e6">applyDiagonalOp</a> (<a class="el" href="structQureg.html">Qureg</a> qureg, <a class="el" href="structDiagonalOp.html">DiagonalOp</a> op)</td></tr>
<tr class="memdesc:gad2e953390342cd361cfb4064d47715e6"><td class="mdescLeft">&#160;</td><td class="mdescRight">Apply a diagonal operator, which is possibly non-unitary and non-Hermitian, to the entire <code>qureg</code>.  <a href="group__operator.html#gad2e953390342cd361cfb4064d47715e6">More...</a><br /></td></tr>
<tr class="separator:gad2e953390342cd361cfb4064d47715e6"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gaf26f32c25db760065486188497c1da8b"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__operator.html#gaf26f32c25db760065486188497c1da8b">applyFullQFT</a> (<a class="el" href="structQureg.html">Qureg</a> qureg)</td></tr>
<tr class="memdesc:gaf26f32c25db760065486188497c1da8b"><td class="mdescLeft">&#160;</td><td class="mdescRight">Applies the quantum Fourier transform (QFT) to the entirety of <code>qureg</code>.  <a href="group__operator.html#gaf26f32c25db760065486188497c1da8b">More...</a><br /></td></tr>
<tr class="separator:gaf26f32c25db760065486188497c1da8b"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gadfb5c1d99a22ce666fc715a8da2e0950"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__operator.html#gadfb5c1d99a22ce666fc715a8da2e0950">applyMatrix2</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="memdesc:gadfb5c1d99a22ce666fc715a8da2e0950"><td class="mdescLeft">&#160;</td><td class="mdescRight">Apply a general 2-by-2 matrix, which may be non-unitary.  <a href="group__operator.html#gadfb5c1d99a22ce666fc715a8da2e0950">More...</a><br /></td></tr>
<tr class="separator:gadfb5c1d99a22ce666fc715a8da2e0950"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga74a955ec4bce606d89317bcfc528387f"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__operator.html#ga74a955ec4bce606d89317bcfc528387f">applyMatrix4</a> (<a class="el" href="structQureg.html">Qureg</a> qureg, int targetQubit1, int targetQubit2, <a class="el" href="structComplexMatrix4.html">ComplexMatrix4</a> u)</td></tr>
<tr class="memdesc:ga74a955ec4bce606d89317bcfc528387f"><td class="mdescLeft">&#160;</td><td class="mdescRight">Apply a general 4-by-4 matrix, which may be non-unitary.  <a href="group__operator.html#ga74a955ec4bce606d89317bcfc528387f">More...</a><br /></td></tr>
<tr class="separator:ga74a955ec4bce606d89317bcfc528387f"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga358e7094a98851afa86d27f0147e32a1"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__operator.html#ga358e7094a98851afa86d27f0147e32a1">applyMatrixN</a> (<a class="el" href="structQureg.html">Qureg</a> qureg, int *targs, int numTargs, <a class="el" href="structComplexMatrixN.html">ComplexMatrixN</a> u)</td></tr>
<tr class="memdesc:ga358e7094a98851afa86d27f0147e32a1"><td class="mdescLeft">&#160;</td><td class="mdescRight">Apply a general N-by-N matrix, which may be non-unitary, on any number of target qubits.  <a href="group__operator.html#ga358e7094a98851afa86d27f0147e32a1">More...</a><br /></td></tr>
<tr class="separator:ga358e7094a98851afa86d27f0147e32a1"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gab52b6315c5520b7d311b0458785eed8e"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__operator.html#gab52b6315c5520b7d311b0458785eed8e">applyMultiControlledMatrixN</a> (<a class="el" href="structQureg.html">Qureg</a> qureg, int *ctrls, int numCtrls, int *targs, int numTargs, <a class="el" href="structComplexMatrixN.html">ComplexMatrixN</a> u)</td></tr>
<tr class="memdesc:gab52b6315c5520b7d311b0458785eed8e"><td class="mdescLeft">&#160;</td><td class="mdescRight">Apply a general N-by-N matrix, which may be non-unitary, with additional controlled qubits.  <a href="group__operator.html#gab52b6315c5520b7d311b0458785eed8e">More...</a><br /></td></tr>
<tr class="separator:gab52b6315c5520b7d311b0458785eed8e"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga008a46d178a5a9691e2f5d363e3f518f"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__operator.html#ga008a46d178a5a9691e2f5d363e3f518f">applyMultiVarPhaseFunc</a> (<a class="el" href="structQureg.html">Qureg</a> qureg, int *qubits, int *numQubitsPerReg, int numRegs, enum <a class="el" href="group__type.html#ga9c91c41aa42ae537995e89ffc616afe1">bitEncoding</a> encoding, <a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> *coeffs, <a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> *exponents, int *numTermsPerReg)</td></tr>
<tr class="memdesc:ga008a46d178a5a9691e2f5d363e3f518f"><td class="mdescLeft">&#160;</td><td class="mdescRight">Induces a phase change upon each amplitude of <code>qureg</code>, determined by a multi-variable exponential polynomial "phase function".  <a href="group__operator.html#ga008a46d178a5a9691e2f5d363e3f518f">More...</a><br /></td></tr>
<tr class="separator:ga008a46d178a5a9691e2f5d363e3f518f"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga8dca543fb4d1ee1cd8b4c5d6028b3075"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__operator.html#ga8dca543fb4d1ee1cd8b4c5d6028b3075">applyMultiVarPhaseFuncOverrides</a> (<a class="el" href="structQureg.html">Qureg</a> qureg, int *qubits, int *numQubitsPerReg, int numRegs, enum <a class="el" href="group__type.html#ga9c91c41aa42ae537995e89ffc616afe1">bitEncoding</a> encoding, <a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> *coeffs, <a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> *exponents, int *numTermsPerReg, long long int *overrideInds, <a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> *overridePhases, int numOverrides)</td></tr>
<tr class="memdesc:ga8dca543fb4d1ee1cd8b4c5d6028b3075"><td class="mdescLeft">&#160;</td><td class="mdescRight">Induces a phase change upon each amplitude of <code>qureg</code>, determined by a multi-variable exponential polynomial "phase function", and an explicit set of 'overriding' values at specific state indices.  <a href="group__operator.html#ga8dca543fb4d1ee1cd8b4c5d6028b3075">More...</a><br /></td></tr>
<tr class="separator:ga8dca543fb4d1ee1cd8b4c5d6028b3075"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gac4df97d8c125c8cc65df720f67b2bf69"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__operator.html#gac4df97d8c125c8cc65df720f67b2bf69">applyNamedPhaseFunc</a> (<a class="el" href="structQureg.html">Qureg</a> qureg, int *qubits, int *numQubitsPerReg, int numRegs, enum <a class="el" href="group__type.html#ga9c91c41aa42ae537995e89ffc616afe1">bitEncoding</a> encoding, enum <a class="el" href="group__type.html#gaa7d869b117ba5024d6b84938e8cdfc65">phaseFunc</a> functionNameCode)</td></tr>
<tr class="memdesc:gac4df97d8c125c8cc65df720f67b2bf69"><td class="mdescLeft">&#160;</td><td class="mdescRight">Induces a phase change upon each amplitude of <code>qureg</code>, determined by a named (and potentially multi-variable) phase function.  <a href="group__operator.html#gac4df97d8c125c8cc65df720f67b2bf69">More...</a><br /></td></tr>
<tr class="separator:gac4df97d8c125c8cc65df720f67b2bf69"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga2fbaec3bb21cc01f7a2a4ed2aa911ebf"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__operator.html#ga2fbaec3bb21cc01f7a2a4ed2aa911ebf">applyNamedPhaseFuncOverrides</a> (<a class="el" href="structQureg.html">Qureg</a> qureg, int *qubits, int *numQubitsPerReg, int numRegs, enum <a class="el" href="group__type.html#ga9c91c41aa42ae537995e89ffc616afe1">bitEncoding</a> encoding, enum <a class="el" href="group__type.html#gaa7d869b117ba5024d6b84938e8cdfc65">phaseFunc</a> functionNameCode, long long int *overrideInds, <a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> *overridePhases, int numOverrides)</td></tr>
<tr class="memdesc:ga2fbaec3bb21cc01f7a2a4ed2aa911ebf"><td class="mdescLeft">&#160;</td><td class="mdescRight">Induces a phase change upon each amplitude of <code>qureg</code>, determined by a named (and potentially multi-variable) phase function, and an explicit set of 'overriding' values at specific state indices.  <a href="group__operator.html#ga2fbaec3bb21cc01f7a2a4ed2aa911ebf">More...</a><br /></td></tr>
<tr class="separator:ga2fbaec3bb21cc01f7a2a4ed2aa911ebf"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga225b82ff8b8eed1fff312240ec70c731"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__operator.html#ga225b82ff8b8eed1fff312240ec70c731">applyParamNamedPhaseFunc</a> (<a class="el" href="structQureg.html">Qureg</a> qureg, int *qubits, int *numQubitsPerReg, int numRegs, enum <a class="el" href="group__type.html#ga9c91c41aa42ae537995e89ffc616afe1">bitEncoding</a> encoding, enum <a class="el" href="group__type.html#gaa7d869b117ba5024d6b84938e8cdfc65">phaseFunc</a> functionNameCode, <a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> *params, int numParams)</td></tr>
<tr class="memdesc:ga225b82ff8b8eed1fff312240ec70c731"><td class="mdescLeft">&#160;</td><td class="mdescRight">Induces a phase change upon each amplitude of <code>qureg</code>, determined by a named, paramaterized (and potentially multi-variable) phase function.  <a href="group__operator.html#ga225b82ff8b8eed1fff312240ec70c731">More...</a><br /></td></tr>
<tr class="separator:ga225b82ff8b8eed1fff312240ec70c731"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gaabd7efa3beebc9f3a525321d41a28989"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__operator.html#gaabd7efa3beebc9f3a525321d41a28989">applyParamNamedPhaseFuncOverrides</a> (<a class="el" href="structQureg.html">Qureg</a> qureg, int *qubits, int *numQubitsPerReg, int numRegs, enum <a class="el" href="group__type.html#ga9c91c41aa42ae537995e89ffc616afe1">bitEncoding</a> encoding, enum <a class="el" href="group__type.html#gaa7d869b117ba5024d6b84938e8cdfc65">phaseFunc</a> functionNameCode, <a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> *params, int numParams, long long int *overrideInds, <a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> *overridePhases, int numOverrides)</td></tr>
<tr class="memdesc:gaabd7efa3beebc9f3a525321d41a28989"><td class="mdescLeft">&#160;</td><td class="mdescRight">Induces a phase change upon each amplitude of <code>qureg</code>, determined by a named, parameterised (and potentially multi-variable) phase function, and an explicit set of 'overriding' values at specific state indices.  <a href="group__operator.html#gaabd7efa3beebc9f3a525321d41a28989">More...</a><br /></td></tr>
<tr class="separator:gaabd7efa3beebc9f3a525321d41a28989"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga54d4e589468002bdc998200ae45e7312"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__operator.html#ga54d4e589468002bdc998200ae45e7312">applyPauliHamil</a> (<a class="el" href="structQureg.html">Qureg</a> inQureg, <a class="el" href="structPauliHamil.html">PauliHamil</a> hamil, <a class="el" href="structQureg.html">Qureg</a> outQureg)</td></tr>
<tr class="memdesc:ga54d4e589468002bdc998200ae45e7312"><td class="mdescLeft">&#160;</td><td class="mdescRight">Modifies <code>outQureg</code> to be the result of applying <code><a class="el" href="structPauliHamil.html" title="A Pauli Hamiltonian, expressed as a real-weighted sum of pauli products, and which can hence represen...">PauliHamil</a></code> (a Hermitian but not necessarily unitary operator) to <code>inQureg</code>.  <a href="group__operator.html#ga54d4e589468002bdc998200ae45e7312">More...</a><br /></td></tr>
<tr class="separator:ga54d4e589468002bdc998200ae45e7312"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga6fc26cf857db070e12959e59ecfed8a6"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__operator.html#ga6fc26cf857db070e12959e59ecfed8a6">applyPauliSum</a> (<a class="el" href="structQureg.html">Qureg</a> inQureg, enum <a class="el" href="group__type.html#ga1c703cf89629e4e9c7023cd402d67028">pauliOpType</a> *allPauliCodes, <a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> *termCoeffs, int numSumTerms, <a class="el" href="structQureg.html">Qureg</a> outQureg)</td></tr>
<tr class="memdesc:ga6fc26cf857db070e12959e59ecfed8a6"><td class="mdescLeft">&#160;</td><td class="mdescRight">Modifies <code>outQureg</code> to be the result of applying the weighted sum of Pauli products (a Hermitian but not necessarily unitary operator) to <code>inQureg</code>.  <a href="group__operator.html#ga6fc26cf857db070e12959e59ecfed8a6">More...</a><br /></td></tr>
<tr class="separator:ga6fc26cf857db070e12959e59ecfed8a6"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga467f517abd18dbc3d6fced84c6589161"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__operator.html#ga467f517abd18dbc3d6fced84c6589161">applyPhaseFunc</a> (<a class="el" href="structQureg.html">Qureg</a> qureg, int *qubits, int numQubits, enum <a class="el" href="group__type.html#ga9c91c41aa42ae537995e89ffc616afe1">bitEncoding</a> encoding, <a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> *coeffs, <a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> *exponents, int numTerms)</td></tr>
<tr class="memdesc:ga467f517abd18dbc3d6fced84c6589161"><td class="mdescLeft">&#160;</td><td class="mdescRight">Induces a phase change upon each amplitude of <code>qureg</code>, determined by the passed exponential polynomial "phase function".  <a href="group__operator.html#ga467f517abd18dbc3d6fced84c6589161">More...</a><br /></td></tr>
<tr class="separator:ga467f517abd18dbc3d6fced84c6589161"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gaf5344129240243ad11d0c081eb9036ab"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__operator.html#gaf5344129240243ad11d0c081eb9036ab">applyPhaseFuncOverrides</a> (<a class="el" href="structQureg.html">Qureg</a> qureg, int *qubits, int numQubits, enum <a class="el" href="group__type.html#ga9c91c41aa42ae537995e89ffc616afe1">bitEncoding</a> encoding, <a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> *coeffs, <a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> *exponents, int numTerms, long long int *overrideInds, <a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> *overridePhases, int numOverrides)</td></tr>
<tr class="memdesc:gaf5344129240243ad11d0c081eb9036ab"><td class="mdescLeft">&#160;</td><td class="mdescRight">Induces a phase change upon each amplitude of <code>qureg</code>, determined by the passed exponential polynomial "phase function", and an explicit set of 'overriding' values at specific state indices.  <a href="group__operator.html#gaf5344129240243ad11d0c081eb9036ab">More...</a><br /></td></tr>
<tr class="separator:gaf5344129240243ad11d0c081eb9036ab"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga26db8b8a8a242d388c291e50d228ab18"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__operator.html#ga26db8b8a8a242d388c291e50d228ab18">applyProjector</a> (<a class="el" href="structQureg.html">Qureg</a> qureg, int qubit, int outcome)</td></tr>
<tr class="memdesc:ga26db8b8a8a242d388c291e50d228ab18"><td class="mdescLeft">&#160;</td><td class="mdescRight">Force the target <code>qubit</code> of <code>qureg</code> into the given classical <code>outcome</code>, via a non-renormalising projection.  <a href="group__operator.html#ga26db8b8a8a242d388c291e50d228ab18">More...</a><br /></td></tr>
<tr class="separator:ga26db8b8a8a242d388c291e50d228ab18"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga9bc8c4ab44f8233b5766208a0b1c0776"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__operator.html#ga9bc8c4ab44f8233b5766208a0b1c0776">applyQFT</a> (<a class="el" href="structQureg.html">Qureg</a> qureg, int *qubits, int numQubits)</td></tr>
<tr class="memdesc:ga9bc8c4ab44f8233b5766208a0b1c0776"><td class="mdescLeft">&#160;</td><td class="mdescRight">Applies the quantum Fourier transform (QFT) to a specific subset of qubits of the register <code>qureg</code>.  <a href="group__operator.html#ga9bc8c4ab44f8233b5766208a0b1c0776">More...</a><br /></td></tr>
<tr class="separator:ga9bc8c4ab44f8233b5766208a0b1c0776"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga35b6321c578a8c69470132b5ee95f930"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__operator.html#ga35b6321c578a8c69470132b5ee95f930">applyTrotterCircuit</a> (<a class="el" href="structQureg.html">Qureg</a> qureg, <a class="el" href="structPauliHamil.html">PauliHamil</a> hamil, <a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> time, int order, int reps)</td></tr>
<tr class="memdesc:ga35b6321c578a8c69470132b5ee95f930"><td class="mdescLeft">&#160;</td><td class="mdescRight">Applies a trotterisation of unitary evolution <img class="formulaInl" alt="$ \exp(-i \, \text{hamil} \, \text{time}) $" src="form_235.png"/> to <code>qureg</code>.  <a href="group__operator.html#ga35b6321c578a8c69470132b5ee95f930">More...</a><br /></td></tr>
<tr class="separator:ga35b6321c578a8c69470132b5ee95f930"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<p>Non-physical operators which may be non-unitary, non-norm-preserving, even non-Hermitian. </p>
<h2 class="groupheader">Function Documentation</h2>
<a id="gad2e953390342cd361cfb4064d47715e6"></a>
<h2 class="memtitle"><span class="permalink"><a href="#gad2e953390342cd361cfb4064d47715e6">&#9670;&nbsp;</a></span>applyDiagonalOp()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void applyDiagonalOp </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a>&#160;</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>&#160;</td>
          <td class="paramname"><em>op</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Apply a diagonal operator, which is possibly non-unitary and non-Hermitian, to the entire <code>qureg</code>. </p>
<p>Let <img class="formulaInl" alt="$d_j = \text{op.real}[j] + (\text{op.imag}[j])\,\text{i} $" src="form_36.png"/>, and </p><p class="formulaDsp">
<img class="formulaDsp" alt="\[ \hat{D} = \begin{pmatrix} d_0 \\ &amp; d_1 \\ &amp; &amp; \ddots \\ &amp; &amp; &amp; d_{2^{\text{op.numQubits}}-1} \end{pmatrix}. \]" src="form_37.png"/>
</p>
<p> If <code>qureg</code> is a state-vector <img class="formulaInl" alt="$|\psi\rangle$" src="form_38.png"/>, this function performs <img class="formulaInl" alt="$|\psi\rangle \rightarrow \hat{D} \, |\psi\rangle$" src="form_39.png"/>. <br  />
If <code>qureg</code> is a density-matrix <img class="formulaInl" alt="$\rho$" src="form_40.png"/>, this function performs <img class="formulaInl" alt="$\rho \rightarrow \hat{D}\, \rho$" src="form_41.png"/>. Notice this has not applied <img class="formulaInl" alt="$\hat{D}$" src="form_42.png"/> in the fashion of a unitary.</p>
<blockquote class="doxtable">
<p>If your operator is unitary with unit amplitudes, the phases of which can be described by an analytic expression, you should instead use <a class="el" href="group__operator.html#ga467f517abd18dbc3d6fced84c6589161" title="Induces a phase change upon each amplitude of qureg, determined by the passed exponential polynomial ...">applyPhaseFunc()</a> or <a class="el" href="group__operator.html#gac4df97d8c125c8cc65df720f67b2bf69" title="Induces a phase change upon each amplitude of qureg, determined by a named (and potentially multi-var...">applyNamedPhaseFunc()</a> for significant memory and runtime savings. </p>
</blockquote>
<dl class="section see"><dt>See also</dt><dd><ul>
<li><a class="el" href="group__type.html#gaebf896dd8d5eeaf9fd896f6cc8e334fe" title="Creates a DiagonalOp representing a diagonal operator on the full Hilbert space of a Qureg.">createDiagonalOp()</a></li>
<li><a class="el" href="group__calc.html#ga82f17e96a4cb7612fb9c6ef856df3810" title="Computes the expected value of the diagonal operator op for state qureg.">calcExpecDiagonalOp()</a></li>
<li><a class="el" href="group__operator.html#ga467f517abd18dbc3d6fced84c6589161" title="Induces a phase change upon each amplitude of qureg, determined by the passed exponential polynomial ...">applyPhaseFunc()</a></li>
<li><a class="el" href="group__operator.html#gac4df97d8c125c8cc65df720f67b2bf69" title="Induces a phase change upon each amplitude of qureg, determined by a named (and potentially multi-var...">applyNamedPhaseFunc()</a></li>
</ul>
</dd></dl>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in,out]</td><td class="paramname">qureg</td><td>the state to operate the diagonal operator upon </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">op</td><td>the diagonal operator to apply </td></tr>
  </table>
  </dd>
</dl>
<dl class="exception"><dt>Exceptions</dt><dd>
  <table class="exception">
    <tr><td class="paramname"><a class="el" href="group__debug.html#ga51a64b05d31ef9bcf6a63ce26c0092db" title="An internal function called when invalid arguments are passed to a QuEST API call,...">invalidQuESTInputError()</a></td><td><ul>
<li>if <code>op</code> was not created</li>
<li>if <code>op</code> acts on a different number of qubits than <code>qureg</code> represents </li>
</ul>
</td></tr>
  </table>
  </dd>
</dl>
<dl class="section author"><dt>Author</dt><dd>Tyson Jones </dd></dl>

<p class="definition">Definition at line <a class="el" href="QuEST_8c_source.html#l01127">1127</a> of file <a class="el" href="QuEST_8c_source.html">QuEST.c</a>.</p>
<div class="fragment"><div class="line"><a name="l01127"></a><span class="lineno"> 1127</span>&#160;                                                 {</div>
<div class="line"><a name="l01128"></a><span class="lineno"> 1128</span>&#160;    <a class="code" href="QuEST__validation_8c.html#a8a656a83bf0b44447188d06c2f8114cb">validateDiagonalOp</a>(qureg, op, __func__);</div>
<div class="line"><a name="l01129"></a><span class="lineno"> 1129</span>&#160; </div>
<div class="line"><a name="l01130"></a><span class="lineno"> 1130</span>&#160;    <span class="keywordflow">if</span> (qureg.<a class="code" href="structQureg.html#acf78445e9435d09f44f0cc832c6aee79">isDensityMatrix</a>)</div>
<div class="line"><a name="l01131"></a><span class="lineno"> 1131</span>&#160;        <a class="code" href="QuEST__internal_8h.html#aedd7ecccf2f09dd2f1c5d191950b51e6">densmatr_applyDiagonalOp</a>(qureg, op);</div>
<div class="line"><a name="l01132"></a><span class="lineno"> 1132</span>&#160;    <span class="keywordflow">else</span></div>
<div class="line"><a name="l01133"></a><span class="lineno"> 1133</span>&#160;        <a class="code" href="QuEST__internal_8h.html#a27294e3065ebe42a65b3b9e0f85551dd">statevec_applyDiagonalOp</a>(qureg, op);</div>
<div class="line"><a name="l01134"></a><span class="lineno"> 1134</span>&#160; </div>
<div class="line"><a name="l01135"></a><span class="lineno"> 1135</span>&#160;    <a class="code" href="QuEST__qasm_8c.html#a9a385fde708958617bbeb599064b8dcb">qasm_recordComment</a>(qureg, <span class="stringliteral">&quot;Here, the register was modified to an undisclosed and possibly unphysical state (via applyDiagonalOp).&quot;</span>);</div>
<div class="line"><a name="l01136"></a><span class="lineno"> 1136</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST__cpu__distributed_8c_source.html#l01594">densmatr_applyDiagonalOp()</a>, <a class="el" href="QuEST_8h_source.html#l00325">Qureg::isDensityMatrix</a>, <a class="el" href="QuEST__qasm_8c_source.html#l00121">qasm_recordComment()</a>, <a class="el" href="QuEST__cpu_8c_source.html#l04047">statevec_applyDiagonalOp()</a>, and <a class="el" href="QuEST__validation_8c_source.html#l00713">validateDiagonalOp()</a>.</p>

<p class="reference">Referenced by <a class="el" href="test__data__structures_8cpp_source.html#l00768">TEST_CASE()</a>.</p>

</div>
</div>
<a id="gaf26f32c25db760065486188497c1da8b"></a>
<h2 class="memtitle"><span class="permalink"><a href="#gaf26f32c25db760065486188497c1da8b">&#9670;&nbsp;</a></span>applyFullQFT()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void applyFullQFT </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a>&#160;</td>
          <td class="paramname"><em>qureg</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Applies the quantum Fourier transform (QFT) to the entirety of <code>qureg</code>. </p>
<p>The effected unitary circuit (shown here for 4 qubits, bottom qubit is <b>0</b>) resembles </p><p class="formulaDsp">
<img class="formulaDsp" alt="\[ \begin{tikzpicture}[scale=.5] \draw (-2, 5) -- (23, 5); \draw (-2, 3) -- (23, 3); \draw (-2, 1) -- (23, 1); \draw (-2, -1) -- (23, -1); \draw[fill=white] (-1, 4) -- (-1, 6) -- (1, 6) -- (1,4) -- cycle; \node[draw=none] at (0, 5) {H}; \draw(2, 5) -- (2, 3); \draw[fill=black] (2, 5) circle (.2); \draw[fill=black] (2, 3) circle (.2); \draw(4, 5) -- (4, 1); \draw[fill=black] (4, 5) circle (.2); \draw[fill=black] (4, 1) circle (.2); \draw(6, 5) -- (6, -1); \draw[fill=black] (6, 5) circle (.2); \draw[fill=black] (6, -1) circle (.2); \draw[fill=white] (-1+8, 4-2) -- (-1+8, 6-2) -- (1+8, 6-2) -- (1+8,4-2) -- cycle; \node[draw=none] at (8, 5-2) {H}; \draw(10, 5-2) -- (10, 3-2); \draw[fill=black] (10, 5-2) circle (.2); \draw[fill=black] (10, 3-2) circle (.2); \draw(12, 5-2) -- (12, 3-4); \draw[fill=black] (12, 5-2) circle (.2); \draw[fill=black] (12, 3-4) circle (.2); \draw[fill=white] (-1+8+6, 4-4) -- (-1+8+6, 6-4) -- (1+8+6, 6-4) -- (1+8+6,4-4) -- cycle; \node[draw=none] at (8+6, 5-4) {H}; \draw(16, 5-2-2) -- (16, 3-4); \draw[fill=black] (16, 5-2-2) circle (.2); \draw[fill=black] (16, 3-4) circle (.2); \draw[fill=white] (-1+8+6+4, 4-4-2) -- (-1+8+6+4, 6-4-2) -- (1+8+6+4, 6-4-2) -- (1+8+6+4,4-4-2) -- cycle; \node[draw=none] at (8+6+4, 5-4-2) {H}; \draw (20, 5) -- (20, -1); \draw (20 - .35, 5 + .35) -- (20 + .35, 5 - .35); \draw (20 - .35, 5 - .35) -- (20 + .35, 5 + .35); \draw (20 - .35, -1 + .35) -- (20 + .35, -1 - .35); \draw (20 - .35, -1 - .35) -- (20 + .35, -1 + .35); \draw (22, 3) -- (22, 1); \draw (22 - .35, 3 + .35) -- (22 + .35, 3 - .35); \draw (22 - .35, 3 - .35) -- (22 + .35, 3 + .35); \draw (22 - .35, 1 + .35) -- (22 + .35, 1 - .35); \draw (22 - .35, 1 - .35) -- (22 + .35, 1 + .35); \end{tikzpicture} \]" src="form_294.png"/>
</p>
<p> though is performed more efficiently.</p>
<ul>
<li>If <code>qureg</code> is a state-vector, the output amplitudes are the discrete Fourier transform (DFT) of the input amplitudes, in the exact ordering. This is true even if <code>qureg</code> is unnormalised. <br  />
 Precisely, <p class="formulaDsp">
<img class="formulaDsp" alt="\[ \text{QFT} \, \left( \sum\limits_{x=0}^{2^N-1} \alpha_x |x\rangle \right) = \frac{1}{\sqrt{2^N}} \sum\limits_{x=0}^{2^N-1} \left( \sum\limits_{y=0}^{2^N-1} e^{2 \pi \, i \, x \, y / 2^N} \; \alpha_y \right) |x\rangle \]" src="form_295.png"/>
</p>
</li>
<li>If <code>qureg</code> is a density matrix <img class="formulaInl" alt="$\rho$" src="form_40.png"/>, it will be changed under the unitary action of the QFT. This can be imagined as each mixed state-vector undergoing the DFT on its amplitudes. This is true even if <code>qureg</code> is unnormalised. <p class="formulaDsp">
<img class="formulaDsp" alt="\[ \rho \; \rightarrow \; \text{QFT} \; \rho \; \text{QFT}^{\dagger} \]" src="form_296.png"/>
</p>
</li>
</ul>
<blockquote class="doxtable">
<p>This function merges contiguous controlled-phase gates into single invocations of <a class="el" href="group__operator.html#gac4df97d8c125c8cc65df720f67b2bf69" title="Induces a phase change upon each amplitude of qureg, determined by a named (and potentially multi-var...">applyNamedPhaseFunc()</a>, and hence is significantly faster than performing the QFT circuit directly. </p>
</blockquote>
<blockquote class="doxtable">
<p>Furthermore, in distributed mode, this function requires only <img class="formulaInl" alt="$\log_2(\text{\#nodes})$" src="form_297.png"/> rounds of pair-wise communication, and hence is exponentially faster than directly performing the DFT on the amplitudes of <code>qureg</code>. </p>
</blockquote>
<dl class="section see"><dt>See also</dt><dd><ul>
<li><a class="el" href="group__operator.html#ga9bc8c4ab44f8233b5766208a0b1c0776" title="Applies the quantum Fourier transform (QFT) to a specific subset of qubits of the register qureg.">applyQFT()</a> to apply the QFT to a sub-register of <code>qureg</code>.</li>
</ul>
</dd></dl>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in,out]</td><td class="paramname">qureg</td><td>a state-vector or density matrix to modify </td></tr>
  </table>
  </dd>
</dl>
<dl class="section author"><dt>Author</dt><dd>Tyson Jones </dd></dl>

<p class="definition">Definition at line <a class="el" href="QuEST_8c_source.html#l00876">876</a> of file <a class="el" href="QuEST_8c_source.html">QuEST.c</a>.</p>
<div class="fragment"><div class="line"><a name="l00876"></a><span class="lineno">  876</span>&#160;                               {</div>
<div class="line"><a name="l00877"></a><span class="lineno">  877</span>&#160; </div>
<div class="line"><a name="l00878"></a><span class="lineno">  878</span>&#160;    <a class="code" href="QuEST__qasm_8c.html#a9a385fde708958617bbeb599064b8dcb">qasm_recordComment</a>(qureg, <span class="stringliteral">&quot;Beginning of QFT circuit&quot;</span>);</div>
<div class="line"><a name="l00879"></a><span class="lineno">  879</span>&#160;        </div>
<div class="line"><a name="l00880"></a><span class="lineno">  880</span>&#160;    <span class="keywordtype">int</span> qubits[100];</div>
<div class="line"><a name="l00881"></a><span class="lineno">  881</span>&#160;    <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i=0; i&lt;qureg.<a class="code" href="structQureg.html#ad08dff5316b8937f4b2a1417591543dc">numQubitsRepresented</a>; i++)</div>
<div class="line"><a name="l00882"></a><span class="lineno">  882</span>&#160;        qubits[i] = i;</div>
<div class="line"><a name="l00883"></a><span class="lineno">  883</span>&#160;    <a class="code" href="QuEST__common_8c.html#a2b78ab7dd04eab615a0d7c796e73ae8c">agnostic_applyQFT</a>(qureg, qubits, qureg.<a class="code" href="structQureg.html#ad08dff5316b8937f4b2a1417591543dc">numQubitsRepresented</a>);</div>
<div class="line"><a name="l00884"></a><span class="lineno">  884</span>&#160; </div>
<div class="line"><a name="l00885"></a><span class="lineno">  885</span>&#160;    <a class="code" href="QuEST__qasm_8c.html#a9a385fde708958617bbeb599064b8dcb">qasm_recordComment</a>(qureg, <span class="stringliteral">&quot;End of QFT circuit&quot;</span>);</div>
<div class="line"><a name="l00886"></a><span class="lineno">  886</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST__common_8c_source.html#l00849">agnostic_applyQFT()</a>, <a class="el" href="QuEST_8h_source.html#l00327">Qureg::numQubitsRepresented</a>, and <a class="el" href="QuEST__qasm_8c_source.html#l00121">qasm_recordComment()</a>.</p>

<p class="reference">Referenced by <a class="el" href="test__operators_8cpp_source.html#l00083">TEST_CASE()</a>.</p>

</div>
</div>
<a id="gadfb5c1d99a22ce666fc715a8da2e0950"></a>
<h2 class="memtitle"><span class="permalink"><a href="#gadfb5c1d99a22ce666fc715a8da2e0950">&#9670;&nbsp;</a></span>applyMatrix2()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void applyMatrix2 </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a>&#160;</td>
          <td class="paramname"><em>qureg</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>targetQubit</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="structComplexMatrix2.html">ComplexMatrix2</a>&#160;</td>
          <td class="paramname"><em>u</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Apply a general 2-by-2 matrix, which may be non-unitary. </p>
<p>The matrix is left-multiplied onto the state, for both state-vectors and density matrices.</p>
<p>Note this differs from the action of <a class="el" href="group__unitary.html#ga78b814256f851cac70fdf3cbf9cfc206" title="Apply a general single-qubit unitary (including a global phase factor).">unitary()</a> on a density matrix.</p>
<p>This function may leave <code>qureg</code> is an unnormalised state.</p>
<dl class="section see"><dt>See also</dt><dd><ul>
<li><a class="el" href="structComplexMatrix2.html" title="Represents a 2x2 matrix of complex numbers.">ComplexMatrix2</a></li>
<li><a class="el" href="group__unitary.html#ga78b814256f851cac70fdf3cbf9cfc206" title="Apply a general single-qubit unitary (including a global phase factor).">unitary()</a></li>
</ul>
</dd></dl>
<p><br  />
 </p><dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in,out]</td><td class="paramname">qureg</td><td>object representing the set of all qubits </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">targetQubit</td><td>qubit to operate <code>u</code> upon </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">u</td><td>matrix to apply </td></tr>
  </table>
  </dd>
</dl>
<dl class="exception"><dt>Exceptions</dt><dd>
  <table class="exception">
    <tr><td class="paramname"><a class="el" href="group__debug.html#ga51a64b05d31ef9bcf6a63ce26c0092db" title="An internal function called when invalid arguments are passed to a QuEST API call,...">invalidQuESTInputError()</a></td><td><ul>
<li>if <code>targetQubit</code> is outside [0, <code>qureg.numQubitsRepresented</code>) </li>
</ul>
</td></tr>
  </table>
  </dd>
</dl>
<dl class="section author"><dt>Author</dt><dd>Tyson Jones </dd></dl>

<p class="definition">Definition at line <a class="el" href="QuEST_8c_source.html#l01084">1084</a> of file <a class="el" href="QuEST_8c_source.html">QuEST.c</a>.</p>
<div class="fragment"><div class="line"><a name="l01084"></a><span class="lineno"> 1084</span>&#160;                                                                  {</div>
<div class="line"><a name="l01085"></a><span class="lineno"> 1085</span>&#160;    <a class="code" href="QuEST__validation_8c.html#ac31c45c5a31c523be0eb26abba6cf598">validateTarget</a>(qureg, targetQubit, __func__);</div>
<div class="line"><a name="l01086"></a><span class="lineno"> 1086</span>&#160;    </div>
<div class="line"><a name="l01087"></a><span class="lineno"> 1087</span>&#160;    <span class="comment">// actually just left-multiplies any complex matrix</span></div>
<div class="line"><a name="l01088"></a><span class="lineno"> 1088</span>&#160;    <a class="code" href="QuEST__internal_8h.html#ac3735bd959600e57b2ee3a105666cddf">statevec_unitary</a>(qureg, targetQubit, u);</div>
<div class="line"><a name="l01089"></a><span class="lineno"> 1089</span>&#160; </div>
<div class="line"><a name="l01090"></a><span class="lineno"> 1090</span>&#160;    <a class="code" href="QuEST__qasm_8c.html#a9a385fde708958617bbeb599064b8dcb">qasm_recordComment</a>(qureg, <span class="stringliteral">&quot;Here, an undisclosed 2-by-2 matrix (possibly non-unitary) was multiplied onto qubit %d&quot;</span>, targetQubit);</div>
<div class="line"><a name="l01091"></a><span class="lineno"> 1091</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST__qasm_8c_source.html#l00121">qasm_recordComment()</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00895">statevec_unitary()</a>, and <a class="el" href="QuEST__validation_8c_source.html#l00400">validateTarget()</a>.</p>

<p class="reference">Referenced by <a class="el" href="test__operators_8cpp_source.html#l00203">TEST_CASE()</a>.</p>

</div>
</div>
<a id="ga74a955ec4bce606d89317bcfc528387f"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga74a955ec4bce606d89317bcfc528387f">&#9670;&nbsp;</a></span>applyMatrix4()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void applyMatrix4 </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a>&#160;</td>
          <td class="paramname"><em>qureg</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>targetQubit1</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>targetQubit2</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="structComplexMatrix4.html">ComplexMatrix4</a>&#160;</td>
          <td class="paramname"><em>u</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Apply a general 4-by-4 matrix, which may be non-unitary. </p>
<p>The matrix is left-multiplied onto the state, for both state-vectors and density matrices.</p>
<p>Note this differs from the action of <a class="el" href="group__unitary.html#gab525a42d63233f61afeb6be97d89dd36" title="Apply a general two-qubit unitary (including a global phase factor).">twoQubitUnitary()</a> on a density matrix.</p>
<p><code>targetQubit1</code> is treated as the <code>least</code> significant qubit in <code>u</code>, such that a row in <code>u</code> is dotted with the vector <img class="formulaInl" alt="$ |\text{targetQubit2} \;\; \text{targetQubit1}\rangle : \{ |00\rangle, |01\rangle, |10\rangle, |11\rangle \} $" src="form_211.png"/></p>
<p>For example, </p><div class="fragment"><div class="line"><a class="code" href="group__operator.html#ga74a955ec4bce606d89317bcfc528387f">applyMatrix4</a>(qureg, a, b, u);</div>
</div><!-- fragment --><p>will invoke multiplication </p><p class="formulaDsp">
<img class="formulaDsp" alt="\[ \begin{pmatrix} u_{00} &amp; u_{01} &amp; u_{02} &amp; u_{03} \\ u_{10} &amp; u_{11} &amp; u_{12} &amp; u_{13} \\ u_{20} &amp; u_{21} &amp; u_{22} &amp; u_{23} \\ u_{30} &amp; u_{31} &amp; u_{32} &amp; u_{33} \end{pmatrix} \begin{pmatrix} |ba\rangle = |00\rangle \\ |ba\rangle = |01\rangle \\ |ba\rangle = |10\rangle \\ |ba\rangle = |11\rangle \end{pmatrix} \]" src="form_212.png"/>
</p>
<p>This function may leave <code>qureg</code> is an unnormalised state.</p>
<p>Note that in distributed mode, this routine requires that each node contains at least 4 amplitudes. This means an q-qubit register (state vector or density matrix) can be distributed by at most 2^q/4 nodes.</p>
<dl class="section see"><dt>See also</dt><dd><ul>
<li><a class="el" href="structComplexMatrix4.html" title="Represents a 4x4 matrix of complex numbers.">ComplexMatrix4</a></li>
<li><a class="el" href="group__unitary.html#gab525a42d63233f61afeb6be97d89dd36" title="Apply a general two-qubit unitary (including a global phase factor).">twoQubitUnitary()</a></li>
</ul>
</dd></dl>
<p><br  />
 </p><dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in,out]</td><td class="paramname">qureg</td><td>object representing the set of all qubits </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">targetQubit1</td><td>first qubit to operate on, treated as least significant in <code>u</code> </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">targetQubit2</td><td>second qubit to operate on, treated as most significant in <code>u</code> </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">u</td><td>matrix to apply </td></tr>
  </table>
  </dd>
</dl>
<dl class="exception"><dt>Exceptions</dt><dd>
  <table class="exception">
    <tr><td class="paramname"><a class="el" href="group__debug.html#ga51a64b05d31ef9bcf6a63ce26c0092db" title="An internal function called when invalid arguments are passed to a QuEST API call,...">invalidQuESTInputError()</a></td><td><ul>
<li>if <code>targetQubit1</code> or <code>targetQubit2</code> are outside [0, <code>qureg.numQubitsRepresented</code>)</li>
<li>if <code>targetQubit1</code> equals <code>targetQubit2</code> </li>
<li>if each node cannot fit 4 amplitudes in distributed mode </li>
</ul>
</td></tr>
  </table>
  </dd>
</dl>
<dl class="section author"><dt>Author</dt><dd>Tyson Jones </dd></dl>

<p class="definition">Definition at line <a class="el" href="QuEST_8c_source.html#l01093">1093</a> of file <a class="el" href="QuEST_8c_source.html">QuEST.c</a>.</p>
<div class="fragment"><div class="line"><a name="l01093"></a><span class="lineno"> 1093</span>&#160;                                                                                     {</div>
<div class="line"><a name="l01094"></a><span class="lineno"> 1094</span>&#160;    <a class="code" href="QuEST__validation_8c.html#a6776217a5f7ba38b56175cf6db0f96e0">validateMultiTargets</a>(qureg, (<span class="keywordtype">int</span> []) {targetQubit1, targetQubit2}, 2, __func__);</div>
<div class="line"><a name="l01095"></a><span class="lineno"> 1095</span>&#160;    <a class="code" href="QuEST__validation_8c.html#aa28b7d9c0c3cf9c4be0e324fb9d6bf76">validateMultiQubitMatrixFitsInNode</a>(qureg, 2, __func__);</div>
<div class="line"><a name="l01096"></a><span class="lineno"> 1096</span>&#160;    </div>
<div class="line"><a name="l01097"></a><span class="lineno"> 1097</span>&#160;    <span class="comment">// actually just left-multiplies any complex matrix</span></div>
<div class="line"><a name="l01098"></a><span class="lineno"> 1098</span>&#160;    <a class="code" href="QuEST__common_8c.html#a95abbe0cedf45b1ff2f070dba219fd7f">statevec_twoQubitUnitary</a>(qureg, targetQubit1, targetQubit2, u);</div>
<div class="line"><a name="l01099"></a><span class="lineno"> 1099</span>&#160; </div>
<div class="line"><a name="l01100"></a><span class="lineno"> 1100</span>&#160;    <a class="code" href="QuEST__qasm_8c.html#a9a385fde708958617bbeb599064b8dcb">qasm_recordComment</a>(qureg, <span class="stringliteral">&quot;Here, an undisclosed 4-by-4 matrix (possibly non-unitary) was multiplied onto qubits %d and %d&quot;</span>, targetQubit1, targetQubit2);</div>
<div class="line"><a name="l01101"></a><span class="lineno"> 1101</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST__qasm_8c_source.html#l00121">qasm_recordComment()</a>, <a class="el" href="QuEST__common_8c_source.html#l00561">statevec_twoQubitUnitary()</a>, <a class="el" href="QuEST__validation_8c_source.html#l00473">validateMultiQubitMatrixFitsInNode()</a>, and <a class="el" href="QuEST__validation_8c_source.html#l00428">validateMultiTargets()</a>.</p>

<p class="reference">Referenced by <a class="el" href="test__operators_8cpp_source.html#l00253">TEST_CASE()</a>.</p>

</div>
</div>
<a id="ga358e7094a98851afa86d27f0147e32a1"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga358e7094a98851afa86d27f0147e32a1">&#9670;&nbsp;</a></span>applyMatrixN()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void applyMatrixN </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a>&#160;</td>
          <td class="paramname"><em>qureg</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int *&#160;</td>
          <td class="paramname"><em>targs</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>numTargs</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="structComplexMatrixN.html">ComplexMatrixN</a>&#160;</td>
          <td class="paramname"><em>u</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Apply a general N-by-N matrix, which may be non-unitary, on any number of target qubits. </p>
<p>The matrix is left-multiplied onto the state, for both state-vectors and density matrices. Note this differs from the action of <a class="el" href="group__unitary.html#ga20bf9b8a71b8a3ee4651e9497e6d1f4f" title="Apply a general multi-qubit unitary (including a global phase factor) with any number of target qubit...">multiQubitUnitary()</a> on a density matrix.</p>
<p>The first target qubit in <code>targs</code> is treated as <b>least</b> significant in <code>u</code>. For example, </p><div class="fragment"><div class="line"><a class="code" href="group__operator.html#ga358e7094a98851afa86d27f0147e32a1">applyMatrixN</a>(qureg, (<span class="keywordtype">int</span> []) {a, b, c}, 3, u);</div>
</div><!-- fragment --><p>will invoke multiplication </p><p class="formulaDsp">
<img class="formulaDsp" alt="\[ \begin{pmatrix} u_{00} &amp; u_{01} &amp; u_{02} &amp; u_{03} &amp; u_{04} &amp; u_{05} &amp; u_{06} &amp; u_{07} \\ u_{10} &amp; u_{11} &amp; u_{12} &amp; u_{13} &amp; u_{14} &amp; u_{15} &amp; u_{16} &amp; u_{17} \\ u_{20} &amp; u_{21} &amp; u_{22} &amp; u_{23} &amp; u_{24} &amp; u_{25} &amp; u_{26} &amp; u_{27} \\ u_{30} &amp; u_{31} &amp; u_{32} &amp; u_{33} &amp; u_{34} &amp; u_{35} &amp; u_{36} &amp; u_{37} \\ u_{40} &amp; u_{41} &amp; u_{42} &amp; u_{43} &amp; u_{44} &amp; u_{45} &amp; u_{46} &amp; u_{47} \\ u_{50} &amp; u_{51} &amp; u_{52} &amp; u_{53} &amp; u_{54} &amp; u_{55} &amp; u_{56} &amp; u_{57} \\ u_{60} &amp; u_{61} &amp; u_{62} &amp; u_{63} &amp; u_{64} &amp; u_{65} &amp; u_{66} &amp; u_{67} \\ u_{70} &amp; u_{71} &amp; u_{72} &amp; u_{73} &amp; u_{74} &amp; u_{75} &amp; u_{76} &amp; u_{77} \\ \end{pmatrix} \begin{pmatrix} |cba\rangle = |000\rangle \\ |cba\rangle = |001\rangle \\ |cba\rangle = |010\rangle \\ |cba\rangle = |011\rangle \\ |cba\rangle = |100\rangle \\ |cba\rangle = |101\rangle \\ |cba\rangle = |110\rangle \\ |cba\rangle = |111\rangle \end{pmatrix} \]" src="form_217.png"/>
</p>
<p>This function may leave <code>qureg</code> is an unnormalised state.</p>
<p>The passed ComplexMatrix must be a compatible size with the specified number of target qubits, otherwise an error is thrown.</p>
<p>Note that in multithreaded mode, each thread will clone 2^<code>numTargs</code> amplitudes, and store these in the runtime stack. Using t threads, the total memory overhead of this function is t*2^<code>numTargs</code>. For many targets (e.g. 16 qubits), this may cause a stack-overflow / seg-fault (e.g. on a 1 MiB stack).</p>
<p>Note too that in distributed mode, this routine requires that each node contains at least 2^<code>numTargs</code> amplitudes in the register. This means an q-qubit register (state vector or density matrix) can be distributed by at most 2^q / 2^<code>numTargs</code> nodes.</p>
<dl class="section see"><dt>See also</dt><dd><ul>
<li><a class="el" href="group__type.html#ga815103261fb22ea9690e1427571df00e" title="Allocate dynamic memory for a square complex matrix of any size, which can be passed to functions lik...">createComplexMatrixN()</a></li>
<li><a class="el" href="group__type.html#ga927beeee2ba3b110f33ebb440c154ae2" title="Creates a ComplexMatrixN struct which lives in the stack and so does not need freeing,...">getStaticComplexMatrixN()</a></li>
<li><a class="el" href="group__operator.html#gab52b6315c5520b7d311b0458785eed8e" title="Apply a general N-by-N matrix, which may be non-unitary, with additional controlled qubits.">applyMultiControlledMatrixN()</a></li>
<li><a class="el" href="group__unitary.html#ga20bf9b8a71b8a3ee4651e9497e6d1f4f" title="Apply a general multi-qubit unitary (including a global phase factor) with any number of target qubit...">multiQubitUnitary()</a></li>
</ul>
</dd></dl>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in,out]</td><td class="paramname">qureg</td><td>object representing the set of all qubits </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">targs</td><td>a list of the target qubits, ordered least significant to most in <code>u</code> </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">numTargs</td><td>the number of target qubits </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">u</td><td>matrix to apply </td></tr>
  </table>
  </dd>
</dl>
<dl class="exception"><dt>Exceptions</dt><dd>
  <table class="exception">
    <tr><td class="paramname"><a class="el" href="group__debug.html#ga51a64b05d31ef9bcf6a63ce26c0092db" title="An internal function called when invalid arguments are passed to a QuEST API call,...">invalidQuESTInputError()</a></td><td><ul>
<li>if any index in <code>targs</code> is outside of [0, <code>qureg.numQubitsRepresented</code>)</li>
<li>if <code>targs</code> are not unique</li>
<li>if <code>u</code> is not of a compatible size with <code>numTargs</code> </li>
<li>if a node cannot fit the required number of target amplitudes in distributed mode </li>
</ul>
</td></tr>
  </table>
  </dd>
</dl>
<dl class="section author"><dt>Author</dt><dd>Tyson Jones </dd></dl>

<p class="definition">Definition at line <a class="el" href="QuEST_8c_source.html#l01103">1103</a> of file <a class="el" href="QuEST_8c_source.html">QuEST.c</a>.</p>
<div class="fragment"><div class="line"><a name="l01103"></a><span class="lineno"> 1103</span>&#160;                                                                           {</div>
<div class="line"><a name="l01104"></a><span class="lineno"> 1104</span>&#160;    <a class="code" href="QuEST__validation_8c.html#a6776217a5f7ba38b56175cf6db0f96e0">validateMultiTargets</a>(qureg, targs, numTargs, __func__);</div>
<div class="line"><a name="l01105"></a><span class="lineno"> 1105</span>&#160;    <a class="code" href="QuEST__validation_8c.html#a576519ac36b7cb25bab78d05b5d1975f">validateMultiQubitMatrix</a>(qureg, u, numTargs, __func__);</div>
<div class="line"><a name="l01106"></a><span class="lineno"> 1106</span>&#160;    </div>
<div class="line"><a name="l01107"></a><span class="lineno"> 1107</span>&#160;    <span class="comment">// actually just left-multiplies any complex matrix</span></div>
<div class="line"><a name="l01108"></a><span class="lineno"> 1108</span>&#160;    <a class="code" href="QuEST__common_8c.html#a7a76950824f17e821415070a4bfdad5b">statevec_multiQubitUnitary</a>(qureg, targs, numTargs, u);</div>
<div class="line"><a name="l01109"></a><span class="lineno"> 1109</span>&#160;    </div>
<div class="line"><a name="l01110"></a><span class="lineno"> 1110</span>&#160;    <span class="keywordtype">int</span> dim = (1 &lt;&lt; numTargs);</div>
<div class="line"><a name="l01111"></a><span class="lineno"> 1111</span>&#160;    <a class="code" href="QuEST__qasm_8c.html#a9a385fde708958617bbeb599064b8dcb">qasm_recordComment</a>(qureg, <span class="stringliteral">&quot;Here, an undisclosed %d-by-%d matrix (possibly non-unitary) was multiplied onto %d undisclosed qubits&quot;</span>, dim, dim, numTargs);</div>
<div class="line"><a name="l01112"></a><span class="lineno"> 1112</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST__qasm_8c_source.html#l00121">qasm_recordComment()</a>, <a class="el" href="QuEST__common_8c_source.html#l00573">statevec_multiQubitUnitary()</a>, <a class="el" href="QuEST__validation_8c_source.html#l00496">validateMultiQubitMatrix()</a>, and <a class="el" href="QuEST__validation_8c_source.html#l00428">validateMultiTargets()</a>.</p>

<p class="reference">Referenced by <a class="el" href="test__operators_8cpp_source.html#l00318">TEST_CASE()</a>.</p>

</div>
</div>
<a id="gab52b6315c5520b7d311b0458785eed8e"></a>
<h2 class="memtitle"><span class="permalink"><a href="#gab52b6315c5520b7d311b0458785eed8e">&#9670;&nbsp;</a></span>applyMultiControlledMatrixN()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void applyMultiControlledMatrixN </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a>&#160;</td>
          <td class="paramname"><em>qureg</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int *&#160;</td>
          <td class="paramname"><em>ctrls</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>numCtrls</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int *&#160;</td>
          <td class="paramname"><em>targs</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>numTargs</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="structComplexMatrixN.html">ComplexMatrixN</a>&#160;</td>
          <td class="paramname"><em>u</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Apply a general N-by-N matrix, which may be non-unitary, with additional controlled qubits. </p>
<p>The matrix is left-multiplied onto the state, for both state-vectors and density matrices. Hence, this function differs from <a class="el" href="group__unitary.html#ga3ad6c477edcdbc845fc1143e860fda08" title="Apply a general multi-controlled multi-qubit unitary (including a global phase factor).">multiControlledMultiQubitUnitary()</a> by more than just permitting a non-unitary matrix.</p>
<p>This function may leave <code>qureg</code> is an unnormalised state.</p>
<p>Any number of control and target qubits can be specified. This effects the many-qubit matrix </p><p class="formulaDsp">
<img class="formulaDsp" alt="\[ \begin{pmatrix} 1 \\ &amp; 1 \\\ &amp; &amp; \ddots \\ &amp; &amp; &amp; u_{00} &amp; u_{01} &amp; \dots \\ &amp; &amp; &amp; u_{10} &amp; u_{11} &amp; \dots \\ &amp; &amp; &amp; \vdots &amp; \vdots &amp; \ddots \end{pmatrix} \]" src="form_221.png"/>
</p>
<p> on the control and target qubits.</p>
<p>The target qubits in <code>targs</code> are treated as ordered least significant to most significant in <code>u</code>.</p>
<p>The passed ComplexMatrix must be a compatible size with the specified number of target qubits, otherwise an error is thrown.</p>
<p>Note that in multithreaded mode, each thread will clone 2^<code>numTargs</code> amplitudes, and store these in the runtime stack. Using t threads, the total memory overhead of this function is t*2^<code>numTargs</code>. For many targets (e.g. 16 qubits), this may cause a stack-overflow / seg-fault (e.g. on a 1 MiB stack).</p>
<p>Note that in distributed mode, this routine requires that each node contains at least 2^<code>numTargs</code> amplitudes. This means an q-qubit register (state vector or density matrix) can be distributed by at most 2^q / 2^<code>numTargs</code> nodes.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in,out]</td><td class="paramname">qureg</td><td>object representing the set of all qubits </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">ctrls</td><td>a list of the control qubits </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">numCtrls</td><td>the number of control qubits </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">targs</td><td>a list of the target qubits, ordered least to most significant </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">numTargs</td><td>the number of target qubits </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">u</td><td>matrix to apply </td></tr>
  </table>
  </dd>
</dl>
<dl class="exception"><dt>Exceptions</dt><dd>
  <table class="exception">
    <tr><td class="paramname"><a class="el" href="group__debug.html#ga51a64b05d31ef9bcf6a63ce26c0092db" title="An internal function called when invalid arguments are passed to a QuEST API call,...">invalidQuESTInputError()</a></td><td><ul>
<li>if any index in <code>ctrls</code> and <code>targs</code> is outside of [0, <code>qureg.numQubitsRepresented</code>)</li>
<li>if <code>ctrls</code> and <code>targs</code> are not unique</li>
<li>if matrix <code>u</code> is not a compatible size with <code>numTargs</code> </li>
<li>if a node cannot fit the required number of target amplitudes in distributed mode </li>
</ul>
</td></tr>
  </table>
  </dd>
</dl>
<dl class="section author"><dt>Author</dt><dd>Tyson Jones </dd></dl>

<p class="definition">Definition at line <a class="el" href="QuEST_8c_source.html#l01114">1114</a> of file <a class="el" href="QuEST_8c_source.html">QuEST.c</a>.</p>
<div class="fragment"><div class="line"><a name="l01114"></a><span class="lineno"> 1114</span>&#160;                                                                                                                    {</div>
<div class="line"><a name="l01115"></a><span class="lineno"> 1115</span>&#160;    <a class="code" href="QuEST__validation_8c.html#a5b0392701c555a898403f80ef4a32f62">validateMultiControlsMultiTargets</a>(qureg, ctrls, numCtrls, targs, numTargs, __func__);</div>
<div class="line"><a name="l01116"></a><span class="lineno"> 1116</span>&#160;    <a class="code" href="QuEST__validation_8c.html#a576519ac36b7cb25bab78d05b5d1975f">validateMultiQubitMatrix</a>(qureg, u, numTargs, __func__);</div>
<div class="line"><a name="l01117"></a><span class="lineno"> 1117</span>&#160;    </div>
<div class="line"><a name="l01118"></a><span class="lineno"> 1118</span>&#160;    <span class="comment">// actually just left-multiplies any complex matrix</span></div>
<div class="line"><a name="l01119"></a><span class="lineno"> 1119</span>&#160;    <span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> ctrlMask = <a class="code" href="QuEST__common_8c.html#acc45bb8300922ea5933e294921e25ea2">getQubitBitMask</a>(ctrls, numCtrls);</div>
<div class="line"><a name="l01120"></a><span class="lineno"> 1120</span>&#160;    <a class="code" href="QuEST__internal_8h.html#a0acfe30083d0bc2a84da196378a36122">statevec_multiControlledMultiQubitUnitary</a>(qureg, ctrlMask, targs, numTargs, u);</div>
<div class="line"><a name="l01121"></a><span class="lineno"> 1121</span>&#160;    </div>
<div class="line"><a name="l01122"></a><span class="lineno"> 1122</span>&#160;    <span class="keywordtype">int</span> numTot = numTargs + numCtrls;</div>
<div class="line"><a name="l01123"></a><span class="lineno"> 1123</span>&#160;    <span class="keywordtype">int</span> dim = (1 &lt;&lt; numTot );</div>
<div class="line"><a name="l01124"></a><span class="lineno"> 1124</span>&#160;    <a class="code" href="QuEST__qasm_8c.html#a9a385fde708958617bbeb599064b8dcb">qasm_recordComment</a>(qureg, <span class="stringliteral">&quot;Here, an undisclosed %d-by-%d matrix (possibly non-unitary, and including %d controlled qubits) was multiplied onto %d undisclosed qubits&quot;</span>, dim, dim, numCtrls, numTot);</div>
<div class="line"><a name="l01125"></a><span class="lineno"> 1125</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST__common_8c_source.html#l00050">getQubitBitMask()</a>, <a class="el" href="QuEST__qasm_8c_source.html#l00121">qasm_recordComment()</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l01514">statevec_multiControlledMultiQubitUnitary()</a>, <a class="el" href="QuEST__validation_8c_source.html#l00459">validateMultiControlsMultiTargets()</a>, and <a class="el" href="QuEST__validation_8c_source.html#l00496">validateMultiQubitMatrix()</a>.</p>

<p class="reference">Referenced by <a class="el" href="test__operators_8cpp_source.html#l00429">TEST_CASE()</a>.</p>

</div>
</div>
<a id="ga008a46d178a5a9691e2f5d363e3f518f"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga008a46d178a5a9691e2f5d363e3f518f">&#9670;&nbsp;</a></span>applyMultiVarPhaseFunc()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void applyMultiVarPhaseFunc </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a>&#160;</td>
          <td class="paramname"><em>qureg</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int *&#160;</td>
          <td class="paramname"><em>qubits</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int *&#160;</td>
          <td class="paramname"><em>numQubitsPerReg</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>numRegs</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">enum <a class="el" href="group__type.html#ga9c91c41aa42ae537995e89ffc616afe1">bitEncoding</a>&#160;</td>
          <td class="paramname"><em>encoding</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> *&#160;</td>
          <td class="paramname"><em>coeffs</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> *&#160;</td>
          <td class="paramname"><em>exponents</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int *&#160;</td>
          <td class="paramname"><em>numTermsPerReg</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Induces a phase change upon each amplitude of <code>qureg</code>, determined by a multi-variable exponential polynomial "phase function". </p>
<p>This is a multi-variable extension of <a class="el" href="group__operator.html#ga467f517abd18dbc3d6fced84c6589161" title="Induces a phase change upon each amplitude of qureg, determined by the passed exponential polynomial ...">applyPhaseFunc()</a>, whereby multiple sub-registers inform separate variables in the exponential polynomial function, and effects a diagonal unitary operator.</p>
<ul>
<li><p class="startli">Arguments <code>coeffs</code>, <code>exponents</code> and <code>numTermsPerReg</code> together specify a real exponential polynomial <img class="formulaInl" alt="$f(\vec{r})$" src="form_262.png"/> of the form </p><p class="formulaDsp">
<img class="formulaDsp" alt="\[ f(r_1, \; \dots, \; r_{\text{numRegs}}) = \sum\limits_j^{\text{numRegs}} \; \sum\limits_{i}^{\text{numTermsPerReg}[j]} \; c_{i,j} \; {r_j}^{\; p_{i,j}}\,, \]" src="form_263.png"/>
</p>
<p> where both coefficients <img class="formulaInl" alt="$c_{i,j}$" src="form_264.png"/> and exponents <img class="formulaInl" alt="$p_{i,j}$" src="form_265.png"/> can be any real number, subject to constraints described below. <br  />
<br  />
 While <code>coeffs</code> and <code>exponents</code> are flat lists, they should be considered grouped into #<code>numRegs</code> sublists with lengths given by <code>numTermsPerReg</code> (which itself has length <code>numRegs</code>). <br  />
<br  />
 For example, </p><div class="fragment"><div class="line"><span class="keywordtype">int</span> numRegs = 3;</div>
<div class="line"><a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> coeffs[] =        {1,  2, 4,  -3.14};</div>
<div class="line"><a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> exponents[] =     {2,  1, 5,   0.5 };</div>
<div class="line"><span class="keywordtype">int</span> numTermsPerReg[] =  {1,  2,      1   };</div>
</div><!-- fragment --><p class="startli">constitutes the function </p><p class="formulaDsp">
<img class="formulaDsp" alt="\[ f(\vec{r}) = 1 \, {r_1}^2 + 2 \, {r_2} + 4 \, {r_2}^{5} - 3.14 \, {r_3}^{0.5}. \]" src="form_266.png"/>
</p>
<p> <br  />
</p><blockquote class="doxtable">
<p>This means lists <code>coeffs</code> and <code>exponents</code> should both be of length equal to the sum of <code>numTermsPerReg</code>. </p>
</blockquote>
<p>Unlike <a class="el" href="group__operator.html#ga467f517abd18dbc3d6fced84c6589161" title="Induces a phase change upon each amplitude of qureg, determined by the passed exponential polynomial ...">applyPhaseFunc()</a>, <a class="el" href="group__operator.html#ga008a46d178a5a9691e2f5d363e3f518f" title="Induces a phase change upon each amplitude of qureg, determined by a multi-variable exponential polyn...">applyMultiVarPhaseFunc()</a> places additional constraints on the exponents in <img class="formulaInl" alt="$f(\vec{r})$" src="form_262.png"/>, due to the exponentially growing costs of overriding diverging indices. Namely:<br  />
</p><ol type="1">
<li><code>exponents</code> must not contain a negative number, since this would result in a divergence when that register is zero, which would need to be overriden for every other register basis state. If <img class="formulaInl" alt="$f(\vec{r})$" src="form_262.png"/> must contain a negative exponent, you should instead call <a class="el" href="group__operator.html#gaf5344129240243ad11d0c081eb9036ab" title="Induces a phase change upon each amplitude of qureg, determined by the passed exponential polynomial ...">applyPhaseFuncOverrides()</a> once for each register/variable, and override the zero index for the relevant variable. This works, because <p class="formulaDsp">
<img class="formulaDsp" alt="\[ \exp( i \sum_j f_j(r_j) ) = \prod_j \exp(i f_j(r_j) ). \]" src="form_267.png"/>
</p>
</li>
<li><code>exponents</code> must not contain a fractional number if <code>endoding</code> <b>=</b> <a class="el" href="group__type.html#gga9c91c41aa42ae537995e89ffc616afe1a9aa2a35d92976c7de970506c4d19a96c">TWOS_COMPLEMENT</a>, because such a term would produce illegal complex values at negative register indices. Similar to the problem above, each negative register index would require overriding at every index of the other registers, and hence require an exponential number of overrides. Therefore, if <img class="formulaInl" alt="$f(\vec{r})$" src="form_262.png"/> must contain a negative exponent, you should instead call <a class="el" href="group__operator.html#gaf5344129240243ad11d0c081eb9036ab" title="Induces a phase change upon each amplitude of qureg, determined by the passed exponential polynomial ...">applyPhaseFuncOverrides()</a> once for each register/variable, and override every negative index of each register in turn. <br  />
<br  />
</li>
</ol>
</li>
<li><p class="startli">Lists <code>qubits</code> and <code>numQubitsPerReg</code> together describe #<code>numRegs</code> sub-registers of <code>qureg</code>, which can each contain a different number of qubits. <br  />
 Although <code>qubits</code> is a flat list of unique qubit indices, it should be imagined grouped into #<code>numRegs</code> sub-lists, of lengths given by <code>numQubitsPerReg</code>. <br  />
<br  />
 For example, </p><div class="fragment"><div class="line"><span class="keywordtype">int</span> qubits[] =          {0,1,  3,4,5,  7}</div>
<div class="line"><span class="keywordtype">int</span> numQubitsPerReg[] = {2,    3,      1};</div>
<div class="line"><span class="keywordtype">int</span> numRegs = 3;</div>
</div><!-- fragment --><p class="startli">describes three sub-registers, which are bolded below in an eight-qubit zero-state. </p><p class="formulaDsp">
<img class="formulaDsp" alt="\[ |r_3\rangle \; |0\rangle \; |r_2\rangle \; |0\rangle \; |r_1\rangle = |\mathbf{0}\rangle \; |0\rangle \; |\mathbf{000}\rangle \; |0\rangle \; |\mathbf{00}\rangle \]" src="form_268.png"/>
</p>
<p> Note that the qubits need not be ordered increasing, and qubits within each sub-register are assumed ordered least to most significant in that sub-register.<br  />
<br  />
</p><blockquote class="doxtable">
<p>List <code>qubits</code> should have length equal to the sum of elements in <code>numQubitsPerReg</code>. </p>
</blockquote>
</li>
<li>Each sub-register is associated with a variable <img class="formulaInl" alt="$r_j$" src="form_269.png"/> in phase function <img class="formulaInl" alt="$f(\vec{r})$" src="form_262.png"/>. <br  />
 For a given computational basis state of <code>qureg</code>, the value of each variable is determined by the binary value in the corresponding sub-register, when intepreted with <a class="el" href="group__type.html#ga9c91c41aa42ae537995e89ffc616afe1" title="Flags for specifying how the bits in sub-register computational basis states are mapped to indices in...">bitEncoding</a> <code>encoding</code>. <br  />
 See <a class="el" href="group__type.html#ga9c91c41aa42ae537995e89ffc616afe1" title="Flags for specifying how the bits in sub-register computational basis states are mapped to indices in...">bitEncoding</a> for more information.<br  />
<br  />
</li>
<li>The function <img class="formulaInl" alt="$f(\vec{r})$" src="form_262.png"/> specifies the phase change to induce upon amplitude <img class="formulaInl" alt="$\alpha$" src="form_88.png"/> of computational basis state with the nominated sub-registers encoding values <img class="formulaInl" alt="$r_1, \; \dots$" src="form_270.png"/>. <p class="formulaDsp">
<img class="formulaDsp" alt="\[ \alpha \, |r_{\text{numRegs}}, \; \dots, \; r_2, \; r_1 \rangle \rightarrow \, \exp(i f(\vec{r}\,)) \; \alpha \, |r_{\text{numRegs}}, \; \dots, \; r_2, \; r_1 \rangle. \]" src="form_271.png"/>
</p>
 For example, using the sub-registers in the previous example and <code>encoding</code> <b>=</b> <code>UNSIGNED</code>, the following states receive amplitude factors: <p class="formulaDsp">
<img class="formulaDsp" alt="\[ \begin{aligned} |\mathbf{0}\rangle \; |0\rangle \; |\mathbf{000}\rangle \; |0\rangle \; |\mathbf{00}\rangle &amp; \rightarrow \, e^{i f(r_3=0,r_2=0,r_1=0)} \\ |\mathbf{0}\rangle \; |0\rangle \; |\mathbf{000}\rangle \; |0\rangle \; |\mathbf{01}\rangle &amp; \rightarrow \, e^{i f(r_3=0,r_2=0,r_1=1)} \\ |\mathbf{0}\rangle \; |0\rangle \; |\mathbf{000}\rangle \; |0\rangle \; |\mathbf{10}\rangle &amp; \rightarrow \, e^{i f(r_3=0,r_2=0,r_1=2)} \\ |\mathbf{0}\rangle \; |0\rangle \; |\mathbf{000}\rangle \; |0\rangle \; |\mathbf{11}\rangle &amp; \rightarrow \, e^{i f(r_3=0,r_2=0,r_1=3)} \\ |\mathbf{0}\rangle \; |0\rangle \; |\mathbf{000}\rangle \; |1\rangle \; |\mathbf{00}\rangle &amp; \rightarrow \, e^{i f(r_3=0,r_2=0,r_1=0)} \\ &amp; \;\;\;\vdots \\ |\mathbf{0}\rangle \; |0\rangle \; |\mathbf{111}\rangle \; |0\rangle \; |\mathbf{01}\rangle &amp; \rightarrow \, e^{i f(r_3=0,r_2=7,r_1=1)} \\ &amp; \;\;\;\vdots \\ |\mathbf{1}\rangle \; |0\rangle \; |\mathbf{111}\rangle \; |0\rangle \; |\mathbf{11}\rangle &amp; \rightarrow \, e^{i f(r_3=1,r_2=7,r_1=3)} \end{aligned} \]" src="form_272.png"/>
</p>
</li>
<li>If <code>qureg</code> is a density matrix <img class="formulaInl" alt="$\rho$" src="form_40.png"/>, then its elements are modified as <p class="formulaDsp">
<img class="formulaDsp" alt="\[ \alpha \, |j\rangle\langle k| \; \rightarrow \; \exp(i \, (f(\vec{r}_j) - f(\vec{r}_k)) \, ) \; \alpha \, |j\rangle\langle k|, \]" src="form_273.png"/>
</p>
 where <img class="formulaInl" alt="$f(\vec{r}_j)$" src="form_274.png"/> and <img class="formulaInl" alt="$f(\vec{r}_k)$" src="form_275.png"/> are determined as above.<br  />
<br  />
</li>
<li><p class="startli">The interpreted phase function can be previewed in the QASM log, as a comment. <br  />
 For example: </p><div class="fragment"><div class="line"><a class="code" href="group__qasm.html#ga65bf1906298ca6355e2942f4923d77b6">startRecordingQASM</a>(qureg);</div>
<div class="line"><a class="code" href="group__operator.html#ga008a46d178a5a9691e2f5d363e3f518f">applyMultiVarPhaseFunc</a>(qureg, ...);</div>
<div class="line"><a class="code" href="group__qasm.html#gacf139d0a54b1f9e5c2f2feff742b8c76">printRecordedQASM</a>(qureg);</div>
</div><!-- fragment --><p class="startli">would show, for the above example, </p><div class="fragment"><div class="line"><span class="comment">// Here, applyMultiVarPhaseFunc() multiplied a complex scalar of the form</span></div>
<div class="line"><span class="comment">//     exp(i (</span></div>
<div class="line"><span class="comment">//          + 1 x^2</span></div>
<div class="line"><span class="comment">//          + 2 y + 4 y^(-1)</span></div>
<div class="line"><span class="comment">//          - 3.14 z^0.5 ))</span></div>
<div class="line"><span class="comment">//   upon substates informed by qubits (under an unsigned binary encoding)</span></div>
<div class="line"><span class="comment">//     |x&gt; = {0, 1}</span></div>
<div class="line"><span class="comment">//     |y&gt; = {3, 4, 5}</span></div>
<div class="line"><span class="comment">//     |z&gt; = {7}</span></div>
</div><!-- fragment --></li>
</ul>
<p><br  />
</p>
<dl class="section see"><dt>See also</dt><dd><ul>
<li><a class="el" href="group__operator.html#ga8dca543fb4d1ee1cd8b4c5d6028b3075" title="Induces a phase change upon each amplitude of qureg, determined by a multi-variable exponential polyn...">applyMultiVarPhaseFuncOverrides()</a> to additionally specify explicit phases for specific sub-register values.</li>
<li><a class="el" href="group__operator.html#gac4df97d8c125c8cc65df720f67b2bf69" title="Induces a phase change upon each amplitude of qureg, determined by a named (and potentially multi-var...">applyNamedPhaseFunc()</a> for a set of specific and potentially multi-variable phase functions.</li>
<li><a class="el" href="group__operator.html#ga467f517abd18dbc3d6fced84c6589161" title="Induces a phase change upon each amplitude of qureg, determined by the passed exponential polynomial ...">applyPhaseFunc()</a> for a single-variable polynomial exponential phase function, which is approximately twice as fast.</li>
<li><a class="el" href="group__operator.html#gad2e953390342cd361cfb4064d47715e6" title="Apply a diagonal operator, which is possibly non-unitary and non-Hermitian, to the entire qureg.">applyDiagonalOp()</a> to apply a non-unitary diagonal <a class="el" href="group__operator.html" title="Non-physical operators which may be non-unitary, non-norm-preserving, even non-Hermitian.">Operators</a>.</li>
</ul>
</dd></dl>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in,out]</td><td class="paramname">qureg</td><td>the state-vector or density matrix to be modified </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">qubits</td><td>a list of all the qubit indices contained in each sub-register </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">numQubitsPerReg</td><td>a list of the lengths of each sub-list in <code>qubits</code> </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">numRegs</td><td>the number of sub-registers, which is the length of both <code>numQubitsPerReg</code> and <code>numTermsPerReg</code> </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">encoding</td><td>the <a class="el" href="group__type.html#ga9c91c41aa42ae537995e89ffc616afe1" title="Flags for specifying how the bits in sub-register computational basis states are mapped to indices in...">bitEncoding</a> under which to infer the binary value <img class="formulaInl" alt="$r_j$" src="form_269.png"/> from the bits of a sub-register </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">coeffs</td><td>the coefficients of all terms of the exponential polynomial phase function <img class="formulaInl" alt="$f(\vec{r})$" src="form_262.png"/> </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">exponents</td><td>the exponents of all terms of the exponential polynomial phase function <img class="formulaInl" alt="$f(\vec{r})$" src="form_262.png"/> </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">numTermsPerReg</td><td>a list of the number of <code>coeff</code> and <code>exponent</code> terms supplied for each variable/sub-register </td></tr>
  </table>
  </dd>
</dl>
<dl class="exception"><dt>Exceptions</dt><dd>
  <table class="exception">
    <tr><td class="paramname"><a class="el" href="group__debug.html#ga51a64b05d31ef9bcf6a63ce26c0092db" title="An internal function called when invalid arguments are passed to a QuEST API call,...">invalidQuESTInputError()</a></td><td><ul>
<li>if any qubit in <code>qubits</code> has an invalid index (i.e. does not satisfy 0 &lt;= qubit &lt; <code>qureg.numQubitsRepresented</code>)</li>
<li>if the elements of <code>qubits</code> are not unique (including if sub-registers overlap)</li>
<li>if <code>numRegs</code> &lt;= 0 or <code>numRegs</code> &gt; 100 (constrained by <code>MAX_NUM_REGS_APPLY_ARBITRARY_PHASE</code> in <a class="el" href="QuEST__precision_8h.html">QuEST_precision.h</a>)</li>
<li>if <code>encoding</code> is not a valid <a class="el" href="group__type.html#ga9c91c41aa42ae537995e89ffc616afe1" title="Flags for specifying how the bits in sub-register computational basis states are mapped to indices in...">bitEncoding</a></li>
<li>if the size of any sub-register is incompatible with <code>encoding</code> (e.g. contains fewer than two qubits in <code>encoding</code> <b>=</b> <code>TWOS_COMPLEMENT</code>)</li>
<li>if any element of <code>numTermsPerReg</code> is &lt; 1</li>
<li>if <code>exponents</code> contains a negative number</li>
<li>if <code>exponents</code> contains a fractional number despite <code>encoding</code> <b>=</b> <a class="el" href="group__type.html#gga9c91c41aa42ae537995e89ffc616afe1a9aa2a35d92976c7de970506c4d19a96c">TWOS_COMPLEMENT</a> </li>
</ul>
</td></tr>
  </table>
  </dd>
</dl>
<dl class="section author"><dt>Author</dt><dd>Tyson Jones </dd></dl>

<p class="definition">Definition at line <a class="el" href="QuEST_8c_source.html#l00761">761</a> of file <a class="el" href="QuEST_8c_source.html">QuEST.c</a>.</p>
<div class="fragment"><div class="line"><a name="l00761"></a><span class="lineno">  761</span>&#160;                                                                                                                                                                          {</div>
<div class="line"><a name="l00762"></a><span class="lineno">  762</span>&#160;    <a class="code" href="QuEST__validation_8c.html#a0a45c9c3015af276ff7e624ae207ba7a">validateQubitSubregs</a>(qureg, qubits, numQubitsPerReg, numRegs, __func__);</div>
<div class="line"><a name="l00763"></a><span class="lineno">  763</span>&#160;    <a class="code" href="QuEST__validation_8c.html#a9b348fc98867d01990da93a8de36936c">validateMultiRegBitEncoding</a>(numQubitsPerReg, numRegs, encoding, __func__);</div>
<div class="line"><a name="l00764"></a><span class="lineno">  764</span>&#160;    <a class="code" href="QuEST__validation_8c.html#a14317136bb150eb0d4bdada1d0aac058">validateMultiVarPhaseFuncTerms</a>(numQubitsPerReg, numRegs, encoding, exponents, numTermsPerReg, __func__);</div>
<div class="line"><a name="l00765"></a><span class="lineno">  765</span>&#160; </div>
<div class="line"><a name="l00766"></a><span class="lineno">  766</span>&#160;    <span class="keywordtype">int</span> conj = 0;</div>
<div class="line"><a name="l00767"></a><span class="lineno">  767</span>&#160;    <a class="code" href="QuEST__internal_8h.html#ab33437d10c1ce1c4b034c7c411db553f">statevec_applyMultiVarPhaseFuncOverrides</a>(qureg, qubits, numQubitsPerReg, numRegs, encoding, coeffs, exponents, numTermsPerReg, NULL, NULL, 0, conj);</div>
<div class="line"><a name="l00768"></a><span class="lineno">  768</span>&#160;    <span class="keywordflow">if</span> (qureg.<a class="code" href="structQureg.html#acf78445e9435d09f44f0cc832c6aee79">isDensityMatrix</a>) {</div>
<div class="line"><a name="l00769"></a><span class="lineno">  769</span>&#160;        conj = 1;</div>
<div class="line"><a name="l00770"></a><span class="lineno">  770</span>&#160;        <a class="code" href="QuEST__common_8c.html#aecc3c36b275c53b321de1611c2f06f78">shiftSubregIndices</a>(qubits, numQubitsPerReg, numRegs, qureg.<a class="code" href="structQureg.html#ad08dff5316b8937f4b2a1417591543dc">numQubitsRepresented</a>);</div>
<div class="line"><a name="l00771"></a><span class="lineno">  771</span>&#160;        <a class="code" href="QuEST__internal_8h.html#ab33437d10c1ce1c4b034c7c411db553f">statevec_applyMultiVarPhaseFuncOverrides</a>(qureg, qubits, numQubitsPerReg, numRegs, encoding, coeffs, exponents, numTermsPerReg, NULL, NULL, 0, conj);</div>
<div class="line"><a name="l00772"></a><span class="lineno">  772</span>&#160;        <a class="code" href="QuEST__common_8c.html#aecc3c36b275c53b321de1611c2f06f78">shiftSubregIndices</a>(qubits, numQubitsPerReg, numRegs, - qureg.<a class="code" href="structQureg.html#ad08dff5316b8937f4b2a1417591543dc">numQubitsRepresented</a>);</div>
<div class="line"><a name="l00773"></a><span class="lineno">  773</span>&#160;    }</div>
<div class="line"><a name="l00774"></a><span class="lineno">  774</span>&#160; </div>
<div class="line"><a name="l00775"></a><span class="lineno">  775</span>&#160;    <a class="code" href="QuEST__qasm_8c.html#a6d239705dc0400ae75f8715c1f88b79f">qasm_recordMultiVarPhaseFunc</a>(qureg, qubits, numQubitsPerReg, numRegs, encoding, coeffs, exponents, numTermsPerReg, NULL, NULL, 0);</div>
<div class="line"><a name="l00776"></a><span class="lineno">  776</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST_8h_source.html#l00325">Qureg::isDensityMatrix</a>, <a class="el" href="QuEST_8h_source.html#l00327">Qureg::numQubitsRepresented</a>, <a class="el" href="QuEST__qasm_8c_source.html#l00666">qasm_recordMultiVarPhaseFunc()</a>, <a class="el" href="QuEST__common_8c_source.html#l00161">shiftSubregIndices()</a>, <a class="el" href="QuEST__cpu_8c_source.html#l04345">statevec_applyMultiVarPhaseFuncOverrides()</a>, <a class="el" href="QuEST__validation_8c_source.html#l00976">validateMultiRegBitEncoding()</a>, <a class="el" href="QuEST__validation_8c_source.html#l00836">validateMultiVarPhaseFuncTerms()</a>, and <a class="el" href="QuEST__validation_8c_source.html#l00757">validateQubitSubregs()</a>.</p>

<p class="reference">Referenced by <a class="el" href="test__operators_8cpp_source.html#l00589">TEST_CASE()</a>.</p>

</div>
</div>
<a id="ga8dca543fb4d1ee1cd8b4c5d6028b3075"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga8dca543fb4d1ee1cd8b4c5d6028b3075">&#9670;&nbsp;</a></span>applyMultiVarPhaseFuncOverrides()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void applyMultiVarPhaseFuncOverrides </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a>&#160;</td>
          <td class="paramname"><em>qureg</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int *&#160;</td>
          <td class="paramname"><em>qubits</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int *&#160;</td>
          <td class="paramname"><em>numQubitsPerReg</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>numRegs</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">enum <a class="el" href="group__type.html#ga9c91c41aa42ae537995e89ffc616afe1">bitEncoding</a>&#160;</td>
          <td class="paramname"><em>encoding</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> *&#160;</td>
          <td class="paramname"><em>coeffs</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> *&#160;</td>
          <td class="paramname"><em>exponents</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int *&#160;</td>
          <td class="paramname"><em>numTermsPerReg</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">long long int *&#160;</td>
          <td class="paramname"><em>overrideInds</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> *&#160;</td>
          <td class="paramname"><em>overridePhases</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>numOverrides</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Induces a phase change upon each amplitude of <code>qureg</code>, determined by a multi-variable exponential polynomial "phase function", and an explicit set of 'overriding' values at specific state indices. </p>
<p>See <a class="el" href="group__operator.html#ga008a46d178a5a9691e2f5d363e3f518f" title="Induces a phase change upon each amplitude of qureg, determined by a multi-variable exponential polyn...">applyMultiVarPhaseFunc()</a> first for a full description.</p>
<ul>
<li>As in <a class="el" href="group__operator.html#ga008a46d178a5a9691e2f5d363e3f518f" title="Induces a phase change upon each amplitude of qureg, determined by a multi-variable exponential polyn...">applyMultiVarPhaseFunc()</a>, the arguments <code>coeffs</code> and <code>exponents</code> specify a multi-variable phase function <img class="formulaInl" alt="$f(\vec{r})$" src="form_262.png"/>, where <img class="formulaInl" alt="$\vec{r}$" src="form_276.png"/> is determined by the sub-registers in <code>qubits</code>, and <a class="el" href="group__type.html#ga9c91c41aa42ae537995e89ffc616afe1" title="Flags for specifying how the bits in sub-register computational basis states are mapped to indices in...">bitEncoding</a> <code>encoding</code> for each basis state of <code>qureg</code>.<br  />
<br  />
</li>
<li><p class="startli">Additionally, <code>overrideInds</code> is a list of length <code>numOverrides</code> which specifies the values of <img class="formulaInl" alt="$\vec{r}$" src="form_276.png"/> for which to explicitly set the induced phase change.<br  />
 While flat, <code>overrideInds</code> should be imagined grouped into sub-lists of length <code>numRegs</code>, which specify the full <img class="formulaInl" alt="$\{r_1,\; \dots \;r_{\text{numRegs}} \} $" src="form_277.png"/> coordinate to override. <br  />
 Each sublist corresponds to a single element of <code>overridePhases</code>. <br  />
 For example, </p><div class="fragment"><div class="line"><span class="keywordtype">int</span> numRegs = 3;</div>
<div class="line"><span class="keywordtype">int</span> numOverrides = 2;</div>
<div class="line"><span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> overrideInds[] = { 0,0,0,   1,2,3  };</div>
<div class="line"><a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> overridePhases[]       = { <a class="code" href="QuEST__common_8c.html#ae71449b1cc6e6250b91f539153a7a0d3">M_PI</a>,   - <a class="code" href="QuEST__common_8c.html#ae71449b1cc6e6250b91f539153a7a0d3">M_PI</a> };</div>
</div><!-- fragment --><p class="startli">denotes that any basis state of <code>qureg</code> with sub-register values <img class="formulaInl" alt="$\{r_3,r_2,r_1\} = \{0, 0, 0\}$" src="form_278.png"/> (or <img class="formulaInl" alt="$\{r_3,r_2,r_1\} = \{1,2,3\}$" src="form_279.png"/>) should receive phase change <img class="formulaInl" alt="$\pi$" src="form_114.png"/> (or <img class="formulaInl" alt="$-\pi$" src="form_280.png"/>) in lieu of <img class="formulaInl" alt="$\exp(i f(r_3=0,r_2=0,r_1=0))$" src="form_281.png"/>.<br  />
<br  />
</p><blockquote class="doxtable">
<p>Note that you cannot use <a class="el" href="group__operator.html#ga8dca543fb4d1ee1cd8b4c5d6028b3075" title="Induces a phase change upon each amplitude of qureg, determined by a multi-variable exponential polyn...">applyMultiVarPhaseFuncOverrides()</a> to override divergences in <img class="formulaInl" alt="$f(\vec{r})$" src="form_262.png"/>, since each diverging value <img class="formulaInl" alt="$r_j$" src="form_269.png"/> would need to be overriden as an <img class="formulaInl" alt="$\vec{r}$" src="form_276.png"/> coordinate for every basis state of the other registers; the number of overrides grows exponentially. Ergo, if <code>exponents</code> contains a negative number (diverging at <img class="formulaInl" alt="$r_j=0$" src="form_282.png"/>), or <code>exponents</code> contains a fractional number despite <code>encoding</code> <b>=</b> <a class="el" href="group__type.html#gga9c91c41aa42ae537995e89ffc616afe1a9aa2a35d92976c7de970506c4d19a96c">TWOS_COMPLEMENT</a> (producing complex phases at negative indices), you must instead call <a class="el" href="group__operator.html#gaf5344129240243ad11d0c081eb9036ab" title="Induces a phase change upon each amplitude of qureg, determined by the passed exponential polynomial ...">applyPhaseFuncOverrides()</a> for each variable in turn and override the diverging <img class="formulaInl" alt="$r_j$" src="form_269.png"/> (each independently of the other registers). </p>
</blockquote>
</li>
<li><p class="startli">The interpreted overrides can be previewed in the QASM log, as a comment. <br  />
 For example: </p><div class="fragment"><div class="line"><a class="code" href="group__qasm.html#ga65bf1906298ca6355e2942f4923d77b6">startRecordingQASM</a>(qureg);</div>
<div class="line"><a class="code" href="group__operator.html#ga8dca543fb4d1ee1cd8b4c5d6028b3075">applyMultiVarPhaseFuncOverrides</a>(qureg, ...);</div>
<div class="line"><a class="code" href="group__qasm.html#gacf139d0a54b1f9e5c2f2feff742b8c76">printRecordedQASM</a>(qureg);</div>
</div><!-- fragment --><p class="startli">may show </p><div class="fragment"><div class="line"><span class="comment">// Here, applyMultiVarPhaseFunc() multiplied ...</span></div>
<div class="line"><span class="comment">//   though with overrides</span></div>
<div class="line"><span class="comment">//     |x=0, y=0, z=0&gt; -&gt; exp(i 3.14159)</span></div>
<div class="line"><span class="comment">//     |x=1, y=2, z=3&gt; -&gt; exp(i (-3.14159))</span></div>
</div><!-- fragment --></li>
</ul>
<p><br  />
</p>
<dl class="section see"><dt>See also</dt><dd><ul>
<li><a class="el" href="group__operator.html#gac4df97d8c125c8cc65df720f67b2bf69" title="Induces a phase change upon each amplitude of qureg, determined by a named (and potentially multi-var...">applyNamedPhaseFunc()</a> for a set of specific and potentially multi-variable phase functions.</li>
<li><a class="el" href="group__operator.html#gad2e953390342cd361cfb4064d47715e6" title="Apply a diagonal operator, which is possibly non-unitary and non-Hermitian, to the entire qureg.">applyDiagonalOp()</a> to apply a non-unitary diagonal <a class="el" href="group__operator.html" title="Non-physical operators which may be non-unitary, non-norm-preserving, even non-Hermitian.">Operators</a>.</li>
</ul>
</dd></dl>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in,out]</td><td class="paramname">qureg</td><td>the state-vector or density-matrix to be modified </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">qubits</td><td>a list of all the qubit indices contained in each sub-register </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">numQubitsPerReg</td><td>a list of the lengths of each sub-list in <code>qubits</code> </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">numRegs</td><td>the number of sub-registers, which is the length of both <code>numQubitsPerReg</code> and <code>numTermsPerReg</code> </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">encoding</td><td>the <a class="el" href="group__type.html#ga9c91c41aa42ae537995e89ffc616afe1" title="Flags for specifying how the bits in sub-register computational basis states are mapped to indices in...">bitEncoding</a> under which to infer the binary value <img class="formulaInl" alt="$r_j$" src="form_269.png"/> from the bits of a sub-register </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">coeffs</td><td>the coefficients of all terms of the exponential polynomial phase function <img class="formulaInl" alt="$f(\vec{r})$" src="form_262.png"/> </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">exponents</td><td>the exponents of all terms of the exponential polynomial phase function <img class="formulaInl" alt="$f(\vec{r})$" src="form_262.png"/> </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">numTermsPerReg</td><td>a list of the number of <code>coeff</code> and <code>exponent</code> terms supplied for each variable/sub-register </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">overrideInds</td><td>a flattened list of sub-register coordinates (values of <img class="formulaInl" alt="$\vec{r}$" src="form_276.png"/>) of which to explicit set the phase change </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">overridePhases</td><td>a list of replacement phase changes, for the corresponding <img class="formulaInl" alt="$\vec{r}$" src="form_276.png"/> values in <code>overrideInds</code> </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">numOverrides</td><td>the lengths of list <code>overridePhases</code> (but not necessarily of <code>overrideInds</code>) </td></tr>
  </table>
  </dd>
</dl>
<dl class="exception"><dt>Exceptions</dt><dd>
  <table class="exception">
    <tr><td class="paramname"><a class="el" href="group__debug.html#ga51a64b05d31ef9bcf6a63ce26c0092db" title="An internal function called when invalid arguments are passed to a QuEST API call,...">invalidQuESTInputError()</a></td><td><ul>
<li>if any qubit in <code>qubits</code> has an invalid index (i.e. does not satisfy 0 &lt;= qubit &lt; <code>qureg.numQubitsRepresented</code>)</li>
<li>if the elements of <code>qubits</code> are not unique (including if sub-registers overlap)</li>
<li>if <code>numRegs</code> &lt;= 0 or <code>numRegs</code> &gt; 100 (constrained by <code>MAX_NUM_REGS_APPLY_ARBITRARY_PHASE</code> in <a class="el" href="QuEST__precision_8h.html">QuEST_precision.h</a>)</li>
<li>if <code>encoding</code> is not a valid <a class="el" href="group__type.html#ga9c91c41aa42ae537995e89ffc616afe1" title="Flags for specifying how the bits in sub-register computational basis states are mapped to indices in...">bitEncoding</a></li>
<li>if the size of any sub-register is incompatible with <code>encoding</code> (e.g. contains fewer than two qubits in <code>encoding</code> <b>=</b> <code>TWOS_COMPLEMENT</code>)</li>
<li>if any element of <code>numTermsPerReg</code> is &lt; 1</li>
<li>if <code>exponents</code> contains a negative number</li>
<li>if <code>exponents</code> contains a fractional number despite <code>encoding</code> <b>=</b> <a class="el" href="group__type.html#gga9c91c41aa42ae537995e89ffc616afe1a9aa2a35d92976c7de970506c4d19a96c">TWOS_COMPLEMENT</a></li>
<li>if any value in <code>overrideInds</code> is not producible by its corresponding sub-register under the given <code>encoding</code> (e.g. 2 unsigned qubits cannot represent index 9)</li>
<li>if <code>numOverrides</code> &lt; 0 </li>
</ul>
</td></tr>
  </table>
  </dd>
</dl>
<dl class="section author"><dt>Author</dt><dd>Tyson Jones </dd></dl>

<p class="definition">Definition at line <a class="el" href="QuEST_8c_source.html#l00778">778</a> of file <a class="el" href="QuEST_8c_source.html">QuEST.c</a>.</p>
<div class="fragment"><div class="line"><a name="l00778"></a><span class="lineno">  778</span>&#160;                                                                                                                                                                                                                                                         {</div>
<div class="line"><a name="l00779"></a><span class="lineno">  779</span>&#160;    <a class="code" href="QuEST__validation_8c.html#a0a45c9c3015af276ff7e624ae207ba7a">validateQubitSubregs</a>(qureg, qubits, numQubitsPerReg, numRegs, __func__);</div>
<div class="line"><a name="l00780"></a><span class="lineno">  780</span>&#160;    <a class="code" href="QuEST__validation_8c.html#a9b348fc98867d01990da93a8de36936c">validateMultiRegBitEncoding</a>(numQubitsPerReg, numRegs, encoding, __func__);</div>
<div class="line"><a name="l00781"></a><span class="lineno">  781</span>&#160;    <a class="code" href="QuEST__validation_8c.html#a14317136bb150eb0d4bdada1d0aac058">validateMultiVarPhaseFuncTerms</a>(numQubitsPerReg, numRegs, encoding, exponents, numTermsPerReg, __func__);</div>
<div class="line"><a name="l00782"></a><span class="lineno">  782</span>&#160;    <a class="code" href="QuEST__validation_8c.html#a0edb4d9df94a40b8ea89c1c14997ee76">validateMultiVarPhaseFuncOverrides</a>(numQubitsPerReg, numRegs, encoding, overrideInds, numOverrides, __func__);</div>
<div class="line"><a name="l00783"></a><span class="lineno">  783</span>&#160; </div>
<div class="line"><a name="l00784"></a><span class="lineno">  784</span>&#160;    <span class="keywordtype">int</span> conj = 0;</div>
<div class="line"><a name="l00785"></a><span class="lineno">  785</span>&#160;    <a class="code" href="QuEST__internal_8h.html#ab33437d10c1ce1c4b034c7c411db553f">statevec_applyMultiVarPhaseFuncOverrides</a>(qureg, qubits, numQubitsPerReg, numRegs, encoding, coeffs, exponents, numTermsPerReg, overrideInds, overridePhases, numOverrides, conj);</div>
<div class="line"><a name="l00786"></a><span class="lineno">  786</span>&#160;    <span class="keywordflow">if</span> (qureg.<a class="code" href="structQureg.html#acf78445e9435d09f44f0cc832c6aee79">isDensityMatrix</a>) {</div>
<div class="line"><a name="l00787"></a><span class="lineno">  787</span>&#160;        conj = 1;</div>
<div class="line"><a name="l00788"></a><span class="lineno">  788</span>&#160;        <a class="code" href="QuEST__common_8c.html#aecc3c36b275c53b321de1611c2f06f78">shiftSubregIndices</a>(qubits, numQubitsPerReg, numRegs, qureg.<a class="code" href="structQureg.html#ad08dff5316b8937f4b2a1417591543dc">numQubitsRepresented</a>);</div>
<div class="line"><a name="l00789"></a><span class="lineno">  789</span>&#160;        <a class="code" href="QuEST__internal_8h.html#ab33437d10c1ce1c4b034c7c411db553f">statevec_applyMultiVarPhaseFuncOverrides</a>(qureg, qubits, numQubitsPerReg, numRegs, encoding, coeffs, exponents, numTermsPerReg, overrideInds, overridePhases, numOverrides, conj);</div>
<div class="line"><a name="l00790"></a><span class="lineno">  790</span>&#160;        <a class="code" href="QuEST__common_8c.html#aecc3c36b275c53b321de1611c2f06f78">shiftSubregIndices</a>(qubits, numQubitsPerReg, numRegs, - qureg.<a class="code" href="structQureg.html#ad08dff5316b8937f4b2a1417591543dc">numQubitsRepresented</a>);</div>
<div class="line"><a name="l00791"></a><span class="lineno">  791</span>&#160;    }</div>
<div class="line"><a name="l00792"></a><span class="lineno">  792</span>&#160; </div>
<div class="line"><a name="l00793"></a><span class="lineno">  793</span>&#160;    <a class="code" href="QuEST__qasm_8c.html#a6d239705dc0400ae75f8715c1f88b79f">qasm_recordMultiVarPhaseFunc</a>(qureg, qubits, numQubitsPerReg, numRegs, encoding, coeffs, exponents, numTermsPerReg, overrideInds, overridePhases, numOverrides);</div>
<div class="line"><a name="l00794"></a><span class="lineno">  794</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST_8h_source.html#l00325">Qureg::isDensityMatrix</a>, <a class="el" href="QuEST_8h_source.html#l00327">Qureg::numQubitsRepresented</a>, <a class="el" href="QuEST__qasm_8c_source.html#l00666">qasm_recordMultiVarPhaseFunc()</a>, <a class="el" href="QuEST__common_8c_source.html#l00161">shiftSubregIndices()</a>, <a class="el" href="QuEST__cpu_8c_source.html#l04345">statevec_applyMultiVarPhaseFuncOverrides()</a>, <a class="el" href="QuEST__validation_8c_source.html#l00976">validateMultiRegBitEncoding()</a>, <a class="el" href="QuEST__validation_8c_source.html#l00886">validateMultiVarPhaseFuncOverrides()</a>, <a class="el" href="QuEST__validation_8c_source.html#l00836">validateMultiVarPhaseFuncTerms()</a>, and <a class="el" href="QuEST__validation_8c_source.html#l00757">validateQubitSubregs()</a>.</p>

<p class="reference">Referenced by <a class="el" href="test__operators_8cpp_source.html#l00790">TEST_CASE()</a>.</p>

</div>
</div>
<a id="gac4df97d8c125c8cc65df720f67b2bf69"></a>
<h2 class="memtitle"><span class="permalink"><a href="#gac4df97d8c125c8cc65df720f67b2bf69">&#9670;&nbsp;</a></span>applyNamedPhaseFunc()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void applyNamedPhaseFunc </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a>&#160;</td>
          <td class="paramname"><em>qureg</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int *&#160;</td>
          <td class="paramname"><em>qubits</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int *&#160;</td>
          <td class="paramname"><em>numQubitsPerReg</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>numRegs</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">enum <a class="el" href="group__type.html#ga9c91c41aa42ae537995e89ffc616afe1">bitEncoding</a>&#160;</td>
          <td class="paramname"><em>encoding</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">enum <a class="el" href="group__type.html#gaa7d869b117ba5024d6b84938e8cdfc65">phaseFunc</a>&#160;</td>
          <td class="paramname"><em>functionNameCode</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Induces a phase change upon each amplitude of <code>qureg</code>, determined by a named (and potentially multi-variable) phase function. </p>
<p>This effects a diagonal unitary operator, with a phase function <img class="formulaInl" alt="$f(\vec{r})$" src="form_262.png"/> which may not be simply expressible as an exponential polynomial in functions <a class="el" href="group__operator.html#ga467f517abd18dbc3d6fced84c6589161" title="Induces a phase change upon each amplitude of qureg, determined by the passed exponential polynomial ...">applyPhaseFunc()</a> and <a class="el" href="group__operator.html#ga008a46d178a5a9691e2f5d363e3f518f" title="Induces a phase change upon each amplitude of qureg, determined by a multi-variable exponential polyn...">applyMultiVarPhaseFunc()</a>.</p>
<p>Arguments <code>qubits</code> and <code>numQubitsPerReg</code> encode sub-registers of <code>qureg</code> in the same manner as in <a class="el" href="group__operator.html#ga008a46d178a5a9691e2f5d363e3f518f" title="Induces a phase change upon each amplitude of qureg, determined by a multi-variable exponential polyn...">applyMultiVarPhaseFunc()</a>:</p><ul>
<li><p class="startli">Lists <code>qubits</code> and <code>numQubitsPerReg</code> together describe #<code>numRegs</code> sub-registers of <code>qureg</code>, which can each contain a different number of qubits. <br  />
 Although <code>qubits</code> is a flat list of unique qubit indices, it should be imagined grouped into #<code>numRegs</code> sub-lists, of lengths given by <code>numQubitsPerReg</code>. <br  />
<br  />
 For example, </p><div class="fragment"><div class="line"><span class="keywordtype">int</span> qubits[] =          {0,1,  3,4,5,  7}</div>
<div class="line"><span class="keywordtype">int</span> numQubitsPerReg[] = {2,    3,      1};</div>
<div class="line"><span class="keywordtype">int</span> numRegs = 3;</div>
</div><!-- fragment --><p class="startli">describes three sub-registers, which are bolded below in an eight-qubit zero-state. </p><p class="formulaDsp">
<img class="formulaDsp" alt="\[ |r_3\rangle \; |0\rangle \; |r_2\rangle \; |0\rangle \; |r_1\rangle = |\mathbf{0}\rangle \; |0\rangle \; |\mathbf{000}\rangle \; |0\rangle \; |\mathbf{00}\rangle \]" src="form_268.png"/>
</p>
<p> Note that the qubits need not be ordered increasing, and qubits within each sub-register are assumed ordered least to most significant in that sub-register.<br  />
<br  />
</p><blockquote class="doxtable">
<p>List <code>qubits</code> should have length equal to the sum of elements in <code>numQubitsPerReg</code>. </p>
</blockquote>
</li>
<li>Each sub-register is associated with a variable <img class="formulaInl" alt="$r_j$" src="form_269.png"/> in phase function <img class="formulaInl" alt="$f(\vec{r})$" src="form_262.png"/>. <br  />
 For a given computational basis state of <code>qureg</code>, the value of each variable is determined by the binary value in the corresponding sub-register, when intepreted with <a class="el" href="group__type.html#ga9c91c41aa42ae537995e89ffc616afe1" title="Flags for specifying how the bits in sub-register computational basis states are mapped to indices in...">bitEncoding</a> <code>encoding</code>. <br  />
 See <a class="el" href="group__type.html#ga9c91c41aa42ae537995e89ffc616afe1" title="Flags for specifying how the bits in sub-register computational basis states are mapped to indices in...">bitEncoding</a> for more information.<br  />
<br  />
</li>
<li><p class="startli">Argument <code>functionNameCode</code> determines the phase function <img class="formulaInl" alt="$f(\vec{r})$" src="form_262.png"/>.<br  />
 For example, </p><div class="fragment"><div class="line"><span class="keywordtype">int</span> numRegs = 3;</div>
<div class="line"><span class="keyword">enum</span> <a class="code" href="group__type.html#gaa7d869b117ba5024d6b84938e8cdfc65">phaseFunc</a> functionNameCode = <a class="code" href="group__type.html#ggaa7d869b117ba5024d6b84938e8cdfc65ae003ec1158e3a4e295616ced12af154e">NORM</a>;</div>
</div><!-- fragment --><p class="startli">describes phase function </p><p class="formulaDsp">
<img class="formulaDsp" alt="\[ f(\vec{r}) = \sqrt{ {r_1}^2 + {r_2}^2 + {r_3} ^2 }. \]" src="form_283.png"/>
</p>
<p> See <a class="el" href="group__type.html#gaa7d869b117ba5024d6b84938e8cdfc65" title="Flags for specifying named phase functions.">phaseFunc</a> for a list and description of all named phase functions. <br  />
 Some phase functions, like <code>SCALED_NORM</code>, require passing additional parameters, through the function <a class="el" href="group__operator.html#ga225b82ff8b8eed1fff312240ec70c731" title="Induces a phase change upon each amplitude of qureg, determined by a named, paramaterized (and potent...">applyParamNamedPhaseFunc()</a>.<br  />
<br  />
</p><blockquote class="doxtable">
<p>If the phase function <img class="formulaInl" alt="$f(\vec{r})$" src="form_262.png"/> diverges at one or more <img class="formulaInl" alt="$\vec{r}$" src="form_276.png"/> values, you should instead use <a class="el" href="group__operator.html#ga2fbaec3bb21cc01f7a2a4ed2aa911ebf" title="Induces a phase change upon each amplitude of qureg, determined by a named (and potentially multi-var...">applyNamedPhaseFuncOverrides()</a> and specify explicit phase changes for these coordinates. Otherwise, the corresponding amplitudes of <code>qureg</code> will become indeterminate (like <code>NaN</code>). <br  />
</p>
</blockquote>
</li>
<li>The function <img class="formulaInl" alt="$f(\vec{r})$" src="form_262.png"/> specifies the phase change to induce upon amplitude <img class="formulaInl" alt="$\alpha$" src="form_88.png"/> of computational basis state with the nominated sub-registers encoding values <img class="formulaInl" alt="$r_1, \; \dots$" src="form_270.png"/>. <p class="formulaDsp">
<img class="formulaDsp" alt="\[ \alpha \, |r_{\text{numRegs}}, \; \dots, \; r_2, \; r_1 \rangle \rightarrow \, \exp(i f(\vec{r}\,)) \; \alpha \, |r_{\text{numRegs}}, \; \dots, \; r_2, \; r_1 \rangle. \]" src="form_271.png"/>
</p>
 For example, using the sub-registers in the above example and <code>encoding</code> <b>=</b> <code>UNSIGNED</code>, the following states receive amplitude factors: <p class="formulaDsp">
<img class="formulaDsp" alt="\[ \begin{aligned} |\mathbf{0}\rangle \; |0\rangle \; |\mathbf{000}\rangle \; |0\rangle \; |\mathbf{00}\rangle &amp; \rightarrow \, e^{i f(r_3=0,r_2=0,r_1=0)} \\ |\mathbf{0}\rangle \; |0\rangle \; |\mathbf{000}\rangle \; |0\rangle \; |\mathbf{01}\rangle &amp; \rightarrow \, e^{i f(r_3=0,r_2=0,r_1=1)} \\ |\mathbf{0}\rangle \; |0\rangle \; |\mathbf{000}\rangle \; |0\rangle \; |\mathbf{10}\rangle &amp; \rightarrow \, e^{i f(r_3=0,r_2=0,r_1=2)} \\ |\mathbf{0}\rangle \; |0\rangle \; |\mathbf{000}\rangle \; |0\rangle \; |\mathbf{11}\rangle &amp; \rightarrow \, e^{i f(r_3=0,r_2=0,r_1=3)} \\ |\mathbf{0}\rangle \; |0\rangle \; |\mathbf{000}\rangle \; |1\rangle \; |\mathbf{00}\rangle &amp; \rightarrow \, e^{i f(r_3=0,r_2=0,r_1=0)} \\ &amp; \;\;\;\vdots \\ |\mathbf{0}\rangle \; |0\rangle \; |\mathbf{111}\rangle \; |0\rangle \; |\mathbf{01}\rangle &amp; \rightarrow \, e^{i f(r_3=0,r_2=7,r_1=1)} \\ &amp; \;\;\;\vdots \\ |\mathbf{1}\rangle \; |0\rangle \; |\mathbf{111}\rangle \; |0\rangle \; |\mathbf{11}\rangle &amp; \rightarrow \, e^{i f(r_3=1,r_2=7,r_1=3)} \end{aligned} \]" src="form_272.png"/>
</p>
<br  />
</li>
<li>If <code>qureg</code> is a density matrix, its elements are modified to <p class="formulaDsp">
<img class="formulaDsp" alt="\[ \alpha \, |j\rangle\langle k| \; \rightarrow \; \exp(i (f(\vec{r}_j) \, - \, f(\vec{r}_k))) \; \alpha \, |j\rangle\langle k| \]" src="form_284.png"/>
</p>
 where <img class="formulaInl" alt="$f(\vec{r}_j)$" src="form_274.png"/> and <img class="formulaInl" alt="$f(\vec{r}_k)$" src="form_275.png"/> are determined as above. This is equivalent to modification <p class="formulaDsp">
<img class="formulaDsp" alt="\[ \rho \; \rightarrow \; \hat{D} \, \rho \, \hat{D}^\dagger \]" src="form_285.png"/>
</p>
 where <img class="formulaInl" alt="$\hat{D}$" src="form_42.png"/> is the diagonal unitary <p class="formulaDsp">
<img class="formulaDsp" alt="\[ \hat{D} = \text{diag}\, \{ \; e^{i f(\vec{r_0})}, \; e^{i f(\vec{r_1})}, \; \dots \; \}. \]" src="form_286.png"/>
</p>
<br  />
</li>
<li><p class="startli">The interpreted phase function can be previewed in the QASM log, as a comment. <br  />
 For example: </p><div class="fragment"><div class="line"><a class="code" href="group__qasm.html#ga65bf1906298ca6355e2942f4923d77b6">startRecordingQASM</a>(qureg);</div>
<div class="line"><a class="code" href="group__operator.html#gac4df97d8c125c8cc65df720f67b2bf69">applyNamedPhaseFunc</a>(qureg, ..., <a class="code" href="group__type.html#ggaa7d869b117ba5024d6b84938e8cdfc65a6313e6ff48163c11c47866c4fda4bfa0">INVERSE_DISTANCE</a>, ... );</div>
<div class="line"><a class="code" href="group__qasm.html#gacf139d0a54b1f9e5c2f2feff742b8c76">printRecordedQASM</a>(qureg);</div>
</div><!-- fragment --><p class="startli">may show </p><div class="fragment"><div class="line"><span class="comment">// Here, applyNamedPhaseFunc() multiplied a complex scalar of form</span></div>
<div class="line"><span class="comment">//     exp(i 1 / sqrt((x-y)^2 + (z-t)^2))</span></div>
</div><!-- fragment --></li>
</ul>
<p><br  />
</p>
<dl class="section see"><dt>See also</dt><dd><ul>
<li><a class="el" href="group__operator.html#ga2fbaec3bb21cc01f7a2a4ed2aa911ebf" title="Induces a phase change upon each amplitude of qureg, determined by a named (and potentially multi-var...">applyNamedPhaseFuncOverrides()</a> to additionally specify phase values for specific sub-register indices.</li>
<li><a class="el" href="group__operator.html#ga225b82ff8b8eed1fff312240ec70c731" title="Induces a phase change upon each amplitude of qureg, determined by a named, paramaterized (and potent...">applyParamNamedPhaseFunc()</a> to specify named phase functions which require additional parameters.</li>
<li><a class="el" href="group__operator.html#ga467f517abd18dbc3d6fced84c6589161" title="Induces a phase change upon each amplitude of qureg, determined by the passed exponential polynomial ...">applyPhaseFunc()</a> to specify a general single-variable exponential polynomial phase function.</li>
<li><a class="el" href="group__operator.html#ga008a46d178a5a9691e2f5d363e3f518f" title="Induces a phase change upon each amplitude of qureg, determined by a multi-variable exponential polyn...">applyMultiVarPhaseFunc()</a> to specify a general multi-variable exponential polynomial phase function.</li>
<li><a class="el" href="group__operator.html#gad2e953390342cd361cfb4064d47715e6" title="Apply a diagonal operator, which is possibly non-unitary and non-Hermitian, to the entire qureg.">applyDiagonalOp()</a> to apply a non-unitary diagonal <a class="el" href="group__operator.html" title="Non-physical operators which may be non-unitary, non-norm-preserving, even non-Hermitian.">Operators</a>.</li>
</ul>
</dd></dl>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in,out]</td><td class="paramname">qureg</td><td>the state-vector or density-matrix to be modified </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">qubits</td><td>a list of all the qubit indices contained in each sub-register </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">numQubitsPerReg</td><td>a list of the lengths of each sub-list in <code>qubits</code> </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">numRegs</td><td>the number of sub-registers, which is the length of both <code>numQubitsPerReg</code> and <code>numTermsPerReg</code> </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">encoding</td><td>the <a class="el" href="group__type.html#ga9c91c41aa42ae537995e89ffc616afe1" title="Flags for specifying how the bits in sub-register computational basis states are mapped to indices in...">bitEncoding</a> under which to infer the binary value <img class="formulaInl" alt="$r_j$" src="form_269.png"/> from the bits of a sub-register </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">functionNameCode</td><td>the <a class="el" href="group__type.html#gaa7d869b117ba5024d6b84938e8cdfc65" title="Flags for specifying named phase functions.">phaseFunc</a> <img class="formulaInl" alt="$f(\vec{r})$" src="form_262.png"/> </td></tr>
  </table>
  </dd>
</dl>
<dl class="exception"><dt>Exceptions</dt><dd>
  <table class="exception">
    <tr><td class="paramname"><a class="el" href="group__debug.html#ga51a64b05d31ef9bcf6a63ce26c0092db" title="An internal function called when invalid arguments are passed to a QuEST API call,...">invalidQuESTInputError()</a></td><td><ul>
<li>if any qubit in <code>qubits</code> has an invalid index (i.e. does not satisfy 0 &lt;= qubit &lt; <code>qureg.numQubitsRepresented</code>)</li>
<li>if the elements of <code>qubits</code> are not unique (including if sub-registers overlap)</li>
<li>if <code>numRegs</code> &lt;= 0 or <code>numRegs</code> &gt; 100 (constrained by <code>MAX_NUM_REGS_APPLY_ARBITRARY_PHASE</code> in <a class="el" href="QuEST__precision_8h.html">QuEST_precision.h</a>)</li>
<li>if <code>encoding</code> is not a valid <a class="el" href="group__type.html#ga9c91c41aa42ae537995e89ffc616afe1" title="Flags for specifying how the bits in sub-register computational basis states are mapped to indices in...">bitEncoding</a></li>
<li>if the size of any sub-register is incompatible with <code>encoding</code> (e.g. contains fewer than two qubits in <code>encoding</code> <b>=</b> <code>TWOS_COMPLEMENT</code>)</li>
<li>if <code>functionNameCode</code> is not a valid <a class="el" href="group__type.html#gaa7d869b117ba5024d6b84938e8cdfc65" title="Flags for specifying named phase functions.">phaseFunc</a></li>
<li>if <code>functionNameCode</code> requires additional parameters, which must instead be passed with <a class="el" href="group__operator.html#ga225b82ff8b8eed1fff312240ec70c731" title="Induces a phase change upon each amplitude of qureg, determined by a named, paramaterized (and potent...">applyParamNamedPhaseFunc()</a> </li>
</ul>
</td></tr>
  </table>
  </dd>
</dl>
<dl class="section author"><dt>Author</dt><dd>Tyson Jones </dd></dl>

<p class="definition">Definition at line <a class="el" href="QuEST_8c_source.html#l00796">796</a> of file <a class="el" href="QuEST_8c_source.html">QuEST.c</a>.</p>
<div class="fragment"><div class="line"><a name="l00796"></a><span class="lineno">  796</span>&#160;                                                                                                                                                  {</div>
<div class="line"><a name="l00797"></a><span class="lineno">  797</span>&#160;    <a class="code" href="QuEST__validation_8c.html#a0a45c9c3015af276ff7e624ae207ba7a">validateQubitSubregs</a>(qureg, qubits, numQubitsPerReg, numRegs, __func__);</div>
<div class="line"><a name="l00798"></a><span class="lineno">  798</span>&#160;    <a class="code" href="QuEST__validation_8c.html#a9b348fc98867d01990da93a8de36936c">validateMultiRegBitEncoding</a>(numQubitsPerReg, numRegs, encoding, __func__);</div>
<div class="line"><a name="l00799"></a><span class="lineno">  799</span>&#160;    <a class="code" href="QuEST__validation_8c.html#a99e98bb5d38287fbb51f1e094d1eb68e">validatePhaseFuncName</a>(functionNameCode, numRegs, 0, __func__);</div>
<div class="line"><a name="l00800"></a><span class="lineno">  800</span>&#160; </div>
<div class="line"><a name="l00801"></a><span class="lineno">  801</span>&#160;    <span class="keywordtype">int</span> conj = 0;</div>
<div class="line"><a name="l00802"></a><span class="lineno">  802</span>&#160;    <a class="code" href="QuEST__internal_8h.html#a7d8a817207847d2646a52044a63fd469">statevec_applyParamNamedPhaseFuncOverrides</a>(qureg, qubits, numQubitsPerReg, numRegs, encoding, functionNameCode, NULL, 0, NULL, NULL, 0, conj);</div>
<div class="line"><a name="l00803"></a><span class="lineno">  803</span>&#160;    <span class="keywordflow">if</span> (qureg.<a class="code" href="structQureg.html#acf78445e9435d09f44f0cc832c6aee79">isDensityMatrix</a>) {</div>
<div class="line"><a name="l00804"></a><span class="lineno">  804</span>&#160;        conj = 1;</div>
<div class="line"><a name="l00805"></a><span class="lineno">  805</span>&#160;        <a class="code" href="QuEST__common_8c.html#aecc3c36b275c53b321de1611c2f06f78">shiftSubregIndices</a>(qubits, numQubitsPerReg, numRegs, qureg.<a class="code" href="structQureg.html#ad08dff5316b8937f4b2a1417591543dc">numQubitsRepresented</a>);</div>
<div class="line"><a name="l00806"></a><span class="lineno">  806</span>&#160;        <a class="code" href="QuEST__internal_8h.html#a7d8a817207847d2646a52044a63fd469">statevec_applyParamNamedPhaseFuncOverrides</a>(qureg, qubits, numQubitsPerReg, numRegs, encoding, functionNameCode, NULL, 0, NULL, NULL, 0, conj);</div>
<div class="line"><a name="l00807"></a><span class="lineno">  807</span>&#160;        <a class="code" href="QuEST__common_8c.html#aecc3c36b275c53b321de1611c2f06f78">shiftSubregIndices</a>(qubits, numQubitsPerReg, numRegs, - qureg.<a class="code" href="structQureg.html#ad08dff5316b8937f4b2a1417591543dc">numQubitsRepresented</a>);</div>
<div class="line"><a name="l00808"></a><span class="lineno">  808</span>&#160;    }</div>
<div class="line"><a name="l00809"></a><span class="lineno">  809</span>&#160; </div>
<div class="line"><a name="l00810"></a><span class="lineno">  810</span>&#160;    <a class="code" href="QuEST__qasm_8c.html#ab60a4a8af0530cbfa8cba1b02692d448">qasm_recordNamedPhaseFunc</a>(qureg, qubits, numQubitsPerReg, numRegs, encoding, functionNameCode, NULL, 0, NULL, NULL, 0);</div>
<div class="line"><a name="l00811"></a><span class="lineno">  811</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST_8h_source.html#l00325">Qureg::isDensityMatrix</a>, <a class="el" href="QuEST_8h_source.html#l00327">Qureg::numQubitsRepresented</a>, <a class="el" href="QuEST__qasm_8c_source.html#l00726">qasm_recordNamedPhaseFunc()</a>, <a class="el" href="QuEST__common_8c_source.html#l00161">shiftSubregIndices()</a>, <a class="el" href="QuEST__cpu_8c_source.html#l04446">statevec_applyParamNamedPhaseFuncOverrides()</a>, <a class="el" href="QuEST__validation_8c_source.html#l00976">validateMultiRegBitEncoding()</a>, <a class="el" href="QuEST__validation_8c_source.html#l00913">validatePhaseFuncName()</a>, and <a class="el" href="QuEST__validation_8c_source.html#l00757">validateQubitSubregs()</a>.</p>

<p class="reference">Referenced by <a class="el" href="test__operators_8cpp_source.html#l01061">TEST_CASE()</a>.</p>

</div>
</div>
<a id="ga2fbaec3bb21cc01f7a2a4ed2aa911ebf"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga2fbaec3bb21cc01f7a2a4ed2aa911ebf">&#9670;&nbsp;</a></span>applyNamedPhaseFuncOverrides()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void applyNamedPhaseFuncOverrides </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a>&#160;</td>
          <td class="paramname"><em>qureg</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int *&#160;</td>
          <td class="paramname"><em>qubits</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int *&#160;</td>
          <td class="paramname"><em>numQubitsPerReg</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>numRegs</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">enum <a class="el" href="group__type.html#ga9c91c41aa42ae537995e89ffc616afe1">bitEncoding</a>&#160;</td>
          <td class="paramname"><em>encoding</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">enum <a class="el" href="group__type.html#gaa7d869b117ba5024d6b84938e8cdfc65">phaseFunc</a>&#160;</td>
          <td class="paramname"><em>functionNameCode</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">long long int *&#160;</td>
          <td class="paramname"><em>overrideInds</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> *&#160;</td>
          <td class="paramname"><em>overridePhases</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>numOverrides</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Induces a phase change upon each amplitude of <code>qureg</code>, determined by a named (and potentially multi-variable) phase function, and an explicit set of 'overriding' values at specific state indices. </p>
<p>See <a class="el" href="group__operator.html#gac4df97d8c125c8cc65df720f67b2bf69" title="Induces a phase change upon each amplitude of qureg, determined by a named (and potentially multi-var...">applyNamedPhaseFunc()</a> first for a full description.</p>
<ul>
<li>As in <a class="el" href="group__operator.html#gac4df97d8c125c8cc65df720f67b2bf69" title="Induces a phase change upon each amplitude of qureg, determined by a named (and potentially multi-var...">applyNamedPhaseFunc()</a>, <code>functionNameCode</code> specifies a multi-variable phase function <img class="formulaInl" alt="$f(\vec{r})$" src="form_262.png"/>, where <img class="formulaInl" alt="$\vec{r}$" src="form_276.png"/> is determined by the sub-registers in <code>qubits</code>, and <a class="el" href="group__type.html#ga9c91c41aa42ae537995e89ffc616afe1" title="Flags for specifying how the bits in sub-register computational basis states are mapped to indices in...">bitEncoding</a> <code>encoding</code> for each basis state of <code>qureg</code>.<br  />
<br  />
</li>
<li><p class="startli">Additionally, <code>overrideInds</code> is a list of length <code>numOverrides</code> which specifies the values of <img class="formulaInl" alt="$\vec{r}$" src="form_276.png"/> for which to explicitly set the induced phase change.<br  />
 While flat, <code>overrideInds</code> should be imagined grouped into sub-lists of length <code>numRegs</code>, which specify the full <img class="formulaInl" alt="$\{r_1,\; \dots \;r_{\text{numRegs}} \} $" src="form_277.png"/> coordinate to override. <br  />
 Each sublist corresponds to a single element of <code>overridePhases</code>. <br  />
 For example, </p><div class="fragment"><div class="line"><span class="keywordtype">int</span> numRegs = 3;</div>
<div class="line"><span class="keywordtype">int</span> numOverrides = 2;</div>
<div class="line"><span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> overrideInds[] = { 0,0,0,   1,2,3  };</div>
<div class="line"><a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> overridePhases[]       = { <a class="code" href="QuEST__common_8c.html#ae71449b1cc6e6250b91f539153a7a0d3">M_PI</a>,   - <a class="code" href="QuEST__common_8c.html#ae71449b1cc6e6250b91f539153a7a0d3">M_PI</a> };</div>
</div><!-- fragment --><p class="startli">denotes that any basis state of <code>qureg</code> with sub-register values <img class="formulaInl" alt="$\{r_3,r_2,r_1\} = \{0, 0, 0\}$" src="form_278.png"/> (or <img class="formulaInl" alt="$\{r_3,r_2,r_1\} = \{1,2,3\}$" src="form_279.png"/>) should receive phase change <img class="formulaInl" alt="$\pi$" src="form_114.png"/> (or <img class="formulaInl" alt="$-\pi$" src="form_280.png"/>) in lieu of <img class="formulaInl" alt="$\exp(i f(r_3=0,r_2=0,r_1=0))$" src="form_281.png"/>.<br  />
<br  />
</p>
</li>
<li><p class="startli">The interpreted overrides can be previewed in the QASM log, as a comment. <br  />
 For example: </p><div class="fragment"><div class="line"><a class="code" href="group__qasm.html#ga65bf1906298ca6355e2942f4923d77b6">startRecordingQASM</a>(qureg);</div>
<div class="line"><a class="code" href="group__operator.html#ga2fbaec3bb21cc01f7a2a4ed2aa911ebf">applyNamedPhaseFuncOverrides</a>(qureg, ...);</div>
<div class="line"><a class="code" href="group__qasm.html#gacf139d0a54b1f9e5c2f2feff742b8c76">printRecordedQASM</a>(qureg);</div>
</div><!-- fragment --><p class="startli">may show </p><div class="fragment"><div class="line"><span class="comment">// Here, applyNamedPhaseFunc() multiplied ...</span></div>
<div class="line"><span class="comment">//   though with overrides</span></div>
<div class="line"><span class="comment">//     |x=0, y=0, z=0&gt; -&gt; exp(i 3.14159)</span></div>
<div class="line"><span class="comment">//     |x=1, y=2, z=3&gt; -&gt; exp(i (-3.14159))</span></div>
</div><!-- fragment --></li>
</ul>
<p><br  />
</p>
<dl class="section see"><dt>See also</dt><dd><ul>
<li><a class="el" href="group__operator.html#gaabd7efa3beebc9f3a525321d41a28989" title="Induces a phase change upon each amplitude of qureg, determined by a named, parameterised (and potent...">applyParamNamedPhaseFuncOverrides()</a> to specify <em>parameterised</em> named phase functions, with phase overrides.</li>
<li><a class="el" href="group__operator.html#ga467f517abd18dbc3d6fced84c6589161" title="Induces a phase change upon each amplitude of qureg, determined by the passed exponential polynomial ...">applyPhaseFunc()</a> to specify a general single-variable exponential polynomial phase function.</li>
<li><a class="el" href="group__operator.html#ga008a46d178a5a9691e2f5d363e3f518f" title="Induces a phase change upon each amplitude of qureg, determined by a multi-variable exponential polyn...">applyMultiVarPhaseFunc()</a> to specify a general multi-variable exponential polynomial phase function.</li>
<li><a class="el" href="group__operator.html#gad2e953390342cd361cfb4064d47715e6" title="Apply a diagonal operator, which is possibly non-unitary and non-Hermitian, to the entire qureg.">applyDiagonalOp()</a> to apply a non-unitary diagonal <a class="el" href="group__operator.html" title="Non-physical operators which may be non-unitary, non-norm-preserving, even non-Hermitian.">Operators</a>.</li>
</ul>
</dd></dl>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in,out]</td><td class="paramname">qureg</td><td>the state-vector pr density-matrix to be modified </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">qubits</td><td>a list of all the qubit indices contained in each sub-register </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">numQubitsPerReg</td><td>a list of the lengths of each sub-list in <code>qubits</code> </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">numRegs</td><td>the number of sub-registers, which is the length of both <code>numQubitsPerReg</code> and <code>numTermsPerReg</code> </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">encoding</td><td>the <a class="el" href="group__type.html#ga9c91c41aa42ae537995e89ffc616afe1" title="Flags for specifying how the bits in sub-register computational basis states are mapped to indices in...">bitEncoding</a> under which to infer the binary value <img class="formulaInl" alt="$r_j$" src="form_269.png"/> from the bits of a sub-register </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">functionNameCode</td><td>the <a class="el" href="group__type.html#gaa7d869b117ba5024d6b84938e8cdfc65" title="Flags for specifying named phase functions.">phaseFunc</a> <img class="formulaInl" alt="$f(\vec{r})$" src="form_262.png"/> </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">overrideInds</td><td>a flattened list of sub-register coordinates (values of <img class="formulaInl" alt="$\vec{r}$" src="form_276.png"/>) of which to explicit set the phase change </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">overridePhases</td><td>a list of replacement phase changes, for the corresponding <img class="formulaInl" alt="$\vec{r}$" src="form_276.png"/> values in <code>overrideInds</code> </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">numOverrides</td><td>the lengths of list <code>overridePhases</code> (but not necessarily of <code>overrideInds</code>) </td></tr>
  </table>
  </dd>
</dl>
<dl class="exception"><dt>Exceptions</dt><dd>
  <table class="exception">
    <tr><td class="paramname"><a class="el" href="group__debug.html#ga51a64b05d31ef9bcf6a63ce26c0092db" title="An internal function called when invalid arguments are passed to a QuEST API call,...">invalidQuESTInputError()</a></td><td><ul>
<li>if any qubit in <code>qubits</code> has an invalid index (i.e. does not satisfy 0 &lt;= qubit &lt; <code>qureg.numQubitsRepresented</code>)</li>
<li>if the elements of <code>qubits</code> are not unique (including if sub-registers overlap)</li>
<li>if <code>numRegs</code> &lt;= 0 or <code>numRegs</code> &gt; 100 (constrained by <code>MAX_NUM_REGS_APPLY_ARBITRARY_PHASE</code> in <a class="el" href="QuEST__precision_8h.html">QuEST_precision.h</a>)</li>
<li>if <code>encoding</code> is not a valid <a class="el" href="group__type.html#ga9c91c41aa42ae537995e89ffc616afe1" title="Flags for specifying how the bits in sub-register computational basis states are mapped to indices in...">bitEncoding</a></li>
<li>if the size of any sub-register is incompatible with <code>encoding</code> (e.g. contains fewer than two qubits in <code>encoding</code> <b>=</b> <code>TWOS_COMPLEMENT</code>)</li>
<li>if <code>functionNameCode</code> is not a valid <a class="el" href="group__type.html#gaa7d869b117ba5024d6b84938e8cdfc65" title="Flags for specifying named phase functions.">phaseFunc</a></li>
<li>if <code>functionNameCode</code> requires additional parameters, which must instead be passed with <a class="el" href="group__operator.html#ga225b82ff8b8eed1fff312240ec70c731" title="Induces a phase change upon each amplitude of qureg, determined by a named, paramaterized (and potent...">applyParamNamedPhaseFunc()</a></li>
<li>if any value in <code>overrideInds</code> is not producible by its corresponding sub-register under the given <code>encoding</code> (e.g. 2 unsigned qubits cannot represent index 9)</li>
<li>if <code>numOverrides</code> &lt; 0 </li>
</ul>
</td></tr>
  </table>
  </dd>
</dl>
<dl class="section author"><dt>Author</dt><dd>Tyson Jones </dd></dl>

<p class="definition">Definition at line <a class="el" href="QuEST_8c_source.html#l00813">813</a> of file <a class="el" href="QuEST_8c_source.html">QuEST.c</a>.</p>
<div class="fragment"><div class="line"><a name="l00813"></a><span class="lineno">  813</span>&#160;                                                                                                                                                                                                                                 {</div>
<div class="line"><a name="l00814"></a><span class="lineno">  814</span>&#160;    <a class="code" href="QuEST__validation_8c.html#a0a45c9c3015af276ff7e624ae207ba7a">validateQubitSubregs</a>(qureg, qubits, numQubitsPerReg, numRegs, __func__);</div>
<div class="line"><a name="l00815"></a><span class="lineno">  815</span>&#160;    <a class="code" href="QuEST__validation_8c.html#a9b348fc98867d01990da93a8de36936c">validateMultiRegBitEncoding</a>(numQubitsPerReg, numRegs, encoding, __func__);</div>
<div class="line"><a name="l00816"></a><span class="lineno">  816</span>&#160;    <a class="code" href="QuEST__validation_8c.html#a99e98bb5d38287fbb51f1e094d1eb68e">validatePhaseFuncName</a>(functionNameCode, numRegs, 0, __func__);</div>
<div class="line"><a name="l00817"></a><span class="lineno">  817</span>&#160;    <a class="code" href="QuEST__validation_8c.html#a0edb4d9df94a40b8ea89c1c14997ee76">validateMultiVarPhaseFuncOverrides</a>(numQubitsPerReg, numRegs, encoding, overrideInds, numOverrides, __func__);</div>
<div class="line"><a name="l00818"></a><span class="lineno">  818</span>&#160; </div>
<div class="line"><a name="l00819"></a><span class="lineno">  819</span>&#160;    <span class="keywordtype">int</span> conj = 0;</div>
<div class="line"><a name="l00820"></a><span class="lineno">  820</span>&#160;    <a class="code" href="QuEST__internal_8h.html#a7d8a817207847d2646a52044a63fd469">statevec_applyParamNamedPhaseFuncOverrides</a>(qureg, qubits, numQubitsPerReg, numRegs, encoding, functionNameCode, NULL, 0, overrideInds, overridePhases, numOverrides, conj);</div>
<div class="line"><a name="l00821"></a><span class="lineno">  821</span>&#160;    <span class="keywordflow">if</span> (qureg.<a class="code" href="structQureg.html#acf78445e9435d09f44f0cc832c6aee79">isDensityMatrix</a>) {</div>
<div class="line"><a name="l00822"></a><span class="lineno">  822</span>&#160;        conj = 1;</div>
<div class="line"><a name="l00823"></a><span class="lineno">  823</span>&#160;        <a class="code" href="QuEST__common_8c.html#aecc3c36b275c53b321de1611c2f06f78">shiftSubregIndices</a>(qubits, numQubitsPerReg, numRegs, qureg.<a class="code" href="structQureg.html#ad08dff5316b8937f4b2a1417591543dc">numQubitsRepresented</a>);</div>
<div class="line"><a name="l00824"></a><span class="lineno">  824</span>&#160;        <a class="code" href="QuEST__internal_8h.html#a7d8a817207847d2646a52044a63fd469">statevec_applyParamNamedPhaseFuncOverrides</a>(qureg, qubits, numQubitsPerReg, numRegs, encoding, functionNameCode, NULL, 0, overrideInds, overridePhases, numOverrides, conj);</div>
<div class="line"><a name="l00825"></a><span class="lineno">  825</span>&#160;        <a class="code" href="QuEST__common_8c.html#aecc3c36b275c53b321de1611c2f06f78">shiftSubregIndices</a>(qubits, numQubitsPerReg, numRegs, - qureg.<a class="code" href="structQureg.html#ad08dff5316b8937f4b2a1417591543dc">numQubitsRepresented</a>);</div>
<div class="line"><a name="l00826"></a><span class="lineno">  826</span>&#160;    }</div>
<div class="line"><a name="l00827"></a><span class="lineno">  827</span>&#160; </div>
<div class="line"><a name="l00828"></a><span class="lineno">  828</span>&#160;    <a class="code" href="QuEST__qasm_8c.html#ab60a4a8af0530cbfa8cba1b02692d448">qasm_recordNamedPhaseFunc</a>(qureg, qubits, numQubitsPerReg, numRegs, encoding, functionNameCode, NULL, 0, overrideInds, overridePhases, numOverrides);</div>
<div class="line"><a name="l00829"></a><span class="lineno">  829</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST_8h_source.html#l00325">Qureg::isDensityMatrix</a>, <a class="el" href="QuEST_8h_source.html#l00327">Qureg::numQubitsRepresented</a>, <a class="el" href="QuEST__qasm_8c_source.html#l00726">qasm_recordNamedPhaseFunc()</a>, <a class="el" href="QuEST__common_8c_source.html#l00161">shiftSubregIndices()</a>, <a class="el" href="QuEST__cpu_8c_source.html#l04446">statevec_applyParamNamedPhaseFuncOverrides()</a>, <a class="el" href="QuEST__validation_8c_source.html#l00976">validateMultiRegBitEncoding()</a>, <a class="el" href="QuEST__validation_8c_source.html#l00886">validateMultiVarPhaseFuncOverrides()</a>, <a class="el" href="QuEST__validation_8c_source.html#l00913">validatePhaseFuncName()</a>, and <a class="el" href="QuEST__validation_8c_source.html#l00757">validateQubitSubregs()</a>.</p>

<p class="reference">Referenced by <a class="el" href="test__operators_8cpp_source.html#l01273">TEST_CASE()</a>.</p>

</div>
</div>
<a id="ga225b82ff8b8eed1fff312240ec70c731"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga225b82ff8b8eed1fff312240ec70c731">&#9670;&nbsp;</a></span>applyParamNamedPhaseFunc()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void applyParamNamedPhaseFunc </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a>&#160;</td>
          <td class="paramname"><em>qureg</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int *&#160;</td>
          <td class="paramname"><em>qubits</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int *&#160;</td>
          <td class="paramname"><em>numQubitsPerReg</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>numRegs</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">enum <a class="el" href="group__type.html#ga9c91c41aa42ae537995e89ffc616afe1">bitEncoding</a>&#160;</td>
          <td class="paramname"><em>encoding</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">enum <a class="el" href="group__type.html#gaa7d869b117ba5024d6b84938e8cdfc65">phaseFunc</a>&#160;</td>
          <td class="paramname"><em>functionNameCode</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> *&#160;</td>
          <td class="paramname"><em>params</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>numParams</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Induces a phase change upon each amplitude of <code>qureg</code>, determined by a named, paramaterized (and potentially multi-variable) phase function. </p>
<p>See <a class="el" href="group__operator.html#gac4df97d8c125c8cc65df720f67b2bf69" title="Induces a phase change upon each amplitude of qureg, determined by a named (and potentially multi-var...">applyNamedPhaseFunc()</a> for full documentation. <br  />
This function merely accepts additional <a class="el" href="group__type.html#gaa7d869b117ba5024d6b84938e8cdfc65" title="Flags for specifying named phase functions.">phaseFunc</a> names which accept one (or more) parameters.</p>
<ul>
<li><p class="startli">Argument <code>functionNameCode</code>, which determines the phase function <img class="formulaInl" alt="$f(\vec{r}, \vec{\theta})$" src="form_287.png"/>, can include parameterised <a class="el" href="group__type.html#gaa7d869b117ba5024d6b84938e8cdfc65" title="Flags for specifying named phase functions.">phaseFunc</a> names like <code>SCALED_NORM</code>, which require additional parameters <img class="formulaInl" alt="$\vec{\theta}$" src="form_288.png"/> passed via list <code>params</code>.<br  />
 For example, </p><div class="fragment"><div class="line"><span class="keyword">enum</span> <a class="code" href="group__type.html#gaa7d869b117ba5024d6b84938e8cdfc65">phaseFunc</a> functionNameCode = <a class="code" href="group__type.html#ggaa7d869b117ba5024d6b84938e8cdfc65a31a29a30f92fe34c35098f941adbbc93">SCALED_PRODUCT</a>;</div>
<div class="line"><a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> params[] = {0.5};</div>
<div class="line"><span class="keywordtype">int</span> numParams = 1;</div>
<div class="line"><a class="code" href="group__operator.html#ga225b82ff8b8eed1fff312240ec70c731">applyParamNamedPhaseFunc</a>(..., functionNameCode, params, numParams);</div>
</div><!-- fragment --><p class="startli">invokes phase function </p><p class="formulaDsp">
<img class="formulaDsp" alt="\[ f(\vec{r}, \theta)|_{\theta=0.5} \; = \; 0.5 \prod_j^{\text{numRegs}} \; r_j\,. \]" src="form_289.png"/>
</p>
<p> See <a class="el" href="group__type.html#gaa7d869b117ba5024d6b84938e8cdfc65" title="Flags for specifying named phase functions.">phaseFunc</a> for all named phased functions.</p>
</li>
<li><p class="startli">Functions with divergences, like <code>INVERSE_NORM</code> and <code>SCALED_INVERSE_DISTANCE</code>, must accompany an extra parameter to specify an overriding phase at the divergence. For example, </p><div class="fragment"><div class="line"><span class="keyword">enum</span> <a class="code" href="group__type.html#gaa7d869b117ba5024d6b84938e8cdfc65">phaseFunc</a> functionNameCode = <a class="code" href="group__type.html#ggaa7d869b117ba5024d6b84938e8cdfc65ae8c96906c1ec109d295c491e572d01e2">SCALED_INVERSE_NORM</a>;</div>
<div class="line"><a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> params[] = {0.5, <a class="code" href="QuEST__common_8c.html#ae71449b1cc6e6250b91f539153a7a0d3">M_PI</a>};</div>
<div class="line"><span class="keywordtype">int</span> numParams = 2;</div>
<div class="line"><a class="code" href="group__operator.html#ga225b82ff8b8eed1fff312240ec70c731">applyParamNamedPhaseFunc</a>(..., functionNameCode, params, numParams);</div>
</div><!-- fragment --><p class="startli">invokes phase function </p><p class="formulaDsp">
<img class="formulaDsp" alt="\[ f(\vec{r}, \theta)|_{\theta=0.5} \; = \; \begin{cases} \pi &amp; \;\;\; \vec{r}=\vec{0} \\ \displaystyle 0.5 \left[ \sum_j^{\text{numRegs}} {r_j}^2 \right]^{-1/2} &amp; \;\;\;\text{otherwise} \end{cases}. \]" src="form_290.png"/>
</p>
<p> Notice the order of the parameters matches the order of the words in the <code>phaseFunc</code>. </p><blockquote class="doxtable">
<p>Functions <code>SCALED_INVERSE_SHIFTED_NORM</code> and <code>SCALED_INVERSE_SHIFTED_DISTANCE</code>, which can have denominators arbitrarily close to zero, will invoke the divergence parameter whenever the denominator is smaller than (or equal to) machine precision <code>REAL_EPS</code>. </p>
</blockquote>
</li>
<li><p class="startli">Functions allowing the shifting of sub-register values, which are <code>SCALED_INVERSE_SHIFTED_NORM</code> and <code>SCALED_INVERSE_SHIFTED_DISTANCE</code>, need these shift values to be passed in the <code>params</code> argument <em>after</em> the scaling and divergence override parameters listed above. The function <code>SCALED_INVERSE_SHIFTED_NORM</code> needs as many extra parameters, as there are sub-registers; <code>SCALED_INVERSE_SHIFTED_DISTANCE</code> needs one extra parameter for each pair of sub-registers. For example, </p><div class="fragment"><div class="line"><span class="keyword">enum</span> <a class="code" href="group__type.html#gaa7d869b117ba5024d6b84938e8cdfc65">phaseFunc</a> functionNameCode = <a class="code" href="group__type.html#ggaa7d869b117ba5024d6b84938e8cdfc65aa318172feec5b530e9a7849f2f7b44e7">SCALED_INVERSE_SHIFTED_NORM</a>;</div>
<div class="line"><span class="keywordtype">int</span> qubits[] = {0,1,2,3, 4,5,6,7};</div>
<div class="line"><span class="keywordtype">int</span> qubitsPerReg[] = {4, 4};</div>
<div class="line"><a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> params[] = {0.5, <a class="code" href="QuEST__common_8c.html#ae71449b1cc6e6250b91f539153a7a0d3">M_PI</a>, 0.8, -0.3};</div>
<div class="line"><span class="keywordtype">int</span> numParams = 4;</div>
<div class="line"><a class="code" href="group__operator.html#ga225b82ff8b8eed1fff312240ec70c731">applyParamNamedPhaseFunc</a>(..., qubits, qubitsPerReg, 2, ..., functionNameCode, params, numParams);</div>
</div><!-- fragment --><p class="startli">invokes phase function </p><p class="formulaDsp">
<img class="formulaDsp" alt="\[ f(\vec{r}) \; = \; \begin{cases} \pi &amp; \;\;\; \vec{r}=\vec{0} \\ \displaystyle 0.5 \left[(r_1-0.8)^2 + (r_2+0.3)^2\right]^{-1/2} &amp; \;\;\;\text{otherwise} \end{cases}. \]" src="form_291.png"/>
</p>
<p> and </p><div class="fragment"><div class="line"><span class="keyword">enum</span> <a class="code" href="group__type.html#gaa7d869b117ba5024d6b84938e8cdfc65">phaseFunc</a> functionNameCode = <a class="code" href="group__type.html#ggaa7d869b117ba5024d6b84938e8cdfc65a39111120b79016d6b3e773b711fa63f7">SCALED_INVERSE_SHIFTED_DISTANCE</a>;</div>
<div class="line"><span class="keywordtype">int</span> qubits[] = {0,1, 2,3, 4,5, 6,7};</div>
<div class="line"><span class="keywordtype">int</span> qubitsPerReg[] = {2, 2, 2, 2};</div>
<div class="line"><a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> params[] = {0.5, <a class="code" href="QuEST__common_8c.html#ae71449b1cc6e6250b91f539153a7a0d3">M_PI</a>, 0.8, -0.3};</div>
<div class="line"><span class="keywordtype">int</span> numParams = 4;</div>
<div class="line"><a class="code" href="group__operator.html#ga225b82ff8b8eed1fff312240ec70c731">applyParamNamedPhaseFunc</a>(..., qubits, qubitsPerReg, 4, ..., functionNameCode, params, numParams);</div>
</div><!-- fragment --><p class="startli">invokes phase function </p><p class="formulaDsp">
<img class="formulaDsp" alt="\[ f(\vec{r}) \; = \; \begin{cases} \pi &amp; \;\;\; \vec{r}=\vec{0} \\ \displaystyle 0.5 \left[(r_1-r_2-0.8)^2 + (r_3-r_4+0.3)^2\right]^{-1/2} &amp; \;\;\;\text{otherwise} \end{cases}. \]" src="form_292.png"/>
</p>
</li>
</ul>
<blockquote class="doxtable">
<p>You can further override <img class="formulaInl" alt="$f(\vec{r}, \vec{\theta})$" src="form_287.png"/> at one or more <img class="formulaInl" alt="$\vec{r}$" src="form_276.png"/> values via <a class="el" href="group__operator.html#gaabd7efa3beebc9f3a525321d41a28989" title="Induces a phase change upon each amplitude of qureg, determined by a named, parameterised (and potent...">applyParamNamedPhaseFuncOverrides()</a>. </p>
</blockquote>
<ul>
<li><p class="startli">The interpreted parameterised phase function can be previewed in the QASM log, as a comment. <br  />
 For example: </p><div class="fragment"><div class="line"><a class="code" href="group__qasm.html#ga65bf1906298ca6355e2942f4923d77b6">startRecordingQASM</a>(qureg);</div>
<div class="line"><a class="code" href="group__operator.html#ga225b82ff8b8eed1fff312240ec70c731">applyParamNamedPhaseFunc</a>(...);</div>
<div class="line"><a class="code" href="group__qasm.html#gacf139d0a54b1f9e5c2f2feff742b8c76">printRecordedQASM</a>(qureg);</div>
</div><!-- fragment --><p class="startli">may show </p><div class="fragment"><div class="line"><span class="comment">// Here, applyNamedPhaseFunc() multiplied a complex scalar of form</span></div>
<div class="line"><span class="comment">//     exp(i (-0.5) / (x y z))</span></div>
</div><!-- fragment --></li>
</ul>
<p><br  />
</p>
<dl class="section see"><dt>See also</dt><dd><ul>
<li><a class="el" href="group__operator.html#gaabd7efa3beebc9f3a525321d41a28989" title="Induces a phase change upon each amplitude of qureg, determined by a named, parameterised (and potent...">applyParamNamedPhaseFuncOverrides()</a> to additionally specify phase values for specific sub-register indices.</li>
<li><a class="el" href="group__operator.html#ga467f517abd18dbc3d6fced84c6589161" title="Induces a phase change upon each amplitude of qureg, determined by the passed exponential polynomial ...">applyPhaseFunc()</a> to specify a general single-variable exponential polynomial phase function.</li>
<li><a class="el" href="group__operator.html#ga008a46d178a5a9691e2f5d363e3f518f" title="Induces a phase change upon each amplitude of qureg, determined by a multi-variable exponential polyn...">applyMultiVarPhaseFunc()</a> to specify a general multi-variable exponential polynomial phase function.</li>
<li><a class="el" href="group__operator.html#gad2e953390342cd361cfb4064d47715e6" title="Apply a diagonal operator, which is possibly non-unitary and non-Hermitian, to the entire qureg.">applyDiagonalOp()</a> to apply a non-unitary diagonal <a class="el" href="group__operator.html" title="Non-physical operators which may be non-unitary, non-norm-preserving, even non-Hermitian.">Operators</a>.</li>
</ul>
</dd></dl>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in,out]</td><td class="paramname">qureg</td><td>the state-vector or density-matrix to be modified </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">qubits</td><td>a list of all the qubit indices contained in each sub-register </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">numQubitsPerReg</td><td>a list of the lengths of each sub-list in <code>qubits</code> </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">numRegs</td><td>the number of sub-registers, which is the length of both <code>numQubitsPerReg</code> and <code>numTermsPerReg</code> </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">encoding</td><td>the <a class="el" href="group__type.html#ga9c91c41aa42ae537995e89ffc616afe1" title="Flags for specifying how the bits in sub-register computational basis states are mapped to indices in...">bitEncoding</a> under which to infer the binary value <img class="formulaInl" alt="$r_j$" src="form_269.png"/> from the bits of a sub-register </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">functionNameCode</td><td>the <a class="el" href="group__type.html#gaa7d869b117ba5024d6b84938e8cdfc65" title="Flags for specifying named phase functions.">phaseFunc</a> <img class="formulaInl" alt="$f(\vec{r}, \vec{\theta})$" src="form_287.png"/> </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">params</td><td>a list of any additional parameters needed by the <a class="el" href="group__type.html#gaa7d869b117ba5024d6b84938e8cdfc65" title="Flags for specifying named phase functions.">phaseFunc</a> <code>functionNameCode</code> </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">numParams</td><td>the length of list <code>params</code> </td></tr>
  </table>
  </dd>
</dl>
<dl class="exception"><dt>Exceptions</dt><dd>
  <table class="exception">
    <tr><td class="paramname"><a class="el" href="group__debug.html#ga51a64b05d31ef9bcf6a63ce26c0092db" title="An internal function called when invalid arguments are passed to a QuEST API call,...">invalidQuESTInputError()</a></td><td><ul>
<li>if any qubit in <code>qubits</code> has an invalid index (i.e. does not satisfy 0 &lt;= qubit &lt; <code>qureg.numQubitsRepresented</code>)</li>
<li>if the elements of <code>qubits</code> are not unique (including if sub-registers overlap)</li>
<li>if <code>numRegs</code> &lt;= 0 or <code>numRegs</code> &gt; 100 (constrained by <code>MAX_NUM_REGS_APPLY_ARBITRARY_PHASE</code> in <a class="el" href="QuEST__precision_8h.html">QuEST_precision.h</a>)</li>
<li>if <code>encoding</code> is not a valid <a class="el" href="group__type.html#ga9c91c41aa42ae537995e89ffc616afe1" title="Flags for specifying how the bits in sub-register computational basis states are mapped to indices in...">bitEncoding</a></li>
<li>if the size of any sub-register is incompatible with <code>encoding</code> (e.g. contains fewer than two qubits in <code>encoding</code> <b>=</b> <code>TWOS_COMPLEMENT</code>)</li>
<li>if <code>functionNameCode</code> is not a valid <a class="el" href="group__type.html#gaa7d869b117ba5024d6b84938e8cdfc65" title="Flags for specifying named phase functions.">phaseFunc</a></li>
<li>if <code>numParams</code> is incompatible with <code>functionNameCode</code> (for example, no parameters were passed to <code>SCALED_PRODUCT</code>) </li>
</ul>
</td></tr>
  </table>
  </dd>
</dl>
<dl class="section author"><dt>Author</dt><dd>Tyson Jones </dd>
<dd>
Richard Meister (shifted functions) </dd></dl>

<p class="definition">Definition at line <a class="el" href="QuEST_8c_source.html#l00831">831</a> of file <a class="el" href="QuEST_8c_source.html">QuEST.c</a>.</p>
<div class="fragment"><div class="line"><a name="l00831"></a><span class="lineno">  831</span>&#160;                                                                                                                                                                                     {</div>
<div class="line"><a name="l00832"></a><span class="lineno">  832</span>&#160;    <a class="code" href="QuEST__validation_8c.html#a0a45c9c3015af276ff7e624ae207ba7a">validateQubitSubregs</a>(qureg, qubits, numQubitsPerReg, numRegs, __func__);</div>
<div class="line"><a name="l00833"></a><span class="lineno">  833</span>&#160;    <a class="code" href="QuEST__validation_8c.html#a9b348fc98867d01990da93a8de36936c">validateMultiRegBitEncoding</a>(numQubitsPerReg, numRegs, encoding, __func__);</div>
<div class="line"><a name="l00834"></a><span class="lineno">  834</span>&#160;    <a class="code" href="QuEST__validation_8c.html#a99e98bb5d38287fbb51f1e094d1eb68e">validatePhaseFuncName</a>(functionNameCode, numRegs, numParams, __func__);</div>
<div class="line"><a name="l00835"></a><span class="lineno">  835</span>&#160; </div>
<div class="line"><a name="l00836"></a><span class="lineno">  836</span>&#160;    <span class="keywordtype">int</span> conj = 0;</div>
<div class="line"><a name="l00837"></a><span class="lineno">  837</span>&#160;    <a class="code" href="QuEST__internal_8h.html#a7d8a817207847d2646a52044a63fd469">statevec_applyParamNamedPhaseFuncOverrides</a>(qureg, qubits, numQubitsPerReg, numRegs, encoding, functionNameCode, params, numParams, NULL, NULL, 0, conj);</div>
<div class="line"><a name="l00838"></a><span class="lineno">  838</span>&#160;    <span class="keywordflow">if</span> (qureg.<a class="code" href="structQureg.html#acf78445e9435d09f44f0cc832c6aee79">isDensityMatrix</a>) {</div>
<div class="line"><a name="l00839"></a><span class="lineno">  839</span>&#160;        conj = 1;</div>
<div class="line"><a name="l00840"></a><span class="lineno">  840</span>&#160;        <a class="code" href="QuEST__common_8c.html#aecc3c36b275c53b321de1611c2f06f78">shiftSubregIndices</a>(qubits, numQubitsPerReg, numRegs, qureg.<a class="code" href="structQureg.html#ad08dff5316b8937f4b2a1417591543dc">numQubitsRepresented</a>);</div>
<div class="line"><a name="l00841"></a><span class="lineno">  841</span>&#160;        <a class="code" href="QuEST__internal_8h.html#a7d8a817207847d2646a52044a63fd469">statevec_applyParamNamedPhaseFuncOverrides</a>(qureg, qubits, numQubitsPerReg, numRegs, encoding, functionNameCode, params, numParams, NULL, NULL, 0, conj);</div>
<div class="line"><a name="l00842"></a><span class="lineno">  842</span>&#160;        <a class="code" href="QuEST__common_8c.html#aecc3c36b275c53b321de1611c2f06f78">shiftSubregIndices</a>(qubits, numQubitsPerReg, numRegs, - qureg.<a class="code" href="structQureg.html#ad08dff5316b8937f4b2a1417591543dc">numQubitsRepresented</a>);</div>
<div class="line"><a name="l00843"></a><span class="lineno">  843</span>&#160;    }</div>
<div class="line"><a name="l00844"></a><span class="lineno">  844</span>&#160; </div>
<div class="line"><a name="l00845"></a><span class="lineno">  845</span>&#160;    <a class="code" href="QuEST__qasm_8c.html#ab60a4a8af0530cbfa8cba1b02692d448">qasm_recordNamedPhaseFunc</a>(qureg, qubits, numQubitsPerReg, numRegs, encoding, functionNameCode, params, numParams, NULL, NULL, 0);</div>
<div class="line"><a name="l00846"></a><span class="lineno">  846</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST_8h_source.html#l00325">Qureg::isDensityMatrix</a>, <a class="el" href="QuEST_8h_source.html#l00327">Qureg::numQubitsRepresented</a>, <a class="el" href="QuEST__qasm_8c_source.html#l00726">qasm_recordNamedPhaseFunc()</a>, <a class="el" href="QuEST__common_8c_source.html#l00161">shiftSubregIndices()</a>, <a class="el" href="QuEST__cpu_8c_source.html#l04446">statevec_applyParamNamedPhaseFuncOverrides()</a>, <a class="el" href="QuEST__validation_8c_source.html#l00976">validateMultiRegBitEncoding()</a>, <a class="el" href="QuEST__validation_8c_source.html#l00913">validatePhaseFuncName()</a>, and <a class="el" href="QuEST__validation_8c_source.html#l00757">validateQubitSubregs()</a>.</p>

<p class="reference">Referenced by <a class="el" href="test__operators_8cpp_source.html#l01552">TEST_CASE()</a>.</p>

</div>
</div>
<a id="gaabd7efa3beebc9f3a525321d41a28989"></a>
<h2 class="memtitle"><span class="permalink"><a href="#gaabd7efa3beebc9f3a525321d41a28989">&#9670;&nbsp;</a></span>applyParamNamedPhaseFuncOverrides()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void applyParamNamedPhaseFuncOverrides </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a>&#160;</td>
          <td class="paramname"><em>qureg</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int *&#160;</td>
          <td class="paramname"><em>qubits</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int *&#160;</td>
          <td class="paramname"><em>numQubitsPerReg</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>numRegs</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">enum <a class="el" href="group__type.html#ga9c91c41aa42ae537995e89ffc616afe1">bitEncoding</a>&#160;</td>
          <td class="paramname"><em>encoding</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">enum <a class="el" href="group__type.html#gaa7d869b117ba5024d6b84938e8cdfc65">phaseFunc</a>&#160;</td>
          <td class="paramname"><em>functionNameCode</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> *&#160;</td>
          <td class="paramname"><em>params</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>numParams</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">long long int *&#160;</td>
          <td class="paramname"><em>overrideInds</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> *&#160;</td>
          <td class="paramname"><em>overridePhases</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>numOverrides</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Induces a phase change upon each amplitude of <code>qureg</code>, determined by a named, parameterised (and potentially multi-variable) phase function, and an explicit set of 'overriding' values at specific state indices. </p>
<p>See <a class="el" href="group__operator.html#ga225b82ff8b8eed1fff312240ec70c731" title="Induces a phase change upon each amplitude of qureg, determined by a named, paramaterized (and potent...">applyParamNamedPhaseFunc()</a> and <a class="el" href="group__operator.html#gac4df97d8c125c8cc65df720f67b2bf69" title="Induces a phase change upon each amplitude of qureg, determined by a named (and potentially multi-var...">applyNamedPhaseFunc()</a> first for a full description.</p>
<ul>
<li>As in <a class="el" href="group__operator.html#ga225b82ff8b8eed1fff312240ec70c731" title="Induces a phase change upon each amplitude of qureg, determined by a named, paramaterized (and potent...">applyParamNamedPhaseFunc()</a>, <code>functionNameCode</code> specifies a parameterised multi-variable phase function <img class="formulaInl" alt="$f(\vec{r}, \vec{\theta})$" src="form_287.png"/>, where <img class="formulaInl" alt="$\vec{\theta}$" src="form_288.png"/> is passed in list <code>params</code>, and <img class="formulaInl" alt="$\vec{r}$" src="form_276.png"/> is determined both by the sub-registers in <code>qubits</code>, and <a class="el" href="group__type.html#ga9c91c41aa42ae537995e89ffc616afe1" title="Flags for specifying how the bits in sub-register computational basis states are mapped to indices in...">bitEncoding</a> <code>encoding</code> for each basis state of <code>qureg</code>.<br  />
<br  />
</li>
<li><p class="startli">Additionally, <code>overrideInds</code> is a list of length <code>numOverrides</code> which specifies the values of <img class="formulaInl" alt="$\vec{r}$" src="form_276.png"/> for which to explicitly set the induced phase change.<br  />
 While flat, <code>overrideInds</code> should be imagined grouped into sub-lists of length <code>numRegs</code>, which specify the full <img class="formulaInl" alt="$\{r_1,\; \dots \;r_{\text{numRegs}} \} $" src="form_277.png"/> coordinate to override. <br  />
 Each sublist corresponds to a single element of <code>overridePhases</code>. <br  />
 For example, </p><div class="fragment"><div class="line"><span class="keywordtype">int</span> numRegs = 3;</div>
<div class="line"><span class="keywordtype">int</span> numOverrides = 2;</div>
<div class="line"><span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> overrideInds[] = { 0,0,0,   1,2,3  };</div>
<div class="line"><a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> overridePhases[]       = { <a class="code" href="QuEST__common_8c.html#ae71449b1cc6e6250b91f539153a7a0d3">M_PI</a>,   - <a class="code" href="QuEST__common_8c.html#ae71449b1cc6e6250b91f539153a7a0d3">M_PI</a> };</div>
</div><!-- fragment --><p class="startli">denotes that any basis state of <code>qureg</code> with sub-register values <img class="formulaInl" alt="$\{r_3,r_2,r_1\} = \{0, 0, 0\}$" src="form_278.png"/> (or <img class="formulaInl" alt="$\{r_3,r_2,r_1\} = \{1,2,3\}$" src="form_279.png"/>) should receive phase change <img class="formulaInl" alt="$\pi$" src="form_114.png"/> (or <img class="formulaInl" alt="$-\pi$" src="form_280.png"/>) in lieu of <img class="formulaInl" alt="$\exp(i f(r_3=0,r_2=0,r_1=0, \vec{\theta}))$" src="form_293.png"/>.<br  />
<br  />
</p>
</li>
<li><p class="startli">The interpreted overrides can be previewed in the QASM log, as a comment. <br  />
 For example: </p><div class="fragment"><div class="line"><a class="code" href="group__qasm.html#ga65bf1906298ca6355e2942f4923d77b6">startRecordingQASM</a>(qureg);</div>
<div class="line"><a class="code" href="group__operator.html#gaabd7efa3beebc9f3a525321d41a28989">applyParamNamedPhaseFuncOverrides</a>(qureg, ...);</div>
<div class="line"><a class="code" href="group__qasm.html#gacf139d0a54b1f9e5c2f2feff742b8c76">printRecordedQASM</a>(qureg);</div>
</div><!-- fragment --><p class="startli">may show </p><div class="fragment"><div class="line"><span class="comment">// Here, applyParamNamedPhaseFunc() multiplied ...</span></div>
<div class="line"><span class="comment">//   though with overrides</span></div>
<div class="line"><span class="comment">//     |x=0, y=0, z=0&gt; -&gt; exp(i 3.14159)</span></div>
<div class="line"><span class="comment">//     |x=1, y=2, z=3&gt; -&gt; exp(i (-3.14159))</span></div>
</div><!-- fragment --></li>
</ul>
<p><br  />
</p>
<dl class="section see"><dt>See also</dt><dd><ul>
<li><a class="el" href="group__operator.html#ga467f517abd18dbc3d6fced84c6589161" title="Induces a phase change upon each amplitude of qureg, determined by the passed exponential polynomial ...">applyPhaseFunc()</a> to specify a general single-variable exponential polynomial phase function.</li>
<li><a class="el" href="group__operator.html#ga008a46d178a5a9691e2f5d363e3f518f" title="Induces a phase change upon each amplitude of qureg, determined by a multi-variable exponential polyn...">applyMultiVarPhaseFunc()</a> to specify a general multi-variable exponential polynomial phase function.</li>
<li><a class="el" href="group__operator.html#gad2e953390342cd361cfb4064d47715e6" title="Apply a diagonal operator, which is possibly non-unitary and non-Hermitian, to the entire qureg.">applyDiagonalOp()</a> to apply a non-unitary diagonal <a class="el" href="group__operator.html" title="Non-physical operators which may be non-unitary, non-norm-preserving, even non-Hermitian.">Operators</a>.</li>
</ul>
</dd></dl>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in,out]</td><td class="paramname">qureg</td><td>the state-vector or density-matrix to be modified </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">qubits</td><td>a list of all the qubit indices contained in each sub-register </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">numQubitsPerReg</td><td>a list of the lengths of each sub-list in <code>qubits</code> </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">numRegs</td><td>the number of sub-registers, which is the length of both <code>numQubitsPerReg</code> and <code>numTermsPerReg</code> </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">encoding</td><td>the <a class="el" href="group__type.html#ga9c91c41aa42ae537995e89ffc616afe1" title="Flags for specifying how the bits in sub-register computational basis states are mapped to indices in...">bitEncoding</a> under which to infer the binary value <img class="formulaInl" alt="$r_j$" src="form_269.png"/> from the bits of a sub-register </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">functionNameCode</td><td>the <a class="el" href="group__type.html#gaa7d869b117ba5024d6b84938e8cdfc65" title="Flags for specifying named phase functions.">phaseFunc</a> <img class="formulaInl" alt="$f(\vec{r}, \vec{\theta})$" src="form_287.png"/> </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">params</td><td>a list of any additional parameters <img class="formulaInl" alt="$\vec{\theta}$" src="form_288.png"/> needed by the <a class="el" href="group__type.html#gaa7d869b117ba5024d6b84938e8cdfc65" title="Flags for specifying named phase functions.">phaseFunc</a> <code>functionNameCode</code> </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">numParams</td><td>the length of list <code>params</code> </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">overrideInds</td><td>a flattened list of sub-register coordinates (values of <img class="formulaInl" alt="$\vec{r}$" src="form_276.png"/>) of which to explicit set the phase change </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">overridePhases</td><td>a list of replacement phase changes, for the corresponding <img class="formulaInl" alt="$\vec{r}$" src="form_276.png"/> values in <code>overrideInds</code> </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">numOverrides</td><td>the lengths of list <code>overridePhases</code> (but not necessarily of <code>overrideInds</code>) </td></tr>
  </table>
  </dd>
</dl>
<dl class="exception"><dt>Exceptions</dt><dd>
  <table class="exception">
    <tr><td class="paramname"><a class="el" href="group__debug.html#ga51a64b05d31ef9bcf6a63ce26c0092db" title="An internal function called when invalid arguments are passed to a QuEST API call,...">invalidQuESTInputError()</a></td><td><ul>
<li>if any qubit in <code>qubits</code> has an invalid index (i.e. does not satisfy 0 &lt;= qubit &lt; <code>qureg.numQubitsRepresented</code>)</li>
<li>if the elements of <code>qubits</code> are not unique (including if sub-registers overlap)</li>
<li>if <code>numRegs</code> &lt;= 0 or <code>numRegs</code> &gt; 100 (constrained by <code>MAX_NUM_REGS_APPLY_ARBITRARY_PHASE</code> in <a class="el" href="QuEST__precision_8h.html">QuEST_precision.h</a>)</li>
<li>if <code>encoding</code> is not a valid <a class="el" href="group__type.html#ga9c91c41aa42ae537995e89ffc616afe1" title="Flags for specifying how the bits in sub-register computational basis states are mapped to indices in...">bitEncoding</a></li>
<li>if the size of any sub-register is incompatible with <code>encoding</code> (e.g. contains fewer than two qubits in <code>encoding</code> <b>=</b> <code>TWOS_COMPLEMENT</code>)</li>
<li>if <code>functionNameCode</code> is not a valid <a class="el" href="group__type.html#gaa7d869b117ba5024d6b84938e8cdfc65" title="Flags for specifying named phase functions.">phaseFunc</a></li>
<li>if <code>numParams</code> is incompatible with <code>functionNameCode</code> (for example, no parameters were passed to <code>SCALED_PRODUCT</code>)</li>
<li>if any value in <code>overrideInds</code> is not producible by its corresponding sub-register under the given <code>encoding</code> (e.g. 2 unsigned qubits cannot represent index 9)</li>
<li>if <code>numOverrides</code> &lt; 0 </li>
</ul>
</td></tr>
  </table>
  </dd>
</dl>
<dl class="section author"><dt>Author</dt><dd>Tyson Jones </dd></dl>

<p class="definition">Definition at line <a class="el" href="QuEST_8c_source.html#l00848">848</a> of file <a class="el" href="QuEST_8c_source.html">QuEST.c</a>.</p>
<div class="fragment"><div class="line"><a name="l00848"></a><span class="lineno">  848</span>&#160;                                                                                                                                                                                                                                                                    {</div>
<div class="line"><a name="l00849"></a><span class="lineno">  849</span>&#160;    <a class="code" href="QuEST__validation_8c.html#a0a45c9c3015af276ff7e624ae207ba7a">validateQubitSubregs</a>(qureg, qubits, numQubitsPerReg, numRegs, __func__);</div>
<div class="line"><a name="l00850"></a><span class="lineno">  850</span>&#160;    <a class="code" href="QuEST__validation_8c.html#a9b348fc98867d01990da93a8de36936c">validateMultiRegBitEncoding</a>(numQubitsPerReg, numRegs, encoding, __func__);</div>
<div class="line"><a name="l00851"></a><span class="lineno">  851</span>&#160;    <a class="code" href="QuEST__validation_8c.html#a99e98bb5d38287fbb51f1e094d1eb68e">validatePhaseFuncName</a>(functionNameCode, numRegs, numParams, __func__);</div>
<div class="line"><a name="l00852"></a><span class="lineno">  852</span>&#160;    <a class="code" href="QuEST__validation_8c.html#a0edb4d9df94a40b8ea89c1c14997ee76">validateMultiVarPhaseFuncOverrides</a>(numQubitsPerReg, numRegs, encoding, overrideInds, numOverrides, __func__);</div>
<div class="line"><a name="l00853"></a><span class="lineno">  853</span>&#160; </div>
<div class="line"><a name="l00854"></a><span class="lineno">  854</span>&#160;    <span class="keywordtype">int</span> conj = 0;</div>
<div class="line"><a name="l00855"></a><span class="lineno">  855</span>&#160;    <a class="code" href="QuEST__internal_8h.html#a7d8a817207847d2646a52044a63fd469">statevec_applyParamNamedPhaseFuncOverrides</a>(qureg, qubits, numQubitsPerReg, numRegs, encoding, functionNameCode, params, numParams, overrideInds, overridePhases, numOverrides, conj);</div>
<div class="line"><a name="l00856"></a><span class="lineno">  856</span>&#160;    <span class="keywordflow">if</span> (qureg.<a class="code" href="structQureg.html#acf78445e9435d09f44f0cc832c6aee79">isDensityMatrix</a>) {</div>
<div class="line"><a name="l00857"></a><span class="lineno">  857</span>&#160;        conj = 1;</div>
<div class="line"><a name="l00858"></a><span class="lineno">  858</span>&#160;        <a class="code" href="QuEST__common_8c.html#aecc3c36b275c53b321de1611c2f06f78">shiftSubregIndices</a>(qubits, numQubitsPerReg, numRegs, qureg.<a class="code" href="structQureg.html#ad08dff5316b8937f4b2a1417591543dc">numQubitsRepresented</a>);</div>
<div class="line"><a name="l00859"></a><span class="lineno">  859</span>&#160;        <a class="code" href="QuEST__internal_8h.html#a7d8a817207847d2646a52044a63fd469">statevec_applyParamNamedPhaseFuncOverrides</a>(qureg, qubits, numQubitsPerReg, numRegs, encoding, functionNameCode, params, numParams, overrideInds, overridePhases, numOverrides, conj);</div>
<div class="line"><a name="l00860"></a><span class="lineno">  860</span>&#160;        <a class="code" href="QuEST__common_8c.html#aecc3c36b275c53b321de1611c2f06f78">shiftSubregIndices</a>(qubits, numQubitsPerReg, numRegs, - qureg.<a class="code" href="structQureg.html#ad08dff5316b8937f4b2a1417591543dc">numQubitsRepresented</a>);</div>
<div class="line"><a name="l00861"></a><span class="lineno">  861</span>&#160;    }</div>
<div class="line"><a name="l00862"></a><span class="lineno">  862</span>&#160; </div>
<div class="line"><a name="l00863"></a><span class="lineno">  863</span>&#160;    <a class="code" href="QuEST__qasm_8c.html#ab60a4a8af0530cbfa8cba1b02692d448">qasm_recordNamedPhaseFunc</a>(qureg, qubits, numQubitsPerReg, numRegs, encoding, functionNameCode, params, numParams, overrideInds, overridePhases, numOverrides);</div>
<div class="line"><a name="l00864"></a><span class="lineno">  864</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST_8h_source.html#l00325">Qureg::isDensityMatrix</a>, <a class="el" href="QuEST_8h_source.html#l00327">Qureg::numQubitsRepresented</a>, <a class="el" href="QuEST__qasm_8c_source.html#l00726">qasm_recordNamedPhaseFunc()</a>, <a class="el" href="QuEST__common_8c_source.html#l00161">shiftSubregIndices()</a>, <a class="el" href="QuEST__cpu_8c_source.html#l04446">statevec_applyParamNamedPhaseFuncOverrides()</a>, <a class="el" href="QuEST__validation_8c_source.html#l00976">validateMultiRegBitEncoding()</a>, <a class="el" href="QuEST__validation_8c_source.html#l00886">validateMultiVarPhaseFuncOverrides()</a>, <a class="el" href="QuEST__validation_8c_source.html#l00913">validatePhaseFuncName()</a>, and <a class="el" href="QuEST__validation_8c_source.html#l00757">validateQubitSubregs()</a>.</p>

<p class="reference">Referenced by <a class="el" href="test__operators_8cpp_source.html#l02079">TEST_CASE()</a>.</p>

</div>
</div>
<a id="ga54d4e589468002bdc998200ae45e7312"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga54d4e589468002bdc998200ae45e7312">&#9670;&nbsp;</a></span>applyPauliHamil()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void applyPauliHamil </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a>&#160;</td>
          <td class="paramname"><em>inQureg</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="structPauliHamil.html">PauliHamil</a>&#160;</td>
          <td class="paramname"><em>hamil</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a>&#160;</td>
          <td class="paramname"><em>outQureg</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Modifies <code>outQureg</code> to be the result of applying <code><a class="el" href="structPauliHamil.html" title="A Pauli Hamiltonian, expressed as a real-weighted sum of pauli products, and which can hence represen...">PauliHamil</a></code> (a Hermitian but not necessarily unitary operator) to <code>inQureg</code>. </p>
<p>Note that afterward, <code>outQureg</code> may no longer be normalised and ergo not a state-vector or density matrix. Users must therefore be careful passing <code>outQureg</code> to other QuEST functions which assume normalisation in order to function correctly.</p>
<p>This is merely an encapsulation of <a class="el" href="group__operator.html#ga6fc26cf857db070e12959e59ecfed8a6" title="Modifies outQureg to be the result of applying the weighted sum of Pauli products (a Hermitian but no...">applyPauliSum()</a>, which can refer to for elaborated doc.</p>
<p>Letting <code>hamil</code> be expressed as <img class="formulaInl" alt="$ \alpha = \sum_i c_i \otimes_j^{N} \hat{\sigma}_{i,j} $" src="form_230.png"/> (where <img class="formulaInl" alt="$ c_i \in $" src="form_203.png"/> <code>hamil.termCoeffs</code> and <img class="formulaInl" alt="$ N = $" src="form_204.png"/> <code>hamil.numQubits</code>), this function effects <img class="formulaInl" alt="$ \alpha | \psi \rangle $" src="form_231.png"/> on state-vector <img class="formulaInl" alt="$ |\psi\rangle $" src="form_232.png"/> and <img class="formulaInl" alt="$\alpha \rho$" src="form_233.png"/> (left matrix multiplication) on density matrix <img class="formulaInl" alt="$ \rho $" src="form_47.png"/>.</p>
<p>In theory, <code>inQureg</code> is unchanged though its state is temporarily modified and is reverted by re-applying Paulis (XX=YY=ZZ=I), so may see a change by small numerical errors. The initial state in <code>outQureg</code> is not used.</p>
<p><code>inQureg</code> and <code>outQureg</code> must both be state-vectors, or both density matrices, of equal dimensions to <code>hamil</code>. <code>inQureg</code> cannot be <code>outQureg</code>.</p>
<p>This function works by applying each Pauli product in <code>hamil</code> to <code>inQureg</code> in turn, and adding the resulting state (weighted by a coefficient in <code>termCoeffs</code>) to the initially-blanked <code>outQureg</code>. Ergo it should scale with the total number of Pauli operators specified (excluding identities), and the qureg dimension.</p>
<dl class="section see"><dt>See also</dt><dd><ul>
<li><a class="el" href="group__type.html#ga35b28710877c462927366fa602e591cb" title="Dynamically allocates a Hamiltonian expressed as a real-weighted sum of products of Pauli operators.">createPauliHamil()</a></li>
<li><a class="el" href="group__type.html#gaa77376c5e3518186eb085f37826d6008" title="Creates a PauliHamil instance, a real-weighted sum of products of Pauli operators,...">createPauliHamilFromFile()</a></li>
<li><a class="el" href="group__calc.html#ga5544d2833a69941b8820797b79daf79f" title="Computes the expected value of qureg under Hermitian operator hamil.">calcExpecPauliHamil()</a></li>
<li><a class="el" href="group__operator.html#ga35b6321c578a8c69470132b5ee95f930" title="Applies a trotterisation of unitary evolution  to qureg.">applyTrotterCircuit()</a></li>
</ul>
</dd></dl>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in]</td><td class="paramname">inQureg</td><td>the register containing the state which <code>outQureg</code> will be set to, under the action of <code>hamil</code>. <code>inQureg</code> should be unchanged, though may vary slightly due to numerical error. </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">hamil</td><td>a weighted sum of products of pauli operators </td></tr>
    <tr><td class="paramdir">[out]</td><td class="paramname">outQureg</td><td>the qureg to modify to be the result of applyling <code>hamil</code> to the state in <code>inQureg</code> </td></tr>
  </table>
  </dd>
</dl>
<dl class="exception"><dt>Exceptions</dt><dd>
  <table class="exception">
    <tr><td class="paramname"><a class="el" href="group__debug.html#ga51a64b05d31ef9bcf6a63ce26c0092db" title="An internal function called when invalid arguments are passed to a QuEST API call,...">invalidQuESTInputError()</a></td><td><ul>
<li>if any code in <code>hamil.pauliCodes</code> is not a valid Pauli code</li>
<li>if <code>numSumTerms</code> &lt;= 0</li>
<li>if <code>inQureg</code> is not of the same type and dimensions as <code>outQureg</code> and <code>hamil</code> </li>
</ul>
</td></tr>
  </table>
  </dd>
</dl>
<dl class="section author"><dt>Author</dt><dd>Tyson Jones </dd></dl>

<p class="definition">Definition at line <a class="el" href="QuEST_8c_source.html#l01059">1059</a> of file <a class="el" href="QuEST_8c_source.html">QuEST.c</a>.</p>
<div class="fragment"><div class="line"><a name="l01059"></a><span class="lineno"> 1059</span>&#160;                                                                      {</div>
<div class="line"><a name="l01060"></a><span class="lineno"> 1060</span>&#160;    <a class="code" href="QuEST__validation_8c.html#a031812e1cf2c98d72d795cea7bbe73a5">validateMatchingQuregTypes</a>(inQureg, outQureg, __func__);</div>
<div class="line"><a name="l01061"></a><span class="lineno"> 1061</span>&#160;    <a class="code" href="QuEST__validation_8c.html#a87d22240ccfd81827a2a34b8d569d347">validateMatchingQuregDims</a>(inQureg, outQureg, __func__);</div>
<div class="line"><a name="l01062"></a><span class="lineno"> 1062</span>&#160;    <a class="code" href="QuEST__validation_8c.html#a066b0c4d0b02a0f3b9be7e5c68d9de6a">validatePauliHamil</a>(hamil, __func__);</div>
<div class="line"><a name="l01063"></a><span class="lineno"> 1063</span>&#160;    <a class="code" href="QuEST__validation_8c.html#a2b88b068a8242ee28da42c7324cdd078">validateMatchingQuregPauliHamilDims</a>(inQureg, hamil, __func__);</div>
<div class="line"><a name="l01064"></a><span class="lineno"> 1064</span>&#160;    </div>
<div class="line"><a name="l01065"></a><span class="lineno"> 1065</span>&#160;    <a class="code" href="QuEST__common_8c.html#af71c2470694795a8d639be8ff9c34ed5">statevec_applyPauliSum</a>(inQureg, hamil.<a class="code" href="structPauliHamil.html#a4b8d38c403553c07ceddcd40c46ce6c8">pauliCodes</a>, hamil.<a class="code" href="structPauliHamil.html#ac1c6c9f6299cf83bbba88123216c3cac">termCoeffs</a>, hamil.<a class="code" href="structPauliHamil.html#a737e46b40ef8990cf004d22eb9dbe2e4">numSumTerms</a>, outQureg);</div>
<div class="line"><a name="l01066"></a><span class="lineno"> 1066</span>&#160;    </div>
<div class="line"><a name="l01067"></a><span class="lineno"> 1067</span>&#160;    <a class="code" href="QuEST__qasm_8c.html#a9a385fde708958617bbeb599064b8dcb">qasm_recordComment</a>(outQureg, <span class="stringliteral">&quot;Here, the register was modified to an undisclosed and possibly unphysical state (applyPauliHamil).&quot;</span>);</div>
<div class="line"><a name="l01068"></a><span class="lineno"> 1068</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST_8h_source.html#l00285">PauliHamil::numSumTerms</a>, <a class="el" href="QuEST_8h_source.html#l00281">PauliHamil::pauliCodes</a>, <a class="el" href="QuEST__qasm_8c_source.html#l00121">qasm_recordComment()</a>, <a class="el" href="QuEST__common_8c_source.html#l00538">statevec_applyPauliSum()</a>, <a class="el" href="QuEST_8h_source.html#l00283">PauliHamil::termCoeffs</a>, <a class="el" href="QuEST__validation_8c_source.html#l00531">validateMatchingQuregDims()</a>, <a class="el" href="QuEST__validation_8c_source.html#l00660">validateMatchingQuregPauliHamilDims()</a>, <a class="el" href="QuEST__validation_8c_source.html#l00535">validateMatchingQuregTypes()</a>, and <a class="el" href="QuEST__validation_8c_source.html#l00655">validatePauliHamil()</a>.</p>

<p class="reference">Referenced by <a class="el" href="test__operators_8cpp_source.html#l02675">TEST_CASE()</a>.</p>

</div>
</div>
<a id="ga6fc26cf857db070e12959e59ecfed8a6"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga6fc26cf857db070e12959e59ecfed8a6">&#9670;&nbsp;</a></span>applyPauliSum()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void applyPauliSum </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a>&#160;</td>
          <td class="paramname"><em>inQureg</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">enum <a class="el" href="group__type.html#ga1c703cf89629e4e9c7023cd402d67028">pauliOpType</a> *&#160;</td>
          <td class="paramname"><em>allPauliCodes</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> *&#160;</td>
          <td class="paramname"><em>termCoeffs</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>numSumTerms</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a>&#160;</td>
          <td class="paramname"><em>outQureg</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Modifies <code>outQureg</code> to be the result of applying the weighted sum of Pauli products (a Hermitian but not necessarily unitary operator) to <code>inQureg</code>. </p>
<p>Note that afterward, <code>outQureg</code> may no longer be normalised and ergo not a state-vector or density matrix. Users must therefore be careful passing <code>outQureg</code> to other QuEST functions which assume normalisation in order to function correctly.</p>
<p>Letting <img class="formulaInl" alt="$ \alpha = \sum_i c_i \otimes_j^{N} \hat{\sigma}_{i,j} $" src="form_230.png"/> be the operators indicated by <code>allPauliCodes</code> (where <img class="formulaInl" alt="$ c_i \in $" src="form_203.png"/> <code>termCoeffs</code> and <img class="formulaInl" alt="$ N = $" src="form_204.png"/> <code>qureg.numQubitsRepresented</code>), this function effects <img class="formulaInl" alt="$ \alpha | \psi \rangle $" src="form_231.png"/> on state-vector <img class="formulaInl" alt="$ |\psi\rangle $" src="form_232.png"/> and <img class="formulaInl" alt="$\alpha \rho$" src="form_233.png"/> (left matrix multiplication) on density matrix <img class="formulaInl" alt="$ \rho $" src="form_47.png"/>.</p>
<p><code>allPauliCodes</code> is an array of length <code>numSumTerms*<code>qureg.numQubitsRepresented</code> which</code> specifies which Pauli operators to apply, where 0 = <code>PAULI_I</code>, 1 = <code>PAULI_X</code>, 2 = <code>PAULI_Y</code>, 3 = <code>PAULI_Z</code>. For each sum term, a Pauli operator must be specified for EVERY qubit in <code>qureg</code>; each set of <code>numSumTerms</code> operators will be grouped into a product. <code>termCoeffs</code> is an arrray of length <code>numSumTerms</code> containing the term coefficients. For example, on a 3-qubit state-vector, </p><div class="fragment"><div class="line"><span class="keywordtype">int</span> paulis[6] = {<a class="code" href="group__type.html#gga1c703cf89629e4e9c7023cd402d67028a7abac7bb5b71e17382014c443244ad5c">PAULI_X</a>, <a class="code" href="group__type.html#gga1c703cf89629e4e9c7023cd402d67028a63800f45b01ccc2608f754aee850bf4a">PAULI_I</a>, <a class="code" href="group__type.html#gga1c703cf89629e4e9c7023cd402d67028a63800f45b01ccc2608f754aee850bf4a">PAULI_I</a>,  <a class="code" href="group__type.html#gga1c703cf89629e4e9c7023cd402d67028a7abac7bb5b71e17382014c443244ad5c">PAULI_X</a>, <a class="code" href="group__type.html#gga1c703cf89629e4e9c7023cd402d67028a2c64a9aaee27f6bcfef894d159e759bd">PAULI_Y</a>, <a class="code" href="group__type.html#gga1c703cf89629e4e9c7023cd402d67028a085c85cff6ba79c52d8b1e61c42ddddf">PAULI_Z</a>};</div>
<div class="line"><a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> coeffs[2] = {1.5, -3.6};</div>
<div class="line"><a class="code" href="group__operator.html#ga6fc26cf857db070e12959e59ecfed8a6">applyPauliSum</a>(inQureg, paulis, coeffs, 2, outQureg);</div>
</div><!-- fragment --><p>will apply Hermitian operation <img class="formulaInl" alt="$ (1.5 X I I - 3.6 X Y Z) $" src="form_234.png"/> (where in this notation, the left-most operator applies to the least-significant qubit, i.e. that with index 0).</p>
<p>In theory, <code>inQureg</code> is unchanged though its state is temporarily modified and is reverted by re-applying Paulis (XX=YY=ZZ=I), so may see a change by small numerical errors. The initial state in <code>outQureg</code> is not used.</p>
<p><code>inQureg</code> and <code>outQureg</code> must both be state-vectors, or both density matrices, of equal dimensions. <code>inQureg</code> cannot be <code>outQureg</code>.</p>
<p>This function works by applying each Pauli product to <code>inQureg</code> in turn, and adding the resulting state (weighted by a coefficient in <code>termCoeffs</code>) to the initially-blanked <code>outQureg</code>. Ergo it should scale with the total number of Pauli operators specified (excluding identities), and the qureg dimension.</p>
<dl class="section see"><dt>See also</dt><dd><ul>
<li><a class="el" href="group__calc.html#ga50ee589fd5ceab52fdd70d0082352b41" title="Computes the expected value of a sum of products of Pauli operators.">calcExpecPauliSum()</a></li>
<li><a class="el" href="group__operator.html#ga54d4e589468002bdc998200ae45e7312" title="Modifies outQureg to be the result of applying PauliHamil (a Hermitian but not necessarily unitary op...">applyPauliHamil()</a></li>
</ul>
</dd></dl>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in]</td><td class="paramname">inQureg</td><td>the register containing the state which <code>outQureg</code> will be set to, under the action of the Hermitiain operator specified by the Pauli codes. <code>inQureg</code> should be unchanged, though may vary slightly due to numerical error. </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">allPauliCodes</td><td>a list of the Pauli codes (0=PAULI_I, 1=PAULI_X, 2=PAULI_Y, 3=PAULI_Z) of all Paulis involved in the products of terms. A Pauli must be specified for each qubit in the register, in every term of the sum. </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">termCoeffs</td><td>The coefficients of each term in the sum of Pauli products </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">numSumTerms</td><td>The total number of Pauli products specified </td></tr>
    <tr><td class="paramdir">[out]</td><td class="paramname">outQureg</td><td>the qureg to modify to be the result of applyling the weighted Pauli sum operator to the state in <code>inQureg</code> </td></tr>
  </table>
  </dd>
</dl>
<dl class="exception"><dt>Exceptions</dt><dd>
  <table class="exception">
    <tr><td class="paramname"><a class="el" href="group__debug.html#ga51a64b05d31ef9bcf6a63ce26c0092db" title="An internal function called when invalid arguments are passed to a QuEST API call,...">invalidQuESTInputError()</a></td><td><ul>
<li>if any code in <code>allPauliCodes</code> is not in {0,1,2,3}</li>
<li>if numSumTerms &lt;= 0</li>
<li>if <code>inQureg</code> is not of the same type and dimensions as <code>outQureg</code> </li>
</ul>
</td></tr>
  </table>
  </dd>
</dl>
<dl class="section author"><dt>Author</dt><dd>Tyson Jones </dd></dl>

<p class="definition">Definition at line <a class="el" href="QuEST_8c_source.html#l01048">1048</a> of file <a class="el" href="QuEST_8c_source.html">QuEST.c</a>.</p>
<div class="fragment"><div class="line"><a name="l01048"></a><span class="lineno"> 1048</span>&#160;                                                                                                                       {</div>
<div class="line"><a name="l01049"></a><span class="lineno"> 1049</span>&#160;    <a class="code" href="QuEST__validation_8c.html#a031812e1cf2c98d72d795cea7bbe73a5">validateMatchingQuregTypes</a>(inQureg, outQureg, __func__);</div>
<div class="line"><a name="l01050"></a><span class="lineno"> 1050</span>&#160;    <a class="code" href="QuEST__validation_8c.html#a87d22240ccfd81827a2a34b8d569d347">validateMatchingQuregDims</a>(inQureg, outQureg, __func__);</div>
<div class="line"><a name="l01051"></a><span class="lineno"> 1051</span>&#160;    <a class="code" href="QuEST__validation_8c.html#a5be128290a7bba9a7f12d32cabe2276b">validateNumPauliSumTerms</a>(numSumTerms, __func__);</div>
<div class="line"><a name="l01052"></a><span class="lineno"> 1052</span>&#160;    <a class="code" href="QuEST__validation_8c.html#aa194ba5f5c6e19c6caa4c715b3dbefcc">validatePauliCodes</a>(allPauliCodes, numSumTerms*inQureg.<a class="code" href="structQureg.html#ad08dff5316b8937f4b2a1417591543dc">numQubitsRepresented</a>, __func__);</div>
<div class="line"><a name="l01053"></a><span class="lineno"> 1053</span>&#160;    </div>
<div class="line"><a name="l01054"></a><span class="lineno"> 1054</span>&#160;    <a class="code" href="QuEST__common_8c.html#af71c2470694795a8d639be8ff9c34ed5">statevec_applyPauliSum</a>(inQureg, allPauliCodes, termCoeffs, numSumTerms, outQureg);</div>
<div class="line"><a name="l01055"></a><span class="lineno"> 1055</span>&#160;    </div>
<div class="line"><a name="l01056"></a><span class="lineno"> 1056</span>&#160;    <a class="code" href="QuEST__qasm_8c.html#a9a385fde708958617bbeb599064b8dcb">qasm_recordComment</a>(outQureg, <span class="stringliteral">&quot;Here, the register was modified to an undisclosed and possibly unphysical state (applyPauliSum).&quot;</span>);</div>
<div class="line"><a name="l01057"></a><span class="lineno"> 1057</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST_8h_source.html#l00327">Qureg::numQubitsRepresented</a>, <a class="el" href="QuEST__qasm_8c_source.html#l00121">qasm_recordComment()</a>, <a class="el" href="QuEST__common_8c_source.html#l00538">statevec_applyPauliSum()</a>, <a class="el" href="QuEST__validation_8c_source.html#l00531">validateMatchingQuregDims()</a>, <a class="el" href="QuEST__validation_8c_source.html#l00535">validateMatchingQuregTypes()</a>, <a class="el" href="QuEST__validation_8c_source.html#l00606">validateNumPauliSumTerms()</a>, and <a class="el" href="QuEST__validation_8c_source.html#l00599">validatePauliCodes()</a>.</p>

<p class="reference">Referenced by <a class="el" href="test__operators_8cpp_source.html#l02775">TEST_CASE()</a>.</p>

</div>
</div>
<a id="ga467f517abd18dbc3d6fced84c6589161"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga467f517abd18dbc3d6fced84c6589161">&#9670;&nbsp;</a></span>applyPhaseFunc()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void applyPhaseFunc </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a>&#160;</td>
          <td class="paramname"><em>qureg</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int *&#160;</td>
          <td class="paramname"><em>qubits</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>numQubits</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">enum <a class="el" href="group__type.html#ga9c91c41aa42ae537995e89ffc616afe1">bitEncoding</a>&#160;</td>
          <td class="paramname"><em>encoding</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> *&#160;</td>
          <td class="paramname"><em>coeffs</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> *&#160;</td>
          <td class="paramname"><em>exponents</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>numTerms</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Induces a phase change upon each amplitude of <code>qureg</code>, determined by the passed exponential polynomial "phase function". </p>
<p>This effects a diagonal unitary of unit complex scalars, targeting the nominated <code>qubits</code>.</p>
<ul>
<li><p class="startli">Arguments <code>coeffs</code> and <code>exponents</code> together specify a real exponential polynomial <img class="formulaInl" alt="$f(r)$" src="form_245.png"/> with <code>numTerms</code> terms, of the form </p><p class="formulaDsp">
<img class="formulaDsp" alt="\[ f(r) = \sum\limits_{i}^{\text{numTerms}} \text{coeffs}[i] \; r^{\, \text{exponents}[i]}\,, \]" src="form_246.png"/>
</p>
<p> where both <code>coeffs</code> and <code>exponents</code> can be negative, positive and fractional. For example, </p><div class="fragment"><div class="line"><a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> coeffs[] = {1, -3.14};</div>
<div class="line"><a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> exponents[] = {2, -5.5};</div>
<div class="line"><span class="keywordtype">int</span> numTerms = 2;</div>
</div><!-- fragment --><p class="startli">constitutes the function </p><p class="formulaDsp">
<img class="formulaDsp" alt="\[ f(r) = 1 \, r^2 - 3.14 \, r^{-5.5}. \]" src="form_247.png"/>
</p>
<p> Note you cannot use fractional exponents with <code>encoding</code> <b>=</b> <a class="el" href="group__type.html#gga9c91c41aa42ae537995e89ffc616afe1a9aa2a35d92976c7de970506c4d19a96c">TWOS_COMPLEMENT</a>, since the negative indices would generate (illegal) complex phases, and must be overriden with <a class="el" href="group__operator.html#gaf5344129240243ad11d0c081eb9036ab" title="Induces a phase change upon each amplitude of qureg, determined by the passed exponential polynomial ...">applyPhaseFuncOverrides()</a>. <br  />
</p><blockquote class="doxtable">
<p>If your function <img class="formulaInl" alt="$f(r)$" src="form_245.png"/> diverges at one or more <img class="formulaInl" alt="$r$" src="form_248.png"/> values, you must instead use <a class="el" href="group__operator.html#gaf5344129240243ad11d0c081eb9036ab" title="Induces a phase change upon each amplitude of qureg, determined by the passed exponential polynomial ...">applyPhaseFuncOverrides()</a> and specify explicit phase changes for these values. Otherwise, the corresponding amplitudes of the state-vector will become indeterminate (like <code>NaN</code>). Note that use of any negative exponent will result in divergences at <img class="formulaInl" alt="$r=0$" src="form_249.png"/>. </p>
</blockquote>
</li>
<li>The function <img class="formulaInl" alt="$f(r)$" src="form_245.png"/> specifies the phase change to induce upon amplitude <img class="formulaInl" alt="$\alpha$" src="form_88.png"/> of computational basis state with index <img class="formulaInl" alt="$r$" src="form_248.png"/>, such that <p class="formulaDsp">
<img class="formulaDsp" alt="\[ \alpha \, |r\rangle \rightarrow \, \exp(i f(r)) \; \alpha \, |r\rangle. \]" src="form_250.png"/>
</p>
 The index <img class="formulaInl" alt="$r$" src="form_248.png"/> associated with each computational basis state is determined by the binary value of the specified <code>qubits</code> (ordered least to most significant), interpreted under the given <a class="el" href="group__type.html#ga9c91c41aa42ae537995e89ffc616afe1" title="Flags for specifying how the bits in sub-register computational basis states are mapped to indices in...">bitEncoding</a> <code>encoding</code>. <br  />
<br  />
 For example, under <code>encoding</code> <b>=</b> <code>UNSIGNED</code> and <code>qubits</code> <b>= {0,1}</b>, <p class="formulaDsp">
<img class="formulaDsp" alt="\[ \begin{aligned} |0\mathbf{00}\rangle &amp; \rightarrow \, e^{i f(0)}\,|0\mathbf{00}\rangle \\ |0\mathbf{01}\rangle &amp; \rightarrow \, e^{i f(1)}\,|0\mathbf{01}\rangle \\ |0\mathbf{10}\rangle &amp; \rightarrow \, e^{i f(2)}\,|0\mathbf{10}\rangle \\ |0\mathbf{11}\rangle &amp; \rightarrow \, e^{i f(3)}\,|0\mathbf{11}\rangle \\ |1\mathbf{00}\rangle &amp; \rightarrow \, e^{i f(0)}\,|1\mathbf{00}\rangle \\ |1\mathbf{01}\rangle &amp; \rightarrow \, e^{i f(1)}\,|1\mathbf{01}\rangle \\ |1\mathbf{10}\rangle &amp; \rightarrow \, e^{i f(2)}\,|1\mathbf{10}\rangle \\ |1\mathbf{11}\rangle &amp; \rightarrow \, e^{i f(3)}\,|1\mathbf{11}\rangle \end{aligned} \]" src="form_251.png"/>
</p>
</li>
<li>If <code>qureg</code> is a density matrix <img class="formulaInl" alt="$\rho$" src="form_40.png"/>, this function modifies <code>qureg</code> to <p class="formulaDsp">
<img class="formulaDsp" alt="\[ \rho \rightarrow \hat{D} \, \rho \, \hat{D}^\dagger \]" src="form_252.png"/>
</p>
 where <img class="formulaInl" alt="$\hat{D}$" src="form_42.png"/> is the diagonal unitary operator <p class="formulaDsp">
<img class="formulaDsp" alt="\[ \hat{D} = \text{diag} \, \{ \; e^{i f(r_0)}, \; e^{i f(r_1)}, \; \dots \; \}. \]" src="form_253.png"/>
</p>
 This means element <img class="formulaInl" alt="$\rho_{jk}$" src="form_254.png"/> is modified to <p class="formulaDsp">
<img class="formulaDsp" alt="\[ \alpha \, |j\rangle\langle k| \; \rightarrow \; e^{i (f(r_j) - f(r_k))} \; \alpha \, |j\rangle\langle k| \]" src="form_255.png"/>
</p>
<br  />
</li>
<li><p class="startli">The interpreted phase function can be previewed in the QASM log, as a comment. <br  />
 For example: </p><div class="fragment"><div class="line"><a class="code" href="group__qasm.html#ga65bf1906298ca6355e2942f4923d77b6">startRecordingQASM</a>(qureg);</div>
<div class="line"><a class="code" href="group__operator.html#ga467f517abd18dbc3d6fced84c6589161">applyPhaseFunc</a>(qureg, ...);</div>
<div class="line"><a class="code" href="group__qasm.html#gacf139d0a54b1f9e5c2f2feff742b8c76">printRecordedQASM</a>(qureg);</div>
</div><!-- fragment --><p class="startli">may show </p><div class="fragment"><div class="line"><span class="comment">// Here, applyPhaseFunc() multiplied a complex scalar of the form</span></div>
<div class="line"><span class="comment">//     exp(i (1 x^3))</span></div>
<div class="line"><span class="comment">//   upon every substate |x&gt;, informed by qubits (under an unsigned binary encoding)</span></div>
<div class="line"><span class="comment">//     {4, 1, 2, 0}</span></div>
</div><!-- fragment --></li>
</ul>
<blockquote class="doxtable">
<p>This function may become numerically imprecise for quickly growing phase functions which admit very large phases, for example of 10^10. </p>
</blockquote>
<dl class="section see"><dt>See also</dt><dd><ul>
<li><a class="el" href="group__operator.html#gaf5344129240243ad11d0c081eb9036ab" title="Induces a phase change upon each amplitude of qureg, determined by the passed exponential polynomial ...">applyPhaseFuncOverrides()</a> to override the phase function for specific states.</li>
<li><a class="el" href="group__operator.html#ga008a46d178a5a9691e2f5d363e3f518f" title="Induces a phase change upon each amplitude of qureg, determined by a multi-variable exponential polyn...">applyMultiVarPhaseFunc()</a> for multi-variable exponential polynomial phase functions.</li>
<li><a class="el" href="group__operator.html#gac4df97d8c125c8cc65df720f67b2bf69" title="Induces a phase change upon each amplitude of qureg, determined by a named (and potentially multi-var...">applyNamedPhaseFunc()</a> for a set of specific phase functions.</li>
<li><a class="el" href="group__operator.html#gad2e953390342cd361cfb4064d47715e6" title="Apply a diagonal operator, which is possibly non-unitary and non-Hermitian, to the entire qureg.">applyDiagonalOp()</a> to apply a non-unitary diagonal <a class="el" href="group__operator.html" title="Non-physical operators which may be non-unitary, non-norm-preserving, even non-Hermitian.">Operators</a>.</li>
</ul>
</dd></dl>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in,out]</td><td class="paramname">qureg</td><td>the state-vector or density matrix to be modified </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">qubits</td><td>a list of the indices of the qubits which will inform <img class="formulaInl" alt="$r$" src="form_248.png"/> for each amplitude in <code>qureg</code> </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">numQubits</td><td>the length of list <code>qubits</code> </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">encoding</td><td>the <a class="el" href="group__type.html#ga9c91c41aa42ae537995e89ffc616afe1" title="Flags for specifying how the bits in sub-register computational basis states are mapped to indices in...">bitEncoding</a> under which to infer the binary value <img class="formulaInl" alt="$r$" src="form_248.png"/> from the bits of <code>qubits</code> in each basis state of <code>qureg</code> </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">coeffs</td><td>the coefficients of the exponential polynomial phase function <img class="formulaInl" alt="$f(r)$" src="form_245.png"/> </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">exponents</td><td>the exponents of the exponential polynomial phase function <img class="formulaInl" alt="$f(r)$" src="form_245.png"/> </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">numTerms</td><td>the length of list <code>coeffs</code>, which must be the same as that of <code>exponents</code> </td></tr>
  </table>
  </dd>
</dl>
<dl class="exception"><dt>Exceptions</dt><dd>
  <table class="exception">
    <tr><td class="paramname"><a class="el" href="group__debug.html#ga51a64b05d31ef9bcf6a63ce26c0092db" title="An internal function called when invalid arguments are passed to a QuEST API call,...">invalidQuESTInputError()</a></td><td><ul>
<li>if any qubit in <code>qubits</code> has an invalid index (i.e. does not satisfy 0 &lt;= qubit &lt; <code>qureg.numQubitsRepresented</code>)</li>
<li>if the elements of <code>qubits</code> are not unique</li>
<li>if <code>numQubits</code> &lt; 0 or <code>numQubits</code> &gt;= <code>qureg.numQubitsRepresented</code></li>
<li>if <code>encoding</code> is not a valid <a class="el" href="group__type.html#ga9c91c41aa42ae537995e89ffc616afe1" title="Flags for specifying how the bits in sub-register computational basis states are mapped to indices in...">bitEncoding</a></li>
<li>if <code>encoding</code> is not compatible with <code>numQubits</code> (e.g. <code>TWOS_COMPLEMENT</code> with only 1 qubit)</li>
<li>if <code>exponents</code> contains a fractional number despite <code>encoding</code> <b>=</b> <a class="el" href="group__type.html#gga9c91c41aa42ae537995e89ffc616afe1a9aa2a35d92976c7de970506c4d19a96c">TWOS_COMPLEMENT</a> (you must instead use <a class="el" href="group__operator.html#gaf5344129240243ad11d0c081eb9036ab" title="Induces a phase change upon each amplitude of qureg, determined by the passed exponential polynomial ...">applyPhaseFuncOverrides()</a> and override all negative indices)</li>
<li>if <code>exponents</code> contains a negative power (you must instead use <a class="el" href="group__operator.html#gaf5344129240243ad11d0c081eb9036ab" title="Induces a phase change upon each amplitude of qureg, determined by the passed exponential polynomial ...">applyPhaseFuncOverrides()</a> and override the zero index)</li>
<li>if <code>numTerms</code> &lt;= 0 </li>
</ul>
</td></tr>
  </table>
  </dd>
</dl>
<dl class="section author"><dt>Author</dt><dd>Tyson Jones </dd></dl>

<p class="definition">Definition at line <a class="el" href="QuEST_8c_source.html#l00726">726</a> of file <a class="el" href="QuEST_8c_source.html">QuEST.c</a>.</p>
<div class="fragment"><div class="line"><a name="l00726"></a><span class="lineno">  726</span>&#160;                                                                                                                                       {</div>
<div class="line"><a name="l00727"></a><span class="lineno">  727</span>&#160;    <a class="code" href="QuEST__validation_8c.html#a9e7e85cfc36e3ce1f456a840a217bfd9">validateMultiQubits</a>(qureg, qubits, numQubits, __func__);</div>
<div class="line"><a name="l00728"></a><span class="lineno">  728</span>&#160;    <a class="code" href="QuEST__validation_8c.html#aa8a0654753645b30d6fed4ed0f4e7d16">validateBitEncoding</a>(numQubits, encoding, __func__);</div>
<div class="line"><a name="l00729"></a><span class="lineno">  729</span>&#160;    <a class="code" href="QuEST__validation_8c.html#a91dad925cb9383384f135b936e5a7f43">validatePhaseFuncTerms</a>(numQubits, encoding, coeffs, exponents, numTerms, NULL, 0, __func__);</div>
<div class="line"><a name="l00730"></a><span class="lineno">  730</span>&#160; </div>
<div class="line"><a name="l00731"></a><span class="lineno">  731</span>&#160;    <span class="keywordtype">int</span> conj = 0;</div>
<div class="line"><a name="l00732"></a><span class="lineno">  732</span>&#160;    <a class="code" href="QuEST__internal_8h.html#a9d7928473aca695a614e9c24d903e578">statevec_applyPhaseFuncOverrides</a>(qureg, qubits, numQubits, encoding, coeffs, exponents, numTerms, NULL, NULL, 0, conj);</div>
<div class="line"><a name="l00733"></a><span class="lineno">  733</span>&#160;    <span class="keywordflow">if</span> (qureg.<a class="code" href="structQureg.html#acf78445e9435d09f44f0cc832c6aee79">isDensityMatrix</a>) {</div>
<div class="line"><a name="l00734"></a><span class="lineno">  734</span>&#160;        conj = 1;</div>
<div class="line"><a name="l00735"></a><span class="lineno">  735</span>&#160;        <a class="code" href="QuEST__common_8c.html#acf1c651a4359a370a2d9b3e1e1ebd430">shiftIndices</a>(qubits, numQubits, qureg.<a class="code" href="structQureg.html#ad08dff5316b8937f4b2a1417591543dc">numQubitsRepresented</a>);</div>
<div class="line"><a name="l00736"></a><span class="lineno">  736</span>&#160;        <a class="code" href="QuEST__internal_8h.html#a9d7928473aca695a614e9c24d903e578">statevec_applyPhaseFuncOverrides</a>(qureg, qubits, numQubits, encoding, coeffs, exponents, numTerms, NULL, NULL, 0, conj);</div>
<div class="line"><a name="l00737"></a><span class="lineno">  737</span>&#160;        <a class="code" href="QuEST__common_8c.html#acf1c651a4359a370a2d9b3e1e1ebd430">shiftIndices</a>(qubits, numQubits, - qureg.<a class="code" href="structQureg.html#ad08dff5316b8937f4b2a1417591543dc">numQubitsRepresented</a>);</div>
<div class="line"><a name="l00738"></a><span class="lineno">  738</span>&#160;    }</div>
<div class="line"><a name="l00739"></a><span class="lineno">  739</span>&#160; </div>
<div class="line"><a name="l00740"></a><span class="lineno">  740</span>&#160;    <a class="code" href="QuEST__qasm_8c.html#a383ddaecc94e1ce4a6fdbdbabeaa3131">qasm_recordPhaseFunc</a>(qureg, qubits, numQubits, encoding, coeffs, exponents, numTerms, NULL, NULL, 0);</div>
<div class="line"><a name="l00741"></a><span class="lineno">  741</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST_8h_source.html#l00325">Qureg::isDensityMatrix</a>, <a class="el" href="QuEST_8h_source.html#l00327">Qureg::numQubitsRepresented</a>, <a class="el" href="QuEST__qasm_8c_source.html#l00490">qasm_recordPhaseFunc()</a>, <a class="el" href="QuEST__common_8c_source.html#l00156">shiftIndices()</a>, <a class="el" href="QuEST__cpu_8c_source.html#l04268">statevec_applyPhaseFuncOverrides()</a>, <a class="el" href="QuEST__validation_8c_source.html#l00966">validateBitEncoding()</a>, <a class="el" href="QuEST__validation_8c_source.html#l00444">validateMultiQubits()</a>, and <a class="el" href="QuEST__validation_8c_source.html#l00773">validatePhaseFuncTerms()</a>.</p>

<p class="reference">Referenced by <a class="el" href="test__operators_8cpp_source.html#l02871">TEST_CASE()</a>.</p>

</div>
</div>
<a id="gaf5344129240243ad11d0c081eb9036ab"></a>
<h2 class="memtitle"><span class="permalink"><a href="#gaf5344129240243ad11d0c081eb9036ab">&#9670;&nbsp;</a></span>applyPhaseFuncOverrides()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void applyPhaseFuncOverrides </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a>&#160;</td>
          <td class="paramname"><em>qureg</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int *&#160;</td>
          <td class="paramname"><em>qubits</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>numQubits</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">enum <a class="el" href="group__type.html#ga9c91c41aa42ae537995e89ffc616afe1">bitEncoding</a>&#160;</td>
          <td class="paramname"><em>encoding</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> *&#160;</td>
          <td class="paramname"><em>coeffs</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> *&#160;</td>
          <td class="paramname"><em>exponents</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>numTerms</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">long long int *&#160;</td>
          <td class="paramname"><em>overrideInds</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> *&#160;</td>
          <td class="paramname"><em>overridePhases</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>numOverrides</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Induces a phase change upon each amplitude of <code>qureg</code>, determined by the passed exponential polynomial "phase function", and an explicit set of 'overriding' values at specific state indices. </p>
<p>See <a class="el" href="group__operator.html#ga467f517abd18dbc3d6fced84c6589161" title="Induces a phase change upon each amplitude of qureg, determined by the passed exponential polynomial ...">applyPhaseFunc()</a> first for a full description.</p>
<ul>
<li>As in <a class="el" href="group__operator.html#ga467f517abd18dbc3d6fced84c6589161" title="Induces a phase change upon each amplitude of qureg, determined by the passed exponential polynomial ...">applyPhaseFunc()</a>, the arguments <code>coeffs</code> and <code>exponents</code> specify a phase function <img class="formulaInl" alt="$f(r)$" src="form_245.png"/>, where <img class="formulaInl" alt="$r$" src="form_248.png"/> is determined by <code>qubits</code> and <code>encoding</code> for each basis state of <code>qureg</code>.<br  />
<br  />
</li>
<li><p class="startli">Additionally, <code>overrideInds</code> is a list of length <code>numOverrides</code> which specifies the values of <img class="formulaInl" alt="$r$" src="form_248.png"/> for which to explicitly set the induced phase change.<br  />
 The overriding phase changes are specified in the corresponding elements of <code>overridePhases</code>.<br  />
<br  />
 For example, </p><div class="fragment"><div class="line"><span class="keywordtype">int</span> qubits[] = {0,1};</div>
<div class="line"><span class="keyword">enum</span> <a class="code" href="group__type.html#ga9c91c41aa42ae537995e89ffc616afe1">bitEncoding</a> encoding = <a class="code" href="group__type.html#gga9c91c41aa42ae537995e89ffc616afe1a7165f9a47792f47c718ca128556fb3ae">UNSIGNED</a>;</div>
<div class="line"> </div>
<div class="line"><span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> overrideInds[] = {2};</div>
<div class="line"><a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> overridePhases[] = {<a class="code" href="QuEST__common_8c.html#ae71449b1cc6e6250b91f539153a7a0d3">M_PI</a>};</div>
<div class="line"> </div>
<div class="line"><a class="code" href="group__operator.html#gaf5344129240243ad11d0c081eb9036ab">applyPhaseFuncOverrides</a>(...);</div>
</div><!-- fragment --><p class="startli">would effect the same diagonal unitary of <a class="el" href="group__operator.html#ga467f517abd18dbc3d6fced84c6589161" title="Induces a phase change upon each amplitude of qureg, determined by the passed exponential polynomial ...">applyPhaseFunc()</a>, <em>except</em> that all instance of <img class="formulaInl" alt="$f(r=2)$" src="form_256.png"/> are overriden with phase <img class="formulaInl" alt="$\pi$" src="form_114.png"/>. <br  />
 I.e. </p><p class="formulaDsp">
<img class="formulaDsp" alt="\[ \begin{aligned} |0\mathbf{00}\rangle &amp; \rightarrow \, e^{i f(0)}\,|0\mathbf{00}\rangle \\ |0\mathbf{01}\rangle &amp; \rightarrow \, e^{i f(1)}\,|0\mathbf{01}\rangle \\ |0\mathbf{10}\rangle &amp; \rightarrow \, e^{i \pi} \hspace{12pt} |0\mathbf{10}\rangle \\ |0\mathbf{11}\rangle &amp; \rightarrow \, e^{i f(3)}\,|0\mathbf{11}\rangle \\ |1\mathbf{00}\rangle &amp; \rightarrow \, e^{i f(0)}\,|1\mathbf{00}\rangle \\ |1\mathbf{01}\rangle &amp; \rightarrow \, e^{i f(1)}\,|1\mathbf{01}\rangle \\ |1\mathbf{10}\rangle &amp; \rightarrow \, e^{i \pi} \hspace{12pt} |1\mathbf{10}\rangle \\ |1\mathbf{11}\rangle &amp; \rightarrow \, e^{i f(3)}\,|1\mathbf{11}\rangle \end{aligned} \]" src="form_257.png"/>
</p>
<p> Note that if <code>encoding</code> <b>=</b> <a class="el" href="group__type.html#gga9c91c41aa42ae537995e89ffc616afe1a9aa2a35d92976c7de970506c4d19a96c">TWOS_COMPLEMENT</a>, <em>and</em> <img class="formulaInl" alt="$f(r)$" src="form_245.png"/> features a fractional exponent, then every negative phase index must be overriden. This is checked and enforced by QuEST's validation, <em>unless</em> there are more than 16 targeted qubits, in which case valid input is assumed (due to an otherwise prohibitive performance overhead). <br  />
</p><blockquote class="doxtable">
<p>Overriding phases are checked at each computational basis state of <code>qureg</code> <em>before</em> evaluating the phase function <img class="formulaInl" alt="$f(r)$" src="form_245.png"/>, and hence are useful for avoiding singularities or errors at diverging values of <img class="formulaInl" alt="$r$" src="form_248.png"/>. </p>
</blockquote>
</li>
<li>If <code>qureg</code> is a density matrix <img class="formulaInl" alt="$\rho$" src="form_40.png"/>, the overrides determine the diagonal unitary matrix <img class="formulaInl" alt="$\hat{D}$" src="form_42.png"/>, which is then applied to <code>qureg</code> as <p class="formulaDsp">
<img class="formulaDsp" alt="\[ \rho \; \rightarrow \; \hat{D} \, \rho \hat{D}^\dagger. \]" src="form_258.png"/>
</p>
 This means that with overrides <img class="formulaInl" alt="$f(r_j) \rightarrow \theta$" src="form_259.png"/> and <img class="formulaInl" alt="$f(r_k) \rightarrow \phi$" src="form_260.png"/>, element <img class="formulaInl" alt="$\rho_{jk}$" src="form_254.png"/> is modified to <p class="formulaDsp">
<img class="formulaDsp" alt="\[ \alpha \, |j\rangle\langle k| \; \rightarrow \; \exp(\, i \, (\theta - \phi) \, ) \; \alpha \, |j\rangle\langle k|. \]" src="form_261.png"/>
</p>
<br  />
</li>
<li><p class="startli">The interpreted phase function and list of overrides can be previewed in the QASM log, as a comment. <br  />
 For example: </p><div class="fragment"><div class="line"><a class="code" href="group__qasm.html#ga65bf1906298ca6355e2942f4923d77b6">startRecordingQASM</a>(qureg);</div>
<div class="line"><a class="code" href="group__operator.html#ga467f517abd18dbc3d6fced84c6589161">applyPhaseFunc</a>(qureg, ...);</div>
<div class="line"><a class="code" href="group__qasm.html#gacf139d0a54b1f9e5c2f2feff742b8c76">printRecordedQASM</a>(qureg);</div>
</div><!-- fragment --><p class="startli">may show </p><div class="fragment"><div class="line"><span class="comment">// Here, applyPhaseFunc() multiplied a complex scalar of the form</span></div>
<div class="line"><span class="comment">//     exp(i (0.3 x^(-5) + 4 x^1 + 1 x^3))</span></div>
<div class="line"><span class="comment">//   upon every substate |x&gt;, informed by qubits (under a two&#39;s complement binary encoding)</span></div>
<div class="line"><span class="comment">//     {4, 1, 2, 0}</span></div>
<div class="line"><span class="comment">//   though with overrides</span></div>
<div class="line"><span class="comment">//     |0&gt; -&gt; exp(i 3.14159)</span></div>
<div class="line"><span class="comment">//     |1&gt; -&gt; exp(i (-3.14159))</span></div>
<div class="line"><span class="comment">//     |2&gt; -&gt; exp(i 0)</span></div>
</div><!-- fragment --></li>
</ul>
<p><br  />
</p>
<dl class="section see"><dt>See also</dt><dd><ul>
<li><a class="el" href="group__operator.html#ga467f517abd18dbc3d6fced84c6589161" title="Induces a phase change upon each amplitude of qureg, determined by the passed exponential polynomial ...">applyPhaseFunc()</a> for full doc on how <img class="formulaInl" alt="$f(r)$" src="form_245.png"/> is evaluated.</li>
<li><a class="el" href="group__operator.html#ga008a46d178a5a9691e2f5d363e3f518f" title="Induces a phase change upon each amplitude of qureg, determined by a multi-variable exponential polyn...">applyMultiVarPhaseFunc()</a> for multi-variable exponential polynomial phase functions.</li>
<li><a class="el" href="group__operator.html#gac4df97d8c125c8cc65df720f67b2bf69" title="Induces a phase change upon each amplitude of qureg, determined by a named (and potentially multi-var...">applyNamedPhaseFunc()</a> for a set of specific phase functions.</li>
<li><a class="el" href="group__operator.html#gad2e953390342cd361cfb4064d47715e6" title="Apply a diagonal operator, which is possibly non-unitary and non-Hermitian, to the entire qureg.">applyDiagonalOp()</a> to apply a non-unitary diagonal <a class="el" href="group__operator.html" title="Non-physical operators which may be non-unitary, non-norm-preserving, even non-Hermitian.">Operators</a>.</li>
</ul>
</dd></dl>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in,out]</td><td class="paramname">qureg</td><td>the state-vector or density matrix to be modified </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">qubits</td><td>a list of the indices of the qubits which will inform <img class="formulaInl" alt="$r$" src="form_248.png"/> for each amplitude in <code>qureg</code> </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">numQubits</td><td>the length of list <code>qubits</code> </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">encoding</td><td>the <a class="el" href="group__type.html#ga9c91c41aa42ae537995e89ffc616afe1" title="Flags for specifying how the bits in sub-register computational basis states are mapped to indices in...">bitEncoding</a> under which to infer the binary value <img class="formulaInl" alt="$r$" src="form_248.png"/> from the bits of <code>qubits</code> in each basis state of <code>qureg</code> </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">coeffs</td><td>the coefficients of the exponential polynomial phase function <img class="formulaInl" alt="$f(r)$" src="form_245.png"/> </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">exponents</td><td>the exponents of the exponential polynomial phase function <img class="formulaInl" alt="$f(r)$" src="form_245.png"/> </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">numTerms</td><td>the length of list <code>coeffs</code>, which must be the same as that of <code>exponents</code> </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">overrideInds</td><td>a list of sub-state indices (values of <img class="formulaInl" alt="$r$" src="form_248.png"/>) of which to explicit set the phase change </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">overridePhases</td><td>a list of replacement phase changes, for the corresponding <img class="formulaInl" alt="$r$" src="form_248.png"/> values in <code>overrideInds</code> (one to one) </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">numOverrides</td><td>the lengths of lists <code>overrideInds</code> and <code>overridePhases</code> </td></tr>
  </table>
  </dd>
</dl>
<dl class="exception"><dt>Exceptions</dt><dd>
  <table class="exception">
    <tr><td class="paramname"><a class="el" href="group__debug.html#ga51a64b05d31ef9bcf6a63ce26c0092db" title="An internal function called when invalid arguments are passed to a QuEST API call,...">invalidQuESTInputError()</a></td><td><ul>
<li>if any qubit in <code>qubits</code> has an invalid index (i.e. does not satisfy 0 &lt;= qubit &lt; <code>qureg.numQubitsRepresented</code>)</li>
<li>if the elements of <code>qubits</code> are not unique</li>
<li>if <code>numQubits</code> &lt; 0 or <code>numQubits</code> &gt;= <code>qureg.numQubitsRepresented</code></li>
<li>if <code>encoding</code> is not a valid <a class="el" href="group__type.html#ga9c91c41aa42ae537995e89ffc616afe1" title="Flags for specifying how the bits in sub-register computational basis states are mapped to indices in...">bitEncoding</a></li>
<li>if <code>encoding</code> is not compatible with <code>numQubits</code> (i.e. <code>TWOS_COMPLEMENT</code> with 1 qubit)</li>
<li>if <code>numTerms</code> &lt;= 0</li>
<li>if any value in <code>overrideInds</code> is not producible by <code>qubits</code> under the given <code>encoding</code> (e.g. 2 unsigned qubits cannot represent index 9)</li>
<li>if <code>numOverrides</code> &lt; 0</li>
<li>if <code>exponents</code> contains a negative power and the (consequently diverging) zero index is not contained in <code>overrideInds</code> </li>
<li>if <code>encoding</code> is <a class="el" href="group__type.html#gga9c91c41aa42ae537995e89ffc616afe1a9aa2a35d92976c7de970506c4d19a96c">TWOS_COMPLEMENT</a>, and <code>exponents</code> contains a fractional number, but <code>overrideInds</code> does not contain every possible negative index (checked only up to 16 targeted qubits) </li>
</ul>
</td></tr>
  </table>
  </dd>
</dl>
<dl class="section author"><dt>Author</dt><dd>Tyson Jones </dd></dl>

<p class="definition">Definition at line <a class="el" href="QuEST_8c_source.html#l00743">743</a> of file <a class="el" href="QuEST_8c_source.html">QuEST.c</a>.</p>
<div class="fragment"><div class="line"><a name="l00743"></a><span class="lineno">  743</span>&#160;                                                                                                                                                                                                                      {</div>
<div class="line"><a name="l00744"></a><span class="lineno">  744</span>&#160;    <a class="code" href="QuEST__validation_8c.html#a9e7e85cfc36e3ce1f456a840a217bfd9">validateMultiQubits</a>(qureg, qubits, numQubits, __func__);</div>
<div class="line"><a name="l00745"></a><span class="lineno">  745</span>&#160;    <a class="code" href="QuEST__validation_8c.html#aa8a0654753645b30d6fed4ed0f4e7d16">validateBitEncoding</a>(numQubits, encoding, __func__);</div>
<div class="line"><a name="l00746"></a><span class="lineno">  746</span>&#160;    <a class="code" href="QuEST__validation_8c.html#a12511cc6d45e137de6542d4721f1fa4e">validatePhaseFuncOverrides</a>(numQubits, encoding, overrideInds, numOverrides, __func__);</div>
<div class="line"><a name="l00747"></a><span class="lineno">  747</span>&#160;    <a class="code" href="QuEST__validation_8c.html#a91dad925cb9383384f135b936e5a7f43">validatePhaseFuncTerms</a>(numQubits, encoding, coeffs, exponents, numTerms, overrideInds, numOverrides, __func__);</div>
<div class="line"><a name="l00748"></a><span class="lineno">  748</span>&#160; </div>
<div class="line"><a name="l00749"></a><span class="lineno">  749</span>&#160;    <span class="keywordtype">int</span> conj = 0;</div>
<div class="line"><a name="l00750"></a><span class="lineno">  750</span>&#160;    <a class="code" href="QuEST__internal_8h.html#a9d7928473aca695a614e9c24d903e578">statevec_applyPhaseFuncOverrides</a>(qureg, qubits, numQubits, encoding, coeffs, exponents, numTerms, overrideInds, overridePhases, numOverrides, conj);</div>
<div class="line"><a name="l00751"></a><span class="lineno">  751</span>&#160;    <span class="keywordflow">if</span> (qureg.<a class="code" href="structQureg.html#acf78445e9435d09f44f0cc832c6aee79">isDensityMatrix</a>) {</div>
<div class="line"><a name="l00752"></a><span class="lineno">  752</span>&#160;        conj = 1;</div>
<div class="line"><a name="l00753"></a><span class="lineno">  753</span>&#160;        <a class="code" href="QuEST__common_8c.html#acf1c651a4359a370a2d9b3e1e1ebd430">shiftIndices</a>(qubits, numQubits, qureg.<a class="code" href="structQureg.html#ad08dff5316b8937f4b2a1417591543dc">numQubitsRepresented</a>);</div>
<div class="line"><a name="l00754"></a><span class="lineno">  754</span>&#160;        <a class="code" href="QuEST__internal_8h.html#a9d7928473aca695a614e9c24d903e578">statevec_applyPhaseFuncOverrides</a>(qureg, qubits, numQubits, encoding, coeffs, exponents, numTerms, overrideInds, overridePhases, numOverrides, conj);</div>
<div class="line"><a name="l00755"></a><span class="lineno">  755</span>&#160;        <a class="code" href="QuEST__common_8c.html#acf1c651a4359a370a2d9b3e1e1ebd430">shiftIndices</a>(qubits, numQubits, - qureg.<a class="code" href="structQureg.html#ad08dff5316b8937f4b2a1417591543dc">numQubitsRepresented</a>);</div>
<div class="line"><a name="l00756"></a><span class="lineno">  756</span>&#160;    }</div>
<div class="line"><a name="l00757"></a><span class="lineno">  757</span>&#160; </div>
<div class="line"><a name="l00758"></a><span class="lineno">  758</span>&#160;    <a class="code" href="QuEST__qasm_8c.html#a383ddaecc94e1ce4a6fdbdbabeaa3131">qasm_recordPhaseFunc</a>(qureg, qubits, numQubits, encoding, coeffs, exponents, numTerms, overrideInds, overridePhases, numOverrides);</div>
<div class="line"><a name="l00759"></a><span class="lineno">  759</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST_8h_source.html#l00325">Qureg::isDensityMatrix</a>, <a class="el" href="QuEST_8h_source.html#l00327">Qureg::numQubitsRepresented</a>, <a class="el" href="QuEST__qasm_8c_source.html#l00490">qasm_recordPhaseFunc()</a>, <a class="el" href="QuEST__common_8c_source.html#l00156">shiftIndices()</a>, <a class="el" href="QuEST__cpu_8c_source.html#l04268">statevec_applyPhaseFuncOverrides()</a>, <a class="el" href="QuEST__validation_8c_source.html#l00966">validateBitEncoding()</a>, <a class="el" href="QuEST__validation_8c_source.html#l00444">validateMultiQubits()</a>, <a class="el" href="QuEST__validation_8c_source.html#l00862">validatePhaseFuncOverrides()</a>, and <a class="el" href="QuEST__validation_8c_source.html#l00773">validatePhaseFuncTerms()</a>.</p>

<p class="reference">Referenced by <a class="el" href="test__operators_8cpp_source.html#l03001">TEST_CASE()</a>.</p>

</div>
</div>
<a id="ga26db8b8a8a242d388c291e50d228ab18"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga26db8b8a8a242d388c291e50d228ab18">&#9670;&nbsp;</a></span>applyProjector()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void applyProjector </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a>&#160;</td>
          <td class="paramname"><em>qureg</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>qubit</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>outcome</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Force the target <code>qubit</code> of <code>qureg</code> into the given classical <code>outcome</code>, via a non-renormalising projection. </p>
<p>This function zeroes all amplitudes in the state-vector or density-matrix which correspond to the opposite <code>outcome</code> given. Unlike <a class="el" href="group__normgate.html#ga34457f7f62ccd75fb7d3fe67cd2f815a" title="Updates qureg to be consistent with measuring measureQubit in the given outcome (0 or 1),...">collapseToOutcome()</a>, it does not thereafter normalise <code>qureg</code>, and hence may leave it in a non-physical state.</p>
<p>Note there is no requirement that the <code>outcome</code> state has a non-zero proability, and hence this function may leave <code>qureg</code> in a blank state, like that produced by <a class="el" href="group__init.html#gada7230491a50cd409f8b00f5ee1db953" title="Initialises a qureg to have all-zero-amplitudes.">initBlankState()</a>.</p>
<dl class="section see"><dt>See also</dt><dd><ul>
<li><a class="el" href="group__normgate.html#ga34457f7f62ccd75fb7d3fe67cd2f815a" title="Updates qureg to be consistent with measuring measureQubit in the given outcome (0 or 1),...">collapseToOutcome()</a> for a norm-preserving equivalent, like a forced measurement</li>
</ul>
</dd></dl>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in,out]</td><td class="paramname">qureg</td><td>a state-vector or density matrix to modify </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">qubit</td><td>the qubit to which to apply the projector </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">the</td><td>single-qubit outcome (<code>0</code> or <code>1</code>) to project <code>qubit</code> into </td></tr>
  </table>
  </dd>
</dl>
<dl class="exception"><dt>Exceptions</dt><dd>
  <table class="exception">
    <tr><td class="paramname"><a class="el" href="group__debug.html#ga51a64b05d31ef9bcf6a63ce26c0092db" title="An internal function called when invalid arguments are passed to a QuEST API call,...">invalidQuESTInputError()</a></td><td><ul>
<li>if <code>qubit</code> is outside [0, <code>qureg.numQubitsRepresented</code>)</li>
<li>if <code>outcome</code> is not in {0,1} </li>
</ul>
</td></tr>
  </table>
  </dd>
</dl>
<dl class="section author"><dt>Author</dt><dd>Tyson Jones </dd></dl>

<p class="definition">Definition at line <a class="el" href="QuEST_8c_source.html#l00888">888</a> of file <a class="el" href="QuEST_8c_source.html">QuEST.c</a>.</p>
<div class="fragment"><div class="line"><a name="l00888"></a><span class="lineno">  888</span>&#160;                                                         {</div>
<div class="line"><a name="l00889"></a><span class="lineno">  889</span>&#160;    <a class="code" href="QuEST__validation_8c.html#ac31c45c5a31c523be0eb26abba6cf598">validateTarget</a>(qureg, qubit, __func__);</div>
<div class="line"><a name="l00890"></a><span class="lineno">  890</span>&#160;    <a class="code" href="QuEST__validation_8c.html#ad613c75ff252a88e54f911053bd2032c">validateOutcome</a>(outcome, __func__);</div>
<div class="line"><a name="l00891"></a><span class="lineno">  891</span>&#160;     </div>
<div class="line"><a name="l00892"></a><span class="lineno">  892</span>&#160;    <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> renorm = 1;</div>
<div class="line"><a name="l00893"></a><span class="lineno">  893</span>&#160;    </div>
<div class="line"><a name="l00894"></a><span class="lineno">  894</span>&#160;    <span class="keywordflow">if</span> (qureg.<a class="code" href="structQureg.html#acf78445e9435d09f44f0cc832c6aee79">isDensityMatrix</a>)</div>
<div class="line"><a name="l00895"></a><span class="lineno">  895</span>&#160;        <a class="code" href="QuEST__internal_8h.html#a5658f2ecbbd4ea425db5f7dc7fc4ba92">densmatr_collapseToKnownProbOutcome</a>(qureg, qubit, outcome, renorm);</div>
<div class="line"><a name="l00896"></a><span class="lineno">  896</span>&#160;    <span class="keywordflow">else</span></div>
<div class="line"><a name="l00897"></a><span class="lineno">  897</span>&#160;        <a class="code" href="QuEST__internal_8h.html#a008becc4a18f868340836e0ab9fd6df6">statevec_collapseToKnownProbOutcome</a>(qureg, qubit, outcome, renorm);</div>
<div class="line"><a name="l00898"></a><span class="lineno">  898</span>&#160;    </div>
<div class="line"><a name="l00899"></a><span class="lineno">  899</span>&#160;    <a class="code" href="QuEST__qasm_8c.html#a9a385fde708958617bbeb599064b8dcb">qasm_recordComment</a>(qureg, <span class="stringliteral">&quot;Here, qubit %d was un-physically projected into outcome %d&quot;</span>, qubit, outcome);</div>
<div class="line"><a name="l00900"></a><span class="lineno">  900</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST__cpu_8c_source.html#l00791">densmatr_collapseToKnownProbOutcome()</a>, <a class="el" href="QuEST_8h_source.html#l00325">Qureg::isDensityMatrix</a>, <a class="el" href="QuEST__qasm_8c_source.html#l00121">qasm_recordComment()</a>, <a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l01368">statevec_collapseToKnownProbOutcome()</a>, <a class="el" href="QuEST__validation_8c_source.html#l00523">validateOutcome()</a>, and <a class="el" href="QuEST__validation_8c_source.html#l00400">validateTarget()</a>.</p>

<p class="reference">Referenced by <a class="el" href="test__operators_8cpp_source.html#l03214">TEST_CASE()</a>.</p>

</div>
</div>
<a id="ga9bc8c4ab44f8233b5766208a0b1c0776"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga9bc8c4ab44f8233b5766208a0b1c0776">&#9670;&nbsp;</a></span>applyQFT()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void applyQFT </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a>&#160;</td>
          <td class="paramname"><em>qureg</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int *&#160;</td>
          <td class="paramname"><em>qubits</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>numQubits</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Applies the quantum Fourier transform (QFT) to a specific subset of qubits of the register <code>qureg</code>. </p>
<p>The order of <code>qubits</code> affects the ultimate unitary. The canonical full-state QFT (<a class="el" href="group__operator.html#gaf26f32c25db760065486188497c1da8b" title="Applies the quantum Fourier transform (QFT) to the entirety of qureg.">applyFullQFT()</a>) is achieved by targeting every qubit in increasing order.</p>
<p>The effected unitary circuit (shown here for <code>numQubits</code> <b>= 4</b>) resembles </p><p class="formulaDsp">
<img class="formulaDsp" alt="\[ \begin{tikzpicture}[scale=.5] \draw (-2, 5) -- (23, 5); \node[draw=none] at (-4,5) {qubits[3]}; \draw (-2, 3) -- (23, 3); \node[draw=none] at (-4,3) {qubits[2]}; \draw (-2, 1) -- (23, 1); \node[draw=none] at (-4,1) {qubits[1]}; \draw (-2, -1) -- (23, -1); \node[draw=none] at (-4,-1) {qubits[0]}; \draw[fill=white] (-1, 4) -- (-1, 6) -- (1, 6) -- (1,4) -- cycle; \node[draw=none] at (0, 5) {H}; \draw(2, 5) -- (2, 3); \draw[fill=black] (2, 5) circle (.2); \draw[fill=black] (2, 3) circle (.2); \draw(4, 5) -- (4, 1); \draw[fill=black] (4, 5) circle (.2); \draw[fill=black] (4, 1) circle (.2); \draw(6, 5) -- (6, -1); \draw[fill=black] (6, 5) circle (.2); \draw[fill=black] (6, -1) circle (.2); \draw[fill=white] (-1+8, 4-2) -- (-1+8, 6-2) -- (1+8, 6-2) -- (1+8,4-2) -- cycle; \node[draw=none] at (8, 5-2) {H}; \draw(10, 5-2) -- (10, 3-2); \draw[fill=black] (10, 5-2) circle (.2); \draw[fill=black] (10, 3-2) circle (.2); \draw(12, 5-2) -- (12, 3-4); \draw[fill=black] (12, 5-2) circle (.2); \draw[fill=black] (12, 3-4) circle (.2); \draw[fill=white] (-1+8+6, 4-4) -- (-1+8+6, 6-4) -- (1+8+6, 6-4) -- (1+8+6,4-4) -- cycle; \node[draw=none] at (8+6, 5-4) {H}; \draw(16, 5-2-2) -- (16, 3-4); \draw[fill=black] (16, 5-2-2) circle (.2); \draw[fill=black] (16, 3-4) circle (.2); \draw[fill=white] (-1+8+6+4, 4-4-2) -- (-1+8+6+4, 6-4-2) -- (1+8+6+4, 6-4-2) -- (1+8+6+4,4-4-2) -- cycle; \node[draw=none] at (8+6+4, 5-4-2) {H}; \draw (20, 5) -- (20, -1); \draw (20 - .35, 5 + .35) -- (20 + .35, 5 - .35); \draw (20 - .35, 5 - .35) -- (20 + .35, 5 + .35); \draw (20 - .35, -1 + .35) -- (20 + .35, -1 - .35); \draw (20 - .35, -1 - .35) -- (20 + .35, -1 + .35); \draw (22, 3) -- (22, 1); \draw (22 - .35, 3 + .35) -- (22 + .35, 3 - .35); \draw (22 - .35, 3 - .35) -- (22 + .35, 3 + .35); \draw (22 - .35, 1 + .35) -- (22 + .35, 1 - .35); \draw (22 - .35, 1 - .35) -- (22 + .35, 1 + .35); \end{tikzpicture} \]" src="form_298.png"/>
</p>
<p> though is performed more efficiently.</p>
<ul>
<li>If <code>qureg</code> is a state-vector, the output amplitudes are a kronecker product of the discrete Fourier transform (DFT) acting upon the targeted amplitudes, and the remaining. <br  />
 Precisely,<ul>
<li>let <img class="formulaInl" alt="$|x,r\rangle$" src="form_299.png"/> represent a computational basis state where <img class="formulaInl" alt="$x$" src="form_300.png"/> is the binary value of the targeted qubits, and <img class="formulaInl" alt="$r$" src="form_248.png"/> is the binary value of the remaining qubits.</li>
<li>let <img class="formulaInl" alt="$|x_j,r_j\rangle$" src="form_301.png"/> be the <img class="formulaInl" alt="$j\text{th}$" src="form_302.png"/> such state.</li>
<li>let <img class="formulaInl" alt="$n =$" src="form_303.png"/> <code>numQubits</code>, and <img class="formulaInl" alt="$N =$" src="form_304.png"/> <code>qureg.numQubitsRepresented</code>.<br  />
Then, this function effects <p class="formulaDsp">
<img class="formulaDsp" alt="\[ (\text{QFT}\otimes 1) \, \left( \sum\limits_{j=0}^{2^N-1} \alpha_j \, |x_j,r_j\rangle \right) = \frac{1}{\sqrt{2^n}} \sum\limits_{j=0}^{2^N-1} \alpha_j \left( \sum\limits_{y=0}^{2^n-1} e^{2 \pi \, i \, x_j \, y / 2^n} \; |y,r_j \rangle \right) \]" src="form_305.png"/>
</p>
</li>
</ul>
</li>
<li>If <code>qureg</code> is a density matrix <img class="formulaInl" alt="$\rho$" src="form_40.png"/>, it will be changed under the unitary action of the QFT. This can be imagined as each mixed state-vector undergoing the DFT on its amplitudes. This is true even if <code>qureg</code> is unnormalised. <p class="formulaDsp">
<img class="formulaDsp" alt="\[ \rho \; \rightarrow \; \text{QFT} \; \rho \; \text{QFT}^{\dagger} \]" src="form_296.png"/>
</p>
</li>
</ul>
<blockquote class="doxtable">
<p>This function merges contiguous controlled-phase gates into single invocations of <a class="el" href="group__operator.html#gac4df97d8c125c8cc65df720f67b2bf69" title="Induces a phase change upon each amplitude of qureg, determined by a named (and potentially multi-var...">applyNamedPhaseFunc()</a>, and hence is significantly faster than performing the QFT circuit directly. </p>
</blockquote>
<blockquote class="doxtable">
<p>Furthermore, in distributed mode, this function requires only <img class="formulaInl" alt="$\log_2(\text{\#nodes})$" src="form_297.png"/> rounds of pair-wise communication, and hence is exponentially faster than directly performing the DFT on the amplitudes of <code>qureg</code>. </p>
</blockquote>
<dl class="section see"><dt>See also</dt><dd><ul>
<li><a class="el" href="group__operator.html#gaf26f32c25db760065486188497c1da8b" title="Applies the quantum Fourier transform (QFT) to the entirety of qureg.">applyFullQFT()</a> to apply the QFT to the entirety of <code>qureg</code>.</li>
</ul>
</dd></dl>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in,out]</td><td class="paramname">qureg</td><td>a state-vector or density matrix to modify </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">qubits</td><td>a list of the qubits to operate the QFT upon </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">numQubits</td><td>the length of list <code>qubits</code> </td></tr>
  </table>
  </dd>
</dl>
<dl class="exception"><dt>Exceptions</dt><dd>
  <table class="exception">
    <tr><td class="paramname"><a class="el" href="group__debug.html#ga51a64b05d31ef9bcf6a63ce26c0092db" title="An internal function called when invalid arguments are passed to a QuEST API call,...">invalidQuESTInputError()</a></td><td><ul>
<li>if any qubit in <code>qubits</code> is invalid, i.e. outside <b>[0, </b><code>qureg.numQubitsRepresented</code><b>)</b></li>
<li>if <code>qubits</code> contain any repetitions</li>
<li>if <code>numQubits</code> <b>&lt; 1</b></li>
<li>if <code>numQubits</code> <b>&gt;</b><code>qureg.numQubitsRepresented</code> </li>
</ul>
</td></tr>
    <tr><td class="paramname">segmentation-fault</td><td><ul>
<li>if <code>qubits</code> contains fewer elements than <code>numQubits</code> </li>
</ul>
</td></tr>
  </table>
  </dd>
</dl>
<dl class="section author"><dt>Author</dt><dd>Tyson Jones </dd></dl>

<p class="definition">Definition at line <a class="el" href="QuEST_8c_source.html#l00866">866</a> of file <a class="el" href="QuEST_8c_source.html">QuEST.c</a>.</p>
<div class="fragment"><div class="line"><a name="l00866"></a><span class="lineno">  866</span>&#160;                                                       {</div>
<div class="line"><a name="l00867"></a><span class="lineno">  867</span>&#160;    <a class="code" href="QuEST__validation_8c.html#a6776217a5f7ba38b56175cf6db0f96e0">validateMultiTargets</a>(qureg, qubits, numQubits, __func__);</div>
<div class="line"><a name="l00868"></a><span class="lineno">  868</span>&#160;    </div>
<div class="line"><a name="l00869"></a><span class="lineno">  869</span>&#160;    <a class="code" href="QuEST__qasm_8c.html#a9a385fde708958617bbeb599064b8dcb">qasm_recordComment</a>(qureg, <span class="stringliteral">&quot;Beginning of QFT circuit&quot;</span>);</div>
<div class="line"><a name="l00870"></a><span class="lineno">  870</span>&#160;        </div>
<div class="line"><a name="l00871"></a><span class="lineno">  871</span>&#160;    <a class="code" href="QuEST__common_8c.html#a2b78ab7dd04eab615a0d7c796e73ae8c">agnostic_applyQFT</a>(qureg, qubits, numQubits);</div>
<div class="line"><a name="l00872"></a><span class="lineno">  872</span>&#160; </div>
<div class="line"><a name="l00873"></a><span class="lineno">  873</span>&#160;    <a class="code" href="QuEST__qasm_8c.html#a9a385fde708958617bbeb599064b8dcb">qasm_recordComment</a>(qureg, <span class="stringliteral">&quot;End of QFT circuit&quot;</span>);</div>
<div class="line"><a name="l00874"></a><span class="lineno">  874</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST__common_8c_source.html#l00849">agnostic_applyQFT()</a>, <a class="el" href="QuEST__qasm_8c_source.html#l00121">qasm_recordComment()</a>, and <a class="el" href="QuEST__validation_8c_source.html#l00428">validateMultiTargets()</a>.</p>

<p class="reference">Referenced by <a class="el" href="test__operators_8cpp_source.html#l03349">TEST_CASE()</a>.</p>

</div>
</div>
<a id="ga35b6321c578a8c69470132b5ee95f930"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga35b6321c578a8c69470132b5ee95f930">&#9670;&nbsp;</a></span>applyTrotterCircuit()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void applyTrotterCircuit </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a>&#160;</td>
          <td class="paramname"><em>qureg</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="structPauliHamil.html">PauliHamil</a>&#160;</td>
          <td class="paramname"><em>hamil</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>&#160;</td>
          <td class="paramname"><em>time</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>order</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>reps</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Applies a trotterisation of unitary evolution <img class="formulaInl" alt="$ \exp(-i \, \text{hamil} \, \text{time}) $" src="form_235.png"/> to <code>qureg</code>. </p>
<p>This is a sequence of unitary operators, effected by <a class="el" href="group__unitary.html#ga34aa4865c92f9aa5d898c91286c9eca5" title="Apply a multi-qubit multi-Pauli rotation, also known as a Pauli gadget, on a selected number of qubit...">multiRotatePauli()</a>, which together approximate the action of full unitary-time evolution under the given Hamiltonian.</p>
<p>Notate <img class="formulaInl" alt="$ \text{hamil} = \sum_j^N c_j \, \hat \sigma_j $" src="form_236.png"/> where <img class="formulaInl" alt="$c_j$" src="form_237.png"/> is a real coefficient in <code>hamil</code>, <img class="formulaInl" alt="$\hat \sigma_j$" src="form_238.png"/> is the corresponding product of Pauli operators, of which there are a total <img class="formulaInl" alt="$N$" src="form_30.png"/>. Then, <code>order=1</code> performs first-order Trotterisation, whereby </p><p class="formulaDsp">
<img class="formulaDsp" alt="\[ \exp(-i \, \text{hamil} \, \text{time}) \approx \prod\limits^{\text{reps}} \prod\limits_{j=1}^{N} \exp(-i \, c_j \, \text{time} \, \hat\sigma_j / \text{reps}) \]" src="form_239.png"/>
</p>
<p> <code>order=2</code> performs the lowest order "symmetrized" Suzuki decomposition, whereby </p><p class="formulaDsp">
<img class="formulaDsp" alt="\[ \exp(-i \, \text{hamil} \, \text{time}) \approx \prod\limits^{\text{reps}} \left[ \prod\limits_{j=1}^{N} \exp(-i \, c_j \, \text{time} \, \hat\sigma_j / (2 \, \text{reps})) \prod\limits_{j=N}^{1} \exp(-i \, c_j \, \text{time} \, \hat\sigma_j / (2 \, \text{reps})) \right] \]" src="form_240.png"/>
</p>
<p> Greater even values of <code>order</code> specify higher-order symmetrized decompositions <img class="formulaInl" alt="$ S[\text{time}, \text{order}, \text{reps}] $" src="form_241.png"/> which satisfy </p><p class="formulaDsp">
<img class="formulaDsp" alt="\[ S[\text{time}, \text{order}, 1] = \left( \prod\limits^2 S[p \, \text{time}, \text{order}-2, 1] \right) S[ (1-4p)\,\text{time}, \text{order}-2, 1] \left( \prod\limits^2 S[p \, \text{time}, \text{order}-2, 1] \right) \]" src="form_242.png"/>
</p>
<p> and </p><p class="formulaDsp">
<img class="formulaDsp" alt="\[ S[\text{time}, \text{order}, \text{reps}] = \prod\limits^{\text{reps}} S[\text{time}/\text{reps}, \text{order}, 1] \]" src="form_243.png"/>
</p>
<p> where <img class="formulaInl" alt="$ p = \left( 4 - 4^{1/(\text{order}-1)} \right)^{-1} $" src="form_244.png"/>.</p>
<p>These formulations are taken from 'Finding Exponential Product Formulas of Higher Orders', Naomichi Hatano and Masuo Suzuki (2005) (<a href="https://arxiv.org/abs/math-ph/0506007">arXiv</a>).</p>
<p>Note that the applied Trotter circuit is captured by QASM, if QASM logging is enabled on <code>qureg</code>. <br  />
For example: </p><div class="fragment"><div class="line"><a class="code" href="group__qasm.html#ga65bf1906298ca6355e2942f4923d77b6">startRecordingQASM</a>(qureg);</div>
<div class="line"><a class="code" href="group__operator.html#ga35b6321c578a8c69470132b5ee95f930">applyTrotterCircuit</a>(qureg, hamil, 1, 2, 1);</div>
<div class="line"><a class="code" href="group__qasm.html#gacf139d0a54b1f9e5c2f2feff742b8c76">printRecordedQASM</a>(qureg);</div>
</div><!-- fragment --><p>may show </p><div class="fragment"><div class="line"><span class="comment">// Beginning of Trotter circuit (time 1, order 2, 1 repetitions).</span></div>
<div class="line"><span class="comment">// Here, a multiRotatePauli with angle 0.5 and paulis X Y I  was applied.</span></div>
<div class="line"><span class="comment">// Here, a multiRotatePauli with angle -0.5 and paulis I Z X  was applied.</span></div>
<div class="line"><span class="comment">// Here, a multiRotatePauli with angle -0.5 and paulis I Z X  was applied.</span></div>
<div class="line"><span class="comment">// Here, a multiRotatePauli with angle 0.5 and paulis X Y I  was applied.</span></div>
<div class="line"><span class="comment">// End of Trotter circuit</span></div>
</div><!-- fragment --><p><br  />
</p>
<dl class="section see"><dt>See also</dt><dd><ul>
<li><a class="el" href="group__type.html#ga35b28710877c462927366fa602e591cb" title="Dynamically allocates a Hamiltonian expressed as a real-weighted sum of products of Pauli operators.">createPauliHamil()</a></li>
</ul>
</dd></dl>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in,out]</td><td class="paramname">qureg</td><td>the register to modify under the approximate unitary-time evolution </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">hamil</td><td>the hamiltonian under which to approxiamte unitary-time evolution </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">time</td><td>the target evolution time, which is permitted to be both positive and negative. </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">order</td><td>the order of Trotter-Suzuki decomposition to use. Higher orders (necessarily even) are more accurate but prescribe an exponentially increasing number of gates. </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">reps</td><td>the number of repetitions of the decomposition of the given order. This improves the accuracy but prescribes a linearly increasing number of gates. </td></tr>
  </table>
  </dd>
</dl>
<dl class="exception"><dt>Exceptions</dt><dd>
  <table class="exception">
    <tr><td class="paramname"><a class="el" href="group__debug.html#ga51a64b05d31ef9bcf6a63ce26c0092db" title="An internal function called when invalid arguments are passed to a QuEST API call,...">invalidQuESTInputError()</a></td><td><ul>
<li>if <code>qureg.numQubitsRepresented</code> != <code>hamil.numQubits</code> </li>
<li>if <code>hamil</code> contains invalid parameters or Pauli codes,</li>
<li>if <code>order</code> is not in {1, 2, 4, 6, ...}</li>
<li>or if <code>reps</code> &lt;= 0 </li>
</ul>
</td></tr>
  </table>
  </dd>
</dl>
<dl class="section author"><dt>Author</dt><dd>Tyson Jones </dd></dl>

<p class="definition">Definition at line <a class="el" href="QuEST_8c_source.html#l01070">1070</a> of file <a class="el" href="QuEST_8c_source.html">QuEST.c</a>.</p>
<div class="fragment"><div class="line"><a name="l01070"></a><span class="lineno"> 1070</span>&#160;                                                                                         {</div>
<div class="line"><a name="l01071"></a><span class="lineno"> 1071</span>&#160;    <a class="code" href="QuEST__validation_8c.html#a82b142fe77ba20c87142274f32e57689">validateTrotterParams</a>(order, reps, __func__);</div>
<div class="line"><a name="l01072"></a><span class="lineno"> 1072</span>&#160;    <a class="code" href="QuEST__validation_8c.html#a066b0c4d0b02a0f3b9be7e5c68d9de6a">validatePauliHamil</a>(hamil, __func__);</div>
<div class="line"><a name="l01073"></a><span class="lineno"> 1073</span>&#160;    <a class="code" href="QuEST__validation_8c.html#a2b88b068a8242ee28da42c7324cdd078">validateMatchingQuregPauliHamilDims</a>(qureg, hamil, __func__);</div>
<div class="line"><a name="l01074"></a><span class="lineno"> 1074</span>&#160;    </div>
<div class="line"><a name="l01075"></a><span class="lineno"> 1075</span>&#160;    <a class="code" href="QuEST__qasm_8c.html#a9a385fde708958617bbeb599064b8dcb">qasm_recordComment</a>(qureg, </div>
<div class="line"><a name="l01076"></a><span class="lineno"> 1076</span>&#160;        <span class="stringliteral">&quot;Beginning of Trotter circuit (time %g, order %d, %d repetitions).&quot;</span>,</div>
<div class="line"><a name="l01077"></a><span class="lineno"> 1077</span>&#160;        time, order, reps);</div>
<div class="line"><a name="l01078"></a><span class="lineno"> 1078</span>&#160;        </div>
<div class="line"><a name="l01079"></a><span class="lineno"> 1079</span>&#160;    <a class="code" href="QuEST__common_8c.html#a8a8e789585651f90fcc587042d4cdfb8">agnostic_applyTrotterCircuit</a>(qureg, hamil, time, order, reps);</div>
<div class="line"><a name="l01080"></a><span class="lineno"> 1080</span>&#160; </div>
<div class="line"><a name="l01081"></a><span class="lineno"> 1081</span>&#160;    <a class="code" href="QuEST__qasm_8c.html#a9a385fde708958617bbeb599064b8dcb">qasm_recordComment</a>(qureg, <span class="stringliteral">&quot;End of Trotter circuit&quot;</span>);</div>
<div class="line"><a name="l01082"></a><span class="lineno"> 1082</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST__common_8c_source.html#l00840">agnostic_applyTrotterCircuit()</a>, <a class="el" href="QuEST__qasm_8c_source.html#l00121">qasm_recordComment()</a>, <a class="el" href="QuEST__validation_8c_source.html#l00660">validateMatchingQuregPauliHamilDims()</a>, <a class="el" href="QuEST__validation_8c_source.html#l00655">validatePauliHamil()</a>, and <a class="el" href="QuEST__validation_8c_source.html#l00703">validateTrotterParams()</a>.</p>

<p class="reference">Referenced by <a class="el" href="test__operators_8cpp_source.html#l03500">TEST_CASE()</a>.</p>

</div>
</div>
</div><!-- contents -->
<div class="ttc" id="agroup__operator_html_ga467f517abd18dbc3d6fced84c6589161"><div class="ttname"><a href="group__operator.html#ga467f517abd18dbc3d6fced84c6589161">applyPhaseFunc</a></div><div class="ttdeci">void applyPhaseFunc(Qureg qureg, int *qubits, int numQubits, enum bitEncoding encoding, qreal *coeffs, qreal *exponents, int numTerms)</div><div class="ttdoc">Induces a phase change upon each amplitude of qureg, determined by the passed exponential polynomial ...</div><div class="ttdef"><b>Definition:</b> <a href="QuEST_8c_source.html#l00726">QuEST.c:726</a></div></div>
<div class="ttc" id="aQuEST__validation_8c_html_ac31c45c5a31c523be0eb26abba6cf598"><div class="ttname"><a href="QuEST__validation_8c.html#ac31c45c5a31c523be0eb26abba6cf598">validateTarget</a></div><div class="ttdeci">void validateTarget(Qureg qureg, int targetQubit, const char *caller)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__validation_8c_source.html#l00400">QuEST_validation.c:400</a></div></div>
<div class="ttc" id="agroup__operator_html_ga2fbaec3bb21cc01f7a2a4ed2aa911ebf"><div class="ttname"><a href="group__operator.html#ga2fbaec3bb21cc01f7a2a4ed2aa911ebf">applyNamedPhaseFuncOverrides</a></div><div class="ttdeci">void applyNamedPhaseFuncOverrides(Qureg qureg, int *qubits, int *numQubitsPerReg, int numRegs, enum bitEncoding encoding, enum phaseFunc functionNameCode, long long int *overrideInds, qreal *overridePhases, int numOverrides)</div><div class="ttdoc">Induces a phase change upon each amplitude of qureg, determined by a named (and potentially multi-var...</div><div class="ttdef"><b>Definition:</b> <a href="QuEST_8c_source.html#l00813">QuEST.c:813</a></div></div>
<div class="ttc" id="aQuEST__common_8c_html_a2b78ab7dd04eab615a0d7c796e73ae8c"><div class="ttname"><a href="QuEST__common_8c.html#a2b78ab7dd04eab615a0d7c796e73ae8c">agnostic_applyQFT</a></div><div class="ttdeci">void agnostic_applyQFT(Qureg qureg, int *qubits, int numQubits)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__common_8c_source.html#l00849">QuEST_common.c:849</a></div></div>
<div class="ttc" id="aQuEST__validation_8c_html_aa8a0654753645b30d6fed4ed0f4e7d16"><div class="ttname"><a href="QuEST__validation_8c.html#aa8a0654753645b30d6fed4ed0f4e7d16">validateBitEncoding</a></div><div class="ttdeci">void validateBitEncoding(int numQubits, enum bitEncoding encoding, const char *caller)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__validation_8c_source.html#l00966">QuEST_validation.c:966</a></div></div>
<div class="ttc" id="aQuEST__validation_8c_html_ad613c75ff252a88e54f911053bd2032c"><div class="ttname"><a href="QuEST__validation_8c.html#ad613c75ff252a88e54f911053bd2032c">validateOutcome</a></div><div class="ttdeci">void validateOutcome(int outcome, const char *caller)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__validation_8c_source.html#l00523">QuEST_validation.c:523</a></div></div>
<div class="ttc" id="aQuEST__validation_8c_html_a9b348fc98867d01990da93a8de36936c"><div class="ttname"><a href="QuEST__validation_8c.html#a9b348fc98867d01990da93a8de36936c">validateMultiRegBitEncoding</a></div><div class="ttdeci">void validateMultiRegBitEncoding(int *numQubitsPerReg, int numRegs, enum bitEncoding encoding, const char *caller)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__validation_8c_source.html#l00976">QuEST_validation.c:976</a></div></div>
<div class="ttc" id="aQuEST__validation_8c_html_a0edb4d9df94a40b8ea89c1c14997ee76"><div class="ttname"><a href="QuEST__validation_8c.html#a0edb4d9df94a40b8ea89c1c14997ee76">validateMultiVarPhaseFuncOverrides</a></div><div class="ttdeci">void validateMultiVarPhaseFuncOverrides(int *numQubitsPerReg, const int numRegs, enum bitEncoding encoding, long long int *overrideInds, int numOverrides, const char *caller)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__validation_8c_source.html#l00886">QuEST_validation.c:886</a></div></div>
<div class="ttc" id="agroup__type_html_gga1c703cf89629e4e9c7023cd402d67028a085c85cff6ba79c52d8b1e61c42ddddf"><div class="ttname"><a href="group__type.html#gga1c703cf89629e4e9c7023cd402d67028a085c85cff6ba79c52d8b1e61c42ddddf">PAULI_Z</a></div><div class="ttdeci">@ PAULI_Z</div><div class="ttdef"><b>Definition:</b> <a href="QuEST_8h_source.html#l00096">QuEST.h:96</a></div></div>
<div class="ttc" id="aQuEST__common_8c_html_acf1c651a4359a370a2d9b3e1e1ebd430"><div class="ttname"><a href="QuEST__common_8c.html#acf1c651a4359a370a2d9b3e1e1ebd430">shiftIndices</a></div><div class="ttdeci">void shiftIndices(int *indices, int numIndices, int shift)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__common_8c_source.html#l00156">QuEST_common.c:156</a></div></div>
<div class="ttc" id="agroup__operator_html_gac4df97d8c125c8cc65df720f67b2bf69"><div class="ttname"><a href="group__operator.html#gac4df97d8c125c8cc65df720f67b2bf69">applyNamedPhaseFunc</a></div><div class="ttdeci">void applyNamedPhaseFunc(Qureg qureg, int *qubits, int *numQubitsPerReg, int numRegs, enum bitEncoding encoding, enum phaseFunc functionNameCode)</div><div class="ttdoc">Induces a phase change upon each amplitude of qureg, determined by a named (and potentially multi-var...</div><div class="ttdef"><b>Definition:</b> <a href="QuEST_8c_source.html#l00796">QuEST.c:796</a></div></div>
<div class="ttc" id="agroup__type_html_gga1c703cf89629e4e9c7023cd402d67028a63800f45b01ccc2608f754aee850bf4a"><div class="ttname"><a href="group__type.html#gga1c703cf89629e4e9c7023cd402d67028a63800f45b01ccc2608f754aee850bf4a">PAULI_I</a></div><div class="ttdeci">@ PAULI_I</div><div class="ttdef"><b>Definition:</b> <a href="QuEST_8h_source.html#l00096">QuEST.h:96</a></div></div>
<div class="ttc" id="aQuEST__validation_8c_html_aa28b7d9c0c3cf9c4be0e324fb9d6bf76"><div class="ttname"><a href="QuEST__validation_8c.html#aa28b7d9c0c3cf9c4be0e324fb9d6bf76">validateMultiQubitMatrixFitsInNode</a></div><div class="ttdeci">void validateMultiQubitMatrixFitsInNode(Qureg qureg, int numTargets, const char *caller)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__validation_8c_source.html#l00473">QuEST_validation.c:473</a></div></div>
<div class="ttc" id="aQuEST__common_8c_html_a95abbe0cedf45b1ff2f070dba219fd7f"><div class="ttname"><a href="QuEST__common_8c.html#a95abbe0cedf45b1ff2f070dba219fd7f">statevec_twoQubitUnitary</a></div><div class="ttdeci">void statevec_twoQubitUnitary(Qureg qureg, int targetQubit1, int targetQubit2, ComplexMatrix4 u)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__common_8c_source.html#l00561">QuEST_common.c:561</a></div></div>
<div class="ttc" id="aQuEST__internal_8h_html_ac3735bd959600e57b2ee3a105666cddf"><div class="ttname"><a href="QuEST__internal_8h.html#ac3735bd959600e57b2ee3a105666cddf">statevec_unitary</a></div><div class="ttdeci">void statevec_unitary(Qureg qureg, int targetQubit, ComplexMatrix2 u)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__cpu__distributed_8c_source.html#l00895">QuEST_cpu_distributed.c:895</a></div></div>
<div class="ttc" id="aQuEST__internal_8h_html_a0acfe30083d0bc2a84da196378a36122"><div class="ttname"><a href="QuEST__internal_8h.html#a0acfe30083d0bc2a84da196378a36122">statevec_multiControlledMultiQubitUnitary</a></div><div class="ttdeci">void statevec_multiControlledMultiQubitUnitary(Qureg qureg, long long int ctrlMask, int *targs, int numTargs, ComplexMatrixN u)</div><div class="ttdoc">This calls swapQubitAmps only when it would involve a distributed communication; if the qubit chunks ...</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__cpu__distributed_8c_source.html#l01514">QuEST_cpu_distributed.c:1514</a></div></div>
<div class="ttc" id="agroup__type_html_ggaa7d869b117ba5024d6b84938e8cdfc65ae003ec1158e3a4e295616ced12af154e"><div class="ttname"><a href="group__type.html#ggaa7d869b117ba5024d6b84938e8cdfc65ae003ec1158e3a4e295616ced12af154e">NORM</a></div><div class="ttdeci">@ NORM</div><div class="ttdef"><b>Definition:</b> <a href="QuEST_8h_source.html#l00232">QuEST.h:232</a></div></div>
<div class="ttc" id="aQuEST__validation_8c_html_a14317136bb150eb0d4bdada1d0aac058"><div class="ttname"><a href="QuEST__validation_8c.html#a14317136bb150eb0d4bdada1d0aac058">validateMultiVarPhaseFuncTerms</a></div><div class="ttdeci">void validateMultiVarPhaseFuncTerms(int *numQubitsPerReg, int numRegs, enum bitEncoding encoding, qreal *exponents, int *numTermsPerReg, const char *caller)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__validation_8c_source.html#l00836">QuEST_validation.c:836</a></div></div>
<div class="ttc" id="aQuEST__validation_8c_html_a12511cc6d45e137de6542d4721f1fa4e"><div class="ttname"><a href="QuEST__validation_8c.html#a12511cc6d45e137de6542d4721f1fa4e">validatePhaseFuncOverrides</a></div><div class="ttdeci">void validatePhaseFuncOverrides(const int numQubits, enum bitEncoding encoding, long long int *overrideInds, int numOverrides, const char *caller)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__validation_8c_source.html#l00862">QuEST_validation.c:862</a></div></div>
<div class="ttc" id="agroup__type_html_gga9c91c41aa42ae537995e89ffc616afe1a7165f9a47792f47c718ca128556fb3ae"><div class="ttname"><a href="group__type.html#gga9c91c41aa42ae537995e89ffc616afe1a7165f9a47792f47c718ca128556fb3ae">UNSIGNED</a></div><div class="ttdeci">@ UNSIGNED</div><div class="ttdef"><b>Definition:</b> <a href="QuEST_8h_source.html#l00269">QuEST.h:269</a></div></div>
<div class="ttc" id="agroup__operator_html_gaf5344129240243ad11d0c081eb9036ab"><div class="ttname"><a href="group__operator.html#gaf5344129240243ad11d0c081eb9036ab">applyPhaseFuncOverrides</a></div><div class="ttdeci">void applyPhaseFuncOverrides(Qureg qureg, int *qubits, int numQubits, enum bitEncoding encoding, qreal *coeffs, qreal *exponents, int numTerms, long long int *overrideInds, qreal *overridePhases, int numOverrides)</div><div class="ttdoc">Induces a phase change upon each amplitude of qureg, determined by the passed exponential polynomial ...</div><div class="ttdef"><b>Definition:</b> <a href="QuEST_8c_source.html#l00743">QuEST.c:743</a></div></div>
<div class="ttc" id="agroup__type_html_ggaa7d869b117ba5024d6b84938e8cdfc65a6313e6ff48163c11c47866c4fda4bfa0"><div class="ttname"><a href="group__type.html#ggaa7d869b117ba5024d6b84938e8cdfc65a6313e6ff48163c11c47866c4fda4bfa0">INVERSE_DISTANCE</a></div><div class="ttdeci">@ INVERSE_DISTANCE</div><div class="ttdef"><b>Definition:</b> <a href="QuEST_8h_source.html#l00234">QuEST.h:234</a></div></div>
<div class="ttc" id="aQuEST__validation_8c_html_a5be128290a7bba9a7f12d32cabe2276b"><div class="ttname"><a href="QuEST__validation_8c.html#a5be128290a7bba9a7f12d32cabe2276b">validateNumPauliSumTerms</a></div><div class="ttdeci">void validateNumPauliSumTerms(int numTerms, const char *caller)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__validation_8c_source.html#l00606">QuEST_validation.c:606</a></div></div>
<div class="ttc" id="agroup__type_html_ga7740e349b4f8bae6451547680f0ce2d6"><div class="ttname"><a href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a></div><div class="ttdeci">#define qreal</div></div>
<div class="ttc" id="agroup__type_html_gga1c703cf89629e4e9c7023cd402d67028a7abac7bb5b71e17382014c443244ad5c"><div class="ttname"><a href="group__type.html#gga1c703cf89629e4e9c7023cd402d67028a7abac7bb5b71e17382014c443244ad5c">PAULI_X</a></div><div class="ttdeci">@ PAULI_X</div><div class="ttdef"><b>Definition:</b> <a href="QuEST_8h_source.html#l00096">QuEST.h:96</a></div></div>
<div class="ttc" id="aQuEST__validation_8c_html_a9e7e85cfc36e3ce1f456a840a217bfd9"><div class="ttname"><a href="QuEST__validation_8c.html#a9e7e85cfc36e3ce1f456a840a217bfd9">validateMultiQubits</a></div><div class="ttdeci">void validateMultiQubits(Qureg qureg, int *qubits, int numQubits, const char *caller)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__validation_8c_source.html#l00444">QuEST_validation.c:444</a></div></div>
<div class="ttc" id="aQuEST__internal_8h_html_a5658f2ecbbd4ea425db5f7dc7fc4ba92"><div class="ttname"><a href="QuEST__internal_8h.html#a5658f2ecbbd4ea425db5f7dc7fc4ba92">densmatr_collapseToKnownProbOutcome</a></div><div class="ttdeci">void densmatr_collapseToKnownProbOutcome(Qureg qureg, int measureQubit, int outcome, qreal outcomeProb)</div><div class="ttdoc">Renorms (/prob) every | * outcome * &gt;&lt; * outcome * | state, setting all others to zero.</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__cpu_8c_source.html#l00791">QuEST_cpu.c:791</a></div></div>
<div class="ttc" id="aQuEST__validation_8c_html_a8a656a83bf0b44447188d06c2f8114cb"><div class="ttname"><a href="QuEST__validation_8c.html#a8a656a83bf0b44447188d06c2f8114cb">validateDiagonalOp</a></div><div class="ttdeci">void validateDiagonalOp(Qureg qureg, DiagonalOp op, const char *caller)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__validation_8c_source.html#l00713">QuEST_validation.c:713</a></div></div>
<div class="ttc" id="aQuEST__internal_8h_html_a7d8a817207847d2646a52044a63fd469"><div class="ttname"><a href="QuEST__internal_8h.html#a7d8a817207847d2646a52044a63fd469">statevec_applyParamNamedPhaseFuncOverrides</a></div><div class="ttdeci">void statevec_applyParamNamedPhaseFuncOverrides(Qureg qureg, int *qubits, int *numQubitsPerReg, int numRegs, enum bitEncoding encoding, enum phaseFunc functionNameCode, qreal *params, int numParams, long long int *overrideInds, qreal *overridePhases, int numOverrides, int conj)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__cpu_8c_source.html#l04446">QuEST_cpu.c:4446</a></div></div>
<div class="ttc" id="agroup__type_html_gaa7d869b117ba5024d6b84938e8cdfc65"><div class="ttname"><a href="group__type.html#gaa7d869b117ba5024d6b84938e8cdfc65">phaseFunc</a></div><div class="ttdeci">phaseFunc</div><div class="ttdoc">Flags for specifying named phase functions.</div><div class="ttdef"><b>Definition:</b> <a href="QuEST_8h_source.html#l00231">QuEST.h:231</a></div></div>
<div class="ttc" id="astructPauliHamil_html_ac1c6c9f6299cf83bbba88123216c3cac"><div class="ttname"><a href="structPauliHamil.html#ac1c6c9f6299cf83bbba88123216c3cac">PauliHamil::termCoeffs</a></div><div class="ttdeci">qreal * termCoeffs</div><div class="ttdoc">The real coefficient of each Pauli product. This is an array of length PauliHamil....</div><div class="ttdef"><b>Definition:</b> <a href="QuEST_8h_source.html#l00283">QuEST.h:283</a></div></div>
<div class="ttc" id="agroup__operator_html_ga74a955ec4bce606d89317bcfc528387f"><div class="ttname"><a href="group__operator.html#ga74a955ec4bce606d89317bcfc528387f">applyMatrix4</a></div><div class="ttdeci">void applyMatrix4(Qureg qureg, int targetQubit1, int targetQubit2, ComplexMatrix4 u)</div><div class="ttdoc">Apply a general 4-by-4 matrix, which may be non-unitary.</div><div class="ttdef"><b>Definition:</b> <a href="QuEST_8c_source.html#l01093">QuEST.c:1093</a></div></div>
<div class="ttc" id="aQuEST__common_8c_html_a8a8e789585651f90fcc587042d4cdfb8"><div class="ttname"><a href="QuEST__common_8c.html#a8a8e789585651f90fcc587042d4cdfb8">agnostic_applyTrotterCircuit</a></div><div class="ttdeci">void agnostic_applyTrotterCircuit(Qureg qureg, PauliHamil hamil, qreal time, int order, int reps)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__common_8c_source.html#l00840">QuEST_common.c:840</a></div></div>
<div class="ttc" id="aQuEST__internal_8h_html_a9d7928473aca695a614e9c24d903e578"><div class="ttname"><a href="QuEST__internal_8h.html#a9d7928473aca695a614e9c24d903e578">statevec_applyPhaseFuncOverrides</a></div><div class="ttdeci">void statevec_applyPhaseFuncOverrides(Qureg qureg, int *qubits, int numQubits, enum bitEncoding encoding, qreal *coeffs, qreal *exponents, int numTerms, long long int *overrideInds, qreal *overridePhases, int numOverrides, int conj)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__cpu_8c_source.html#l04268">QuEST_cpu.c:4268</a></div></div>
<div class="ttc" id="astructPauliHamil_html_a4b8d38c403553c07ceddcd40c46ce6c8"><div class="ttname"><a href="structPauliHamil.html#a4b8d38c403553c07ceddcd40c46ce6c8">PauliHamil::pauliCodes</a></div><div class="ttdeci">enum pauliOpType * pauliCodes</div><div class="ttdoc">The Pauli operators acting on each qubit, flattened over every operator.</div><div class="ttdef"><b>Definition:</b> <a href="QuEST_8h_source.html#l00281">QuEST.h:281</a></div></div>
<div class="ttc" id="aQuEST__internal_8h_html_a27294e3065ebe42a65b3b9e0f85551dd"><div class="ttname"><a href="QuEST__internal_8h.html#a27294e3065ebe42a65b3b9e0f85551dd">statevec_applyDiagonalOp</a></div><div class="ttdeci">void statevec_applyDiagonalOp(Qureg qureg, DiagonalOp op)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__cpu_8c_source.html#l04047">QuEST_cpu.c:4047</a></div></div>
<div class="ttc" id="agroup__type_html_ggaa7d869b117ba5024d6b84938e8cdfc65a31a29a30f92fe34c35098f941adbbc93"><div class="ttname"><a href="group__type.html#ggaa7d869b117ba5024d6b84938e8cdfc65a31a29a30f92fe34c35098f941adbbc93">SCALED_PRODUCT</a></div><div class="ttdeci">@ SCALED_PRODUCT</div><div class="ttdef"><b>Definition:</b> <a href="QuEST_8h_source.html#l00233">QuEST.h:233</a></div></div>
<div class="ttc" id="aQuEST__validation_8c_html_a6776217a5f7ba38b56175cf6db0f96e0"><div class="ttname"><a href="QuEST__validation_8c.html#a6776217a5f7ba38b56175cf6db0f96e0">validateMultiTargets</a></div><div class="ttdeci">void validateMultiTargets(Qureg qureg, int *targetQubits, int numTargetQubits, const char *caller)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__validation_8c_source.html#l00428">QuEST_validation.c:428</a></div></div>
<div class="ttc" id="aQuEST__validation_8c_html_a87d22240ccfd81827a2a34b8d569d347"><div class="ttname"><a href="QuEST__validation_8c.html#a87d22240ccfd81827a2a34b8d569d347">validateMatchingQuregDims</a></div><div class="ttdeci">void validateMatchingQuregDims(Qureg qureg1, Qureg qureg2, const char *caller)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__validation_8c_source.html#l00531">QuEST_validation.c:531</a></div></div>
<div class="ttc" id="astructPauliHamil_html_a737e46b40ef8990cf004d22eb9dbe2e4"><div class="ttname"><a href="structPauliHamil.html#a737e46b40ef8990cf004d22eb9dbe2e4">PauliHamil::numSumTerms</a></div><div class="ttdeci">int numSumTerms</div><div class="ttdoc">The number of terms in the weighted sum, or the number of Pauli products.</div><div class="ttdef"><b>Definition:</b> <a href="QuEST_8h_source.html#l00285">QuEST.h:285</a></div></div>
<div class="ttc" id="aQuEST__common_8c_html_acc45bb8300922ea5933e294921e25ea2"><div class="ttname"><a href="QuEST__common_8c.html#acc45bb8300922ea5933e294921e25ea2">getQubitBitMask</a></div><div class="ttdeci">long long int getQubitBitMask(int *qubits, int numQubits)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__common_8c_source.html#l00050">QuEST_common.c:50</a></div></div>
<div class="ttc" id="agroup__type_html_gga1c703cf89629e4e9c7023cd402d67028a2c64a9aaee27f6bcfef894d159e759bd"><div class="ttname"><a href="group__type.html#gga1c703cf89629e4e9c7023cd402d67028a2c64a9aaee27f6bcfef894d159e759bd">PAULI_Y</a></div><div class="ttdeci">@ PAULI_Y</div><div class="ttdef"><b>Definition:</b> <a href="QuEST_8h_source.html#l00096">QuEST.h:96</a></div></div>
<div class="ttc" id="agroup__operator_html_gaabd7efa3beebc9f3a525321d41a28989"><div class="ttname"><a href="group__operator.html#gaabd7efa3beebc9f3a525321d41a28989">applyParamNamedPhaseFuncOverrides</a></div><div class="ttdeci">void applyParamNamedPhaseFuncOverrides(Qureg qureg, int *qubits, int *numQubitsPerReg, int numRegs, enum bitEncoding encoding, enum phaseFunc functionNameCode, qreal *params, int numParams, long long int *overrideInds, qreal *overridePhases, int numOverrides)</div><div class="ttdoc">Induces a phase change upon each amplitude of qureg, determined by a named, parameterised (and potent...</div><div class="ttdef"><b>Definition:</b> <a href="QuEST_8c_source.html#l00848">QuEST.c:848</a></div></div>
<div class="ttc" id="aQuEST__qasm_8c_html_a9a385fde708958617bbeb599064b8dcb"><div class="ttname"><a href="QuEST__qasm_8c.html#a9a385fde708958617bbeb599064b8dcb">qasm_recordComment</a></div><div class="ttdeci">void qasm_recordComment(Qureg qureg, char *comment,...)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__qasm_8c_source.html#l00121">QuEST_qasm.c:121</a></div></div>
<div class="ttc" id="agroup__type_html_ggaa7d869b117ba5024d6b84938e8cdfc65aa318172feec5b530e9a7849f2f7b44e7"><div class="ttname"><a href="group__type.html#ggaa7d869b117ba5024d6b84938e8cdfc65aa318172feec5b530e9a7849f2f7b44e7">SCALED_INVERSE_SHIFTED_NORM</a></div><div class="ttdeci">@ SCALED_INVERSE_SHIFTED_NORM</div><div class="ttdef"><b>Definition:</b> <a href="QuEST_8h_source.html#l00232">QuEST.h:232</a></div></div>
<div class="ttc" id="aQuEST__common_8c_html_a7a76950824f17e821415070a4bfdad5b"><div class="ttname"><a href="QuEST__common_8c.html#a7a76950824f17e821415070a4bfdad5b">statevec_multiQubitUnitary</a></div><div class="ttdeci">void statevec_multiQubitUnitary(Qureg qureg, int *targets, int numTargets, ComplexMatrixN u)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__common_8c_source.html#l00573">QuEST_common.c:573</a></div></div>
<div class="ttc" id="aQuEST__validation_8c_html_a0a45c9c3015af276ff7e624ae207ba7a"><div class="ttname"><a href="QuEST__validation_8c.html#a0a45c9c3015af276ff7e624ae207ba7a">validateQubitSubregs</a></div><div class="ttdeci">void validateQubitSubregs(Qureg qureg, int *qubits, int *numQubitsPerReg, const int numRegs, const char *caller)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__validation_8c_source.html#l00757">QuEST_validation.c:757</a></div></div>
<div class="ttc" id="agroup__qasm_html_ga65bf1906298ca6355e2942f4923d77b6"><div class="ttname"><a href="group__qasm.html#ga65bf1906298ca6355e2942f4923d77b6">startRecordingQASM</a></div><div class="ttdeci">void startRecordingQASM(Qureg qureg)</div><div class="ttdoc">Enable QASM recording.</div><div class="ttdef"><b>Definition:</b> <a href="QuEST_8c_source.html#l00087">QuEST.c:87</a></div></div>
<div class="ttc" id="aQuEST__common_8c_html_af71c2470694795a8d639be8ff9c34ed5"><div class="ttname"><a href="QuEST__common_8c.html#af71c2470694795a8d639be8ff9c34ed5">statevec_applyPauliSum</a></div><div class="ttdeci">void statevec_applyPauliSum(Qureg inQureg, enum pauliOpType *allCodes, qreal *termCoeffs, int numSumTerms, Qureg outQureg)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__common_8c_source.html#l00538">QuEST_common.c:538</a></div></div>
<div class="ttc" id="agroup__operator_html_ga6fc26cf857db070e12959e59ecfed8a6"><div class="ttname"><a href="group__operator.html#ga6fc26cf857db070e12959e59ecfed8a6">applyPauliSum</a></div><div class="ttdeci">void applyPauliSum(Qureg inQureg, enum pauliOpType *allPauliCodes, qreal *termCoeffs, int numSumTerms, Qureg outQureg)</div><div class="ttdoc">Modifies outQureg to be the result of applying the weighted sum of Pauli products (a Hermitian but no...</div><div class="ttdef"><b>Definition:</b> <a href="QuEST_8c_source.html#l01048">QuEST.c:1048</a></div></div>
<div class="ttc" id="agroup__operator_html_ga358e7094a98851afa86d27f0147e32a1"><div class="ttname"><a href="group__operator.html#ga358e7094a98851afa86d27f0147e32a1">applyMatrixN</a></div><div class="ttdeci">void applyMatrixN(Qureg qureg, int *targs, int numTargs, ComplexMatrixN u)</div><div class="ttdoc">Apply a general N-by-N matrix, which may be non-unitary, on any number of target qubits.</div><div class="ttdef"><b>Definition:</b> <a href="QuEST_8c_source.html#l01103">QuEST.c:1103</a></div></div>
<div class="ttc" id="agroup__operator_html_ga008a46d178a5a9691e2f5d363e3f518f"><div class="ttname"><a href="group__operator.html#ga008a46d178a5a9691e2f5d363e3f518f">applyMultiVarPhaseFunc</a></div><div class="ttdeci">void applyMultiVarPhaseFunc(Qureg qureg, int *qubits, int *numQubitsPerReg, int numRegs, enum bitEncoding encoding, qreal *coeffs, qreal *exponents, int *numTermsPerReg)</div><div class="ttdoc">Induces a phase change upon each amplitude of qureg, determined by a multi-variable exponential polyn...</div><div class="ttdef"><b>Definition:</b> <a href="QuEST_8c_source.html#l00761">QuEST.c:761</a></div></div>
<div class="ttc" id="aQuEST__internal_8h_html_a008becc4a18f868340836e0ab9fd6df6"><div class="ttname"><a href="QuEST__internal_8h.html#a008becc4a18f868340836e0ab9fd6df6">statevec_collapseToKnownProbOutcome</a></div><div class="ttdeci">void statevec_collapseToKnownProbOutcome(Qureg qureg, int measureQubit, int outcome, qreal outcomeProb)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__cpu__distributed_8c_source.html#l01368">QuEST_cpu_distributed.c:1368</a></div></div>
<div class="ttc" id="aQuEST__common_8c_html_aecc3c36b275c53b321de1611c2f06f78"><div class="ttname"><a href="QuEST__common_8c.html#aecc3c36b275c53b321de1611c2f06f78">shiftSubregIndices</a></div><div class="ttdeci">void shiftSubregIndices(int *allInds, int *numIndsPerReg, int numRegs, int shift)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__common_8c_source.html#l00161">QuEST_common.c:161</a></div></div>
<div class="ttc" id="aQuEST__validation_8c_html_a99e98bb5d38287fbb51f1e094d1eb68e"><div class="ttname"><a href="QuEST__validation_8c.html#a99e98bb5d38287fbb51f1e094d1eb68e">validatePhaseFuncName</a></div><div class="ttdeci">void validatePhaseFuncName(enum phaseFunc funcCode, int numRegs, int numParams, const char *caller)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__validation_8c_source.html#l00913">QuEST_validation.c:913</a></div></div>
<div class="ttc" id="aQuEST__validation_8c_html_a066b0c4d0b02a0f3b9be7e5c68d9de6a"><div class="ttname"><a href="QuEST__validation_8c.html#a066b0c4d0b02a0f3b9be7e5c68d9de6a">validatePauliHamil</a></div><div class="ttdeci">void validatePauliHamil(PauliHamil hamil, const char *caller)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__validation_8c_source.html#l00655">QuEST_validation.c:655</a></div></div>
<div class="ttc" id="agroup__operator_html_ga8dca543fb4d1ee1cd8b4c5d6028b3075"><div class="ttname"><a href="group__operator.html#ga8dca543fb4d1ee1cd8b4c5d6028b3075">applyMultiVarPhaseFuncOverrides</a></div><div class="ttdeci">void applyMultiVarPhaseFuncOverrides(Qureg qureg, int *qubits, int *numQubitsPerReg, int numRegs, enum bitEncoding encoding, qreal *coeffs, qreal *exponents, int *numTermsPerReg, long long int *overrideInds, qreal *overridePhases, int numOverrides)</div><div class="ttdoc">Induces a phase change upon each amplitude of qureg, determined by a multi-variable exponential polyn...</div><div class="ttdef"><b>Definition:</b> <a href="QuEST_8c_source.html#l00778">QuEST.c:778</a></div></div>
<div class="ttc" id="aQuEST__validation_8c_html_a2b88b068a8242ee28da42c7324cdd078"><div class="ttname"><a href="QuEST__validation_8c.html#a2b88b068a8242ee28da42c7324cdd078">validateMatchingQuregPauliHamilDims</a></div><div class="ttdeci">void validateMatchingQuregPauliHamilDims(Qureg qureg, PauliHamil hamil, const char *caller)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__validation_8c_source.html#l00660">QuEST_validation.c:660</a></div></div>
<div class="ttc" id="astructQureg_html_acf78445e9435d09f44f0cc832c6aee79"><div class="ttname"><a href="structQureg.html#acf78445e9435d09f44f0cc832c6aee79">Qureg::isDensityMatrix</a></div><div class="ttdeci">int isDensityMatrix</div><div class="ttdoc">Whether this instance is a density-state representation.</div><div class="ttdef"><b>Definition:</b> <a href="QuEST_8h_source.html#l00325">QuEST.h:325</a></div></div>
<div class="ttc" id="aQuEST__validation_8c_html_a031812e1cf2c98d72d795cea7bbe73a5"><div class="ttname"><a href="QuEST__validation_8c.html#a031812e1cf2c98d72d795cea7bbe73a5">validateMatchingQuregTypes</a></div><div class="ttdeci">void validateMatchingQuregTypes(Qureg qureg1, Qureg qureg2, const char *caller)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__validation_8c_source.html#l00535">QuEST_validation.c:535</a></div></div>
<div class="ttc" id="astructQureg_html_ad08dff5316b8937f4b2a1417591543dc"><div class="ttname"><a href="structQureg.html#ad08dff5316b8937f4b2a1417591543dc">Qureg::numQubitsRepresented</a></div><div class="ttdeci">int numQubitsRepresented</div><div class="ttdoc">The number of qubits represented in either the state-vector or density matrix.</div><div class="ttdef"><b>Definition:</b> <a href="QuEST_8h_source.html#l00327">QuEST.h:327</a></div></div>
<div class="ttc" id="aQuEST__validation_8c_html_a5b0392701c555a898403f80ef4a32f62"><div class="ttname"><a href="QuEST__validation_8c.html#a5b0392701c555a898403f80ef4a32f62">validateMultiControlsMultiTargets</a></div><div class="ttdeci">void validateMultiControlsMultiTargets(Qureg qureg, int *controlQubits, int numControlQubits, int *targetQubits, int numTargetQubits, const char *caller)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__validation_8c_source.html#l00459">QuEST_validation.c:459</a></div></div>
<div class="ttc" id="aQuEST__validation_8c_html_a91dad925cb9383384f135b936e5a7f43"><div class="ttname"><a href="QuEST__validation_8c.html#a91dad925cb9383384f135b936e5a7f43">validatePhaseFuncTerms</a></div><div class="ttdeci">void validatePhaseFuncTerms(int numQubits, enum bitEncoding encoding, qreal *coeffs, qreal *exponents, int numTerms, long long int *overrideInds, int numOverrides, const char *caller)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__validation_8c_source.html#l00773">QuEST_validation.c:773</a></div></div>
<div class="ttc" id="aQuEST__validation_8c_html_a576519ac36b7cb25bab78d05b5d1975f"><div class="ttname"><a href="QuEST__validation_8c.html#a576519ac36b7cb25bab78d05b5d1975f">validateMultiQubitMatrix</a></div><div class="ttdeci">void validateMultiQubitMatrix(Qureg qureg, ComplexMatrixN u, int numTargs, const char *caller)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__validation_8c_source.html#l00496">QuEST_validation.c:496</a></div></div>
<div class="ttc" id="aQuEST__qasm_8c_html_a6d239705dc0400ae75f8715c1f88b79f"><div class="ttname"><a href="QuEST__qasm_8c.html#a6d239705dc0400ae75f8715c1f88b79f">qasm_recordMultiVarPhaseFunc</a></div><div class="ttdeci">void qasm_recordMultiVarPhaseFunc(Qureg qureg, int *qubits, int *numQubitsPerReg, int numRegs, enum bitEncoding encoding, qreal *coeffs, qreal *exponents, int *numTermsPerReg, long long int *overrideInds, qreal *overridePhases, int numOverrides)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__qasm_8c_source.html#l00666">QuEST_qasm.c:666</a></div></div>
<div class="ttc" id="agroup__operator_html_ga225b82ff8b8eed1fff312240ec70c731"><div class="ttname"><a href="group__operator.html#ga225b82ff8b8eed1fff312240ec70c731">applyParamNamedPhaseFunc</a></div><div class="ttdeci">void applyParamNamedPhaseFunc(Qureg qureg, int *qubits, int *numQubitsPerReg, int numRegs, enum bitEncoding encoding, enum phaseFunc functionNameCode, qreal *params, int numParams)</div><div class="ttdoc">Induces a phase change upon each amplitude of qureg, determined by a named, paramaterized (and potent...</div><div class="ttdef"><b>Definition:</b> <a href="QuEST_8c_source.html#l00831">QuEST.c:831</a></div></div>
<div class="ttc" id="agroup__type_html_ggaa7d869b117ba5024d6b84938e8cdfc65a39111120b79016d6b3e773b711fa63f7"><div class="ttname"><a href="group__type.html#ggaa7d869b117ba5024d6b84938e8cdfc65a39111120b79016d6b3e773b711fa63f7">SCALED_INVERSE_SHIFTED_DISTANCE</a></div><div class="ttdeci">@ SCALED_INVERSE_SHIFTED_DISTANCE</div><div class="ttdef"><b>Definition:</b> <a href="QuEST_8h_source.html#l00234">QuEST.h:234</a></div></div>
<div class="ttc" id="aQuEST__validation_8c_html_a82b142fe77ba20c87142274f32e57689"><div class="ttname"><a href="QuEST__validation_8c.html#a82b142fe77ba20c87142274f32e57689">validateTrotterParams</a></div><div class="ttdeci">void validateTrotterParams(int order, int reps, const char *caller)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__validation_8c_source.html#l00703">QuEST_validation.c:703</a></div></div>
<div class="ttc" id="aQuEST__validation_8c_html_aa194ba5f5c6e19c6caa4c715b3dbefcc"><div class="ttname"><a href="QuEST__validation_8c.html#aa194ba5f5c6e19c6caa4c715b3dbefcc">validatePauliCodes</a></div><div class="ttdeci">void validatePauliCodes(enum pauliOpType *pauliCodes, int numPauliCodes, const char *caller)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__validation_8c_source.html#l00599">QuEST_validation.c:599</a></div></div>
<div class="ttc" id="aQuEST__common_8c_html_ae71449b1cc6e6250b91f539153a7a0d3"><div class="ttname"><a href="QuEST__common_8c.html#ae71449b1cc6e6250b91f539153a7a0d3">M_PI</a></div><div class="ttdeci">#define M_PI</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__common_8c_source.html#l00041">QuEST_common.c:41</a></div></div>
<div class="ttc" id="agroup__operator_html_ga35b6321c578a8c69470132b5ee95f930"><div class="ttname"><a href="group__operator.html#ga35b6321c578a8c69470132b5ee95f930">applyTrotterCircuit</a></div><div class="ttdeci">void applyTrotterCircuit(Qureg qureg, PauliHamil hamil, qreal time, int order, int reps)</div><div class="ttdoc">Applies a trotterisation of unitary evolution  to qureg.</div><div class="ttdef"><b>Definition:</b> <a href="QuEST_8c_source.html#l01070">QuEST.c:1070</a></div></div>
<div class="ttc" id="aQuEST__qasm_8c_html_ab60a4a8af0530cbfa8cba1b02692d448"><div class="ttname"><a href="QuEST__qasm_8c.html#ab60a4a8af0530cbfa8cba1b02692d448">qasm_recordNamedPhaseFunc</a></div><div class="ttdeci">void qasm_recordNamedPhaseFunc(Qureg qureg, int *qubits, int *numQubitsPerReg, int numRegs, enum bitEncoding encoding, enum phaseFunc funcName, qreal *params, int numParams, long long int *overrideInds, qreal *overridePhases, int numOverrides)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__qasm_8c_source.html#l00726">QuEST_qasm.c:726</a></div></div>
<div class="ttc" id="agroup__type_html_ga9c91c41aa42ae537995e89ffc616afe1"><div class="ttname"><a href="group__type.html#ga9c91c41aa42ae537995e89ffc616afe1">bitEncoding</a></div><div class="ttdeci">bitEncoding</div><div class="ttdoc">Flags for specifying how the bits in sub-register computational basis states are mapped to indices in...</div><div class="ttdef"><b>Definition:</b> <a href="QuEST_8h_source.html#l00269">QuEST.h:269</a></div></div>
<div class="ttc" id="agroup__qasm_html_gacf139d0a54b1f9e5c2f2feff742b8c76"><div class="ttname"><a href="group__qasm.html#gacf139d0a54b1f9e5c2f2feff742b8c76">printRecordedQASM</a></div><div class="ttdeci">void printRecordedQASM(Qureg qureg)</div><div class="ttdoc">Print recorded QASM to stdout.</div><div class="ttdef"><b>Definition:</b> <a href="QuEST_8c_source.html#l00099">QuEST.c:99</a></div></div>
<div class="ttc" id="aQuEST__qasm_8c_html_a383ddaecc94e1ce4a6fdbdbabeaa3131"><div class="ttname"><a href="QuEST__qasm_8c.html#a383ddaecc94e1ce4a6fdbdbabeaa3131">qasm_recordPhaseFunc</a></div><div class="ttdeci">void qasm_recordPhaseFunc(Qureg qureg, int *qubits, int numQubits, enum bitEncoding encoding, qreal *coeffs, qreal *exponents, int numTerms, long long int *overrideInds, qreal *overridePhases, int numOverrides)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__qasm_8c_source.html#l00490">QuEST_qasm.c:490</a></div></div>
<div class="ttc" id="aQuEST__internal_8h_html_ab33437d10c1ce1c4b034c7c411db553f"><div class="ttname"><a href="QuEST__internal_8h.html#ab33437d10c1ce1c4b034c7c411db553f">statevec_applyMultiVarPhaseFuncOverrides</a></div><div class="ttdeci">void statevec_applyMultiVarPhaseFuncOverrides(Qureg qureg, int *qubits, int *numQubitsPerReg, int numRegs, enum bitEncoding encoding, qreal *coeffs, qreal *exponents, int *numTermsPerReg, long long int *overrideInds, qreal *overridePhases, int numOverrides, int conj)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__cpu_8c_source.html#l04345">QuEST_cpu.c:4345</a></div></div>
<div class="ttc" id="agroup__type_html_ggaa7d869b117ba5024d6b84938e8cdfc65ae8c96906c1ec109d295c491e572d01e2"><div class="ttname"><a href="group__type.html#ggaa7d869b117ba5024d6b84938e8cdfc65ae8c96906c1ec109d295c491e572d01e2">SCALED_INVERSE_NORM</a></div><div class="ttdeci">@ SCALED_INVERSE_NORM</div><div class="ttdef"><b>Definition:</b> <a href="QuEST_8h_source.html#l00232">QuEST.h:232</a></div></div>
<div class="ttc" id="aQuEST__internal_8h_html_aedd7ecccf2f09dd2f1c5d191950b51e6"><div class="ttname"><a href="QuEST__internal_8h.html#aedd7ecccf2f09dd2f1c5d191950b51e6">densmatr_applyDiagonalOp</a></div><div class="ttdeci">void densmatr_applyDiagonalOp(Qureg qureg, DiagonalOp op)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__cpu__distributed_8c_source.html#l01594">QuEST_cpu_distributed.c:1594</a></div></div>
<!-- HTML footer for doxygen 1.8.8-->
<!-- start footer part -->
</div>
</div>
</div>
</div>
</div>
</body>
        <script type="text/javascript" src="boot.js"></script>
</html>