Anders and Briegel in Python
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

147 lines
3.5KB

  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. .. toctree::
  6. :maxdepth: 2
  7. Welcome to ``abp``
  8. ===============================
  9. This is the documentation for ``abp``. It's a work in progress.
  10. ``abp`` is a Python port of Anders and Briegel' s `method <https://arxiv.org/abs/quant-ph/0504117>`_ for fast simulation of Clifford circuits.
  11. 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\}`.
  12. It should do thousands of qubits without much trouble.
  13. .. image:: ../examples/demo.gif
  14. Installing
  15. ----------------------------
  16. You can install from ``pip``:
  17. .. code-block:: bash
  18. $ pip install --user abp
  19. Alternatively, clone from the `github repo <https://github.com/peteshadbolt/abp>`_ and run ``setup.py``:
  20. .. code-block:: bash
  21. $ git clone https://github.com/peteshadbolt/abp
  22. $ cd abp
  23. $ python setup.py install --user
  24. If you want to modify and test ``abp`` without having to re-install, switch into ``develop`` mode:
  25. .. code-block:: bash
  26. $ python setup.py develop --user
  27. Quickstart
  28. ----------------------------
  29. It's pretty easy to build a graph state, act some gates, and do measurements::
  30. >>> from abp import GraphState
  31. >>> g = GraphState(range(5))
  32. >>> for i in range(5):
  33. ... g.act_hadamard(i)
  34. ...
  35. >>> for i in range(4):
  36. ... g.act_cz(i, i+1)
  37. ...
  38. >>> print g
  39. 0: IA (1,)
  40. 1: IA (0,2)
  41. 2: IA (1,3)
  42. 3: IA (2,4)
  43. 4: IA (3,)
  44. >>> g.measure(2, "px")
  45. 0
  46. >>> print g
  47. 0: IA (3,)
  48. 1: ZC (3,)
  49. 2: IA -
  50. 3: ZA (0,1,4)
  51. 4: IA (3,)
  52. Working with GraphStates
  53. -------------------------
  54. The ``abp.GraphState`` class is your main interface to ``abp``.
  55. Here follows complete documentation
  56. .. autoclass:: abp.GraphState
  57. .. automethod:: abp.GraphState.__init__
  58. .. automethod:: abp.GraphState.add_node
  59. .. automethod:: abp.GraphState.add_nodes
  60. .. automethod:: abp.GraphState.act_local_rotation
  61. .. automethod:: abp.GraphState.act_hadamard
  62. .. automethod:: abp.GraphState.act_cz
  63. .. automethod:: abp.GraphState.act_circuit
  64. .. automethod:: abp.GraphState.measure
  65. .. automethod:: abp.GraphState.to_json
  66. .. automethod:: abp.GraphState.to_state_vector
  67. .. automethod:: abp.GraphState.to_stabilizer
  68. The Clifford group
  69. ----------------------
  70. Visualization
  71. ----------------------
  72. ``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.
  73. First, run ``abpserver`` in a terminal:
  74. .. code-block:: bash
  75. $ abpserver
  76. Listening on port 5000 for clients..
  77. Then browse to ``http://localhost:5001/`` (in some circumstances ``abp`` will automatically pop a browser window).
  78. Now, in another terminal, use ``abp.fancy.GraphState`` to run a Clifford circuit::
  79. >>> from abp.fancy import GraphState
  80. >>> g = GraphState(10)
  81. >>> g = GraphState(range(10))
  82. >>> for i in range(10):
  83. ... g.act_hadamard(i)
  84. ...
  85. >>> g.update()
  86. >>> for i in range(9):
  87. ... g.act_cz(i, i+1)
  88. ...
  89. >>> g.update()
  90. ```
  91. And you should see a 3D visualization of the state.
  92. .. image:: ../examples/viz.png
  93. Reference
  94. ----------------------------
  95. More detailed docs are available here:
  96. * :ref:`genindex`
  97. * :ref:`modindex`
  98. * :ref:`search`