Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 10,471
- 11,40
- 00,43
- 01,440
- 10,490
- 11,51
- 00,54
- 10,471
- 01,498
- 10,526
- 01,528
- 10,496
- 01,514
- 10,510
- # Set range for rotation
- phi_range = np.linspace(0, np.pi, 128)
- for phi_value in phi_range:
- # inside the loop because putting it outside breaks it and makes it run
- # really really slow
- qr = QuantumRegister(2, name='qr')
- cr = ClassicalRegister(2, name='cr')
- bell = QuantumCircuit(qr, cr, name='bell')
- # Set what state the circuit starts in and the details of the rotation
- if startingState == '00' or startingState == '10':
- theta = np.pi/2
- lam = -phi_value - np.pi/2
- elif startingState == '01' or startingState == '11':
- theta = phi_value
- lam = 0 - np.pi/2
- else:
- raise ValueError('Setting rotation problems')
- phi = -lam
- # initializing the starting state of the circuit (done separately to
- # above for clarity)
- if startingState == '01':
- bell.x(qr[1])
- elif startingState == '10':
- bell.x(qr[0])
- elif startingState == '11':
- bell.x(range(2))
- # this is the bell state code itself
- bell.h(qr[0])
- bell.cx(qr[0], qr[1])
- bell.barrier()
- bell.u3(theta, lam, phi, qr)
- bell.barrier()
- bell.measure(qr[0], cr[0])
- bell.measure(qr[1], cr[1])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement