quest-rs 0.2.8

Safe Rust wrapper around the Quantum Exact Simulation Toolkit (QuEST)
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
<!-- 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: Debugging</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.1.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">Debugging</div>  </div>
</div><!--header-->
<div class="contents">

<p>Utilities for seeding and debugging, such as state-logging.  
<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:ga924ef2dbda6b733b4041270077c76ece"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__debug.html#ga924ef2dbda6b733b4041270077c76ece">copyStateFromGPU</a> (<a class="el" href="structQureg.html">Qureg</a> qureg)</td></tr>
<tr class="memdesc:ga924ef2dbda6b733b4041270077c76ece"><td class="mdescLeft">&#160;</td><td class="mdescRight">In GPU mode, this copies the state-vector (or density matrix) from GPU memory (qureg.deviceStateVec) to RAM (qureg.stateVec), where it can be accessed/modified by the user.  <a href="group__debug.html#ga924ef2dbda6b733b4041270077c76ece">More...</a><br /></td></tr>
<tr class="separator:ga924ef2dbda6b733b4041270077c76ece"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga11448560006dd165128e404b54ebb2f7"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__debug.html#ga11448560006dd165128e404b54ebb2f7">copyStateToGPU</a> (<a class="el" href="structQureg.html">Qureg</a> qureg)</td></tr>
<tr class="memdesc:ga11448560006dd165128e404b54ebb2f7"><td class="mdescLeft">&#160;</td><td class="mdescRight">In GPU mode, this copies the state-vector (or density matrix) from RAM (qureg.stateVec) to VRAM / GPU-memory (qureg.deviceStateVec), which is the version operated upon by other calls to the API.  <a href="group__debug.html#ga11448560006dd165128e404b54ebb2f7">More...</a><br /></td></tr>
<tr class="separator:ga11448560006dd165128e404b54ebb2f7"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga2d955c6e51067371eee69795532a2d62"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__debug.html#ga2d955c6e51067371eee69795532a2d62">getEnvironmentString</a> (<a class="el" href="structQuESTEnv.html">QuESTEnv</a> env, <a class="el" href="structQureg.html">Qureg</a> qureg, char str[200])</td></tr>
<tr class="memdesc:ga2d955c6e51067371eee69795532a2d62"><td class="mdescLeft">&#160;</td><td class="mdescRight">Sets <code>str</code> to a string containing the number of qubits in <code>qureg</code>, and the hardware facilities used (e.g.  <a href="group__debug.html#ga2d955c6e51067371eee69795532a2d62">More...</a><br /></td></tr>
<tr class="separator:ga2d955c6e51067371eee69795532a2d62"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gaa696c94112e5fbbc996af10dfc4e2c1c"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__debug.html#gaa696c94112e5fbbc996af10dfc4e2c1c">initDebugState</a> (<a class="el" href="structQureg.html">Qureg</a> qureg)</td></tr>
<tr class="memdesc:gaa696c94112e5fbbc996af10dfc4e2c1c"><td class="mdescLeft">&#160;</td><td class="mdescRight">Initialises <code>qureg</code> to be in the un-normalised, non-physical state with with n-th complex amplitude (2n/10 + i(2n+1)/10).  <a href="group__debug.html#gaa696c94112e5fbbc996af10dfc4e2c1c">More...</a><br /></td></tr>
<tr class="separator:gaa696c94112e5fbbc996af10dfc4e2c1c"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga51a64b05d31ef9bcf6a63ce26c0092db"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__debug.html#ga51a64b05d31ef9bcf6a63ce26c0092db">invalidQuESTInputError</a> (const char *errMsg, const char *errFunc)</td></tr>
<tr class="memdesc:ga51a64b05d31ef9bcf6a63ce26c0092db"><td class="mdescLeft">&#160;</td><td class="mdescRight">An internal function called when invalid arguments are passed to a QuEST API call, which the user can optionally override by redefining.  <a href="group__debug.html#ga51a64b05d31ef9bcf6a63ce26c0092db">More...</a><br /></td></tr>
<tr class="separator:ga51a64b05d31ef9bcf6a63ce26c0092db"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gaf8a14ae79c3fb2c0b5f6255cc37bebf9"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__debug.html#gaf8a14ae79c3fb2c0b5f6255cc37bebf9">reportQuESTEnv</a> (<a class="el" href="structQuESTEnv.html">QuESTEnv</a> env)</td></tr>
<tr class="memdesc:gaf8a14ae79c3fb2c0b5f6255cc37bebf9"><td class="mdescLeft">&#160;</td><td class="mdescRight">Report information about the QuEST environment.  <a href="group__debug.html#gaf8a14ae79c3fb2c0b5f6255cc37bebf9">More...</a><br /></td></tr>
<tr class="separator:gaf8a14ae79c3fb2c0b5f6255cc37bebf9"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga97d96af7c7ea7b31e32cbe3b25377e09"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__debug.html#ga97d96af7c7ea7b31e32cbe3b25377e09">reportQuregParams</a> (<a class="el" href="structQureg.html">Qureg</a> qureg)</td></tr>
<tr class="memdesc:ga97d96af7c7ea7b31e32cbe3b25377e09"><td class="mdescLeft">&#160;</td><td class="mdescRight">Report metainformation about a set of qubits: number of qubits, number of probability amplitudes.  <a href="group__debug.html#ga97d96af7c7ea7b31e32cbe3b25377e09">More...</a><br /></td></tr>
<tr class="separator:ga97d96af7c7ea7b31e32cbe3b25377e09"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gacd5f0ee488157837a8483c1515817f98"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__debug.html#gacd5f0ee488157837a8483c1515817f98">reportState</a> (<a class="el" href="structQureg.html">Qureg</a> qureg)</td></tr>
<tr class="memdesc:gacd5f0ee488157837a8483c1515817f98"><td class="mdescLeft">&#160;</td><td class="mdescRight">Print the current state vector of probability amplitudes for a set of qubits to file.  <a href="group__debug.html#gacd5f0ee488157837a8483c1515817f98">More...</a><br /></td></tr>
<tr class="separator:gacd5f0ee488157837a8483c1515817f98"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gaa33ed720560d051eb4126b4a534bc4c6"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__debug.html#gaa33ed720560d051eb4126b4a534bc4c6">reportStateToScreen</a> (<a class="el" href="structQureg.html">Qureg</a> qureg, <a class="el" href="structQuESTEnv.html">QuESTEnv</a> env, int reportRank)</td></tr>
<tr class="memdesc:gaa33ed720560d051eb4126b4a534bc4c6"><td class="mdescLeft">&#160;</td><td class="mdescRight">Print the current state vector of probability amplitudes for a set of qubits to standard out.  <a href="group__debug.html#gaa33ed720560d051eb4126b4a534bc4c6">More...</a><br /></td></tr>
<tr class="separator:gaa33ed720560d051eb4126b4a534bc4c6"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga95012dad46509b4b461974c34cfd7b3d"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__debug.html#ga95012dad46509b4b461974c34cfd7b3d">seedQuEST</a> (unsigned long int *seedArray, int numSeeds)</td></tr>
<tr class="memdesc:ga95012dad46509b4b461974c34cfd7b3d"><td class="mdescLeft">&#160;</td><td class="mdescRight">Seed the Mersenne Twister used for random number generation in the QuEST environment with a user defined seed.  <a href="group__debug.html#ga95012dad46509b4b461974c34cfd7b3d">More...</a><br /></td></tr>
<tr class="separator:ga95012dad46509b4b461974c34cfd7b3d"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gaa8437ef3bf135231e2916e64dde1c94e"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__debug.html#gaa8437ef3bf135231e2916e64dde1c94e">seedQuESTDefault</a> (void)</td></tr>
<tr class="memdesc:gaa8437ef3bf135231e2916e64dde1c94e"><td class="mdescLeft">&#160;</td><td class="mdescRight">Seed the Mersenne Twister used for random number generation in the QuEST environment with an example defualt seed.  <a href="group__debug.html#gaa8437ef3bf135231e2916e64dde1c94e">More...</a><br /></td></tr>
<tr class="separator:gaa8437ef3bf135231e2916e64dde1c94e"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga8d31fe2d1ad4d01e2a1f5f6b8bc15b77"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__debug.html#ga8d31fe2d1ad4d01e2a1f5f6b8bc15b77">syncQuESTEnv</a> (<a class="el" href="structQuESTEnv.html">QuESTEnv</a> env)</td></tr>
<tr class="memdesc:ga8d31fe2d1ad4d01e2a1f5f6b8bc15b77"><td class="mdescLeft">&#160;</td><td class="mdescRight">Guarantees that all code up to the given point has been executed on all nodes (if running in distributed mode)  <a href="group__debug.html#ga8d31fe2d1ad4d01e2a1f5f6b8bc15b77">More...</a><br /></td></tr>
<tr class="separator:ga8d31fe2d1ad4d01e2a1f5f6b8bc15b77"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gac7e38d768a1bd79019f88cc1e6295092"><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__debug.html#gac7e38d768a1bd79019f88cc1e6295092">syncQuESTSuccess</a> (int successCode)</td></tr>
<tr class="memdesc:gac7e38d768a1bd79019f88cc1e6295092"><td class="mdescLeft">&#160;</td><td class="mdescRight">Performs a logical AND on all successCodes held by all processes.  <a href="group__debug.html#gac7e38d768a1bd79019f88cc1e6295092">More...</a><br /></td></tr>
<tr class="separator:gac7e38d768a1bd79019f88cc1e6295092"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<p>Utilities for seeding and debugging, such as state-logging. </p>
<dl class="section author"><dt>Author</dt><dd>Ania Brown </dd>
<dd>
Tyson Jones </dd>
<dd>
Balint Koczor </dd>
<dd>
Nicolas Vogt of HQS (one-qubit damping) </dd></dl>
<h2 class="groupheader">Function Documentation</h2>
<a id="ga924ef2dbda6b733b4041270077c76ece"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga924ef2dbda6b733b4041270077c76ece">&#9670;&nbsp;</a></span>copyStateFromGPU()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void copyStateFromGPU </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>In GPU mode, this copies the state-vector (or density matrix) from GPU memory (qureg.deviceStateVec) to RAM (qureg.stateVec), where it can be accessed/modified by the user. </p>
<p>In CPU mode, this function has no effect. In conjunction with <a class="el" href="group__debug.html#ga11448560006dd165128e404b54ebb2f7" title="In GPU mode, this copies the state-vector (or density matrix) from RAM (qureg.stateVec) to VRAM / GPU...">copyStateToGPU()</a>, this allows a user to directly modify the state-vector in a harware agnostic way. Note though that users should instead use <a class="el" href="group__init.html#gabc0c64f8adf307d2a44184dc0f8ca66e" title="Overwrites a subset of the amplitudes in qureg, with those passed in reals and imags.">setAmps()</a> if possible.</p>
<p>For example, to set the first real element to 1, one could do: </p><pre class="fragment">copyStateFromGPU(qureg);
qureg.stateVec.real[0] = 1;
copyStateToGPU(qureg);
</pre><p>Note users should never access qureg.deviceStateVec directly.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in,out]</td><td class="paramname">qureg</td><td>the qureg of which to copy .deviceStateVec to .stateVec in GPU mode </td></tr>
  </table>
  </dd>
