Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tomography notebook #155

Merged
merged 16 commits into from
Jun 24, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added examples/figs/bloch.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added examples/figs/process-tomo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added examples/figs/state-tomo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
61 changes: 61 additions & 0 deletions examples/superoperator_tools.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -601,6 +601,67 @@
"print(choi_is_cptp(AD_choi))"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Project an unphysical state to the closest physical state"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from forest.benchmarking.operator_tools.project_state_matrix import project_state_matrix_to_physical"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"True"
]
},
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# Test the method. Example from fig 1 of maximum likelihood minimum effort \n",
"# https://doi.org/10.1103/PhysRevLett.108.070502\n",
"\n",
"eigs = np.diag(np.array(list(reversed([3.0/5, 1.0/2, 7.0/20, 1.0/10, -11.0/20]))))\n",
"phys = project_state_matrix_to_physical(eigs)\n",
"np.allclose(phys, np.diag([0, 0, 1.0/5, 7.0/20, 9.0/20]))"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from forest.benchmarking.plotting import hinton\n",
"\n",
"rho_unphys = np.random.uniform(-1, 1, (2, 2)) \\\n",
" * np.exp(1.j * np.random.uniform(-np.pi, np.pi, (2, 2)))\n",
"rho_phys = project_state_matrix_to_physical(rho_unphys)\n",
"\n",
"fig, (ax1, ax2) = plt.subplots(1, 2)\n",
"hinton(rho_unphys, ax=ax1)\n",
"hinton(rho_phys, ax=ax2)\n",
"ax1.set_title('Unphysical')\n",
"ax2.set_title('Physical projection')\n",
"fig.tight_layout()"
]
},
{
"cell_type": "markdown",
"metadata": {},
Expand Down
Loading