Anders and Briegel in Python
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

160 lignes
3.7KB

  1. .. abp documentation master file, created by
  2. sphinx-quickstart on Sun Jul 24 18:12:02 2016.
  3. You can adapt this file completely to your liking, but it should at least
  4. contain the root `toctree` directive.
  5. ``abp``
  6. ===============================
  7. This is the documentation for ``abp``. It's a work in progress.
  8. .. toctree::
  9. :hidden:
  10. :maxdepth: 2
  11. modules
  12. ``abp`` is a Python port of Anders and Briegel' s `method <https://arxiv.org/abs/quant-ph/0504117>`_ for fast simulation of Clifford circuits.
  13. That means that you can make quantum states of thousands of qubits, perform any sequence of Clifford operations, and measure in any of :math:`\{\sigma_x, \sigma_y, \sigma_z\}`.
  14. .. image:: ../examples/demo.gif
  15. Installing
  16. ----------------------------
  17. You can install from ``pip``:
  18. .. code-block:: bash
  19. $ pip install --user abp
  20. Alternatively, clone from the `github repo <https://github.com/peteshadbolt/abp>`_ and run ``setup.py``:
  21. .. code-block:: bash
  22. $ git clone https://github.com/peteshadbolt/abp
  23. $ cd abp
  24. $ python setup.py install --user
  25. If you want to modify and test ``abp`` without having to re-install, switch into ``develop`` mode:
  26. .. code-block:: bash
  27. $ python setup.py develop --user
  28. Quickstart
  29. ----------------------------
  30. It's pretty easy to build a graph state, act some gates, and do measurements::
  31. >>> from abp import GraphState
  32. >>> g = GraphState(range(5))
  33. >>> for i in range(5):
  34. ... g.act_hadamard(i)
  35. ...
  36. >>> for i in range(4):
  37. ... g.act_cz(i, i+1)
  38. ...
  39. >>> print g
  40. 0: IA (1,)
  41. 1: IA (0,2)
  42. 2: IA (1,3)
  43. 3: IA (2,4)
  44. 4: IA (3,)
  45. >>> g.measure(2, "px")
  46. 0
  47. >>> print g
  48. 0: IA (3,)
  49. 1: ZC (3,)
  50. 2: IA -
  51. 3: ZA (0,1,4)
  52. 4: IA (3,)
  53. Working with GraphStates
  54. -------------------------
  55. The ``abp.GraphState`` class is the main interface to ``abp``.
  56. .. autoclass:: abp.GraphState
  57. .. automethod:: abp.GraphState.__init__
  58. .. automethod:: abp.GraphState.add_qubit
  59. .. automethod:: abp.GraphState.act_local_rotation
  60. .. automethod:: abp.GraphState.act_hadamard
  61. .. automethod:: abp.GraphState.act_cz
  62. .. automethod:: abp.GraphState.act_circuit
  63. .. automethod:: abp.GraphState.measure
  64. .. automethod:: abp.GraphState.to_json
  65. .. automethod:: abp.GraphState.to_state_vector
  66. .. automethod:: abp.GraphState.to_stabilizer
  67. .. automethod:: abp.GraphState.remove_vop
  68. .. automethod:: abp.GraphState.measure_x
  69. .. automethod:: abp.GraphState.measure_y
  70. .. automethod:: abp.GraphState.measure_z
  71. .. _clifford:
  72. The Clifford group
  73. ----------------------
  74. .. automodule:: abp.clifford
  75. |
  76. The ``clifford`` module provides a few useful functions:
  77. .. autofunction:: abp.clifford.use_old_cz
  78. :noindex:
  79. Visualization
  80. ----------------------
  81. ``abp`` comes with a tool to visualize graph states in a WebGL compatible web browser (Chrome, Firefox, Safari etc). It uses a client-server architecture.
  82. First, run ``abpserver`` in a terminal:
  83. .. code-block:: bash
  84. $ abpserver
  85. Listening on port 5000 for clients..
  86. Then browse to ``http://localhost:5001/`` (in some circumstances ``abp`` will automatically pop a browser window).
  87. Now, in another terminal, use ``abp.fancy.GraphState`` to run a Clifford circuit::
  88. >>> from abp.fancy import GraphState
  89. >>> g = GraphState(range(10))
  90. >>> g.act_circuit([(i, "hadamard") for i in range(10)])
  91. >>> g.act_circuit([((i, i+1), "cz") for i in range(9)])
  92. >>> g.update()
  93. And you should see a 3D visualization of the state. You can call ``update()`` in a loop to see an animation.
  94. .. image:: ../examples/viz.png
  95. Reference
  96. ----------------------------
  97. More detailed docs are available here:
  98. * :ref:`genindex`
  99. * :ref:`modindex`
  100. * :ref:`search`