Advertisement
Guest User

Untitled

a guest
Jun 18th, 2019
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.28 KB | None | 0 0
  1. 10,471
  2. 11,40
  3. 00,43
  4. 01,440
  5. 10,490
  6. 11,51
  7. 00,54
  8.  
  9. 10,471
  10. 01,498
  11. 10,526
  12. 01,528
  13. 10,496
  14. 01,514
  15. 10,510
  16.  
  17. # Set range for rotation
  18. phi_range = np.linspace(0, np.pi, 128)
  19.  
  20. for phi_value in phi_range:
  21. # inside the loop because putting it outside breaks it and makes it run
  22. # really really slow
  23. qr = QuantumRegister(2, name='qr')
  24. cr = ClassicalRegister(2, name='cr')
  25. bell = QuantumCircuit(qr, cr, name='bell')
  26.  
  27. # Set what state the circuit starts in and the details of the rotation
  28. if startingState == '00' or startingState == '10':
  29. theta = np.pi/2
  30. lam = -phi_value - np.pi/2
  31.  
  32. elif startingState == '01' or startingState == '11':
  33. theta = phi_value
  34. lam = 0 - np.pi/2
  35. else:
  36. raise ValueError('Setting rotation problems')
  37.  
  38. phi = -lam
  39.  
  40. # initializing the starting state of the circuit (done separately to
  41. # above for clarity)
  42. if startingState == '01':
  43. bell.x(qr[1])
  44. elif startingState == '10':
  45. bell.x(qr[0])
  46. elif startingState == '11':
  47. bell.x(range(2))
  48.  
  49. # this is the bell state code itself
  50. bell.h(qr[0])
  51. bell.cx(qr[0], qr[1])
  52.  
  53. bell.barrier()
  54. bell.u3(theta, lam, phi, qr)
  55. bell.barrier()
  56.  
  57. bell.measure(qr[0], cr[0])
  58. bell.measure(qr[1], cr[1])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement