From fbea7189a78359f5f666a5c3f5867f7577f9f423 Mon Sep 17 00:00:00 2001 From: vprusso Date: Fri, 1 Jul 2022 08:54:08 -0400 Subject: [PATCH] Updating version and including more tutorials. --- CHANGELOG.md | 5 +- docs/conf.py | 2 +- docs/intro_tutorial.rst | 169 ++++++++++++++++-- docs/tutorials.rst | 16 +- pyproject.toml | 14 +- setup.py | 2 +- toqito/matrices/gell_mann.py | 2 +- .../state_props/entanglement_of_formation.py | 1 + toqito/state_props/is_separable.py | 3 +- 9 files changed, 183 insertions(+), 31 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2e2bf40a8..f1b4950e9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -279,4 +279,7 @@ ## 1.0.3 -- \ No newline at end of file +- Version bump to fix Python package versioning issue. +## 1.0.4 + +- Version bump to fix Python package versioning issue. \ No newline at end of file diff --git a/docs/conf.py b/docs/conf.py index 6e5e166d1..4799c30ad 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -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 --------------------------------------------------- diff --git a/docs/intro_tutorial.rst b/docs/intro_tutorial.rst index 023f4c467..009f5689f 100644 --- a/docs/intro_tutorial.rst +++ b/docs/intro_tutorial.rst @@ -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 -`_. +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 +`_. Distance Metrics for Quantum States ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -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 ------------ diff --git a/docs/tutorials.rst b/docs/tutorials.rst index 360ffd937..858903bde 100644 --- a/docs/tutorials.rst +++ b/docs/tutorials.rst @@ -3,6 +3,14 @@ Tutorials Tutorials for :code:`toqito`. +Introductory Tutorial +-------------------------- + +.. toctree:: + :maxdepth: 5 + + tutorials.intro_tutorial + Nonlocal Games -------------------------- @@ -42,11 +50,3 @@ Quantum State Exclusion :maxdepth: 5 tutorials.state_exclusion - -Quantum Communication ------------------------------------------------------ - -.. toctree:: - :maxdepth: 5 - - tutorials.superdense_coding diff --git a/pyproject.toml b/pyproject.toml index 9ac2c77d8..985eb5374 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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 " @@ -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" diff --git a/setup.py b/setup.py index fa01e80ee..9529865c1 100644 --- a/setup.py +++ b/setup.py @@ -7,7 +7,7 @@ setuptools.setup( name="toqito", - version="1.0.2", + version="1.0.4", author="Vincent Russo", author_email="vincentrusso1@gmail.com", description="Python toolkit for quantum information theory", diff --git a/toqito/matrices/gell_mann.py b/toqito/matrices/gell_mann.py index 73a9fafdd..d40d72802 100644 --- a/toqito/matrices/gell_mann.py +++ b/toqito/matrices/gell_mann.py @@ -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 diff --git a/toqito/state_props/entanglement_of_formation.py b/toqito/state_props/entanglement_of_formation.py index 2fb1cff98..b165a1127 100644 --- a/toqito/state_props/entanglement_of_formation.py +++ b/toqito/state_props/entanglement_of_formation.py @@ -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 diff --git a/toqito/state_props/is_separable.py b/toqito/state_props/is_separable.py index 7d0127b72..ffd53d18e 100644 --- a/toqito/state_props/is_separable.py +++ b/toqito/state_props/is_separable.py @@ -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 \ No newline at end of file + return True + return False \ No newline at end of file