</dl>
<dl class="section author"><dt>Author</dt><dd>Ania Brown </dd>
<dd>
Tyson Jones (doc) </dd></dl>

<p class="definition">Definition at line <a class="el" href="QuEST__cpu_8c_source.html#l00039">39</a> of file <a class="el" href="QuEST__cpu_8c_source.html">QuEST_cpu.c</a>.</p>
<div class="fragment"><div class="line"><a name="l00039"></a><span class="lineno">   39</span>&#160;                                   {</div>
<div class="line"><a name="l00040"></a><span class="lineno">   40</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST__gpu_8cu_source.html#l00020">DEBUG</a>, <a class="el" href="QuEST_8h_source.html#l00184">Qureg::deviceStateVec</a>, <a class="el" href="QuEST_8h_source.html#l00170">Qureg::numAmpsPerChunk</a>, and <a class="el" href="QuEST_8h_source.html#l00179">Qureg::stateVec</a>.</p>

<p class="reference">Referenced by <a class="el" href="utilities_8cpp_source.html#l00681">areEqual()</a>, <a class="el" href="QuEST__gpu_8cu_source.html#l01476">densmatr_calcTotalProb()</a>, <a class="el" href="QuEST__gpu_8cu_source.html#l01499">statevec_calcTotalProb()</a>, <a class="el" href="QuEST__gpu_8cu_source.html#l00649">statevec_compareStates()</a>, <a class="el" href="QuEST__gpu_8cu_source.html#l00421">statevec_reportStateToScreen()</a>, <a class="el" href="utilities_8cpp_source.html#l00862">toQMatrix()</a>, and <a class="el" href="utilities_8cpp_source.html#l00904">toQVector()</a>.</p>

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

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void copyStateToGPU </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>In GPU mode, this copies the state-vector (or density matrix) from RAM (qureg.stateVec) to VRAM / GPU-memory (qureg.deviceStateVec), which is the version operated upon by other calls to the API. </p>
<p>In CPU mode, this function has no effect. In conjunction with <a class="el" href="group__debug.html#ga924ef2dbda6b733b4041270077c76ece" title="In GPU mode, this copies the state-vector (or density matrix) from GPU memory (qureg....">copyStateFromGPU()</a> (which should be called first), this allows a user to directly modify the state-vector in a harware agnostic way. Note though that users should instead use <a class="el" href="group__init.html#gabc0c64f8adf307d2a44184dc0f8ca66e" title="Overwrites a subset of the amplitudes in qureg, with those passed in reals and imags.">setAmps()</a> if possible.</p>
<p>For example, to set the first real element to 1, one could do: </p><pre class="fragment">copyStateFromGPU(qureg);
qureg.stateVec.real[0] = 1;
copyStateToGPU(qureg);
</pre><p>Note users should never access qureg.deviceStateVec directly.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in,out]</td><td class="paramname">qureg</td><td>the qureg of which to copy .stateVec to .deviceStateVec in GPU mode </td></tr>
  </table>
  </dd>
</dl>
<dl class="section author"><dt>Author</dt><dd>Ania Brown </dd>
<dd>
Tyson Jones (doc) </dd></dl>

<p class="definition">Definition at line <a class="el" href="QuEST__cpu_8c_source.html#l00036">36</a> of file <a class="el" href="QuEST__cpu_8c_source.html">QuEST_cpu.c</a>.</p>
<div class="fragment"><div class="line"><a name="l00036"></a><span class="lineno">   36</span>&#160;                                 {</div>
<div class="line"><a name="l00037"></a><span class="lineno">   37</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST__gpu_8cu_source.html#l00020">DEBUG</a>, <a class="el" href="QuEST_8h_source.html#l00184">Qureg::deviceStateVec</a>, <a class="el" href="QuEST_8h_source.html#l00170">Qureg::numAmpsPerChunk</a>, and <a class="el" href="QuEST_8h_source.html#l00179">Qureg::stateVec</a>.</p>

<p class="reference">Referenced by <a class="el" href="QuEST__gpu_8cu_source.html#l00605">statevec_initStateFromSingleFile()</a>, <a class="el" href="test__state__initialisations_8cpp_source.html#l00438">TEST_CASE()</a>, and <a class="el" href="utilities_8cpp_source.html#l00946">toQureg()</a>.</p>

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

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void getEnvironmentString </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structQuESTEnv.html">QuESTEnv</a>&#160;</td>
          <td class="paramname"><em>env</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>qureg</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">char&#160;</td>
          <td class="paramname"><em>str</em>[200]&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Sets <code>str</code> to a string containing the number of qubits in <code>qureg</code>, and the hardware facilities used (e.g. </p>
<p>GPU, MPI and/or OMP).</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in]</td><td class="paramname">env</td><td>object representing the execution environment. A single instance is used for each program </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">qureg</td><td>the qureg of which to query the simulating hardware </td></tr>
    <tr><td class="paramdir">[out]</td><td class="paramname">str</td><td>to be populated with the output string </td></tr>
  </table>
  </dd>
</dl>
<dl class="section author"><dt>Author</dt><dd>Ania Brown </dd></dl>

<p class="definition">Definition at line <a class="el" href="QuEST__gpu_8cu_source.html#l00393">393</a> of file <a class="el" href="QuEST__gpu_8cu_source.html">QuEST_gpu.cu</a>.</p>
<div class="fragment"><div class="line"><a name="l00393"></a><span class="lineno">  393</span>&#160;                                                                   {</div>
<div class="line"><a name="l00394"></a><span class="lineno">  394</span>&#160;    sprintf(str, <span class="stringliteral">&quot;%dqubits_GPU_noMpi_noOMP&quot;</span>, qureg.<a class="code" href="structQureg.html#a0a86e8a50ea8c998b4a0a6640c5a1218">numQubitsInStateVec</a>);    </div>
<div class="line"><a name="l00395"></a><span class="lineno">  395</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST_8h_source.html#l00167">Qureg::numQubitsInStateVec</a>.</p>

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

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void initDebugState </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>Initialises <code>qureg</code> to be in the un-normalised, non-physical state with with n-th complex amplitude (2n/10 + i(2n+1)/10). </p>
<p>This is used internally for debugging and testing.</p>
<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 have its amplitudes overwritten </td></tr>
  </table>
  </dd>
</dl>
<dl class="section author"><dt>Author</dt><dd>Ania Brown </dd>
<dd>
Tyson Jones (doc) </dd></dl>

