quickstart.rst 1.1 KB

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