This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # the state of N qubits is a complex vector of dimension 2^N | |
| n_qubits = 2 | |
| dimension = 2 ** n_qubits | |
| state = [1j, 0, 0, 0] | |
| def print_probs(state, n_qubits): | |
| # the elements of this state are squared to calculate outcome probabilities | |
| for bitstring in range(n_qubits ** 2): | |
| probability = np.abs(state[bitstring]) ** 2 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from pyquil.quil import Program | |
| from pyquil.api import QPUConnection | |
| from pyquil.gates import H, CNOT | |
| qpu = QPUConnection(device_name='19Q-Acorn') | |
| bell_state = Program(H(0), CNOT(0, 1)) | |
| result = qpu.run_and_measure(bell_state, [0, 1]) |
NewerOlder