<p class="definition">Definition at line <a class="el" href="QuEST_8c_source.html#l01057">1057</a> of file <a class="el" href="QuEST_8c_source.html">QuEST.c</a>.</p>
<div class="fragment"><div class="line"><a name="l01057"></a><span class="lineno"> 1057</span>&#160;                                 {</div>
<div class="line"><a name="l01058"></a><span class="lineno"> 1058</span>&#160;    <a class="code" href="QuEST__internal_8h.html#ad9fd3017ea40cf63fd04b39e03494972">statevec_initDebugState</a>(qureg);</div>
<div class="line"><a name="l01059"></a><span class="lineno"> 1059</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST__cpu_8c_source.html#l01559">statevec_initDebugState()</a>.</p>

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

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

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void invalidQuESTInputError </td>
          <td>(</td>
          <td class="paramtype">const char *&#160;</td>
          <td class="paramname"><em>errMsg</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const char *&#160;</td>
          <td class="paramname"><em>errFunc</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>An internal function called when invalid arguments are passed to a QuEST API call, which the user can optionally override by redefining. </p>
<p>This function is a weak symbol, so that users can choose how input errors are handled, by redefining it in their own code. Users must ensure that the triggered API call does not continue (e.g. the user exits or throws an exception), else QuEST will continue with the valid input and likely trigger a seg-fault. This function is triggered before any internal state-change, hence it is safe to interrupt with exceptions.</p>
<p>E.g. in C </p><div class="fragment"><div class="line"><span class="keywordtype">void</span> <a class="code" href="group__debug.html#ga51a64b05d31ef9bcf6a63ce26c0092db">invalidQuESTInputError</a>(<span class="keyword">const</span> <span class="keywordtype">char</span>* errMsg, <span class="keyword">const</span> <span class="keywordtype">char</span>* errFunc) {</div>
<div class="line"> </div>
<div class="line">     <span class="comment">// log to file</span></div>
<div class="line">     printf(<span class="stringliteral">&quot;ERROR! Writing to file...\n&quot;</span>);</div>
<div class="line">     FILE *fp = fopen(<span class="stringliteral">&quot;errorlog.txt&quot;</span>, <span class="stringliteral">&quot;w&quot;</span>);</div>
<div class="line">     fprintf(fp, <span class="stringliteral">&quot;incorrect usage of function &#39;%s&#39;: %s&quot;</span>, errFunc, errMsg);</div>
<div class="line">     fclose(fp);</div>
<div class="line">     </div>
<div class="line">     <span class="comment">// exit</span></div>
<div class="line">     exit(1);</div>
<div class="line">} </div>
</div><!-- fragment --><p>This function is compatible with C++ exceptions, though note the user of extern "C": </p><div class="fragment"><div class="line"><span class="keyword">extern</span> <span class="stringliteral">&quot;C&quot;</span> <span class="keywordtype">void</span> <a class="code" href="group__debug.html#ga51a64b05d31ef9bcf6a63ce26c0092db">invalidQuESTInputError</a>(<span class="keyword">const</span> <span class="keywordtype">char</span>* errMsg, <span class="keyword">const</span> <span class="keywordtype">char</span>* errFunc) {</div>
<div class="line"> </div>
<div class="line">    <span class="keywordtype">string</span> err = <span class="stringliteral">&quot;in function &quot;</span> + string(errFunc) + <span class="stringliteral">&quot;: &quot;</span> + string(errMsg);</div>
<div class="line">    <span class="keywordflow">throw</span> std::invalid_argument(err);</div>
<div class="line">} </div>
</div><!-- fragment --><dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in]</td><td class="paramname">errMsg</td><td>a string describing the nature of the argument error </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">errFunc</td><td>the name of the invalidly-called API function </td></tr>
  </table>
  </dd>
</dl>
<dl class="exception"><dt>Exceptions</dt><dd>
  <table class="exception">
    <tr><td class="paramname">exitWithError</td><td>unless overriden by the user </td></tr>
  </table>
  </dd>
</dl>
<dl class="section author"><dt>Author</dt><dd>Tyson Jones</dd></dl>
<p>An internal function called when invalid arguments are passed to a QuEST API call, which the user can optionally override by redefining.</p>
<p>an negative qubit index). This is redefined here to, in lieu of printing and exiting, throw a C++ exception which can be caught (and hence unit tested for) by Catch2 </p>

<p class="definition">Definition at line <a class="el" href="QuEST__validation_8c_source.html#l00142">142</a> of file <a class="el" href="QuEST__validation_8c_source.html">QuEST_validation.c</a>.</p>
<div class="fragment"><div class="line"><a name="l00142"></a><span class="lineno">  142</span>&#160;                                                                     {</div>
<div class="line"><a name="l00143"></a><span class="lineno">  143</span>&#160;    <a class="code" href="QuEST__validation_8c.html#aa37cc778ac42f5350830b90d0292b501">exitWithError</a>(errMsg, errFunc);</div>
<div class="line"><a name="l00144"></a><span class="lineno">  144</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST__validation_8c_source.html#l00133">exitWithError()</a>.</p>

<p class="reference">Referenced by <a class="el" href="QuEST__validation_8c_source.html#l00146">QuESTAssert()</a>.</p>

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

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void reportQuESTEnv </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structQuESTEnv.html">QuESTEnv</a>&#160;</td>
          <td class="paramname"><em>env</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Report information about the QuEST environment. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in]</td><td class="paramname">env</td><td>object representing the execution environment. A single instance is used for each program </td></tr>
  </table>
  </dd>
</dl>
<dl class="section author"><dt>Author</dt><dd>Ania Brown </dd></dl>

