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

Minor changes to punctuation and code rendering for documentation. #517

Merged
merged 2 commits into from
Mar 25, 2024
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
4 changes: 2 additions & 2 deletions docs/intro_tutorial.rst
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ Taking the partial trace over the second subsystem of :math:`X` yields the follo
X_{pt, 2} = \begin{pmatrix}
7 & 11 \\
23 & 27
\end{pmatrix}
\end{pmatrix}.

By default, the partial trace function in :code:`toqito` takes the trace of the second
subsystem.
Expand All @@ -343,7 +343,7 @@ trace over the first subsystem yields the following matrix
X_{pt, 1} = \begin{pmatrix}
12 & 14 \\
20 & 22
\end{pmatrix}
\end{pmatrix}.

.. code-block:: python

Expand Down
8 changes: 4 additions & 4 deletions docs/tutorials.state_distinguishability.rst
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ may be obtained by solving the following semidefinite program (SDP).
\text{maximize:} \quad & \sum_{i=0}^n p_i \langle M_i,
\rho_i \rangle \\
\text{subject to:} \quad & \sum_{i=0}^n M_i = \mathbb{I}_{\mathcal{X}},\\
& M_i \in \text{Pos}(\mathcal{X})
& M_i \in \text{Pos}(\mathcal{X}).
\end{align*}

This optimization problem is solved in :code:`toqito` to obtain the optimal
Expand All @@ -103,7 +103,7 @@ such that
\rho_1 = | 1 \rangle \langle 1 | = \begin{pmatrix}
0 & 0 \\
0 & 1
\end{pmatrix}
\end{pmatrix}.


These states are completely orthogonal to each other, and it is known that Bob
Expand Down Expand Up @@ -188,9 +188,9 @@ It was shown in [tCosentino13]_ and later extended in [tCR13]_ that for the foll
.. math::
\begin{equation}
\begin{aligned}
\rho_1^{(2)} &= |\psi_0 \rangle | \psi_0 \rangle \langle \psi_0 | \langle \psi_0 |, \\
\rho_1^{(2)} &= |\psi_0 \rangle | \psi_0 \rangle \langle \psi_0 | \langle \psi_0 |, \quad
\rho_2^{(2)} &= |\psi_1 \rangle | \psi_3 \rangle \langle \psi_1 | \langle \psi_3 |, \\
\rho_3^{(2)} &= |\psi_2 \rangle | \psi_3 \rangle \langle \psi_2 | \langle \psi_3 |, \\
\rho_3^{(2)} &= |\psi_2 \rangle | \psi_3 \rangle \langle \psi_2 | \langle \psi_3 |, \quad
\rho_4^{(2)} &= |\psi_3 \rangle | \psi_3 \rangle \langle \psi_3 | \langle \psi_3 |, \\
\end{aligned}
\end{equation}
Expand Down
6 changes: 2 additions & 4 deletions docs/tutorials.xor_quantum_value.rst
Original file line number Diff line number Diff line change
Expand Up @@ -202,10 +202,8 @@ sets of measurements.

.. math::
\begin{equation}
\begin{aligned}
| \phi_0 \rangle &= \cos(\theta)|0 \rangle + \sin(\theta)|1 \rangle, \\
| \phi_1 \rangle &= -\sin(\theta)|0 \rangle + \cos(\theta)|1 \rangle,
\end{aligned}
| \phi_0 \rangle &= \cos(\theta)|0 \rangle + \sin(\theta)|1 \rangle, \quad
| \phi_1 \rangle &= -\sin(\theta)|0 \rangle + \cos(\theta)|1 \rangle,
\end{equation}

such that
Expand Down
2 changes: 1 addition & 1 deletion toqito/channel_metrics/completely_bounded_spectral_norm.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
def completely_bounded_spectral_norm(phi: np.ndarray) -> float:
r"""Compute the completely bounded spectral norm of a quantum channel.

:cite:`Watrous_2009_Semidefinite, QETLAB_link`.
As defined in :cite:`Watrous_2009_Semidefinite` and :cite:`QETLAB_link`.

Examples
========
Expand Down
2 changes: 1 addition & 1 deletion toqito/channel_metrics/diamond_norm.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def diamond_norm(choi_1: np.ndarray, choi_2: np.ndarray) -> float:
The calculation uses the simplified semidefinite program of Watrous in
:cite:`Watrous_2009_Semidefinite`.

This function has been adapted from :cite:`Rigetti_2022_Forest`
This function has been adapted from :cite:`Rigetti_2022_Forest`.

.. note::
This calculation becomes very slow for 4 or more qubits.
Expand Down
36 changes: 17 additions & 19 deletions toqito/channel_props/choi_rank.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,25 +19,23 @@ def choi_rank(phi: np.ndarray | list[list[np.ndarray]]) -> int:

.. math::
\begin{equation}
\begin{aligned}
\frac{1}{\sqrt{2}}
\begin{pmatrix}
0 & i \\ -i & 0
\end{pmatrix}, &\quad
\frac{1}{\sqrt{2}}
\begin{pmatrix}
0 & 1 \\
1 & 0
\end{pmatrix}, \\
\begin{pmatrix}
1 & 0 \\
0 & 0
\end{pmatrix}, &\quad
\begin{pmatrix}
0 & 0 \\
0 & 1
\end{pmatrix}.
\end{aligned}
\frac{1}{\sqrt{2}}
\begin{pmatrix}
0 & i \\ -i & 0
\end{pmatrix}, \quad
\frac{1}{\sqrt{2}}
\begin{pmatrix}
0 & 1 \\
1 & 0
\end{pmatrix}, \quad
\begin{pmatrix}
1 & 0 \\
0 & 0
\end{pmatrix}, \quad
\begin{pmatrix}
0 & 0 \\
0 & 1
\end{pmatrix}.
\end{equation}

and can be generated in :code:`toqito` with the following list:
Expand Down
2 changes: 2 additions & 0 deletions toqito/channel_props/is_quantum_channel.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ def is_quantum_channel(
\end{pmatrix}.

To check if this is a valid quantum channel or not,

>>> import numpy as np
>>> from toqito.matrices import pauli
>>> from toqito.channel_props import is_quantum_channel
Expand All @@ -50,6 +51,7 @@ def is_quantum_channel(
False

If we instead check for the validity of depolarizing channel being a valid quantum channel,

>>> from toqito.channels import depolarizing
>>> from toqito.channel_props import is_quantum_channel
>>> choi_depolarizing = depolarizing(dim=2, param_p=0.2)
Expand Down
2 changes: 1 addition & 1 deletion toqito/channels/partial_trace.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def partial_trace(
X_{pt, 2} = \begin{pmatrix}
7 & 11 \\
23 & 27
\end{pmatrix}
\end{pmatrix}.

By default, the partial trace function in :code:`toqito` takes the trace of the second
subsystem.
Expand Down
2 changes: 2 additions & 0 deletions toqito/matrix_props/has_same_dimension.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,15 @@ def has_same_dimension(items: list[np.ndarray]) -> bool:
True

Check a list of matrices with the same dimension:

>>> import numpy as np
>>> from toqito.matrix_props import has_same_dimension
>>> matrices = [np.array([[1, 0], [0, 1]]), np.array([[2, 3], [4, 5]]), np.array([[6, 7], [8, 9]])]
>>> has_same_dimension(matrices)
True

Check a list containing items of different dimensions:

>>> import numpy as np
>>> from toqito.matrix_props import has_same_dimension
>>> mixed = [np.array([1, 2, 3]), np.array([[1, 0], [0, 1]])]
Expand Down
1 change: 1 addition & 0 deletions toqito/matrix_props/is_orthonormal.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ def is_orthonormal(vectors: list[np.ndarray]) -> bool:
\end{pmatrix}

To check these are a known set of orthonormal vectors:

>>> import numpy as np
>>> from toqito.matrix_props import is_orthonormal
>>> v_1 = np.array([1, 0, 0])
Expand Down
6 changes: 4 additions & 2 deletions toqito/matrix_props/kp_norm.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,20 @@ def kp_norm(mat: np.ndarray, k: int, p: int) -> float:
Examples
========
To compute the p-norm of a vector:

>>> import numpy as np
>>> from toqito.matrix_props import kp_norm
>>> from toqito.states import bell
>>> kp_norm(bell(0), 1, np.inf)
1
1.0

To compute the k-largest singular values of a matrix:

>>> import numpy as np
>>> from toqito.matrix_props import kp_norm
>>> from toqito.rand import random_unitary
>>> kp_norm(random_unitary(5), 5, 2)
2.2360679774997902
2.23606797749979

:param mat: 2D numpy ndarray
:param k: The number of singular values to take.
Expand Down
4 changes: 2 additions & 2 deletions toqito/state_opt/ppt_distinguishability.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ def ppt_distinguishability(
.. math::
\begin{equation}
\begin{aligned}
\rho_1^{(2)} &= |\psi_0 \rangle | \psi_0 \rangle \langle \psi_0 | \langle \psi_0 |, \\
\rho_1^{(2)} &= |\psi_0 \rangle | \psi_0 \rangle \langle \psi_0 | \langle \psi_0 |, \quad
\rho_2^{(2)} &= |\psi_1 \rangle | \psi_3 \rangle \langle \psi_1 | \langle \psi_3 |, \\
\rho_3^{(2)} &= |\psi_2 \rangle | \psi_3 \rangle \langle \psi_2 | \langle \psi_3 |, \\
\rho_3^{(2)} &= |\psi_2 \rangle | \psi_3 \rangle \langle \psi_2 | \langle \psi_3 |, \quad
\rho_4^{(2)} &= |\psi_3 \rangle | \psi_3 \rangle \langle \psi_3 | \langle \psi_3 |, \\
\end{aligned}
\end{equation}
Expand Down
2 changes: 1 addition & 1 deletion toqito/state_opt/state_distinguishability.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def state_distinguishability(
\begin{align*}
\text{maximize:} \quad & \sum_{i=0}^n p_i \langle M_i, \rho_i \rangle \\
\text{subject to:} \quad & M_0 + \ldots + M_n = \mathbb{I},\\
& M_0, \ldots, M_n \geq 0
& M_0, \ldots, M_n \geq 0.
\end{align*}

Examples
Expand Down
Loading