struct.State.html 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  6. <meta name="generator" content="rustdoc">
  7. <meta name="description" content="API documentation for the Rust `State` struct in crate `qcgpu`.">
  8. <meta name="keywords" content="rust, rustlang, rust-lang, State">
  9. <title>qcgpu::State - Rust</title>
  10. <link rel="stylesheet" type="text/css" href="../normalize.css">
  11. <link rel="stylesheet" type="text/css" href="../rustdoc.css" id="mainThemeStyle">
  12. <link rel="stylesheet" type="text/css" href="../dark.css">
  13. <link rel="stylesheet" type="text/css" href="../main.css" id="themeStyle">
  14. <script src="../storage.js"></script>
  15. </head>
  16. <body class="rustdoc struct">
  17. <!--[if lte IE 8]>
  18. <div class="warning">
  19. This old browser is unsupported and will most likely display funky
  20. things.
  21. </div>
  22. <![endif]-->
  23. <nav class="sidebar">
  24. <div class="sidebar-menu">&#9776;</div>
  25. <p class='location'>Struct State</p><div class="sidebar-elems"><div class="block items"><a class="sidebar-title" href="#fields">Fields</a><div class="sidebar-links"><a href="#structfield.buffer">buffer</a><a href="#structfield.num_amps">num_amps</a><a href="#structfield.num_qubits">num_qubits</a><a href="#structfield.backend">backend</a></div><a class="sidebar-title" href="#methods">Methods</a><div class="sidebar-links"><a href="#method.new">new</a><a href="#method.from_bit_string">from_bit_string</a><a href="#method.apply_gate">apply_gate</a><a href="#method.apply_all">apply_all</a><a href="#method.apply_controlled_gate">apply_controlled_gate</a><a href="#method.get_probabilities">get_probabilities</a><a href="#method.get_amplitudes">get_amplitudes</a><a href="#method.measure">measure</a><a href="#method.measure_many">measure_many</a><a href="#method.add_scratch">add_scratch</a><a href="#method.measure_scratch">measure_scratch</a><a href="#method.measure_first">measure_first</a><a href="#method.info">info</a><a href="#method.h">h</a><a href="#method.s">s</a><a href="#method.t">t</a><a href="#method.x">x</a><a href="#method.y">y</a><a href="#method.z">z</a><a href="#method.cx">cx</a><a href="#method.toffoli">toffoli</a><a href="#method.swap">swap</a><a href="#method.pow_mod">pow_mod</a></div><a class="sidebar-title" href="#implementations">Trait Implementations</a><div class="sidebar-links"><a href="#impl-Debug">Debug</a><a href="#impl-Display">Display</a></div></div><p class='location'><a href='index.html'>qcgpu</a></p><script>window.sidebarCurrent = {name: 'State', ty: 'struct', relpath: ''};</script><script defer src="sidebar-items.js"></script></div>
  26. </nav>
  27. <div class="theme-picker">
  28. <button id="theme-picker" aria-label="Pick another theme!">
  29. <img src="../brush.svg" width="18" alt="Pick another theme!">
  30. </button>
  31. <div id="theme-choices"></div>
  32. </div>
  33. <script src="../theme.js"></script>
  34. <nav class="sub">
  35. <form class="search-form js-only">
  36. <div class="search-container">
  37. <input class="search-input" name="search"
  38. autocomplete="off"
  39. placeholder="Click or press ‘S’ to search, ‘?’ for more options…"
  40. type="search">
  41. </div>
  42. </form>
  43. </nav>
  44. <section id='main' class="content">
  45. <h1 class='fqn'><span class='in-band'>Struct <a href='index.html'>qcgpu</a>::<wbr><a class="struct" href=''>State</a></span><span class='out-of-band'><span id='render-detail'>
  46. <a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">
  47. [<span class='inner'>&#x2212;</span>]
  48. </a>
  49. </span><a class='srclink' href='../src/qcgpu/state.rs.html#16-30' title='goto source code'>[src]</a></span></h1>
  50. <pre class='rust struct'>pub struct State {
  51. pub buffer: <a class="struct" href="../ocl/standard/buffer/struct.Buffer.html" title="struct ocl::standard::buffer::Buffer">Buffer</a>&lt;<a class="type" href="../num_complex/type.Complex32.html" title="type num_complex::Complex32">Complex32</a>&gt;,
  52. pub num_amps: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>,
  53. pub num_qubits: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a>,
  54. pub backend: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>,
  55. // some fields omitted
  56. }</pre><div class='docblock'><p>Representation of a quantum register</p>
  57. </div><h2 id='fields' class='fields small-section-header'>
  58. Fields<a href='#fields' class='anchor'></a></h2><span id="structfield.buffer" class="structfield small-section-header">
  59. <a href="#structfield.buffer" class="anchor field"></a>
  60. <span id="buffer.v" class='invisible'>
  61. <code>buffer: <a class="struct" href="../ocl/standard/buffer/struct.Buffer.html" title="struct ocl::standard::buffer::Buffer">Buffer</a>&lt;<a class="type" href="../num_complex/type.Complex32.html" title="type num_complex::Complex32">Complex32</a>&gt;</code>
  62. </span></span><div class='docblock'><p>The OpenCL Buffer for the state vector</p>
  63. </div><span id="structfield.num_amps" class="structfield small-section-header">
  64. <a href="#structfield.num_amps" class="anchor field"></a>
  65. <span id="num_amps.v" class='invisible'>
  66. <code>num_amps: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a></code>
  67. </span></span><div class='docblock'><p>Number of amplitudes stored in the state vector</p>
  68. </div><span id="structfield.num_qubits" class="structfield small-section-header">
  69. <a href="#structfield.num_qubits" class="anchor field"></a>
  70. <span id="num_qubits.v" class='invisible'>
  71. <code>num_qubits: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a></code>
  72. </span></span><div class='docblock'><p>Number of qubits in the register</p>
  73. </div><span id="structfield.backend" class="structfield small-section-header">
  74. <a href="#structfield.backend" class="anchor field"></a>
  75. <span id="backend.v" class='invisible'>
  76. <code>backend: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a></code>
  77. </span></span><div class='docblock'><p>The OpenCL Backend used. Use the method <code>info()</code> to get the devices identifier</p>
  78. </div>
  79. <h2 id='methods' class='small-section-header'>
  80. Methods<a href='#methods' class='anchor'></a>
  81. </h2>
  82. <h3 id='impl' class='impl'><span class='in-band'><code>impl <a class="struct" href="../qcgpu/struct.State.html" title="struct qcgpu::State">State</a></code><a href='#impl' class='anchor'></a></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../src/qcgpu/state.rs.html#32-558' title='goto source code'>[src]</a></span></h3>
  83. <div class='impl-items'><h4 id='method.new' class="method"><span id='new.v' class='invisible'><code>pub fn <a href='#method.new' class='fnname'>new</a>(num_qubits: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a>, backend: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>) -&gt; <a class="struct" href="../qcgpu/struct.State.html" title="struct qcgpu::State">State</a></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../src/qcgpu/state.rs.html#42-81' title='goto source code'>[src]</a></span></h4>
  84. <div class='docblock'><p>Create a new quantum register, with a given number of qubits.
  85. The backend is the OpenCL ID of the accelerator to use.</p>
  86. <p>The register will be initialized in the state |00...0&gt;</p>
  87. <pre class="rust rust-example-rendered">
  88. <span class="kw">let</span> <span class="ident">state</span> <span class="op">=</span> <span class="ident">qcgpu</span>::<span class="ident">State</span>::<span class="ident">new</span>(<span class="number">2</span>,<span class="number">0</span>);</pre>
  89. </div><h4 id='method.from_bit_string' class="method"><span id='from_bit_string.v' class='invisible'><code>pub fn <a href='#method.from_bit_string' class='fnname'>from_bit_string</a>(bit_string: &amp;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a>, backend: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>) -&gt; <a class="struct" href="../qcgpu/struct.State.html" title="struct qcgpu::State">State</a></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../src/qcgpu/state.rs.html#91-133' title='goto source code'>[src]</a></span></h4>
  90. <div class='docblock'><p>Create a new quantum register, starting in the
  91. State given. The backend is the OpenCL ID of the
  92. accelerator to use.</p>
  93. <pre class="rust rust-example-rendered">
  94. <span class="kw">let</span> <span class="ident">state</span> <span class="op">=</span> <span class="ident">qcgpu</span>::<span class="ident">State</span>::<span class="ident">from_bit_string</span>(<span class="string">&quot;|00&gt;&quot;</span>, <span class="number">1</span>);</pre>
  95. </div><h4 id='method.apply_gate' class="method"><span id='apply_gate.v' class='invisible'><code>pub fn <a href='#method.apply_gate' class='fnname'>apply_gate</a>(&amp;mut self, target: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i32.html">i32</a>, gate: <a class="struct" href="../qcgpu/gates/struct.Gate.html" title="struct qcgpu::gates::Gate">Gate</a>)</code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../src/qcgpu/state.rs.html#136-157' title='goto source code'>[src]</a></span></h4>
  96. <div class='docblock'><p>Apply a gate to the target qubit</p>
  97. </div><h4 id='method.apply_all' class="method"><span id='apply_all.v' class='invisible'><code>pub fn <a href='#method.apply_all' class='fnname'>apply_all</a>(&amp;mut self, gate: <a class="struct" href="../qcgpu/gates/struct.Gate.html" title="struct qcgpu::gates::Gate">Gate</a>)</code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../src/qcgpu/state.rs.html#160-164' title='goto source code'>[src]</a></span></h4>
  98. <div class='docblock'><p>Apply a gate to every qubit in the register</p>
  99. </div><h4 id='method.apply_controlled_gate' class="method"><span id='apply_controlled_gate.v' class='invisible'><code>pub fn <a href='#method.apply_controlled_gate' class='fnname'>apply_controlled_gate</a>(&amp;mut self, control: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i32.html">i32</a>, target: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i32.html">i32</a>, gate: <a class="struct" href="../qcgpu/gates/struct.Gate.html" title="struct qcgpu::gates::Gate">Gate</a>)</code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../src/qcgpu/state.rs.html#167-191' title='goto source code'>[src]</a></span></h4>
  100. <div class='docblock'><p>Apply a gate to the register if the control qubit is 1.</p>
  101. </div><h4 id='method.get_probabilities' class="method"><span id='get_probabilities.v' class='invisible'><code>pub fn <a href='#method.get_probabilities' class='fnname'>get_probabilities</a>(&amp;mut self) -&gt; <a class="struct" href="https://doc.rust-lang.org/nightly/alloc/vec/struct.Vec.html" title="struct alloc::vec::Vec">Vec</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.f32.html">f32</a>&gt;</code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../src/qcgpu/state.rs.html#197-215' title='goto source code'>[src]</a></span></h4>
  102. <div class='docblock'><p>Return the probabilities of each outcome.</p>
  103. <p>The probabilitity of a state a|x&gt; being measured
  104. is |a|^2.</p>
  105. </div><h4 id='method.get_amplitudes' class="method"><span id='get_amplitudes.v' class='invisible'><code>pub fn <a href='#method.get_amplitudes' class='fnname'>get_amplitudes</a>(&amp;mut self) -&gt; <a class="struct" href="https://doc.rust-lang.org/nightly/alloc/vec/struct.Vec.html" title="struct alloc::vec::Vec">Vec</a>&lt;<a class="type" href="../num_complex/type.Complex32.html" title="type num_complex::Complex32">Complex32</a>&gt;</code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../src/qcgpu/state.rs.html#218-223' title='goto source code'>[src]</a></span></h4>
  106. <div class='docblock'><p>Return the state vector of the quantum register</p>
  107. </div><h4 id='method.measure' class="method"><span id='measure.v' class='invisible'><code>pub fn <a href='#method.measure' class='fnname'>measure</a>(&amp;mut self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i32.html">i32</a></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../src/qcgpu/state.rs.html#226-244' title='goto source code'>[src]</a></span></h4>
  108. <div class='docblock'><p>Measure the quantum register, returning the measured result</p>
  109. </div><h4 id='method.measure_many' class="method"><span id='measure_many.v' class='invisible'><code>pub fn <a href='#method.measure_many' class='fnname'>measure_many</a>(&amp;mut self, num_iterations: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i32.html">i32</a>) -&gt; <a class="struct" href="https://doc.rust-lang.org/nightly/std/collections/hash/map/struct.HashMap.html" title="struct std::collections::hash::map::HashMap">HashMap</a>&lt;<a class="struct" href="https://doc.rust-lang.org/nightly/alloc/string/struct.String.html" title="struct alloc::string::String">String</a>, <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i32.html">i32</a>&gt;</code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../src/qcgpu/state.rs.html#249-273' title='goto source code'>[src]</a></span></h4>
  110. <div class='docblock'><p>Preform multiple measurements, returning the results
  111. as a HashMap, with the key as the result and the value as the
  112. number of times that result was measured</p>
  113. </div><h4 id='method.add_scratch' class="method"><span id='add_scratch.v' class='invisible'><code>pub fn <a href='#method.add_scratch' class='fnname'>add_scratch</a>(&amp;mut self, num_scratch: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a>)</code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../src/qcgpu/state.rs.html#277-305' title='goto source code'>[src]</a></span></h4>
  114. <div class='docblock'><p>Add qubits to the register. The qubits are initialized to zero.
  115. This should be used as scratch space.</p>
  116. </div><h4 id='method.measure_scratch' class="method"><span id='measure_scratch.v' class='invisible'><code>pub fn <a href='#method.measure_scratch' class='fnname'>measure_scratch</a>(&amp;mut self, num_to_measure: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a>)</code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../src/qcgpu/state.rs.html#339-364' title='goto source code'>[src]</a></span></h4>
  117. <div class='docblock'><p>Measure the scratch qubits. The measurement is discarded, and
  118. the register size is reduced by <code>num_to_measure</code> qubits.</p>
  119. </div><h4 id='method.measure_first' class="method"><span id='measure_first.v' class='invisible'><code>pub fn <a href='#method.measure_first' class='fnname'>measure_first</a>(<br>&nbsp;&nbsp;&nbsp;&nbsp;&amp;mut self, <br>&nbsp;&nbsp;&nbsp;&nbsp;num_to_measure: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i32.html">i32</a>, <br>&nbsp;&nbsp;&nbsp;&nbsp;num_iterations: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i32.html">i32</a><br>) -&gt; <a class="struct" href="https://doc.rust-lang.org/nightly/std/collections/hash/map/struct.HashMap.html" title="struct std::collections::hash::map::HashMap">HashMap</a>&lt;<a class="struct" href="https://doc.rust-lang.org/nightly/alloc/string/struct.String.html" title="struct alloc::string::String">String</a>, <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i32.html">i32</a>&gt;</code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../src/qcgpu/state.rs.html#369-403' title='goto source code'>[src]</a></span></h4>
  120. <div class='docblock'><p>Preform multiple measurements of the first <code>num_to_measure</code>, returning the results
  121. as a HashMap, with the key as the result and the value as the
  122. number of times that result was measured</p>
  123. </div><h4 id='method.info' class="method"><span id='info.v' class='invisible'><code>pub fn <a href='#method.info' class='fnname'>info</a>(&amp;self)</code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../src/qcgpu/state.rs.html#406-411' title='goto source code'>[src]</a></span></h4>
  124. <div class='docblock'><p>Print Information About The Device</p>
  125. </div><h4 id='method.h' class="method"><span id='h.v' class='invisible'><code>pub fn <a href='#method.h' class='fnname'>h</a>(&amp;mut self, target: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i32.html">i32</a>)</code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../src/qcgpu/state.rs.html#419-423' title='goto source code'>[src]</a></span></h4>
  126. <div class='docblock'><p>Hadamard Gate
  127. Shorthand Method</p>
  128. <p>Equivilent to <code>state.apply_gate(target, h());</code></p>
  129. </div><h4 id='method.s' class="method"><span id='s.v' class='invisible'><code>pub fn <a href='#method.s' class='fnname'>s</a>(&amp;mut self, target: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i32.html">i32</a>)</code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../src/qcgpu/state.rs.html#429-433' title='goto source code'>[src]</a></span></h4>
  130. <div class='docblock'><p>S Gate
  131. Shorthand Method</p>
  132. <p>Equivilent to <code>state.apply_gate(target, s());</code></p>
  133. </div><h4 id='method.t' class="method"><span id='t.v' class='invisible'><code>pub fn <a href='#method.t' class='fnname'>t</a>(&amp;mut self, target: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i32.html">i32</a>)</code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../src/qcgpu/state.rs.html#439-443' title='goto source code'>[src]</a></span></h4>
  134. <div class='docblock'><p>T Gate
  135. Shorthand Method</p>
  136. <p>Equivilent to <code>state.apply_gate(target, t());</code></p>
  137. </div><h4 id='method.x' class="method"><span id='x.v' class='invisible'><code>pub fn <a href='#method.x' class='fnname'>x</a>(&amp;mut self, target: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i32.html">i32</a>)</code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../src/qcgpu/state.rs.html#449-453' title='goto source code'>[src]</a></span></h4>
  138. <div class='docblock'><p>Pauli X Gate
  139. Shorthand Method</p>
  140. <p>Equivilent to <code>state.apply_gate(target, x());</code></p>
  141. </div><h4 id='method.y' class="method"><span id='y.v' class='invisible'><code>pub fn <a href='#method.y' class='fnname'>y</a>(&amp;mut self, target: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i32.html">i32</a>)</code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../src/qcgpu/state.rs.html#459-463' title='goto source code'>[src]</a></span></h4>
  142. <div class='docblock'><p>Pauli Y Gate
  143. Shorthand Method</p>
  144. <p>Equivilent to <code>state.apply_gate(target, y());</code></p>
  145. </div><h4 id='method.z' class="method"><span id='z.v' class='invisible'><code>pub fn <a href='#method.z' class='fnname'>z</a>(&amp;mut self, target: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i32.html">i32</a>)</code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../src/qcgpu/state.rs.html#469-473' title='goto source code'>[src]</a></span></h4>
  146. <div class='docblock'><p>Pauli Z Gate
  147. Shorthand Method</p>
  148. <p>Equivilent to <code>state.apply_gate(target, z());</code></p>
  149. </div><h4 id='method.cx' class="method"><span id='cx.v' class='invisible'><code>pub fn <a href='#method.cx' class='fnname'>cx</a>(&amp;mut self, control: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i32.html">i32</a>, target: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i32.html">i32</a>)</code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../src/qcgpu/state.rs.html#479-481' title='goto source code'>[src]</a></span></h4>
  150. <div class='docblock'><p>Controlled Not Gate
  151. Shorthand method</p>
  152. <p>Equivilent to <code>state.apply_controlled_gate(control, target, x());</code></p>
  153. </div><h4 id='method.toffoli' class="method"><span id='toffoli.v' class='invisible'><code>pub fn <a href='#method.toffoli' class='fnname'>toffoli</a>(&amp;mut self, control1: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i32.html">i32</a>, control2: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i32.html">i32</a>, target: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i32.html">i32</a>)</code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../src/qcgpu/state.rs.html#485-512' title='goto source code'>[src]</a></span></h4>
  154. <div class='docblock'><p>Toffoli (Controlled-Controlled-NOT gate)
  155. Shorthand method</p>
  156. </div><h4 id='method.swap' class="method"><span id='swap.v' class='invisible'><code>pub fn <a href='#method.swap' class='fnname'>swap</a>(&amp;mut self, first_qubit: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i32.html">i32</a>, second_qubit: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i32.html">i32</a>)</code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../src/qcgpu/state.rs.html#515-532' title='goto source code'>[src]</a></span></h4>
  157. <div class='docblock'><p>Swap two qubits in the register</p>
  158. </div><h4 id='method.pow_mod' class="method"><span id='pow_mod.v' class='invisible'><code>pub fn <a href='#method.pow_mod' class='fnname'>pow_mod</a>(&amp;mut self, x: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i32.html">i32</a>, n: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i32.html">i32</a>, input_width: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i32.html">i32</a>, output_width: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i32.html">i32</a>)</code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../src/qcgpu/state.rs.html#535-557' title='goto source code'>[src]</a></span></h4>
  159. <div class='docblock'><p>Caclulates f(a) = x^a mod n.</p>
  160. </div></div>
  161. <h2 id='implementations' class='small-section-header'>
  162. Trait Implementations<a href='#implementations' class='anchor'></a>
  163. </h2>
  164. <h3 id='impl-Debug' class='impl'><span class='in-band'><code>impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html" title="trait core::fmt::Debug">Debug</a> for <a class="struct" href="../qcgpu/struct.State.html" title="struct qcgpu::State">State</a></code><a href='#impl-Debug' class='anchor'></a></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../src/qcgpu/state.rs.html#15' title='goto source code'>[src]</a></span></h3>
  165. <div class='impl-items'><h4 id='method.fmt' class="method"><span id='fmt.v' class='invisible'><code>fn <a href='https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html#tymethod.fmt' class='fnname'>fmt</a>(&amp;self, __arg_0: &amp;mut <a class="struct" href="https://doc.rust-lang.org/nightly/core/fmt/struct.Formatter.html" title="struct core::fmt::Formatter">Formatter</a>) -&gt; <a class="type" href="https://doc.rust-lang.org/nightly/core/fmt/type.Result.html" title="type core::fmt::Result">Result</a></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../src/qcgpu/state.rs.html#15' title='goto source code'>[src]</a></span></h4>
  166. <div class='docblock'><p>Formats the value using the given formatter. <a href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html#tymethod.fmt">Read more</a></p>
  167. </div></div><h3 id='impl-Display' class='impl'><span class='in-band'><code>impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/fmt/trait.Display.html" title="trait core::fmt::Display">Display</a> for <a class="struct" href="../qcgpu/struct.State.html" title="struct qcgpu::State">State</a></code><a href='#impl-Display' class='anchor'></a></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../src/qcgpu/state.rs.html#560-578' title='goto source code'>[src]</a></span></h3>
  168. <div class='impl-items'><h4 id='method.fmt-1' class="method"><span id='fmt.v-1' class='invisible'><code>fn <a href='https://doc.rust-lang.org/nightly/core/fmt/trait.Display.html#tymethod.fmt' class='fnname'>fmt</a>(&amp;self, f: &amp;mut <a class="struct" href="https://doc.rust-lang.org/nightly/core/fmt/struct.Formatter.html" title="struct core::fmt::Formatter">Formatter</a>) -&gt; <a class="type" href="https://doc.rust-lang.org/nightly/core/fmt/type.Result.html" title="type core::fmt::Result">Result</a></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../src/qcgpu/state.rs.html#561-577' title='goto source code'>[src]</a></span></h4>
  169. <div class='docblock'><p>Formats the value using the given formatter. <a href="https://doc.rust-lang.org/nightly/core/fmt/trait.Display.html#tymethod.fmt">Read more</a></p>
  170. </div></div></section>
  171. <section id='search' class="content hidden"></section>
  172. <section class="footer"></section>
  173. <aside id="help" class="hidden">
  174. <div>
  175. <h1 class="hidden">Help</h1>
  176. <div class="shortcuts">
  177. <h2>Keyboard Shortcuts</h2>
  178. <dl>
  179. <dt><kbd>?</kbd></dt>
  180. <dd>Show this help dialog</dd>
  181. <dt><kbd>S</kbd></dt>
  182. <dd>Focus the search field</dd>
  183. <dt><kbd>↑</kbd></dt>
  184. <dd>Move up in search results</dd>
  185. <dt><kbd>↓</kbd></dt>
  186. <dd>Move down in search results</dd>
  187. <dt><kbd>↹</kbd></dt>
  188. <dd>Switch tab</dd>
  189. <dt><kbd>&#9166;</kbd></dt>
  190. <dd>Go to active search result</dd>
  191. <dt><kbd>+</kbd></dt>
  192. <dd>Expand all sections</dd>
  193. <dt><kbd>-</kbd></dt>
  194. <dd>Collapse all sections</dd>
  195. </dl>
  196. </div>
  197. <div class="infos">
  198. <h2>Search Tricks</h2>
  199. <p>
  200. Prefix searches with a type followed by a colon (e.g.
  201. <code>fn:</code>) to restrict the search to a given type.
  202. </p>
  203. <p>
  204. Accepted types are: <code>fn</code>, <code>mod</code>,
  205. <code>struct</code>, <code>enum</code>,
  206. <code>trait</code>, <code>type</code>, <code>macro</code>,
  207. and <code>const</code>.
  208. </p>
  209. <p>
  210. Search functions by type signature (e.g.
  211. <code>vec -> usize</code> or <code>* -> vec</code>)
  212. </p>
  213. </div>
  214. </div>
  215. </aside>
  216. <script>
  217. window.rootPath = "../";
  218. window.currentCrate = "qcgpu";
  219. </script>
  220. <script src="../main.js"></script>
  221. <script defer src="../search-index.js"></script>
  222. </body>
  223. </html>