registers.rst 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. =================
  2. Quantum Registers
  3. =================
  4. QCGPU provides a class to represent the register, ``qcgpu.State``. The
  5. register class stores (on the OpenCL device) a state vector. This state
  6. vector is a chunk of memory, the size of which is:
  7. .. math::
  8. 64 \cdot 2^n \text{ bits}.
  9. This means you would need just 2kb of memory to have a 5 qubit register,
  10. a 30 qubit register would take up 9gb of memory.
  11. This is something to be aware of, as the state vector must fit in the
  12. memory of the device you wish to use.
  13. Using the ``State`` class
  14. -------------------------
  15. To create a new register, you can use
  16. .. code:: python
  17. import qcgpu
  18. register = qcgpu.State(5)
  19. This will create a 5 qubit register.
  20. When you run this, you may be prompted to choose a device. This is
  21. normal, as you can have more than 1 device that supports OpenCL in your
  22. computer. Just choose the one you want.
  23. Mathematical Description
  24. -------------------------
  25. This class represents a state vector :math:`\lvert \psi \rangle` with
  26. .. math::
  27. \lvert \psi \rangle = \sum_{j = 0}^{2^n - 1} \alpha_j \lvert j \rangle
  28. where :math:`n` is the number of qubits, :math:`\alpha_j` is the
  29. amplitude and the state is :math:`j` runs overall :math:`2^n` basis
  30. states.