quickstart.rst 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. ===============
  2. Getting Started
  3. ===============
  4. When using this library, you will most likely be using the :class:`~qiskit.State` class.
  5. This class represents the state of a quantum register.
  6. Using this class you can apply gates to the register, measure, get the state vector and things like that.
  7. To run a simple quantum circuit, you can use something like this,
  8. .. code-block:: python
  9. # Import QCGPU
  10. import qcgpu
  11. # Create a new quantum register with 2 qubits
  12. register = qcgpu.State(2)
  13. # Apply a hadamard (H) gate to the first qubit.
  14. # You should note that the qubits are zero indexed
  15. register.h(0)
  16. # Add a controlled not (CNOT/CX) gate, with the control as
  17. # the first qubit and target as the second.
  18. # The register will now be in the bell state.
  19. register.cx(0, 1)
  20. # Perform a measurement with 1000 samples
  21. results = register.measure(samples=1000)
  22. # Show the results
  23. print(results)
  24. The output of a measurement gives a dictionary of measurement outcomes,
  25. along with how often they occurred.
  26. .. code-block:: python
  27. {'00': 486, '11': 514}
  28. There are a few different ways to do things using QCGPU,
  29. so you should check out the rest of the documentation too