From d0613f8dbf23b090732bac715b07bb8d8898ac59 Mon Sep 17 00:00:00 2001 From: Renato Mello Date: Wed, 9 Aug 2023 12:18:30 +0400 Subject: [PATCH 01/10] `purity` doc --- src/qibo/quantum_info/metrics.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/qibo/quantum_info/metrics.py b/src/qibo/quantum_info/metrics.py index a15c0769d3..e82c20de54 100644 --- a/src/qibo/quantum_info/metrics.py +++ b/src/qibo/quantum_info/metrics.py @@ -8,7 +8,10 @@ def purity(state): - """Purity of a quantum state :math:`\\rho`, which is given by :math:`\\text{tr}(\\rho^{2})`. + """Purity of a quantum state :math:`\\rho`, which is given by + + .. math:: + \\text{purity}(\\rho) = \\text{tr}(\\rho^{2}) \\, . Args: state (ndarray): statevector or density matrix. From e55692a9a7011b8393930464dda0ce7f8a75e7dd Mon Sep 17 00:00:00 2001 From: Renato Mello Date: Wed, 9 Aug 2023 12:21:22 +0400 Subject: [PATCH 02/10] `entanglement_entropy` doc --- src/qibo/quantum_info/metrics.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/qibo/quantum_info/metrics.py b/src/qibo/quantum_info/metrics.py index e82c20de54..46769eb1f3 100644 --- a/src/qibo/quantum_info/metrics.py +++ b/src/qibo/quantum_info/metrics.py @@ -250,8 +250,8 @@ def entanglement_entropy( check_hermitian: bool = False, backend=None, ): - """Calculates the entanglement entropy :math:`S` of ``state`` :math:`\\rho`, - which is given by + """Calculates the entanglement entropy :math:`S` of bipartition :math:`A` + of``state`` :math:`\\rho`. This is given by .. math:: S(\\rho_{A}) = -\\text{tr}(\\rho_{A} \\, \\log(\\rho_{A})) \\, , From fb5fc836b112cca50091eb254c6f0d60e3cae9e7 Mon Sep 17 00:00:00 2001 From: Renato Mello Date: Wed, 9 Aug 2023 12:24:00 +0400 Subject: [PATCH 03/10] `bures_distance` doc --- src/qibo/quantum_info/metrics.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/qibo/quantum_info/metrics.py b/src/qibo/quantum_info/metrics.py index 46769eb1f3..2f707a8f7c 100644 --- a/src/qibo/quantum_info/metrics.py +++ b/src/qibo/quantum_info/metrics.py @@ -588,7 +588,7 @@ def bures_distance(state, target, check_hermitian: bool = False, backend=None): and a ``target`` state :math:`\\sigma`. This is given by .. math:: - D_{B}(\\rho, \\, \\sigma) = \\sqrt{2 \\, (1 - \\sqrt{F(\\rho, \\, \\sigma)})} + D_{B}(\\rho, \\, \\sigma) = \\sqrt{2 \\, \\left(1 - \\sqrt{F(\\rho, \\, \\sigma)}\\right)} where :math:`F(\\rho, \\sigma)` is the :func:`qibo.quantum_info.fidelity` between `state` and `target`. From e4d02815bc828060792bdde8039d02560c5beef7 Mon Sep 17 00:00:00 2001 From: Renato Mello Date: Wed, 9 Aug 2023 12:25:00 +0400 Subject: [PATCH 04/10] `entanglement_fidelity` api doc --- doc/source/api-reference/qibo.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/source/api-reference/qibo.rst b/doc/source/api-reference/qibo.rst index 739252b6e6..574c4568c1 100644 --- a/doc/source/api-reference/qibo.rst +++ b/doc/source/api-reference/qibo.rst @@ -1351,7 +1351,7 @@ Bures distance Entanglement fidelity """"""""""""""""""""" -.. autofunction::qibo.quantum_info.entanglement_fidelity +.. autofunction:: qibo.quantum_info.entanglement_fidelity Process fidelity From b08c7fa334c12a7728fbaa46c7dc3463709e1d2e Mon Sep 17 00:00:00 2001 From: Renato Mello Date: Wed, 9 Aug 2023 12:36:50 +0400 Subject: [PATCH 05/10] `diamond_norm` doc --- src/qibo/quantum_info/metrics.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/qibo/quantum_info/metrics.py b/src/qibo/quantum_info/metrics.py index 2f707a8f7c..d7fa393688 100644 --- a/src/qibo/quantum_info/metrics.py +++ b/src/qibo/quantum_info/metrics.py @@ -859,8 +859,16 @@ def gate_error(channel, target=None, check_unitary: bool = False, backend=None): def diamond_norm(channel, target=None, **kwargs): """Calculates the diamond norm :math:`\\|\\mathcal{E}\\|_{\\diamond}` of - ``channel`` :math:`\\mathcal{E}`. If a ``target`` channel :math:`\\Lambda` - is specified, then it calculates :math:`\\| \\mathcal{E} - \\Lambda\\|_{\\diamond}`. + ``channel`` :math:`\\mathcal{E}`, which is given by + + .. math:: + \\|\\mathcal{E}\\|_{\\diamond} = \\max_{\\rho} \\, \\| \\left(\\mathcal{E} \\bigotimes I_{d^{2}}\\right)(\\rho) \\| \\, , + + where :math:`I_{d^{2}}` is the :math:`d^{2} \times d^{2}` Identity operator, + :math:`d = 2^{n}`, and :math:`n` is the number of qubits. + + If a ``target`` channel :math:`\\Lambda` is specified, + then it calculates :math:`\\| \\mathcal{E} - \\Lambda\\|_{\\diamond}`. Example: From 597a80248da701bfa1dda1041a3f28e5b53c523b Mon Sep 17 00:00:00 2001 From: Renato Mello Date: Wed, 9 Aug 2023 12:45:27 +0400 Subject: [PATCH 06/10] `random_density_matrix` doc --- src/qibo/quantum_info/random_ensembles.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/qibo/quantum_info/random_ensembles.py b/src/qibo/quantum_info/random_ensembles.py index 64411e8ac6..72a0af9acc 100644 --- a/src/qibo/quantum_info/random_ensembles.py +++ b/src/qibo/quantum_info/random_ensembles.py @@ -374,7 +374,18 @@ def random_density_matrix( seed=None, backend=None, ): - """Creates a random density matrix :math:`\\rho`. + """Creates a random density matrix :math:`\\rho`. If ``pure=True``, + + .. math:: + \\rho = \\ketbra{\\psi} \\, , + + where :math:`\\ket{\\psi}` is a :func:`qibo.quantum_info.random_statevector`. + If ``pure=False``, then + + .. math:: + \\rho = \\sum_{k} \\, p_{k} \\, \\ketbra{\\psi_{k}} \\, . + + is a mixed state. Args: dims (int): dimension of the matrix. From e2c210c283e67bd402f8904a4d959baa79b55dfc Mon Sep 17 00:00:00 2001 From: Renato Mello Date: Wed, 9 Aug 2023 13:57:18 +0000 Subject: [PATCH 07/10] Update src/qibo/quantum_info/random_ensembles.py Co-authored-by: vodovozovaliza <55856544+vodovozovaliza@users.noreply.github.com> --- src/qibo/quantum_info/random_ensembles.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/qibo/quantum_info/random_ensembles.py b/src/qibo/quantum_info/random_ensembles.py index 72a0af9acc..45d1f10ff4 100644 --- a/src/qibo/quantum_info/random_ensembles.py +++ b/src/qibo/quantum_info/random_ensembles.py @@ -377,7 +377,7 @@ def random_density_matrix( """Creates a random density matrix :math:`\\rho`. If ``pure=True``, .. math:: - \\rho = \\ketbra{\\psi} \\, , + \\rho = \\ketbra{\\psi}{\\psi} \\, , where :math:`\\ket{\\psi}` is a :func:`qibo.quantum_info.random_statevector`. If ``pure=False``, then From 79c88aa5fe42d7671f7f5177b5f426611710ae1d Mon Sep 17 00:00:00 2001 From: Renato Mello Date: Wed, 9 Aug 2023 13:57:26 +0000 Subject: [PATCH 08/10] Update src/qibo/quantum_info/random_ensembles.py Co-authored-by: vodovozovaliza <55856544+vodovozovaliza@users.noreply.github.com> --- src/qibo/quantum_info/random_ensembles.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/qibo/quantum_info/random_ensembles.py b/src/qibo/quantum_info/random_ensembles.py index 45d1f10ff4..d86503f3cf 100644 --- a/src/qibo/quantum_info/random_ensembles.py +++ b/src/qibo/quantum_info/random_ensembles.py @@ -383,7 +383,7 @@ def random_density_matrix( If ``pure=False``, then .. math:: - \\rho = \\sum_{k} \\, p_{k} \\, \\ketbra{\\psi_{k}} \\, . + \\rho = \\sum_{k} \\, p_{k} \\, \\ketbra{\\psi_{k}}{\\psi_{k}} \\, . is a mixed state. From 4d1ac15a6c6f9cd2ba2fb02416b1ebd4752c095f Mon Sep 17 00:00:00 2001 From: Renato Mello Date: Wed, 9 Aug 2023 13:57:35 +0000 Subject: [PATCH 09/10] Update src/qibo/quantum_info/metrics.py Co-authored-by: vodovozovaliza <55856544+vodovozovaliza@users.noreply.github.com> --- src/qibo/quantum_info/metrics.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/qibo/quantum_info/metrics.py b/src/qibo/quantum_info/metrics.py index d7fa393688..1010d6914f 100644 --- a/src/qibo/quantum_info/metrics.py +++ b/src/qibo/quantum_info/metrics.py @@ -864,7 +864,7 @@ def diamond_norm(channel, target=None, **kwargs): .. math:: \\|\\mathcal{E}\\|_{\\diamond} = \\max_{\\rho} \\, \\| \\left(\\mathcal{E} \\bigotimes I_{d^{2}}\\right)(\\rho) \\| \\, , - where :math:`I_{d^{2}}` is the :math:`d^{2} \times d^{2}` Identity operator, + where :math:`I_{d^{2}}` is the :math:`d^{2} \\times d^{2}` Identity operator, :math:`d = 2^{n}`, and :math:`n` is the number of qubits. If a ``target`` channel :math:`\\Lambda` is specified, From e03e773911070ad98d0085acee1c849426ea3521 Mon Sep 17 00:00:00 2001 From: Renato Mello Date: Wed, 9 Aug 2023 18:01:44 +0400 Subject: [PATCH 10/10] Liza's suggestions --- src/qibo/quantum_info/metrics.py | 5 +++-- src/qibo/quantum_info/random_ensembles.py | 2 +- src/qibo/quantum_info/superoperator_transformations.py | 2 +- src/qibo/quantum_info/utils.py | 2 +- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/qibo/quantum_info/metrics.py b/src/qibo/quantum_info/metrics.py index 1010d6914f..60a5ada5e7 100644 --- a/src/qibo/quantum_info/metrics.py +++ b/src/qibo/quantum_info/metrics.py @@ -619,9 +619,10 @@ def entanglement_fidelity( :math:`\\rho`, which is given by .. math:: - \\begin{align*} + \\begin{align} F_{\\mathcal{E}} &= \\text{fidelity}(\\rho_{f}, \\rho) \\nonumber \\\\ - &= \\text{tr}(\\rho_{f} \\, \\rho) + &= \\text{tr}(\\rho_{f} \\, \\rho) \\nonumber + \\end{align} where diff --git a/src/qibo/quantum_info/random_ensembles.py b/src/qibo/quantum_info/random_ensembles.py index d86503f3cf..7ffeb4ea07 100644 --- a/src/qibo/quantum_info/random_ensembles.py +++ b/src/qibo/quantum_info/random_ensembles.py @@ -148,7 +148,7 @@ def random_hermitian( def random_unitary(dims: int, measure: Optional[str] = None, seed=None, backend=None): - """Returns a random Unitary operator :math:`U`,, i.e. + """Returns a random Unitary operator :math:`U`, i.e. a random operator such that :math:`U^{-1} = U^{\\dagger}`. Args: diff --git a/src/qibo/quantum_info/superoperator_transformations.py b/src/qibo/quantum_info/superoperator_transformations.py index fb59753cf2..1ca8d416c4 100644 --- a/src/qibo/quantum_info/superoperator_transformations.py +++ b/src/qibo/quantum_info/superoperator_transformations.py @@ -1671,7 +1671,7 @@ def stinespring_to_choi( to its Choi representation :math:`\\Lambda`. .. math:: - \\Lambda = \\text{kraus_to_choi}(\\text{stinespring_to_kraus}(U_{0}})) + \\Lambda = \\text{kraus_to_choi}(\\text{stinespring_to_kraus}(U_{0})) Args: stinespring (ndarray): quantum channel in the Stinespring representation. diff --git a/src/qibo/quantum_info/utils.py b/src/qibo/quantum_info/utils.py index 6ab993fba1..35a61a99d0 100644 --- a/src/qibo/quantum_info/utils.py +++ b/src/qibo/quantum_info/utils.py @@ -43,7 +43,7 @@ def hamming_weight(bitstring, return_indexes: bool = False): def hadamard_transform(array, implementation: str = "fast", backend=None): """Calculates the (fast) Hadamard Transform :math:`\\text{HT}` of a - :math:`2^{n}`-dimensional vector or :math:`2^{n} \times 2^{n}` matrix :math:`A`, + :math:`2^{n}`-dimensional vector or :math:`2^{n} \\times 2^{n}` matrix :math:`A`, where :math:`n` is the number of qubits in the system. If :math:`A` is a vector, then .. math::