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.

25 lines
552B

  1. from abp import GraphState, VizClient
  2. from abp.util import xyz
  3. import itertools
  4. def grid_2d(width, height):
  5. """ Make a 2D grid """
  6. psi = GraphState()
  7. grid = list(itertools.product(list(range(width)), list(range(height))))
  8. for x, y in grid:
  9. psi.add_qubit((x, y), position=xyz(x, y, 0), vop=0)
  10. for x, y in grid:
  11. if x<width-1: psi.act_cz((x, y), (x+1, y))
  12. if y<height-1: psi.act_cz((x, y), (x, y+1))
  13. return psi
  14. if __name__ == '__main__':
  15. psi = grid_2d(5, 5)
  16. v = VizClient()
  17. v.update(psi)