-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
21 changed files
with
1,395 additions
and
65 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
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 |
---|---|---|
|
@@ -212,3 +212,7 @@ flycheck_*.el | |
|
||
# network security | ||
/network-security.data | ||
|
||
.vscode | ||
.\vscode | ||
./vscode |
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,233 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 1, | ||
"id": "1855e140", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"from quasi.simulation import Simulation\n", | ||
"from quasi.experiement import Experiement\n", | ||
"from quasi.components.gates import Squeezing, Beamsplitter, Phase\n", | ||
"from math import pi\n", | ||
"import numpy as np\n", | ||
"from quasi._math.fock import mean_photon" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 2, | ||
"id": "8d6b64f9", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"squeezing_gate = Squeezing(r=1, phi=pi, cutoff=10)\n", | ||
"\n", | ||
"bs_gate = Beamsplitter(theta=pi/4, phi=0, cutoff=10)\n", | ||
"\n", | ||
"phase_gate = Phase(phi=pi/4, cutoff=10)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 11, | ||
"id": "20f41390", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"from quasi.components.gates import Components\n", | ||
"\n", | ||
"my_comp = Components(doi=\"https://doi.org/10.1038/s41467-023-36159-y\")\n", | ||
"my_comp.matrix = np.identity(3)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 4, | ||
"id": "102388e4", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"exp_1 = Experiement(num_modes=2, cutoff=10)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 5, | ||
"id": "37871484", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"exp_1.state_init(1, [0])\n", | ||
"\n", | ||
"exp_1.add_operation(bs_gate.get_operator().transpose((0, 2, 1, 3)), [0, 1])\n", | ||
"#exp_1.add_operation(squeezing_gate.get_operator(), [0])" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 6, | ||
"id": "abc8426c", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"exp_1.execute()" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 7, | ||
"id": "f50de5c9", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"state = exp_1.state" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "69b22218", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"state." | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 8, | ||
"id": "2c49f439", | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"data": { | ||
"text/plain": [ | ||
"array([[0. , 0.5, 0. , 0. , 0. , 0. , 0. , 0. , 0. , 0. ],\n", | ||
" [0.5, 0. , 0. , 0. , 0. , 0. , 0. , 0. , 0. , 0. ],\n", | ||
" [0. , 0. , 0. , 0. , 0. , 0. , 0. , 0. , 0. , 0. ],\n", | ||
" [0. , 0. , 0. , 0. , 0. , 0. , 0. , 0. , 0. , 0. ],\n", | ||
" [0. , 0. , 0. , 0. , 0. , 0. , 0. , 0. , 0. , 0. ],\n", | ||
" [0. , 0. , 0. , 0. , 0. , 0. , 0. , 0. , 0. , 0. ],\n", | ||
" [0. , 0. , 0. , 0. , 0. , 0. , 0. , 0. , 0. , 0. ],\n", | ||
" [0. , 0. , 0. , 0. , 0. , 0. , 0. , 0. , 0. , 0. ],\n", | ||
" [0. , 0. , 0. , 0. , 0. , 0. , 0. , 0. , 0. , 0. ],\n", | ||
" [0. , 0. , 0. , 0. , 0. , 0. , 0. , 0. , 0. , 0. ]])" | ||
] | ||
}, | ||
"execution_count": 8, | ||
"metadata": {}, | ||
"output_type": "execute_result" | ||
} | ||
], | ||
"source": [ | ||
"probs = state.all_fock_probs()\n", | ||
"probs" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 9, | ||
"id": "885ba32a", | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"data": { | ||
"text/plain": [ | ||
"(0.4999999999999999, 0.5000000000000001)" | ||
] | ||
}, | ||
"execution_count": 9, | ||
"metadata": {}, | ||
"output_type": "execute_result" | ||
} | ||
], | ||
"source": [ | ||
"probs[0, 1], probs[1, 0]" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "0abd708a", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"len(np.diagonal(state.dm()))" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 10, | ||
"id": "f1eef253", | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"data": { | ||
"text/plain": [ | ||
"0.5000000000000001" | ||
] | ||
}, | ||
"execution_count": 10, | ||
"metadata": {}, | ||
"output_type": "execute_result" | ||
} | ||
], | ||
"source": [ | ||
"state.mean_photon(mode=[0])" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 13, | ||
"id": "53740890", | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"data": { | ||
"text/plain": [ | ||
"(True,\n", | ||
" ' @article{Jerbi_2023, title={Quantum machine learning beyond kernel methods}, volume={14}, ISSN={2041-1723}, url={http://dx.doi.org/10.1038/s41467-023-36159-y}, DOI={10.1038/s41467-023-36159-y}, number={1}, journal={Nature Communications}, publisher={Springer Science and Business Media LLC}, author={Jerbi, Sofiene and Fiderer, Lukas J. and Poulsen Nautrup, Hendrik and Kübler, Jonas M. and Briegel, Hans J. and Dunjko, Vedran}, year={2023}, month=jan }\\n')" | ||
] | ||
}, | ||
"execution_count": 13, | ||
"metadata": {}, | ||
"output_type": "execute_result" | ||
} | ||
], | ||
"source": [ | ||
"my_comp.generate_bibtex(doi=\"https://doi.org/10.1038/s41467-023-36159-y\")" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "d58349ca", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "Python 3 (ipykernel)", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.10.12" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 5 | ||
} |
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,28 @@ | ||
from quasi.components.gates import Beamsplitter, Displacment, Phase, Squeezing | ||
from quasi._math.fock import ( | ||
vacuum_state, | ||
mean_photon_number, | ||
fock_probability, | ||
) | ||
from quasi.components.gates import Components | ||
import numpy as np | ||
|
||
qumode = 1 | ||
cutoff = 10 | ||
init_state = vacuum_state(n=qumode, cutoff=cutoff) | ||
|
||
doi = "https://doi.org/10.1088/1742-6596/1612/1/012015" | ||
user_defined_component = Components(cutoff=cutoff, doi=doi) | ||
|
||
user_defined_component.matrix = np.identity(n=10) | ||
bibtex_file = user_defined_component.generate_bibtex(doi) | ||
|
||
displacement_operator = Displacment(1, 0.5, cutoff=10).matrix | ||
|
||
displaced_state = displacement_operator @ init_state | ||
|
||
displaced_state_unphased = Phase(-0.5, cutoff=10).matrix @ displaced_state | ||
|
||
assert mean_photon_number(state=displaced_state) == 1**2 | ||
|
||
assert fock_probability([0], displaced_state) == displaced_state[0].real ** 2 |
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,23 @@ | ||
from .fock.ops import ( | ||
displacement, | ||
phase, | ||
mean_photon_number, | ||
squeezing, | ||
adagger, | ||
a, | ||
beamsplitter, | ||
vacuum_state, | ||
calculate_fidelity, | ||
coherent_state, | ||
fock_state, | ||
fock_probability, | ||
kerr, | ||
apply_channel, | ||
apply_gate_einsum, | ||
thermalState, | ||
partial_trace, | ||
calculate_trace, | ||
cubicPhase, | ||
lossChannel, | ||
tensor, | ||
) |
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,19 @@ | ||
from .ops import ( | ||
displacement, | ||
beamsplitter, | ||
phase, | ||
vacuum_state, | ||
coherent_state, | ||
adagger, | ||
a, | ||
mean_photon_number, | ||
fock_probability, | ||
squeezing, | ||
calculate_fidelity, | ||
calculate_trace, | ||
lossChannel, | ||
cubicPhase, | ||
apply_channel, | ||
apply_gate_einsum, | ||
tensor, | ||
) |
Oops, something went wrong.