<p class="definition">Definition at line <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00179">179</a> of file <a class="el" href="QuEST__cpu__distributed_8c_source.html">QuEST_cpu_distributed.c</a>.</p>
<div class="fragment"><div class="line"><a name="l00179"></a><span class="lineno">  179</span>&#160;                                 {</div>
<div class="line"><a name="l00180"></a><span class="lineno">  180</span>&#160;    <span class="keywordflow">if</span> (env.<a class="code" href="structQuESTEnv.html#aa648bb336cf8598467cb62db00b9cee8">rank</a>==0){</div>
<div class="line"><a name="l00181"></a><span class="lineno">  181</span>&#160;        printf(<span class="stringliteral">&quot;EXECUTION ENVIRONMENT:\n&quot;</span>); </div>
<div class="line"><a name="l00182"></a><span class="lineno">  182</span>&#160;        printf(<span class="stringliteral">&quot;Running distributed (MPI) version\n&quot;</span>);</div>
<div class="line"><a name="l00183"></a><span class="lineno">  183</span>&#160;        printf(<span class="stringliteral">&quot;Number of ranks is %d\n&quot;</span>, env.<a class="code" href="structQuESTEnv.html#af22aacd7c9905accae28484785c193b4">numRanks</a>);</div>
<div class="line"><a name="l00184"></a><span class="lineno">  184</span>&#160;<span class="preprocessor"># ifdef _OPENMP</span></div>
<div class="line"><a name="l00185"></a><span class="lineno">  185</span>&#160;        printf(<span class="stringliteral">&quot;OpenMP enabled\n&quot;</span>);</div>
<div class="line"><a name="l00186"></a><span class="lineno">  186</span>&#160;        printf(<span class="stringliteral">&quot;Number of threads available is %d\n&quot;</span>, omp_get_max_threads());</div>
<div class="line"><a name="l00187"></a><span class="lineno">  187</span>&#160;<span class="preprocessor"># else</span></div>
<div class="line"><a name="l00188"></a><span class="lineno">  188</span>&#160;        printf(<span class="stringliteral">&quot;OpenMP disabled\n&quot;</span>);</div>
<div class="line"><a name="l00189"></a><span class="lineno">  189</span>&#160;<span class="preprocessor"># endif </span></div>
<div class="line"><a name="l00190"></a><span class="lineno">  190</span>&#160;        printf(<span class="stringliteral">&quot;Precision: size of qreal is %ld bytes\n&quot;</span>, <span class="keyword">sizeof</span>(<a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>) );</div>
<div class="line"><a name="l00191"></a><span class="lineno">  191</span>&#160;    }</div>
<div class="line"><a name="l00192"></a><span class="lineno">  192</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST_8h_source.html#l00202">QuESTEnv::numRanks</a>, <a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>, and <a class="el" href="QuEST_8h_source.html#l00201">QuESTEnv::rank</a>.</p>

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

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void reportQuregParams </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>Report metainformation about a set of qubits: number of qubits, number of probability amplitudes. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in]</td><td class="paramname">qureg</td><td>object representing the set of qubits </td></tr>
  </table>
  </dd>
</dl>
<dl class="section author"><dt>Author</dt><dd>Ania Brown </dd></dl>

<p class="definition">Definition at line <a class="el" href="QuEST__common_8c_source.html#l00233">233</a> of file <a class="el" href="QuEST__common_8c_source.html">QuEST_common.c</a>.</p>
<div class="fragment"><div class="line"><a name="l00233"></a><span class="lineno">  233</span>&#160;                                   {</div>
<div class="line"><a name="l00234"></a><span class="lineno">  234</span>&#160;    <span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> numAmps = 1LL &lt;&lt; qureg.<a class="code" href="structQureg.html#a0a86e8a50ea8c998b4a0a6640c5a1218">numQubitsInStateVec</a>;</div>
<div class="line"><a name="l00235"></a><span class="lineno">  235</span>&#160;    <span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> numAmpsPerRank = numAmps/qureg.<a class="code" href="structQureg.html#aa3deb7163aab90a61e755a1f200f5413">numChunks</a>;</div>
<div class="line"><a name="l00236"></a><span class="lineno">  236</span>&#160;    <span class="keywordflow">if</span> (qureg.<a class="code" href="structQureg.html#ac2929e681d3d95591c18cf168dbbe4f0">chunkId</a>==0){</div>
<div class="line"><a name="l00237"></a><span class="lineno">  237</span>&#160;        printf(<span class="stringliteral">&quot;QUBITS:\n&quot;</span>);</div>
<div class="line"><a name="l00238"></a><span class="lineno">  238</span>&#160;        printf(<span class="stringliteral">&quot;Number of qubits is %d.\n&quot;</span>, qureg.<a class="code" href="structQureg.html#a0a86e8a50ea8c998b4a0a6640c5a1218">numQubitsInStateVec</a>);</div>
<div class="line"><a name="l00239"></a><span class="lineno">  239</span>&#160;        printf(<span class="stringliteral">&quot;Number of amps is %lld.\n&quot;</span>, numAmps);</div>
<div class="line"><a name="l00240"></a><span class="lineno">  240</span>&#160;        printf(<span class="stringliteral">&quot;Number of amps per rank is %lld.\n&quot;</span>, numAmpsPerRank);</div>
<div class="line"><a name="l00241"></a><span class="lineno">  241</span>&#160;    }</div>
<div class="line"><a name="l00242"></a><span class="lineno">  242</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST_8h_source.html#l00174">Qureg::chunkId</a>, <a class="el" href="QuEST_8h_source.html#l00176">Qureg::numChunks</a>, and <a class="el" href="QuEST_8h_source.html#l00167">Qureg::numQubitsInStateVec</a>.</p>

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

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void reportState </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>Print the current state vector of probability amplitudes for a set of qubits to file. </p>
<p>File format: </p><pre class="fragment">real, imag
realComponent1, imagComponent1
realComponent2, imagComponent2
...
realComponentN, imagComponentN
</pre><p>File naming convention:</p>
<p>For each node that the program runs on, a file 'state_rank_[node_rank].csv' is generated. If there is more than one node, ranks after the first do not include the header </p><pre class="fragment">real, imag
</pre><p> so that files are easier to combine.</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 qubits </td></tr>
  </table>
  </dd>
</dl>
<dl class="section author"><dt>Author</dt><dd>Ania Brown </dd></dl>

<p class="definition">Definition at line <a class="el" href="QuEST__common_8c_source.html#l00215">215</a> of file <a class="el" href="QuEST__common_8c_source.html">QuEST_common.c</a>.</p>
<div class="fragment"><div class="line"><a name="l00215"></a><span class="lineno">  215</span>&#160;                             {</div>
<div class="line"><a name="l00216"></a><span class="lineno">  216</span>&#160;    FILE *state;</div>
<div class="line"><a name="l00217"></a><span class="lineno">  217</span>&#160;    <span class="keywordtype">char</span> filename[100];</div>
<div class="line"><a name="l00218"></a><span class="lineno">  218</span>&#160;    <span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> index;</div>
<div class="line"><a name="l00219"></a><span class="lineno">  219</span>&#160;    sprintf(filename, <span class="stringliteral">&quot;state_rank_%d.csv&quot;</span>, qureg.<a class="code" href="structQureg.html#ac2929e681d3d95591c18cf168dbbe4f0">chunkId</a>);</div>
<div class="line"><a name="l00220"></a><span class="lineno">  220</span>&#160;    state = fopen(filename, <span class="stringliteral">&quot;w&quot;</span>);</div>
<div class="line"><a name="l00221"></a><span class="lineno">  221</span>&#160;    <span class="keywordflow">if</span> (qureg.<a class="code" href="structQureg.html#ac2929e681d3d95591c18cf168dbbe4f0">chunkId</a>==0) fprintf(state, <span class="stringliteral">&quot;real, imag\n&quot;</span>);</div>
<div class="line"><a name="l00222"></a><span class="lineno">  222</span>&#160; </div>
<div class="line"><a name="l00223"></a><span class="lineno">  223</span>&#160;    <span class="keywordflow">for</span>(index=0; index&lt;qureg.<a class="code" href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">numAmpsPerChunk</a>; index++){</div>
<div class="line"><a name="l00224"></a><span class="lineno">  224</span>&#160;<span class="preprocessor">        # if QuEST_PREC==1 || QuEST_PREC==2</span></div>
<div class="line"><a name="l00225"></a><span class="lineno">  225</span>&#160;        fprintf(state, <span class="stringliteral">&quot;%.12f, %.12f\n&quot;</span>, qureg.<a class="code" href="structQureg.html#a441e4cacef6bd17adb9813c7442d42fe">stateVec</a>.real[index], qureg.<a class="code" href="structQureg.html#a441e4cacef6bd17adb9813c7442d42fe">stateVec</a>.imag[index]);</div>
<div class="line"><a name="l00226"></a><span class="lineno">  226</span>&#160;<span class="preprocessor">        # elif QuEST_PREC == 4</span></div>
<div class="line"><a name="l00227"></a><span class="lineno">  227</span>&#160;        fprintf(state, <span class="stringliteral">&quot;%.12Lf, %.12Lf\n&quot;</span>, qureg.<a class="code" href="structQureg.html#a441e4cacef6bd17adb9813c7442d42fe">stateVec</a>.real[index], qureg.<a class="code" href="structQureg.html#a441e4cacef6bd17adb9813c7442d42fe">stateVec</a>.imag[index]);</div>
<div class="line"><a name="l00228"></a><span class="lineno">  228</span>&#160;<span class="preprocessor">        #endif</span></div>
<div class="line"><a name="l00229"></a><span class="lineno">  229</span>&#160;    }</div>
<div class="line"><a name="l00230"></a><span class="lineno">  230</span>&#160;    fclose(state);</div>
<div class="line"><a name="l00231"></a><span class="lineno">  231</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST_8h_source.html#l00174">Qureg::chunkId</a>, <a class="el" href="QuEST_8h_source.html#l00170">Qureg::numAmpsPerChunk</a>, and <a class="el" href="QuEST_8h_source.html#l00179">Qureg::stateVec</a>.</p>

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

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void reportStateToScreen </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="structQuESTEnv.html">QuESTEnv</a>&#160;</td>
          <td class="paramname"><em>env</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>reportRank</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Print the current state vector of probability amplitudes for a set of qubits to standard out. </p>
<p>For debugging purposes. Each rank should print output serially. Only print output for systems &lt;= 5 qubits</p>
<dl class="section author"><dt>Author</dt><dd>Ania Brown </dd></dl>

<p class="definition">Definition at line <a class="el" href="QuEST_8c_source.html#l01073">1073</a> of file <a class="el" href="QuEST_8c_source.html">QuEST.c</a>.</p>
<div class="fragment"><div class="line"><a name="l01073"></a><span class="lineno"> 1073</span>&#160;                                                                     {</div>
<div class="line"><a name="l01074"></a><span class="lineno"> 1074</span>&#160;    <a class="code" href="QuEST__internal_8h.html#a1e57230c7995447039e62a84c0a36524">statevec_reportStateToScreen</a>(qureg, env, reportRank);</div>
<div class="line"><a name="l01075"></a><span class="lineno"> 1075</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST__cpu_8c_source.html#l01334">statevec_reportStateToScreen()</a>.</p>

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

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void seedQuEST </td>
          <td>(</td>
          <td class="paramtype">unsigned long int *&#160;</td>
          <td class="paramname"><em>seedArray</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>numSeeds</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Seed the Mersenne Twister used for random number generation in the QuEST environment with a user defined seed. </p>
<p>This function uses the mt19937 init_by_array function with numSeeds keys supplied by the user. Subsequent calls to mt19937 genrand functions will use this seeding. For a multi process code, the same seed is given to all process, therefore this seeding is only appropriate to use for functions such as measure where all processes require the same random value.</p>
<p>For more information about the MT, see <a href="http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/MT2002/emt19937ar.html">http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/MT2002/emt19937ar.html</a></p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in]</td><td class="paramname">seedArray</td><td>Array of integers to use as seed. This allows the MT to be initialised with more than a 32-bit integer if required </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">numSeeds</td><td>Length of seedArray </td></tr>
  </table>
  </dd>
</dl>
<dl class="section author"><dt>Author</dt><dd>Ania Brown</dd></dl>
<p>Seed the Mersenne Twister used for random number generation in the QuEST environment with a user defined seed. </p>

<p class="definition">Definition at line <a class="el" href="QuEST__common_8c_source.html#l00208">208</a> of file <a class="el" href="QuEST__common_8c_source.html">QuEST_common.c</a>.</p>
<div class="fragment"><div class="line"><a name="l00208"></a><span class="lineno">  208</span>&#160;                                                          {</div>
<div class="line"><a name="l00209"></a><span class="lineno">  209</span>&#160;    <span class="comment">// init MT random number generator with user defined list of seeds</span></div>
<div class="line"><a name="l00210"></a><span class="lineno">  210</span>&#160;    <span class="comment">// for the MPI version, it is ok that all procs will get the same seed as random numbers will only be </span></div>
<div class="line"><a name="l00211"></a><span class="lineno">  211</span>&#160;    <span class="comment">// used by the master process</span></div>
<div class="line"><a name="l00212"></a><span class="lineno">  212</span>&#160;    <a class="code" href="mt19937ar_8c.html#ac1283f9b1ed571332f5ffe53545ffc16">init_by_array</a>(seedArray, numSeeds); </div>
<div class="line"><a name="l00213"></a><span class="lineno">  213</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="mt19937ar_8c_source.html#l00080">init_by_array()</a>.</p>

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

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void seedQuESTDefault </td>
          <td>(</td>
          <td class="paramtype">void&#160;</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Seed the Mersenne Twister used for random number generation in the QuEST environment with an example defualt seed. </p>
<p>This default seeding function uses the mt19937 init_by_array function with two keys &ndash; time and pid. Subsequent calls to mt19937 genrand functions will use this seeding. For a multi process code, the same seed is given to all process, therefore this seeding is only appropriate to use for functions such as measure where all processes require the same random value.</p>
<p>For more information about the MT, see <a href="http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/MT2002/emt19937ar.html">http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/MT2002/emt19937ar.html</a></p>
<dl class="section author"><dt>Author</dt><dd>Ania Brown </dd>
<dd>
Balint Koczor (Windows compatibility) </dd></dl>

<p class="definition">Definition at line <a class="el" href="QuEST__cpu__distributed_8c_source.html#l01321">1321</a> of file <a class="el" href="QuEST__cpu__distributed_8c_source.html">QuEST_cpu_distributed.c</a>.</p>
<div class="fragment"><div class="line"><a name="l01321"></a><span class="lineno"> 1321</span>&#160;                       {</div>
<div class="line"><a name="l01322"></a><span class="lineno"> 1322</span>&#160;    <span class="comment">// init MT random number generator with three keys -- time and pid</span></div>
<div class="line"><a name="l01323"></a><span class="lineno"> 1323</span>&#160;    <span class="comment">// for the MPI version, it is ok that all procs will get the same seed as random numbers will only be </span></div>
<div class="line"><a name="l01324"></a><span class="lineno"> 1324</span>&#160;    <span class="comment">// used by the master process</span></div>
<div class="line"><a name="l01325"></a><span class="lineno"> 1325</span>&#160; </div>
<div class="line"><a name="l01326"></a><span class="lineno"> 1326</span>&#160;    <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> key[2];</div>
<div class="line"><a name="l01327"></a><span class="lineno"> 1327</span>&#160;    <a class="code" href="QuEST__common_8c.html#a2b323b65cd6512720e6aa27c182fcea0">getQuESTDefaultSeedKey</a>(key);</div>
<div class="line"><a name="l01328"></a><span class="lineno"> 1328</span>&#160;    <span class="comment">// this seed will be used to generate the same random number on all procs,</span></div>
<div class="line"><a name="l01329"></a><span class="lineno"> 1329</span>&#160;    <span class="comment">// therefore we want to make sure all procs receive the same key</span></div>
<div class="line"><a name="l01330"></a><span class="lineno"> 1330</span>&#160;    MPI_Bcast(key, 2, MPI_UNSIGNED_LONG, 0, MPI_COMM_WORLD);</div>
<div class="line"><a name="l01331"></a><span class="lineno"> 1331</span>&#160;    <a class="code" href="mt19937ar_8c.html#ac1283f9b1ed571332f5ffe53545ffc16">init_by_array</a>(key, 2);</div>
<div class="line"><a name="l01332"></a><span class="lineno"> 1332</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST__common_8c_source.html#l00181">getQuESTDefaultSeedKey()</a>, and <a class="el" href="mt19937ar_8c_source.html#l00080">init_by_array()</a>.</p>

<p class="reference">Referenced by <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00129">createQuESTEnv()</a>.</p>

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

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void syncQuESTEnv </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structQuESTEnv.html">QuESTEnv</a>&#160;</td>
          <td class="paramname"><em>env</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Guarantees that all code up to the given point has been executed on all nodes (if running in distributed mode) </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in]</td><td class="paramname">env</td><td>object representing the execution environment. A single instance is used for each program </td></tr>
  </table>
  </dd>
</dl>
<dl class="section author"><dt>Author</dt><dd>Ania Brown </dd></dl>

<p class="definition">Definition at line <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00162">162</a> of file <a class="el" href="QuEST__cpu__distributed_8c_source.html">QuEST_cpu_distributed.c</a>.</p>
<div class="fragment"><div class="line"><a name="l00162"></a><span class="lineno">  162</span>&#160;                               {</div>
<div class="line"><a name="l00163"></a><span class="lineno">  163</span>&#160;    MPI_Barrier(MPI_COMM_WORLD);</div>
<div class="line"><a name="l00164"></a><span class="lineno">  164</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">Referenced by <a class="el" href="utilities_8cpp_source.html#l00681">areEqual()</a>, <a class="el" href="QuEST__cpu_8c_source.html#l01593">statevec_initStateFromSingleFile()</a>, <a class="el" href="QuEST__cpu_8c_source.html#l01334">statevec_reportStateToScreen()</a>, <a class="el" href="utilities_8cpp_source.html#l00862">toQMatrix()</a>, <a class="el" href="utilities_8cpp_source.html#l00946">toQureg()</a>, and <a class="el" href="utilities_8cpp_source.html#l00904">toQVector()</a>.</p>

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

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int syncQuESTSuccess </td>
          <td>(</td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>successCode</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Performs a logical AND on all successCodes held by all processes. </p>
<p>If any one process has a zero successCode all processes will return a zero success code.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in]</td><td class="paramname">successCode</td><td>1 if process task succeeded, 0 if process task failed </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>1 if all processes succeeded, 0 if any one process failed </dd></dl>
<dl class="section author"><dt>Author</dt><dd>Ania Brown </dd></dl>

<p class="definition">Definition at line <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00166">166</a> of file <a class="el" href="QuEST__cpu__distributed_8c_source.html">QuEST_cpu_distributed.c</a>.</p>
<div class="fragment"><div class="line"><a name="l00166"></a><span class="lineno">  166</span>&#160;                                     {</div>
<div class="line"><a name="l00167"></a><span class="lineno">  167</span>&#160;    <span class="keywordtype">int</span> totalSuccess;</div>
<div class="line"><a name="l00168"></a><span class="lineno">  168</span>&#160;    MPI_Allreduce(&amp;successCode, &amp;totalSuccess, 1, MPI_INT, MPI_LAND, MPI_COMM_WORLD);</div>
<div class="line"><a name="l00169"></a><span class="lineno">  169</span>&#160;    <span class="keywordflow">return</span> totalSuccess;</div>
<div class="line"><a name="l00170"></a><span class="lineno">  170</span>&#160;}</div>
</div><!-- fragment -->
</div>
</div>
</div><!-- contents -->
<div class="ttc" id="amt19937ar_8c_html_ac1283f9b1ed571332f5ffe53545ffc16"><div class="ttname"><a href="mt19937ar_8c.html#ac1283f9b1ed571332f5ffe53545ffc16">init_by_array</a></div><div class="ttdeci">void init_by_array(unsigned long init_key[], int key_length)</div><div class="ttdef"><b>Definition:</b> <a href="mt19937ar_8c_source.html#l00080">mt19937ar.c:80</a></div></div>
<div class="ttc" id="astructQuESTEnv_html_aa648bb336cf8598467cb62db00b9cee8"><div class="ttname"><a href="structQuESTEnv.html#aa648bb336cf8598467cb62db00b9cee8">QuESTEnv::rank</a></div><div class="ttdeci">int rank</div><div class="ttdef"><b>Definition:</b> <a href="QuEST_8h_source.html#l00201">QuEST.h:201</a></div></div>
<div class="ttc" id="astructQureg_html_aa3deb7163aab90a61e755a1f200f5413"><div class="ttname"><a href="structQureg.html#aa3deb7163aab90a61e755a1f200f5413">Qureg::numChunks</a></div><div class="ttdeci">int numChunks</div><div class="ttdoc">Number of chunks the state vector is broken up into – the number of MPI processes used.</div><div class="ttdef"><b>Definition:</b> <a href="QuEST_8h_source.html#l00176">QuEST.h:176</a></div></div>
<div class="ttc" id="aQuEST__common_8c_html_a2b323b65cd6512720e6aa27c182fcea0"><div class="ttname"><a href="QuEST__common_8c.html#a2b323b65cd6512720e6aa27c182fcea0">getQuESTDefaultSeedKey</a></div><div class="ttdeci">void getQuESTDefaultSeedKey(unsigned long int *key)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__common_8c_source.html#l00181">QuEST_common.c:181</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="astructQureg_html_a0a86e8a50ea8c998b4a0a6640c5a1218"><div class="ttname"><a href="structQureg.html#a0a86e8a50ea8c998b4a0a6640c5a1218">Qureg::numQubitsInStateVec</a></div><div class="ttdeci">int numQubitsInStateVec</div><div class="ttdoc">Number of qubits in the state-vector - this is double the number represented for mixed states.</div><div class="ttdef"><b>Definition:</b> <a href="QuEST_8h_source.html#l00167">QuEST.h:167</a></div></div>
<div class="ttc" id="agroup__debug_html_ga51a64b05d31ef9bcf6a63ce26c0092db"><div class="ttname"><a href="group__debug.html#ga51a64b05d31ef9bcf6a63ce26c0092db">invalidQuESTInputError</a></div><div class="ttdeci">void invalidQuESTInputError(const char *errMsg, const char *errFunc)</div><div class="ttdoc">An internal function called when invalid arguments are passed to a QuEST API call,...</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__validation_8c_source.html#l00142">QuEST_validation.c:142</a></div></div>
<div class="ttc" id="astructQureg_html_ac2929e681d3d95591c18cf168dbbe4f0"><div class="ttname"><a href="structQureg.html#ac2929e681d3d95591c18cf168dbbe4f0">Qureg::chunkId</a></div><div class="ttdeci">int chunkId</div><div class="ttdoc">The position of the chunk of the state vector held by this process in the full state vector.</div><div class="ttdef"><b>Definition:</b> <a href="QuEST_8h_source.html#l00174">QuEST.h:174</a></div></div>
<div class="ttc" id="aQuEST__validation_8c_html_aa37cc778ac42f5350830b90d0292b501"><div class="ttname"><a href="QuEST__validation_8c.html#aa37cc778ac42f5350830b90d0292b501">exitWithError</a></div><div class="ttdeci">void exitWithError(const char *msg, const char *func)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__validation_8c_source.html#l00133">QuEST_validation.c:133</a></div></div>
<div class="ttc" id="astructQureg_html_ab0ea0358482b62f43fdd781469607d97"><div class="ttname"><a href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">Qureg::numAmpsPerChunk</a></div><div class="ttdeci">long long int numAmpsPerChunk</div><div class="ttdoc">Number of probability amplitudes held in stateVec by this process In the non-MPI version,...</div><div class="ttdef"><b>Definition:</b> <a href="QuEST_8h_source.html#l00170">QuEST.h:170</a></div></div>
<div class="ttc" id="aQuEST__internal_8h_html_a1e57230c7995447039e62a84c0a36524"><div class="ttname"><a href="QuEST__internal_8h.html#a1e57230c7995447039e62a84c0a36524">statevec_reportStateToScreen</a></div><div class="ttdeci">void statevec_reportStateToScreen(Qureg qureg, QuESTEnv env, int reportRank)</div><div class="ttdoc">Print the current state vector of probability amplitudes for a set of qubits to standard out.</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__cpu_8c_source.html#l01334">QuEST_cpu.c:1334</a></div></div>
<div class="ttc" id="astructQuESTEnv_html_af22aacd7c9905accae28484785c193b4"><div class="ttname"><a href="structQuESTEnv.html#af22aacd7c9905accae28484785c193b4">QuESTEnv::numRanks</a></div><div class="ttdeci">int numRanks</div><div class="ttdef"><b>Definition:</b> <a href="QuEST_8h_source.html#l00202">QuEST.h:202</a></div></div>
<div class="ttc" id="aQuEST__internal_8h_html_ad9fd3017ea40cf63fd04b39e03494972"><div class="ttname"><a href="QuEST__internal_8h.html#ad9fd3017ea40cf63fd04b39e03494972">statevec_initDebugState</a></div><div class="ttdeci">void statevec_initDebugState(Qureg qureg)</div><div class="ttdoc">Initialise the state vector of probability amplitudes to an (unphysical) state with each component of...</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__cpu_8c_source.html#l01559">QuEST_cpu.c:1559</a></div></div>
<div class="ttc" id="astructQureg_html_a441e4cacef6bd17adb9813c7442d42fe"><div class="ttname"><a href="structQureg.html#a441e4cacef6bd17adb9813c7442d42fe">Qureg::stateVec</a></div><div class="ttdeci">ComplexArray stateVec</div><div class="ttdoc">Computational state amplitudes - a subset thereof in the MPI version.</div><div class="ttdef"><b>Definition:</b> <a href="QuEST_8h_source.html#l00179">QuEST.h:179</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>