Skip to content

Commit

Permalink
Updating version and including more tutorials.
Browse files Browse the repository at this point in the history
  • Loading branch information
vprusso committed Jul 1, 2022
1 parent 076592a commit fbea718
Show file tree
Hide file tree
Showing 9 changed files with 183 additions and 31 deletions.
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -279,4 +279,7 @@

## 1.0.3

-
- Version bump to fix Python package versioning issue.
## 1.0.4

- Version bump to fix Python package versioning issue.
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
author = "Vincent Russo"

# The full version, including alpha/beta/rc tags
release = "1.0.2"
release = "1.0.4"


# -- General configuration ---------------------------------------------------
Expand Down
169 changes: 157 additions & 12 deletions docs/intro_tutorial.rst
Original file line number Diff line number Diff line change
Expand Up @@ -213,14 +213,28 @@ PPT criterion.
As we can see, the PPT criterion is :code:`False` for an entangled state in
:math:`2 \otimes 2`.

Further properties that one can check via :code:`toqito` may be found `on this page
<https://toqito.readthedocs.io/en/latest/states.html#properties-of-quantum-states>`_.
Determining whether a quantum state is separable or entangled is often useful
but is, unfortunately, NP-hard. For a given density matrix represented by a
quantum state, we can use :code:`toqito` to run a number of separability tests
from the literature to determine if it is separable or entangled.

For instance, the following bound-entangled tile state is found to be entangled
(i.e. not separable).

Operations on Quantum States
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.. code-block:: python
(Coming soon).
>>> import numpy as np
>>> from toqtio.state_props import is_separable
>>> from toqito.states import tile
>>> rho = np.identity(9)
>>> for i in range(5):
>>> rho = rho - tile(i) * tile(i).conj().T
>>> rho = rho / 4
>>> is_separable(rho)
False
Further properties that one can check via :code:`toqito` may be found `on this page
<https://toqito.readthedocs.io/en/latest/states.html#properties-of-quantum-states>`_.

Distance Metrics for Quantum States
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Expand Down Expand Up @@ -280,15 +294,146 @@ such that :math:`\Phi` is completely positive and trace preserving.

Quantum Channels
^^^^^^^^^^^^^^^^
(Coming soon).

Properties of Quantum Channels
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
(Coming soon).
The partial trace operation is an often used in various applications of quantum
information. The partial trace is defined as

.. math::
\left( \text{Tr} \otimes \mathbb{I}_{\mathcal{Y}} \right)
\left(X \otimes Y \right) = \text{Tr}(X)Y
where :math:`X \in \text{L}(\mathcal{X})` and :math:`Y \in
\text{L}(\mathcal{Y})` are linear operators over complex Euclidean spaces
:math:`\mathcal{X}` and :math:`\mathcal{Y}`.

Consider the following matrix

.. math::
X = \begin{pmatrix}
1 & 2 & 3 & 4 \\
5 & 6 & 7 & 8 \\
9 & 10 & 11 & 12 \\
13 & 14 & 15 & 16
\end{pmatrix}.
Taking the partial trace over the second subsystem of :math:`X` yields the following matrix

.. math::
X_{pt, 2} = \begin{pmatrix}
7 & 11 \\
23 & 27
\end{pmatrix}
By default, the partial trace function in :code:`toqito` takes the trace of the second
subsystem.

.. code-block:: python
Operations on Quantum Channels
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
(Coming soon).
>>> from toqito.channels import partial_trace
>>> import numpy as np
>>> test_input_mat = np.array(
>>> [[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12], [13, 14, 15, 16]]
>>> )
>>> partial_trace(test_input_mat)
[[ 7, 11],
[23, 27]]
By specifying the :code:`sys = 1` argument, we can perform the partial trace over the first
subsystem (instead of the default second subsystem as done above). Performing the partial
trace over the first subsystem yields the following matrix

.. math::
X_{pt, 1} = \begin{pmatrix}
12 & 14 \\
20 & 22
\end{pmatrix}
.. code-block:: python
>>> from toqito.channels import partial_trace
>>> import numpy as np
>>> test_input_mat = np.array(
>>> [[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12], [13, 14, 15, 16]]
>>> )
>>> partial_trace(test_input_mat, 1)
[[12, 14],
[20, 22]]
Another often useful channel is the *partial transpose*. The *partial transpose*
is defined as

.. math::
\left( \text{T} \otimes \mathbb{I}_{\mathcal{Y}} \right)
\left(X\right)
where :math:`X \in \text{L}(\mathcal{X})` is a linear operator over the complex
Euclidean space :math:`\mathcal{X}` and where :math:`\text{T}` is the transpose
mapping :math:`\text{T} \in \text{T}(\mathcal{X})` defined as

.. math::
\text{T}(X) = X^{\text{T}}
for all :math:`X \in \text{L}(\mathcal{X})`.

Consider the following matrix

.. math::
X = \begin{pmatrix}
1 & 2 & 3 & 4 \\
5 & 6 & 7 & 8 \\
9 & 10 & 11 & 12 \\
13 & 14 & 15 & 16
\end{pmatrix}.
Performing the partial transpose on the matrix :math:`X` over the second
subsystem yields the following matrix

.. math::
X_{pt, 2} = \begin{pmatrix}
1 & 5 & 3 & 7 \\
2 & 6 & 4 & 8 \\
9 & 13 & 11 & 15 \\
10 & 14 & 12 & 16
\end{pmatrix}.
By default, in :code:`toqito`, the partial transpose function performs the transposition on
the second subsystem as follows.

.. code-block:: python
>>> from toqito.channels import partial_transpose
>>> import numpy as np
>>> test_input_mat = np.arange(1, 17).reshape(4, 4)
>>> partial_transpose(test_input_mat)
[[ 1 5 3 7]
[ 2 6 4 8]
[ 9 13 11 15]
[10 14 12 16]]
By specifying the :code:`sys = 1` argument, we can perform the partial transpose over the
first subsystem (instead of the default second subsystem as done above). Performing the
partial transpose over the first subsystem yields the following matrix

.. math::
X_{pt, 1} = \begin{pmatrix}
1 & 2 & 9 & 10 \\
5 & 6 & 13 & 14 \\
3 & 4 & 11 & 12 \\
7 & 8 & 15 & 16
\end{pmatrix}.
.. code-block:: python
>>> from toqito.channels import partial_transpose
>>> import numpy as np
>>> test_input_mat = np.array(
>>> [[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12], [13, 14, 15, 16]]
>>> )
>>> partial_transpose(test_input_mat, 1)
[[ 1 2 9 10]
[ 5 6 13 14]
[ 3 4 11 12]
[ 7 8 15 16]]
Measurements
------------
Expand Down
16 changes: 8 additions & 8 deletions docs/tutorials.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@ Tutorials

Tutorials for :code:`toqito`.

Introductory Tutorial
--------------------------

.. toctree::
:maxdepth: 5

tutorials.intro_tutorial

Nonlocal Games
--------------------------

Expand Down Expand Up @@ -42,11 +50,3 @@ Quantum State Exclusion
:maxdepth: 5

tutorials.state_exclusion

Quantum Communication
-----------------------------------------------------

.. toctree::
:maxdepth: 5

tutorials.superdense_coding
14 changes: 8 additions & 6 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ exclude = '''

[tool.poetry]
name = "toqito"
version = "1.0.2"
version = "1.0.4"
description = "Python tools for the study of quantum information."
authors = [
"Vincent Russo <[email protected]>"
Expand All @@ -36,14 +36,16 @@ keywords = ["quantum information", "quantum computing", "nonlocal games"]


[tool.poetry.dependencies]
python = "^3.9"
python = ">=3.9,<3.11"
cvxpy = "^1.2.1"
numpy = "*"
scipy = "*"
scs = "^2.1.2"
cvxopt = "^1.2.5"
numpy = "^1.19.4"
scipy = "^1.8.0"
#scs = "^2.1.2"
picos = "^2.0.30"

[tool.poetry.dev-dependencies]
black = "^20.8b1"
black = "^21.10b0"
distlib = "^0.3.4"
flake8 = "^3.7"
flake8-docstrings = "^1.5"
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

setuptools.setup(
name="toqito",
version="1.0.2",
version="1.0.4",
author="Vincent Russo",
author_email="[email protected]",
description="Python toolkit for quantum information theory",
Expand Down
2 changes: 1 addition & 1 deletion toqito/matrices/gell_mann.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,6 @@ def gell_mann(ind: int, is_sparse: bool = False) -> np.ndarray | scipy.sparse.cs
raise ValueError("Gell-Mann index values can only be values from 0 to 8 (inclusive).")

if is_sparse:
gm_op = scipy.sparse.csr.csr_matrix(gm_op)
gm_op = scipy.sparse.csr_matrix(gm_op)

return gm_op
1 change: 1 addition & 0 deletions toqito/state_props/entanglement_of_formation.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ def entanglement_of_formation(rho: np.ndarray, dim: list[int] | int = None) -> f
.. [WikEOF] Quantiki: Entanglement-of-formation
https://www.quantiki.org/wiki/entanglement-formation
:raises ValueError: If matrices have improper dimension.
:param rho: A matrix or vector.
:param dim: The default has both subsystems of equal dimension.
:return: A value between 0 and 1 that corresponds to the
Expand Down
3 changes: 2 additions & 1 deletion toqito/state_props/is_separable.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,4 +170,5 @@ def is_separable(
# The search for symmetric extensions.
for _ in range(2, level):
if has_symmetric_extension(state, level):
return True
return True
return False

0 comments on commit fbea718

Please sign in to comment.