diff --git a/doc/source/api-reference/qibo.rst b/doc/source/api-reference/qibo.rst index 1b254088b3..5d013b103a 100644 --- a/doc/source/api-reference/qibo.rst +++ b/doc/source/api-reference/qibo.rst @@ -2382,7 +2382,7 @@ Hellinger fidelity Hellinger shot error """""""""""""""""""" -.. autofunction:: qibo.quantum_info.hellinger_fidelity +.. autofunction:: qibo.quantum_info.hellinger_shot_error Haar integral diff --git a/src/qibo/gates/channels.py b/src/qibo/gates/channels.py index bde8c50273..be43678318 100644 --- a/src/qibo/gates/channels.py +++ b/src/qibo/gates/channels.py @@ -48,8 +48,11 @@ def to_choi(self, nqubits: Optional[int] = None, order: str = "row", backend=Non of the Kraus channel :math:`\\{K_{\\alpha}\\}_{\\alpha}`. .. math:: - \\mathcal{E} = \\sum_{\\alpha} \\, |K_{\\alpha}\\rangle\\rangle - \\langle\\langle K_{\\alpha}| + \\mathcal{E} = \\sum_{\\alpha} \\, |K_{\\alpha})(K_{\\alpha}| \\, , + + where :math:`|K_{\\alpha})` is the vectorization of the Kraus operator + :math:`K_{\\alpha}`. + For a definition of vectorization, see :func:`qibo.quantum_info.vectorization`. Args: nqubits (int, optional): total number of qubits to be considered diff --git a/src/qibo/quantum_info/basis.py b/src/qibo/quantum_info/basis.py index 5ea541bca0..e3bf042a60 100644 --- a/src/qibo/quantum_info/basis.py +++ b/src/qibo/quantum_info/basis.py @@ -28,15 +28,15 @@ def pauli_basis( vectorize (bool, optional): If ``False``, returns a nested array with all Pauli matrices. If ``True``, retuns an array where every row is a vectorized Pauli matrix. Defaults to ``False``. - sparse (bool, optional) If ``True``, retuns Pauli basis in a sparse - representation. Default is ``False``. + sparse (bool, optional): If ``True``, retuns Pauli basis in a sparse + representation. Defaults to ``False``. order (str, optional): If ``"row"``, vectorization of Pauli basis is performed row-wise. If ``"column"``, vectorization is performed column-wise. If ``"system"``, system-wise vectorization is performed. If ``vectorization=False``, then ``order=None`` is - forced. Default is ``None``. + forced. Defaults to ``None``. pauli_order (str, optional): corresponds to the order of 4 single-qubit - Pauli elements. Default is "IXYZ". + Pauli elements. Defaults to ``"IXYZ"``. backend (:class:`qibo.backends.abstract.Backend`, optional): backend to be used in the execution. If ``None``, it uses :class:`qibo.backends.GlobalBackend`. Defaults to ``None``. @@ -148,15 +148,12 @@ def comp_basis_to_pauli( The unitary :math:`U` is given by .. math:: - U = \\sum_{k = 0}^{d^{2} - 1} \\, \\ketbra{k}{P_{k}} \\,\\, , + U = \\sum_{k = 0}^{d^{2} - 1} \\, |k)(P_{k}| \\,\\, , - where :math:`\\ket{P_{k}}` is the system-vectorization of the :math:`k`-th - Pauli operator :math:`P_{k}`, and :math:`\\ket{k}` is the computational - basis element. - - When converting a state :math:`\\ket{\\rho}` to its Pauli-Liouville - representation :math:`\\ket{\\rho'}`, one should use ``order="system"`` - in :func:`vectorization`. + where :math:`|P_{k})` is the vectorization of the :math:`k`-th + Pauli operator :math:`P_{k}`, and :math:`|k)` is the vectorization + of the :math:`k`-th computational basis element. + For a definition of vectorization, see :func:`qibo.quantum_info.vectorization`. Example: .. code-block:: python @@ -174,13 +171,13 @@ def comp_basis_to_pauli( normalize (bool, optional): If ``True``, converts to the Pauli basis. Defaults to ``False``. sparse (bool, optional): If ``True``, returns unitary matrix in - sparse representation. Default is ``False``. + sparse representation. Defaults to ``False``. order (str, optional): If ``"row"``, vectorization of Pauli basis is performed row-wise. If ``"column"``, vectorization is performed column-wise. If ``"system"``, system-wise vectorization is - performed. Default is ``"row"``. + performed. Defaults to ``"row"``. pauli_order (str, optional): corresponds to the order of 4 single-qubit - Pauli elements. Default is "IXYZ". + Pauli elements. Defaults to ``"IXYZ"``. backend (:class:`qibo.backends.abstract.Backend`, optional): backend to be used in the execution. If ``None``, it uses :class:`qibo.backends.GlobalBackend`. Defaults to ``None``. @@ -237,20 +234,25 @@ def pauli_to_comp_basis( The unitary :math:`U` is given by .. math:: - U = \\sum_{k = 0}^{d^{2} - 1} \\, \\ketbra{P_{k}}{b_{k}} \\, . + U = \\sum_{k = 0}^{d^{2} - 1} \\, |P_{k})(b_{k}| \\, , + + where :math:`|P_{k})` is the vectorization of the :math:`k`-th + Pauli operator :math:`P_{k}`, and :math:`|k)` is the vectorization + of the :math:`k`-th computational basis element. + For a definition of vectorization, see :func:`qibo.quantum_info.vectorization`. Args: nqubits (int): number of qubits. normalize (bool, optional): If ``True``, converts to the Pauli basis. Defaults to ``False``. sparse (bool, optional): If ``True``, returns unitary matrix in - sparse representation. Default is ``False``. + sparse representation. Defaults to ``False``. order (str, optional): If ``"row"``, vectorization of Pauli basis is performed row-wise. If ``"column"``, vectorization is performed column-wise. If ``"system"``, system-wise vectorization is - performed. Default is ``"row"``. + performed. Defaults to ``"row"``. pauli_order (str, optional): corresponds to the order of 4 single-qubit - Pauli elements. Default is "IXYZ". + Pauli elements. Defaults to ``"IXYZ"``. backend (:class:`qibo.backends.abstract.Backend`, optional): backend to be used in the execution. If ``None``, it uses :class:`qibo.backends.GlobalBackend`. Defaults to ``None``. diff --git a/src/qibo/quantum_info/entropies.py b/src/qibo/quantum_info/entropies.py index 05bf3f823f..c9c889b603 100644 --- a/src/qibo/quantum_info/entropies.py +++ b/src/qibo/quantum_info/entropies.py @@ -78,7 +78,7 @@ def classical_relative_entropy(prob_dist_p, prob_dist_q, base: float = 2, backen For probabilities :math:`\\mathbf{p}` and :math:`\\mathbf{q}`, it is defined as - ..math:: + .. math:: D(\\mathbf{p} \\, \\| \\, \\mathbf{q}) = \\sum_{x} \\, \\mathbf{p}(x) \\, \\log\\left( \\frac{\\mathbf{p}(x)}{\\mathbf{q}(x)} \\right) \\, . @@ -680,7 +680,7 @@ def relative_renyi_entropy( This is known as the `min-relative entropy `_. .. note:: - Function raises ``NotImplementedError`` when ``target`` :math:`sigma` + Function raises ``NotImplementedError`` when ``target`` :math:`\\sigma` is a pure state and :math:`\\alpha > 1`. This is due to the fact that it is not possible to calculate :math:`\\sigma^{1 - \\alpha}` when :math:`\\alpha > 1` and :math:`\\sigma` is a projector, i.e. a singular matrix. diff --git a/src/qibo/quantum_info/superoperator_transformations.py b/src/qibo/quantum_info/superoperator_transformations.py index 73bce85f97..dbdb136ad1 100644 --- a/src/qibo/quantum_info/superoperator_transformations.py +++ b/src/qibo/quantum_info/superoperator_transformations.py @@ -14,18 +14,17 @@ def vectorization(state, order: str = "row", backend=None): - """Returns state :math:`\\rho` in its Liouville - representation :math:`|\\rho\\rangle\\rangle`. + """Returns state :math:`\\rho` in its Liouville representation :math:`|\\rho)`. If ``order="row"``, then: .. math:: - |\\rho\\rangle\\rangle = \\sum_{k, l} \\, \\rho_{kl} \\, \\ket{k} \\otimes \\ket{l} + |\\rho) = \\sum_{k, l} \\, \\rho_{kl} \\, \\ket{k} \\otimes \\ket{l} If ``order="column"``, then: .. math:: - |\\rho\\rangle\\rangle = \\sum_{k, l} \\, \\rho_{kl} \\, \\ket{l} \\otimes \\ket{k} + |\\rho) = \\sum_{k, l} \\, \\rho_{kl} \\, \\ket{l} \\otimes \\ket{k} Args: state: state vector or density matrix. @@ -88,12 +87,12 @@ def vectorization(state, order: str = "row", backend=None): def unvectorization(state, order: str = "row", backend=None): """Returns state :math:`\\rho` from its Liouville - representation :math:`|\\rho\\rangle\\rangle`. This operation is + representation :math:`|\\rho)`. This operation is the inverse function of :func:`vectorization`, i.e. .. math:: \\begin{align} - \\rho &= \\text{unvectorization}(|\\rho\\rangle\\rangle) \\nonumber \\\\ + \\rho &= \\text{unvectorization}(|\\rho)) \\nonumber \\\\ &= \\text{unvectorization}(\\text{vectorization}(\\rho)) \\nonumber \\end{align} @@ -152,9 +151,9 @@ def to_choi(channel, order: str = "row", backend=None): """Converts quantum ``channel`` :math:`U` to its Choi representation :math:`\\Lambda`. .. math:: - \\Lambda = | U \\rangle\\rangle \\langle\\langle U | \\, , + \\Lambda = | U ) ( U | \\, , - where :math:`| \\cdot \\rangle\\rangle` is the :func:`qibo.quantum_info.vectorization` + where :math:`| \\cdot )` is the :func:`qibo.quantum_info.vectorization` operation. Args: @@ -376,7 +375,9 @@ def choi_to_kraus( .. math:: \\Lambda = \\sum_{\\alpha} \\, \\lambda_{\\alpha}^{2} \\, - |\\tilde{K}_{\\alpha}\\rangle\\rangle \\langle\\langle \\tilde{K}_{\\alpha}| \\, . + |\\tilde{K}_{\\alpha})(\\tilde{K}_{\\alpha}| \\, . + + where :math:`|\\cdot)` is the :func:`qibo.quantum_info.vectorization` operation. This is the spectral decomposition of :math:`\\Lambda`, Hence, the set :math:`\\{\\lambda_{\\alpha}, \\, \\tilde{K}_{\\alpha}\\}_{\\alpha}` @@ -385,7 +386,7 @@ def choi_to_kraus( .. math:: K_{\\alpha} = \\lambda_{\\alpha} \\, - \\text{unvectorization}(|\\tilde{K}_{\\alpha}\\rangle\\rangle) \\, . + \\text{unvectorization}(|\\tilde{K}_{\\alpha})) \\, . If :math:`\\mathcal{E}` is not CP, then spectral composition is replaced by a singular value decomposition (SVD), i.e. @@ -638,7 +639,11 @@ def kraus_to_choi(kraus_ops, order: str = "row", backend=None): of quantum channel to its Choi representation :math:`\\Lambda`. .. math:: - \\Lambda = \\sum_{\\alpha} \\, |K_{\\alpha}\\rangle\\rangle \\langle\\langle K_{\\alpha}| + \\Lambda = \\sum_{\\alpha} \\, |K_{\\alpha})( K_{\\alpha}| + + where :math:`|K_{\\alpha})` is the vectorization of the Kraus operator + :math:`K_{\\alpha}`. + For a definition of vectorization, see :func:`qibo.quantum_info.vectorization`. Args: kraus_ops (list): List of Kraus operators as pairs ``(qubits, Ak)`` @@ -757,10 +762,11 @@ def kraus_to_chi( of quantum channel to its :math:`\\chi`-matrix representation. .. math:: - \\chi = \\sum_{\\alpha} \\, |c_{\\alpha}\\rangle\\rangle \\langle\\langle c_{\\alpha}|, + \\chi = \\sum_{\\alpha} \\, |c_{\\alpha})( c_{\\alpha}|, - where :math:`|c_{\\alpha}\\rangle\\rangle \\cong |K_{\\alpha}\\rangle\\rangle` - in Pauli-Liouville basis. + where :math:`|c_{\\alpha}) \\cong |K_{\\alpha})` in Pauli-Liouville basis, + and :math:`| \\cdot )` is the :func:`qibo.quantum_info.vectorization` + operation. Args: kraus_ops (list): List of Kraus operators as pairs ``(qubits, Ak)``