-
Notifications
You must be signed in to change notification settings - Fork 272
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #369 from Takishima/release/0.5.1
ProjectQ v0.5.1
- Loading branch information
Showing
31 changed files
with
2,294 additions
and
344 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -71,6 +71,7 @@ instance/ | |
|
||
# Sphinx documentation | ||
docs/_build/ | ||
docs/_doc_gen/ | ||
docs/doxygen | ||
|
||
# PyBuilder | ||
|
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
import matplotlib.pyplot as plt | ||
import getpass | ||
|
||
from projectq import MainEngine | ||
from projectq.backends import AQTBackend | ||
from projectq.libs.hist import histogram | ||
from projectq.ops import Measure, Entangle, All | ||
import projectq.setups.aqt | ||
|
||
|
||
def run_entangle(eng, num_qubits=3): | ||
""" | ||
Runs an entangling operation on the provided compiler engine. | ||
Args: | ||
eng (MainEngine): Main compiler engine to use. | ||
num_qubits (int): Number of qubits to entangle. | ||
Returns: | ||
measurement (list<int>): List of measurement outcomes. | ||
""" | ||
# allocate the quantum register to entangle | ||
qureg = eng.allocate_qureg(num_qubits) | ||
|
||
# entangle the qureg | ||
Entangle | qureg | ||
|
||
# measure; should be all-0 or all-1 | ||
All(Measure) | qureg | ||
|
||
# run the circuit | ||
eng.flush() | ||
|
||
# access the probabilities via the back-end: | ||
# results = eng.backend.get_probabilities(qureg) | ||
# for state in results: | ||
# print("Measured {} with p = {}.".format(state, results[state])) | ||
# or plot them directly: | ||
histogram(eng.backend, qureg) | ||
plt.show() | ||
|
||
# return one (random) measurement outcome. | ||
return [int(q) for q in qureg] | ||
|
||
|
||
if __name__ == "__main__": | ||
#devices available to subscription: | ||
# aqt_simulator (11 qubits) | ||
# aqt_simulator_noise (11 qubits) | ||
# aqt_device (4 qubits) | ||
# | ||
# To get a subscription, create a profile at : | ||
# https://gateway-portal.aqt.eu/ | ||
# | ||
device = None # replace by the AQT device name you want to use | ||
token = None # replace by the token given by AQT | ||
if token is None: | ||
token = getpass.getpass(prompt='AQT token > ') | ||
if device is None: | ||
device = getpass.getpass(prompt='AQT device > ') | ||
# create main compiler engine for the AQT back-end | ||
eng = MainEngine(AQTBackend(use_hardware=True, token=token, num_runs=200, | ||
verbose=False, device=device), | ||
engine_list=projectq.setups.aqt.get_engine_list( | ||
token=token, device=device)) | ||
# run the circuit and print the result | ||
print(run_entangle(eng)) |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,20 @@ | ||
import matplotlib.pyplot as plt | ||
|
||
from projectq import MainEngine | ||
from projectq.backends import CircuitDrawer | ||
from projectq.setups.default import get_engine_list | ||
from projectq.libs.hist import histogram | ||
|
||
from teleport import create_bell_pair | ||
|
||
# create a main compiler engine | ||
drawing_engine = CircuitDrawer() | ||
eng = MainEngine(drawing_engine) | ||
eng = MainEngine(engine_list = get_engine_list() + [drawing_engine]) | ||
|
||
create_bell_pair(eng) | ||
qb0, qb1 = create_bell_pair(eng) | ||
|
||
eng.flush() | ||
print(drawing_engine.get_latex()) | ||
|
||
histogram(eng.backend, [qb0, qb1]) | ||
plt.show() |
This file contains 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
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.