registers.html 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. <!DOCTYPE html>
  2. <html >
  3. <head>
  4. <meta charset="utf-8">
  5. <meta name="viewport" content="width=device-width,initial-scale=1">
  6. <title>Quantum Registers</title>
  7. <link rel="stylesheet" href="_static/pygments.css">
  8. <link rel="stylesheet" href="_static/theme.css">
  9. <script src="_static/theme-vendors.js"></script>
  10. <script src="_static/theme.js" defer></script>
  11. <link rel="index" title="Index" href="genindex.html" />
  12. <link rel="search" title="Search" href="search.html" />
  13. <link rel="next" title="Quantum Gates" href="gates.html" />
  14. <link rel="prev" title="User Guide" href="guide.html" />
  15. </head>
  16. <body><div id="app" class="theme-container" :class="pageClasses"><navbar @toggle-sidebar="toggleSidebar">
  17. <router-link to="index.html" class="home-link">
  18. <span class="site-name">QCGPU</span>
  19. </router-link>
  20. <div class="links">
  21. <navlinks class="can-hide">
  22. <div class="nav-item">
  23. <a href="install.html"
  24. class="nav-link ">
  25. None
  26. </a>
  27. </div>
  28. </navlinks>
  29. </div>
  30. </navbar>
  31. <div class="sidebar-mask" @click="toggleSidebar(false)">
  32. </div>
  33. <sidebar @toggle-sidebar="toggleSidebar">
  34. <navlinks>
  35. <div class="nav-item">
  36. <a href="install.html"
  37. class="nav-link ">
  38. None
  39. </a>
  40. </div>
  41. </navlinks><div class="sidebar-links" role="navigation" aria-label="main navigation">
  42. <div class="sidebar-group">
  43. <ul class="current">
  44. <li class="toctree-l1"><a class="reference internal" href="install.html">Installation</a></li>
  45. <li class="toctree-l1"><a class="reference internal" href="quickstart.html">Getting Started</a></li>
  46. <li class="toctree-l1 current"><a class="reference internal" href="guide.html">User Guide</a><ul class="current">
  47. <li class="toctree-l2 current"><a class="current reference internal" href="#">Quantum Registers</a></li>
  48. <li class="toctree-l2"><a class="reference internal" href="gates.html">Quantum Gates</a></li>
  49. <li class="toctree-l2"><a class="reference internal" href="operations.html">Quantum Operations</a></li>
  50. </ul>
  51. </li>
  52. </ul>
  53. </div>
  54. </div>
  55. </sidebar>
  56. <page>
  57. <div class="content">
  58. <div class="section" id="quantum-registers">
  59. <h1>Quantum Registers<a class="headerlink" href="#quantum-registers" title="Permalink to this headline">¶</a></h1>
  60. <p>QCGPU provides a class to represent the register, <code class="docutils literal notranslate"><span class="pre">qcgpu.State</span></code>. The
  61. register class stores (on the OpenCL device) a state vector. This state
  62. vector is a chunk of memory, the size of which is:</p>
  63. <div class="math notranslate nohighlight">
  64. \[64 \cdot 2^n \text{ bits}.\]</div>
  65. <p>This means you would need just 2kb of memory to have a 5 qubit register,
  66. a 30 qubit register would take up 9gb of memory.</p>
  67. <p>This is something to be aware of, as the state vector must fit in the
  68. memory of the device you wish to use.</p>
  69. <div class="section" id="using-the-state-class">
  70. <h2>Using the <code class="docutils literal notranslate"><span class="pre">State</span></code> class<a class="headerlink" href="#using-the-state-class" title="Permalink to this headline">¶</a></h2>
  71. <p>To create a new register, you can use</p>
  72. <div class="code python highlight-default notranslate"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">qcgpu</span>
  73. <span class="n">register</span> <span class="o">=</span> <span class="n">qcgpu</span><span class="o">.</span><span class="n">State</span><span class="p">(</span><span class="mi">5</span><span class="p">)</span>
  74. </pre></div>
  75. </div>
  76. <p>This will create a 5 qubit register.</p>
  77. <p>When you run this, you may be prompted to choose a device. This is
  78. normal, as you can have more than 1 device that supports OpenCL in your
  79. computer. Just choose the one you want.</p>
  80. </div>
  81. <div class="section" id="mathematical-description">
  82. <h2>Mathematical Description<a class="headerlink" href="#mathematical-description" title="Permalink to this headline">¶</a></h2>
  83. <p>This class represents a state vector <span class="math notranslate nohighlight">\(\lvert \psi \rangle\)</span> with</p>
  84. <div class="math notranslate nohighlight">
  85. \[\lvert \psi \rangle = \sum_{j = 0}^{2^n - 1} \alpha_j \lvert j \rangle\]</div>
  86. <p>where <span class="math notranslate nohighlight">\(n\)</span> is the number of qubits, <span class="math notranslate nohighlight">\(\alpha_j\)</span> is the
  87. amplitude and the state is <span class="math notranslate nohighlight">\(j\)</span> runs overall <span class="math notranslate nohighlight">\(2^n\)</span> basis
  88. states.</p>
  89. </div>
  90. </div>
  91. </div>
  92. <div class="page-nav">
  93. <div class="inner">
  94. <span class="prev">
  95. <a href="guide.html"
  96. title="previous chapter">← User Guide</a>
  97. </span>
  98. <span class="next">
  99. <a href="gates.html"
  100. title="next chapter">Quantum Gates →</a>
  101. </span>
  102. <script type="text/x-mathjax-config">
  103. MathJax.Hub.Config({
  104. tex2jax: {inlineMath: [['$','$'], ['\\(','\\)']], displayMath: [['$$', '$$'], ['\\[', '\\]']]}
  105. });
  106. </script>
  107. <script type="text/javascript"
  108. src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-AMS-MML_HTMLorMML">
  109. </script>
  110. </div>
  111. </div>
  112. </page>
  113. </div></body>
  114. </html>