diff --git a/docs/_autosummary/toqito.channel_metrics.completely_bounded_spectral_norm.rst b/docs/_autosummary/toqito.channel_metrics.completely_bounded_spectral_norm.rst new file mode 100644 index 000000000..d7bd87bd9 --- /dev/null +++ b/docs/_autosummary/toqito.channel_metrics.completely_bounded_spectral_norm.rst @@ -0,0 +1,6 @@ +toqito.channel\_metrics.completely\_bounded\_spectral\_norm +=========================================================== + +.. currentmodule:: toqito.channel_metrics + +.. autofunction:: completely_bounded_spectral_norm \ No newline at end of file diff --git a/docs/_autosummary/toqito.channel_metrics.completely_bounded_trace_norm.rst b/docs/_autosummary/toqito.channel_metrics.completely_bounded_trace_norm.rst new file mode 100644 index 000000000..cc710966f --- /dev/null +++ b/docs/_autosummary/toqito.channel_metrics.completely_bounded_trace_norm.rst @@ -0,0 +1,6 @@ +toqito.channel\_metrics.completely\_bounded\_trace\_norm +======================================================== + +.. currentmodule:: toqito.channel_metrics + +.. autofunction:: completely_bounded_trace_norm \ No newline at end of file diff --git a/docs/_autosummary/toqito.channel_metrics.fidelity_of_separability.rst b/docs/_autosummary/toqito.channel_metrics.fidelity_of_separability.rst new file mode 100644 index 000000000..f217c2b7d --- /dev/null +++ b/docs/_autosummary/toqito.channel_metrics.fidelity_of_separability.rst @@ -0,0 +1,6 @@ +toqito.channel\_metrics.fidelity\_of\_separability +================================================== + +.. currentmodule:: toqito.channel_metrics + +.. autofunction:: fidelity_of_separability \ No newline at end of file diff --git a/docs/_autosummary/toqito.matrices.clock.rst b/docs/_autosummary/toqito.matrices.clock.rst new file mode 100644 index 000000000..6d08adf29 --- /dev/null +++ b/docs/_autosummary/toqito.matrices.clock.rst @@ -0,0 +1,6 @@ +toqito.matrices.clock +===================== + +.. currentmodule:: toqito.matrices + +.. autofunction:: clock \ No newline at end of file diff --git a/docs/_autosummary/toqito.matrices.cnot.rst b/docs/_autosummary/toqito.matrices.cnot.rst new file mode 100644 index 000000000..ec2002f57 --- /dev/null +++ b/docs/_autosummary/toqito.matrices.cnot.rst @@ -0,0 +1,6 @@ +toqito.matrices.cnot +==================== + +.. currentmodule:: toqito.matrices + +.. autofunction:: cnot \ No newline at end of file diff --git a/docs/_autosummary/toqito.matrices.fourier.rst b/docs/_autosummary/toqito.matrices.fourier.rst new file mode 100644 index 000000000..46bac444a --- /dev/null +++ b/docs/_autosummary/toqito.matrices.fourier.rst @@ -0,0 +1,6 @@ +toqito.matrices.fourier +======================= + +.. currentmodule:: toqito.matrices + +.. autofunction:: fourier \ No newline at end of file diff --git a/docs/_autosummary/toqito.matrices.gell_mann.rst b/docs/_autosummary/toqito.matrices.gell_mann.rst new file mode 100644 index 000000000..1cd00db2b --- /dev/null +++ b/docs/_autosummary/toqito.matrices.gell_mann.rst @@ -0,0 +1,6 @@ +toqito.matrices.gell\_mann +========================== + +.. currentmodule:: toqito.matrices + +.. autofunction:: gell_mann \ No newline at end of file diff --git a/docs/_autosummary/toqito.matrices.gen_gell_mann.rst b/docs/_autosummary/toqito.matrices.gen_gell_mann.rst new file mode 100644 index 000000000..7ecbe6e89 --- /dev/null +++ b/docs/_autosummary/toqito.matrices.gen_gell_mann.rst @@ -0,0 +1,6 @@ +toqito.matrices.gen\_gell\_mann +=============================== + +.. currentmodule:: toqito.matrices + +.. autofunction:: gen_gell_mann \ No newline at end of file diff --git a/docs/_autosummary/toqito.matrices.gen_pauli.rst b/docs/_autosummary/toqito.matrices.gen_pauli.rst new file mode 100644 index 000000000..1b50fc77c --- /dev/null +++ b/docs/_autosummary/toqito.matrices.gen_pauli.rst @@ -0,0 +1,6 @@ +toqito.matrices.gen\_pauli +========================== + +.. currentmodule:: toqito.matrices + +.. autofunction:: gen_pauli \ No newline at end of file diff --git a/docs/_autosummary/toqito.matrices.hadamard.rst b/docs/_autosummary/toqito.matrices.hadamard.rst new file mode 100644 index 000000000..63e17372a --- /dev/null +++ b/docs/_autosummary/toqito.matrices.hadamard.rst @@ -0,0 +1,6 @@ +toqito.matrices.hadamard +======================== + +.. currentmodule:: toqito.matrices + +.. autofunction:: hadamard \ No newline at end of file diff --git a/docs/_autosummary/toqito.matrices.pauli.rst b/docs/_autosummary/toqito.matrices.pauli.rst new file mode 100644 index 000000000..18cb4e904 --- /dev/null +++ b/docs/_autosummary/toqito.matrices.pauli.rst @@ -0,0 +1,6 @@ +toqito.matrices.pauli +===================== + +.. currentmodule:: toqito.matrices + +.. autofunction:: pauli \ No newline at end of file diff --git a/docs/_autosummary/toqito.matrices.shift.rst b/docs/_autosummary/toqito.matrices.shift.rst new file mode 100644 index 000000000..e8a784d20 --- /dev/null +++ b/docs/_autosummary/toqito.matrices.shift.rst @@ -0,0 +1,6 @@ +toqito.matrices.shift +===================== + +.. currentmodule:: toqito.matrices + +.. autofunction:: shift \ No newline at end of file diff --git a/docs/_autosummary/toqito.matrices.standard_basis.rst b/docs/_autosummary/toqito.matrices.standard_basis.rst new file mode 100644 index 000000000..fd0697722 --- /dev/null +++ b/docs/_autosummary/toqito.matrices.standard_basis.rst @@ -0,0 +1,6 @@ +toqito.matrices.standard\_basis +=============================== + +.. currentmodule:: toqito.matrices + +.. autofunction:: standard_basis \ No newline at end of file diff --git a/docs/_autosummary/toqito.matrix_ops.inner_product.rst b/docs/_autosummary/toqito.matrix_ops.inner_product.rst new file mode 100644 index 000000000..2089a2a96 --- /dev/null +++ b/docs/_autosummary/toqito.matrix_ops.inner_product.rst @@ -0,0 +1,6 @@ +toqito.matrix\_ops.inner\_product +================================= + +.. currentmodule:: toqito.matrix_ops + +.. autofunction:: inner_product \ No newline at end of file diff --git a/docs/_autosummary/toqito.matrix_ops.outer_product.rst b/docs/_autosummary/toqito.matrix_ops.outer_product.rst new file mode 100644 index 000000000..9910dd901 --- /dev/null +++ b/docs/_autosummary/toqito.matrix_ops.outer_product.rst @@ -0,0 +1,6 @@ +toqito.matrix\_ops.outer\_product +================================= + +.. currentmodule:: toqito.matrix_ops + +.. autofunction:: outer_product \ No newline at end of file diff --git a/docs/_autosummary/toqito.matrix_ops.tensor.rst b/docs/_autosummary/toqito.matrix_ops.tensor.rst new file mode 100644 index 000000000..5d4fcbb73 --- /dev/null +++ b/docs/_autosummary/toqito.matrix_ops.tensor.rst @@ -0,0 +1,6 @@ +toqito.matrix\_ops.tensor +========================= + +.. currentmodule:: toqito.matrix_ops + +.. autofunction:: tensor \ No newline at end of file diff --git a/docs/_autosummary/toqito.matrix_ops.unvec.rst b/docs/_autosummary/toqito.matrix_ops.unvec.rst new file mode 100644 index 000000000..3739af71d --- /dev/null +++ b/docs/_autosummary/toqito.matrix_ops.unvec.rst @@ -0,0 +1,6 @@ +toqito.matrix\_ops.unvec +======================== + +.. currentmodule:: toqito.matrix_ops + +.. autofunction:: unvec \ No newline at end of file diff --git a/docs/_autosummary/toqito.matrix_ops.vec.rst b/docs/_autosummary/toqito.matrix_ops.vec.rst new file mode 100644 index 000000000..270db3212 --- /dev/null +++ b/docs/_autosummary/toqito.matrix_ops.vec.rst @@ -0,0 +1,6 @@ +toqito.matrix\_ops.vec +====================== + +.. currentmodule:: toqito.matrix_ops + +.. autofunction:: vec \ No newline at end of file diff --git a/docs/_autosummary/toqito.matrix_ops.vectors_from_gram_matrix.rst b/docs/_autosummary/toqito.matrix_ops.vectors_from_gram_matrix.rst new file mode 100644 index 000000000..98a20b969 --- /dev/null +++ b/docs/_autosummary/toqito.matrix_ops.vectors_from_gram_matrix.rst @@ -0,0 +1,6 @@ +toqito.matrix\_ops.vectors\_from\_gram\_matrix +============================================== + +.. currentmodule:: toqito.matrix_ops + +.. autofunction:: vectors_from_gram_matrix \ No newline at end of file diff --git a/docs/_autosummary/toqito.matrix_ops.vectors_to_gram_matrix.rst b/docs/_autosummary/toqito.matrix_ops.vectors_to_gram_matrix.rst new file mode 100644 index 000000000..8b5122c72 --- /dev/null +++ b/docs/_autosummary/toqito.matrix_ops.vectors_to_gram_matrix.rst @@ -0,0 +1,6 @@ +toqito.matrix\_ops.vectors\_to\_gram\_matrix +============================================ + +.. currentmodule:: toqito.matrix_ops + +.. autofunction:: vectors_to_gram_matrix \ No newline at end of file diff --git a/docs/_autosummary/toqito.matrix_props.is_block_positive.rst b/docs/_autosummary/toqito.matrix_props.is_block_positive.rst new file mode 100644 index 000000000..e2decc0a9 --- /dev/null +++ b/docs/_autosummary/toqito.matrix_props.is_block_positive.rst @@ -0,0 +1,6 @@ +toqito.matrix\_props.is\_block\_positive +======================================== + +.. currentmodule:: toqito.matrix_props + +.. autofunction:: is_block_positive \ No newline at end of file diff --git a/docs/_autosummary/toqito.matrix_props.is_circulant.rst b/docs/_autosummary/toqito.matrix_props.is_circulant.rst new file mode 100644 index 000000000..1bfc12876 --- /dev/null +++ b/docs/_autosummary/toqito.matrix_props.is_circulant.rst @@ -0,0 +1,6 @@ +toqito.matrix\_props.is\_circulant +================================== + +.. currentmodule:: toqito.matrix_props + +.. autofunction:: is_circulant \ No newline at end of file diff --git a/docs/_autosummary/toqito.matrix_props.is_commuting.rst b/docs/_autosummary/toqito.matrix_props.is_commuting.rst new file mode 100644 index 000000000..bb7dac3ad --- /dev/null +++ b/docs/_autosummary/toqito.matrix_props.is_commuting.rst @@ -0,0 +1,6 @@ +toqito.matrix\_props.is\_commuting +================================== + +.. currentmodule:: toqito.matrix_props + +.. autofunction:: is_commuting \ No newline at end of file diff --git a/docs/_autosummary/toqito.matrix_props.is_density.rst b/docs/_autosummary/toqito.matrix_props.is_density.rst new file mode 100644 index 000000000..cdaa75728 --- /dev/null +++ b/docs/_autosummary/toqito.matrix_props.is_density.rst @@ -0,0 +1,6 @@ +toqito.matrix\_props.is\_density +================================ + +.. currentmodule:: toqito.matrix_props + +.. autofunction:: is_density \ No newline at end of file diff --git a/docs/_autosummary/toqito.matrix_props.is_diagonal.rst b/docs/_autosummary/toqito.matrix_props.is_diagonal.rst new file mode 100644 index 000000000..20ca1109c --- /dev/null +++ b/docs/_autosummary/toqito.matrix_props.is_diagonal.rst @@ -0,0 +1,6 @@ +toqito.matrix\_props.is\_diagonal +================================= + +.. currentmodule:: toqito.matrix_props + +.. autofunction:: is_diagonal \ No newline at end of file diff --git a/docs/_autosummary/toqito.matrix_props.is_diagonally_dominant.rst b/docs/_autosummary/toqito.matrix_props.is_diagonally_dominant.rst new file mode 100644 index 000000000..e3245a440 --- /dev/null +++ b/docs/_autosummary/toqito.matrix_props.is_diagonally_dominant.rst @@ -0,0 +1,6 @@ +toqito.matrix\_props.is\_diagonally\_dominant +============================================= + +.. currentmodule:: toqito.matrix_props + +.. autofunction:: is_diagonally_dominant \ No newline at end of file diff --git a/docs/_autosummary/toqito.matrix_props.is_hermitian.rst b/docs/_autosummary/toqito.matrix_props.is_hermitian.rst new file mode 100644 index 000000000..f229fcc96 --- /dev/null +++ b/docs/_autosummary/toqito.matrix_props.is_hermitian.rst @@ -0,0 +1,6 @@ +toqito.matrix\_props.is\_hermitian +================================== + +.. currentmodule:: toqito.matrix_props + +.. autofunction:: is_hermitian \ No newline at end of file diff --git a/docs/_autosummary/toqito.matrix_props.is_idempotent.rst b/docs/_autosummary/toqito.matrix_props.is_idempotent.rst new file mode 100644 index 000000000..96d84a9d2 --- /dev/null +++ b/docs/_autosummary/toqito.matrix_props.is_idempotent.rst @@ -0,0 +1,6 @@ +toqito.matrix\_props.is\_idempotent +=================================== + +.. currentmodule:: toqito.matrix_props + +.. autofunction:: is_idempotent \ No newline at end of file diff --git a/docs/_autosummary/toqito.matrix_props.is_identity.rst b/docs/_autosummary/toqito.matrix_props.is_identity.rst new file mode 100644 index 000000000..ce2f2a501 --- /dev/null +++ b/docs/_autosummary/toqito.matrix_props.is_identity.rst @@ -0,0 +1,6 @@ +toqito.matrix\_props.is\_identity +================================= + +.. currentmodule:: toqito.matrix_props + +.. autofunction:: is_identity \ No newline at end of file diff --git a/docs/_autosummary/toqito.matrix_props.is_normal.rst b/docs/_autosummary/toqito.matrix_props.is_normal.rst new file mode 100644 index 000000000..a8eabc5fd --- /dev/null +++ b/docs/_autosummary/toqito.matrix_props.is_normal.rst @@ -0,0 +1,6 @@ +toqito.matrix\_props.is\_normal +=============================== + +.. currentmodule:: toqito.matrix_props + +.. autofunction:: is_normal \ No newline at end of file diff --git a/docs/_autosummary/toqito.matrix_props.is_orthonormal.rst b/docs/_autosummary/toqito.matrix_props.is_orthonormal.rst new file mode 100644 index 000000000..67cbe2545 --- /dev/null +++ b/docs/_autosummary/toqito.matrix_props.is_orthonormal.rst @@ -0,0 +1,6 @@ +toqito.matrix\_props.is\_orthonormal +==================================== + +.. currentmodule:: toqito.matrix_props + +.. autofunction:: is_orthonormal \ No newline at end of file diff --git a/docs/_autosummary/toqito.matrix_props.is_permutation.rst b/docs/_autosummary/toqito.matrix_props.is_permutation.rst new file mode 100644 index 000000000..a1a820292 --- /dev/null +++ b/docs/_autosummary/toqito.matrix_props.is_permutation.rst @@ -0,0 +1,6 @@ +toqito.matrix\_props.is\_permutation +==================================== + +.. currentmodule:: toqito.matrix_props + +.. autofunction:: is_permutation \ No newline at end of file diff --git a/docs/_autosummary/toqito.matrix_props.is_positive_definite.rst b/docs/_autosummary/toqito.matrix_props.is_positive_definite.rst new file mode 100644 index 000000000..e7ae0cd97 --- /dev/null +++ b/docs/_autosummary/toqito.matrix_props.is_positive_definite.rst @@ -0,0 +1,6 @@ +toqito.matrix\_props.is\_positive\_definite +=========================================== + +.. currentmodule:: toqito.matrix_props + +.. autofunction:: is_positive_definite \ No newline at end of file diff --git a/docs/_autosummary/toqito.matrix_props.is_positive_semidefinite.rst b/docs/_autosummary/toqito.matrix_props.is_positive_semidefinite.rst new file mode 100644 index 000000000..7a4501f0c --- /dev/null +++ b/docs/_autosummary/toqito.matrix_props.is_positive_semidefinite.rst @@ -0,0 +1,6 @@ +toqito.matrix\_props.is\_positive\_semidefinite +=============================================== + +.. currentmodule:: toqito.matrix_props + +.. autofunction:: is_positive_semidefinite \ No newline at end of file diff --git a/docs/_autosummary/toqito.matrix_props.is_projection.rst b/docs/_autosummary/toqito.matrix_props.is_projection.rst new file mode 100644 index 000000000..4f520c8cf --- /dev/null +++ b/docs/_autosummary/toqito.matrix_props.is_projection.rst @@ -0,0 +1,6 @@ +toqito.matrix\_props.is\_projection +=================================== + +.. currentmodule:: toqito.matrix_props + +.. autofunction:: is_projection \ No newline at end of file diff --git a/docs/_autosummary/toqito.matrix_props.is_square.rst b/docs/_autosummary/toqito.matrix_props.is_square.rst new file mode 100644 index 000000000..976d51a5f --- /dev/null +++ b/docs/_autosummary/toqito.matrix_props.is_square.rst @@ -0,0 +1,6 @@ +toqito.matrix\_props.is\_square +=============================== + +.. currentmodule:: toqito.matrix_props + +.. autofunction:: is_square \ No newline at end of file diff --git a/docs/_autosummary/toqito.matrix_props.is_symmetric.rst b/docs/_autosummary/toqito.matrix_props.is_symmetric.rst new file mode 100644 index 000000000..4285984ed --- /dev/null +++ b/docs/_autosummary/toqito.matrix_props.is_symmetric.rst @@ -0,0 +1,6 @@ +toqito.matrix\_props.is\_symmetric +================================== + +.. currentmodule:: toqito.matrix_props + +.. autofunction:: is_symmetric \ No newline at end of file diff --git a/docs/_autosummary/toqito.matrix_props.is_unitary.rst b/docs/_autosummary/toqito.matrix_props.is_unitary.rst new file mode 100644 index 000000000..93a12e216 --- /dev/null +++ b/docs/_autosummary/toqito.matrix_props.is_unitary.rst @@ -0,0 +1,6 @@ +toqito.matrix\_props.is\_unitary +================================ + +.. currentmodule:: toqito.matrix_props + +.. autofunction:: is_unitary \ No newline at end of file diff --git a/docs/_autosummary/toqito.matrix_props.kp_norm.rst b/docs/_autosummary/toqito.matrix_props.kp_norm.rst new file mode 100644 index 000000000..7f0b08f1e --- /dev/null +++ b/docs/_autosummary/toqito.matrix_props.kp_norm.rst @@ -0,0 +1,6 @@ +toqito.matrix\_props.kp\_norm +============================= + +.. currentmodule:: toqito.matrix_props + +.. autofunction:: kp_norm \ No newline at end of file diff --git a/docs/_autosummary/toqito.matrix_props.majorizes.rst b/docs/_autosummary/toqito.matrix_props.majorizes.rst new file mode 100644 index 000000000..f559d975a --- /dev/null +++ b/docs/_autosummary/toqito.matrix_props.majorizes.rst @@ -0,0 +1,6 @@ +toqito.matrix\_props.majorizes +============================== + +.. currentmodule:: toqito.matrix_props + +.. autofunction:: majorizes \ No newline at end of file diff --git a/docs/_autosummary/toqito.matrix_props.sk_operator_norm.rst b/docs/_autosummary/toqito.matrix_props.sk_operator_norm.rst new file mode 100644 index 000000000..57733899b --- /dev/null +++ b/docs/_autosummary/toqito.matrix_props.sk_operator_norm.rst @@ -0,0 +1,6 @@ +toqito.matrix\_props.sk\_operator\_norm +======================================= + +.. currentmodule:: toqito.matrix_props + +.. autofunction:: sk_operator_norm \ No newline at end of file diff --git a/docs/_autosummary/toqito.matrix_props.trace_norm.rst b/docs/_autosummary/toqito.matrix_props.trace_norm.rst new file mode 100644 index 000000000..3ff0febe1 --- /dev/null +++ b/docs/_autosummary/toqito.matrix_props.trace_norm.rst @@ -0,0 +1,6 @@ +toqito.matrix\_props.trace\_norm +================================ + +.. currentmodule:: toqito.matrix_props + +.. autofunction:: trace_norm \ No newline at end of file diff --git a/docs/_autosummary/toqito.random.random_density_matrix.rst b/docs/_autosummary/toqito.rand.random_density_matrix.rst similarity index 74% rename from docs/_autosummary/toqito.random.random_density_matrix.rst rename to docs/_autosummary/toqito.rand.random_density_matrix.rst index e2298fa79..186634a0f 100644 --- a/docs/_autosummary/toqito.random.random_density_matrix.rst +++ b/docs/_autosummary/toqito.rand.random_density_matrix.rst @@ -1,5 +1,5 @@ toqito.rand.random\_density\_matrix -===================================== +=================================== .. currentmodule:: toqito.rand diff --git a/docs/_autosummary/toqito.random.random_ginibre.rst b/docs/_autosummary/toqito.rand.random_ginibre.rst similarity index 76% rename from docs/_autosummary/toqito.random.random_ginibre.rst rename to docs/_autosummary/toqito.rand.random_ginibre.rst index 5536ac054..a081bbeeb 100644 --- a/docs/_autosummary/toqito.random.random_ginibre.rst +++ b/docs/_autosummary/toqito.rand.random_ginibre.rst @@ -1,5 +1,5 @@ toqito.rand.random\_ginibre -============================= +=========================== .. currentmodule:: toqito.rand diff --git a/docs/_autosummary/toqito.random.random_povm.rst b/docs/_autosummary/toqito.rand.random_povm.rst similarity index 76% rename from docs/_autosummary/toqito.random.random_povm.rst rename to docs/_autosummary/toqito.rand.random_povm.rst index 0df1cca2a..8c19da052 100644 --- a/docs/_autosummary/toqito.random.random_povm.rst +++ b/docs/_autosummary/toqito.rand.random_povm.rst @@ -1,5 +1,5 @@ toqito.rand.random\_povm -========================== +======================== .. currentmodule:: toqito.rand diff --git a/docs/_autosummary/toqito.random.random_state_vector.rst b/docs/_autosummary/toqito.rand.random_state_vector.rst similarity index 74% rename from docs/_autosummary/toqito.random.random_state_vector.rst rename to docs/_autosummary/toqito.rand.random_state_vector.rst index 1d440031e..c0b10fcc6 100644 --- a/docs/_autosummary/toqito.random.random_state_vector.rst +++ b/docs/_autosummary/toqito.rand.random_state_vector.rst @@ -1,5 +1,5 @@ toqito.rand.random\_state\_vector -=================================== +================================= .. currentmodule:: toqito.rand diff --git a/docs/_autosummary/toqito.random.random_unitary.rst b/docs/_autosummary/toqito.rand.random_unitary.rst similarity index 76% rename from docs/_autosummary/toqito.random.random_unitary.rst rename to docs/_autosummary/toqito.rand.random_unitary.rst index bddd4eda4..49ff910f8 100644 --- a/docs/_autosummary/toqito.random.random_unitary.rst +++ b/docs/_autosummary/toqito.rand.random_unitary.rst @@ -1,5 +1,5 @@ toqito.rand.random\_unitary -============================= +=========================== .. currentmodule:: toqito.rand diff --git a/docs/_autosummary/toqito.state_metrics.bures_angle.rst b/docs/_autosummary/toqito.state_metrics.bures_angle.rst index 45d1e765c..1365e8494 100644 --- a/docs/_autosummary/toqito.state_metrics.bures_angle.rst +++ b/docs/_autosummary/toqito.state_metrics.bures_angle.rst @@ -1,5 +1,5 @@ -toqito.state\_metrics.bures\_angle -===================================== +toqito.state\_metrics.bures\_angle +================================== .. currentmodule:: toqito.state_metrics diff --git a/docs/_autosummary/toqito.state_metrics.fidelity_of_separability.rst b/docs/_autosummary/toqito.state_metrics.fidelity_of_separability.rst new file mode 100644 index 000000000..7aa7480ec --- /dev/null +++ b/docs/_autosummary/toqito.state_metrics.fidelity_of_separability.rst @@ -0,0 +1,6 @@ +toqito.state\_metrics.fidelity\_of\_separability +================================================ + +.. currentmodule:: toqito.state_metrics + +.. autofunction:: fidelity_of_separability \ No newline at end of file diff --git a/docs/_autosummary/toqito.state_props.is_npt.rst b/docs/_autosummary/toqito.state_props.is_npt.rst new file mode 100644 index 000000000..864e2f591 --- /dev/null +++ b/docs/_autosummary/toqito.state_props.is_npt.rst @@ -0,0 +1,6 @@ +toqito.state\_props.is\_npt +=========================== + +.. currentmodule:: toqito.state_props + +.. autofunction:: is_npt \ No newline at end of file diff --git a/docs/_autosummary/toqito.state_props.is_separable.rst b/docs/_autosummary/toqito.state_props.is_separable.rst index b9513e8c1..5975eba86 100644 --- a/docs/_autosummary/toqito.state_props.is_separable.rst +++ b/docs/_autosummary/toqito.state_props.is_separable.rst @@ -1,29 +1,6 @@ toqito.state\_props.is\_separable ================================= -.. automodule:: toqito.state_props.is_separable - - - - - - - - .. rubric:: Functions - - .. autosummary:: - - is_separable - - - - - - - - - - - - +.. currentmodule:: toqito.state_props +.. autofunction:: is_separable \ No newline at end of file diff --git a/docs/articles.bib b/docs/articles.bib new file mode 100644 index 000000000..b12ad1973 --- /dev/null +++ b/docs/articles.bib @@ -0,0 +1,1124 @@ +#File for all article, arxiv and other web references +# To add a key, Lastname_year_abbreviatedtitle/firstletteroftitle + +#Last name begins with A +@misc{Aaronson_2018_MaxMixed, + author = {Aaronson, Scott}, + title = "Lecture 6: Mixed States", + howpublished = {https://www.scottaaronson.com/qclec/6.pdf} + +} + + +@misc{Arunachalam_2017_QuantumHedging, + title={Quantum hedging in two-round prover-verifier interactions}, + author={Arunachalam, Srinivasan and Molina, Abel and Russo, Vincent}, + year={2017}, + eprint={1310.7954}, + archivePrefix={arXiv}, + primaryClass={quant-ph} +} + + + +#Last name begins with B +@article{Bandyopadhyay_2014_Conclusive, + title={Conclusive exclusion of quantum states}, + volume={89}, + ISSN={1094-1622}, + url={http://dx.doi.org/10.1103/PhysRevA.89.022336}, + DOI={10.1103/physreva.89.022336}, + number={2}, + journal={Physical Review A}, + publisher={American Physical Society (APS)}, + author={Bandyopadhyay, Somshubhro and Jain, Rahul and Oppenheim, Jonathan and Perry, Christopher}, + year={2014}, + month={Feb}} + +@article{Bennett_1999_QuantumNonlocality, + title={Quantum nonlocality without entanglement}, + volume={59}, + ISSN={1094-1622}, + url={http://dx.doi.org/10.1103/PhysRevA.59.1070}, + DOI={10.1103/physreva.59.1070}, + number={2}, + journal={Physical Review A}, + publisher={American Physical Society (APS)}, + author={Bennett, Charles H. and DiVincenzo, David P. and Fuchs, Christopher A. and Mor, Tal and Rains, Eric and Shor, Peter W. and Smolin, John A. and Wootters, William K.}, + year={1999}, + month={Feb}, pages={1070-1091} } + +@article{Bennett_1999_UPB, + title={Unextendible Product Bases and Bound Entanglement}, + volume={82}, + ISSN={1079-7114}, + url={http://dx.doi.org/10.1103/PhysRevLett.82.5385}, + DOI={10.1103/physrevlett.82.5385}, + number={26}, + journal={Physical Review Letters}, + publisher={American Physical Society (APS)}, + author={Bennett, Charles H. and DiVincenzo, David P. and Mor, Tal and Shor, Peter W. and Smolin, John A. and Terhal, Barbara M.}, + year={1999}, + month={Jun}, pages={5385-5388} } + + +@article{Breuer_2006_Optimal, + title={Optimal Entanglement Criterion for Mixed Quantum States}, + volume={97}, + ISSN={1079-7114}, + url={http://dx.doi.org/10.1103/PhysRevLett.97.080501}, + DOI={10.1103/physrevlett.97.080501}, + number={8}, + journal={Physical Review Letters}, + publisher={American Physical Society (APS)}, + author={Breuer, Heinz-Peter}, + year={2006}, + month={Aug} } + + +#Last name begins with C +@article{Cabello_2002_NParticle, + title = {$N$-Particle $N$-Level Singlet States: Some Properties and Applications}, + author = {Cabello, Ad\'an}, + journal = {Phys. Rev. Lett.}, + volume = {89}, + issue = {10}, + pages = {100402}, + numpages = {4}, + year = {2002}, + month = {Aug}, + publisher = {American Physical Society}, + doi = {10.1103/Cabello_2002_NParticle}, + url = {https://link.aps.org/doi/10.1103/Cabello_2002_NParticle} +} + + +@article{Chen_2014_Symmetric, + title={Symmetric extension of two-qubit states}, + volume={90}, + ISSN={1094-1622}, + url={http://dx.doi.org/10.1103/PhysRevA.90.032318}, + DOI={10.1103/physreva.90.032318}, + number={3}, + journal={Physical Review A}, + publisher={American Physical Society (APS)}, + author={Chen, Jianxin and Ji, Zhengfeng and Kribs, David and Lütkenhaus, Norbert and Zeng, Bei}, + year={2014}, + month={Sep} } + +@article{Choi_1992_Generalized, +title = {Generalized Choi maps in three-dimensional matrix algebra}, +journal = {Linear Algebra and its Applications}, +volume = {171}, +pages = {213-224}, +year = {1992}, +issn = {0024-3795}, +doi = {https://doi.org/10.1016/0024-3795(92)90260-H}, +url = {https://www.sciencedirect.com/science/article/pii/002437959290260H}, +author = {Cho, Sung Je and Kye, Seung-Hyeok and Lee, Sa Ge}, +abstract = {We consider a class of positive linear maps in the three-dimensional matrix algebra, which are generalizations of the positive linear map constructed by Choi in the relation with positive semidefinite biquadratic forms. We find conditions for which such maps are completely positive, completely copositive, decomposable, and two-positive.} +} + +@article{Chruscinski_2011_OnTheSymmetry, + title={On the symmetry of the seminal Horodecki state}, + volume={375}, + ISSN={0375-9601}, + url={http://dx.doi.org/10.1016/j.physleta.2010.11.069}, + DOI={10.1016/j.physleta.2010.11.069}, + number={3}, + journal={Physics Letters A}, + publisher={Elsevier BV}, + author={Chruściński, Dariusz and Kossakowski, Andrzej}, + year={2011}, + month={Jan}, pages={434-436} } + +@misc{Cleve_2008_Strong, + title={Strong Parallel Repetition Theorem for Quantum XOR Proof Systems}, + author={Cleve, Richard and Slofstra, William and Unger, Falk and Upadhyay, Sarvagya}, + year={2008}, + eprint={quant-ph/0608146}, + archivePrefix={arXiv}, + primaryClass={quant-ph} +} + +@misc{Cleve_2010_Consequences, + title={Consequences and Limits of Nonlocal Strategies}, + author={Richard Cleve and Peter Hoyer and Ben Toner and John Watrous}, + year={2010}, + eprint={quant-ph/0404076}, + archivePrefix={arXiv}, + primaryClass={quant-ph} +} + +@article{Cosentino_2013_PPT, + title={Positive-partial-transpose-indistinguishable states via semidefinite programming}, + volume={87}, + ISSN={1094-1622}, + url={http://dx.doi.org/10.1103/PhysRevA.87.012321}, + DOI={10.1103/physreva.87.012321}, + number={1}, + journal={Physical Review A}, + publisher={American Physical Society (APS)}, + author={Cosentino, Alessandro}, + year={2013}, + month={Jan} } + +@misc{Cosentino_2015_QuantumState, + title={Quantum State Local Distinguishability via Convex Optimization}, + author={Cosentino, Alessandro}, + year={2015}, + howpublished = {https://uwspace.uwaterloo.ca/handle/10012/9572} +} + +@misc{Riley_2022_CVXPYKron, + author = {Murray, Riley J}, + title = {{PR:} Have kron support non-constant expressions in either argument from {CXPY:} A Python-embedded modeling language for convex optimization problems}, + howpublished = {https://github.com/cvxpy/cvxpy/issues/457#issue-309891424}} + + +#Last name begins with D +@article{DiVincenzo_2000_Evidence, + title={Evidence for bound entangled states with negative partial transpose}, + volume={61}, + ISSN={1094-1622}, + url={http://dx.doi.org/10.1103/PhysRevA.61.062312}, + DOI={10.1103/physreva.61.062312}, + number={6}, + journal={Physical Review A}, + publisher={American Physical Society (APS)}, + author={DiVincenzo, David P. and Shor, Peter W. and Smolin, John A. and Terhal, Barbara M. and Thapliyal, Ashish V.}, + year={2000}, + month={May} } + + +@article{Doherty_2002_Distinguishing, + title={Distinguishing Separable and Entangled States}, + volume={88}, + ISSN={1079-7114}, + url={http://dx.doi.org/10.1103/PhysRevLett.88.187904}, + DOI={10.1103/physrevlett.88.187904}, + number={18}, + journal={Physical Review Letters}, + publisher={American Physical Society (APS)}, + author={Doherty, A. C. and Parrilo, Pablo A. and Spedalieri, Federico M.}, + year={2002}, + month={Apr} } + +@article{Dur_2000_ThreeQubits, + title={Three qubits can be entangled in two inequivalent ways}, + volume={62}, + ISSN={1094-1622}, + url={http://dx.doi.org/10.1103/PhysRevA.62.062314}, + DOI={10.1103/physreva.62.062314}, + number={6}, + journal={Physical Review A}, + publisher={American Physical Society (APS)}, + author={Dür, W. and Vidal, G. and Cirac, J. I.}, + year={2000}, + month={Nov} } + +#Last name begins with E +@article{Eldar_2003_SDPApproach, + title={A semidefinite programming approach to optimal unambiguous discrimination of quantum states}, + volume={49}, + ISSN={0018-9448}, + url={http://dx.doi.org/10.1109/TIT.2002.807291}, + DOI={10.1109/tit.2002.807291}, + number={2}, + journal={IEEE Transactions on Information Theory}, + publisher={Institute of Electrical and Electronics Engineers (IEEE)}, + author={Eldar, Y.C.}, + year={2003}, + month={Feb}, pages={446-456} } + + +#Last name begins with F + +#Last name begins with G +@misc{Greenberger_2007_Going, + title={Going Beyond Bell's Theorem}, + author={Greenberger, Daniel M. and Horne, Michael A. and Zeilinger, Anton}, + year={2007}, + eprint={0712.0921}, + archivePrefix={arXiv}, + primaryClass={quant-ph} +} + +@article{Gisin_1996_Hidden, +title = {Hidden quantum nonlocality revealed by local filters}, +journal = {Physics Letters A}, +volume = {210}, +number = {3}, +pages = {151-156}, +year = {1996}, +issn = {0375-9601}, +doi = {https://doi.org/10.1016/S0375-9601(96)80001-6}, +url = {https://www.sciencedirect.com/science/article/pii/S0375960196800016}, +author = {Gisin, N.}, +} + +@article{Gurvits_2002_Largest, + title={Largest separable balls around the maximally mixed bipartite quantum state}, + volume={66}, + ISSN={1094-1622}, + url={http://dx.doi.org/10.1103/PhysRevA.66.062311}, + DOI={10.1103/physreva.66.062311}, + number={6}, + journal={Physical Review A}, + publisher={American Physical Society (APS)}, + author={Gurvits, Leonid and Barnum, Howard}, + year={2002}, + month={Dec} } + + +#Last name begins with H +@inproceedings{Hayden_2013_TwoMessage, + title={Two-Message Quantum Interactive Proofs and the Quantum Separability Problem}, + url={http://dx.doi.org/10.1109/CCC.2013.24}, + DOI={10.1109/ccc.2013.24}, + booktitle={2013 IEEE Conference on Computational Complexity}, + publisher={IEEE}, + author={Hayden, Patrick and Milner, Kevin and Wilde, Mark M.}, + year={2013}, + month={Jun} } + +@article{Heinosaari_2018_Antidistinguishability, + title={Antidistinguishability of pure quantum states}, + volume={51}, + ISSN={1751-8121}, + url={http://dx.doi.org/10.1088/1751-8121/aad1fc}, + DOI={10.1088/1751-8121/aad1fc}, + number={36}, + journal={Journal of Physics A: Mathematical and Theoretical}, + publisher={IOP Publishing}, + author={Heinosaari, Teiko and Kerppo, Oskari}, + year={2018}, + month=jul, pages={365303} } + +@article{Heinosaari_2020_Random, + title={Random positive operator valued measures}, + volume={61}, + ISSN={1089-7658}, + url={http://dx.doi.org/10.1063/1.5131028}, + DOI={10.1063/1.5131028}, + number={4}, + journal={Journal of Mathematical Physics}, + publisher={AIP Publishing}, + author={Heinosaari, Teiko and Jivulescu, Maria Anastasia and Nechita, Ion}, + year={2020}, + month={Apr} } + +@article{Horodecki_1997_Separability, + title={Separability criterion and inseparable mixed states with positive partial transposition}, + volume={232}, + ISSN={0375-9601}, + url={http://dx.doi.org/10.1016/S0375-9601(97)00416-7}, + DOI={10.1016/s0375-9601(97)00416-7}, + number={5}, + journal={Physics Letters A}, + publisher={Elsevier BV}, + author={Horodecki, Pawel}, + year={1997}, + month={Aug}, pages={333-339} } + +@misc{Horodecki_1998_Reduction, + title={Reduction criterion of separability and limits for a class of protocols of entanglement distillation}, + author={ Horodecki, Michal and Horodecki, Pawel}, + year={1998}, + eprint={quant-ph/9708015}, + archivePrefix={arXiv}, + primaryClass={quant-ph} +} +#Last name begins with I + +#Last name begins with J +@article{Johnston_2010_AFamily, + title={A family of norms with applications in quantum information theory}, + volume={51}, + ISSN={1089-7658}, + url={http://dx.doi.org/10.1063/1.3459068}, + DOI={10.1063/1.3459068}, + number={8}, + journal={Journal of Mathematical Physics}, + publisher={AIP Publishing}, + author={Johnston, Nathaniel and Kribs, David W.}, + year={2010}, + month={Aug} } + + +@misc{Johnston_2012_Norms, + title={Norms and Cones in the Theory of Quantum Entanglement}, + author={Nathaniel Johnston}, + year={2012}, + eprint={1207.1479}, + archivePrefix={arXiv}, + primaryClass={quant-ph} +} + +@article{Johnston_2016_Extended, + title={Extended non-local games and monogamy-of-entanglement games}, + volume={472}, + ISSN={1471-2946}, + url={http://dx.doi.org/10.1098/rspa.2016.0003}, + DOI={10.1098/rspa.2016.0003}, + number={2189}, + journal={Proceedings of the Royal Society A: Mathematical, Physical and Engineering Sciences}, + publisher={The Royal Society}, + author={Johnston, Nathaniel and Mittal, Rajat and Russo, Vincent and Watrous, John}, + year={2016}, + month={May}, pages={20160003} } + + +@misc{QETLAB_link, + author = {Johnston, Nathaniel}, + title = {{{QETLAB}: {A MATLAB} toolbox for quantum entanglement}}, + howpublished = {https://github.com/nathanieljohnston/QETLAB}, + DOI ={10.5281/zenodo.44637} +} + + +#Last name begins with K +@article{Katariya_2021_Geometric, + title={Geometric distinguishability measures limit quantum channel estimation and discrimination}, + volume={20}, + ISSN={1573-1332}, + url={http://dx.doi.org/10.1007/s11128-021-02992-7}, + DOI={10.1007/s11128-021-02992-7}, + number={2}, + journal={Quantum Information Processing}, + publisher={Springer Science and Business Media LLC}, + author={Katariya, Vishal and Wilde, Mark M.}, + year={2021}, + month={Feb} } + +#Last name begins with L +@article{Liang_2007_Bounds, + title={Bounds on quantum correlations in Bell-inequality experiments}, + volume={75}, + ISSN={1094-1622}, + url={http://dx.doi.org/10.1103/PhysRevA.75.042103}, + DOI={10.1103/physreva.75.042103}, + number={4}, + journal={Physical Review A}, + publisher={American Physical Society (APS)}, + author={Liang, Yeong-Cherng and Doherty, Andrew C.}, + year={2007}, + month={Apr} } + + +@article{Lupo_2008_Bipartite, + title={Bipartite quantum systems: on the realignment criterion and beyond}, + volume={41}, + ISSN={1751-8121}, + url={http://dx.doi.org/10.1088/1751-8113/41/41/415301}, + DOI={10.1088/1751-8113/41/41/415301}, + number={41}, + journal={Journal of Physics A: Mathematical and Theoretical}, + publisher={IOP Publishing}, + author={Lupo, Cosmo and Aniello, Paolo and Scardicchio, Antonello}, + year={2008}, + month={Sep}, pages={415301} } + + +#Last name begins with M +@misc{Matsumoto_2010_Reverse, + title={Reverse test and quantum analogue of classical fidelity and generalized fidelity}, + author={Matsumoto, Keiji}, + year={2010}, + eprint={1006.0302}, + archivePrefix={arXiv}, + primaryClass={quant-ph} +} + +@misc{Miszczak_2008_Sub, + title={Sub-- and super--fidelity as bounds for quantum fidelity}, + author={Miszczak, J. A. and Puchała, Z. and Horodecki, P. and Uhlmann, A. and Życzkowski, K.}, + year={2008}, + eprint={0805.2037}, + archivePrefix={arXiv}, + primaryClass={quant-ph} +} + +@article{Molina_2012_Hedging, + title={Hedging bets with correlated quantum strategies}, + volume={468}, + ISSN={1471-2946}, + url={http://dx.doi.org/10.1098/rspa.2011.0621}, + DOI={10.1098/rspa.2011.0621}, + number={2145}, + journal={Proceedings of the Royal Society A: Mathematical, Physical and Engineering Sciences}, + publisher={The Royal Society}, + author={Molina, Abel and Watrous, John}, + year={2012}, + month={Apr}, pages={2614-2629} } + +@misc{Molina_2012_Optimal, + title={Optimal counterfeiting attacks and generalizations for Wiesner's quantum money}, + author={Molina, Abel and Vidick, Thomas and Watrous, John}, + year={2012}, + eprint={1202.4010}, + archivePrefix={arXiv}, + primaryClass={quant-ph} +} + +#Last name begins with N +@article{Navascues_2008_AConvergent, + title={A convergent hierarchy of semidefinite programs characterizing the set of quantum correlations}, + volume={10}, + ISSN={1367-2630}, + url={http://dx.doi.org/10.1088/1367-2630/10/7/073013}, + DOI={10.1088/1367-2630/10/7/073013}, + number={7}, + journal={New Journal of Physics}, + publisher={IOP Publishing}, + author={Navascués, Miguel and Pironio, Stefano and Acín, Antonio}, + year={2008}, + month={Jul}, pages={073013} } + +@article{Navascues_2008_Pure, + title={Pure State Estimation and the Characterization of Entanglement}, + volume={100}, + ISSN={1079-7114}, + url={http://dx.doi.org/10.1103/PhysRevLett.100.070503}, + DOI={10.1103/physrevlett.100.070503}, + number={7}, + journal={Physical Review Letters}, + publisher={American Physical Society (APS)}, + author={Navascués, Miguel}, + year={2008}, + month={Feb} } + +#Last name begins with O +@misc{Ozols_2009_RandU, + author = "Maris Ozols", + title = "How to generate a random unitary matrix", + year = {2009}, + howpublished = {http://home.lu.lv/~sd20008/papers/essays/Random%20unitary%20[paper].pdf} + +} + +#Last name begins with P +@article{Peres_1996_Separability, + title={Separability Criterion for Density Matrices}, + volume={77}, + ISSN={1079-7114}, + url={http://dx.doi.org/10.1103/PhysRevLett.77.1413}, + DOI={10.1103/physrevlett.77.1413}, + number={8}, + journal={Physical Review Letters}, + publisher={American Physical Society (APS)}, + author={Peres, Asher}, + year={1996}, + month={Aug}, pages={1413-1415} } + +@misc{Philip_2023_Schrodinger, + title={Schr\"odinger as a Quantum Programmer: Estimating Entanglement via Steering}, + author={Philip, Aby and Rethinasamy, Soorya and Russo, Vincent and Wilde, Mark M.}, + year={2023}, + eprint={2303.07911}, + archivePrefix={arXiv}, + primaryClass={quant-ph} +} + +@article{Pusey_2012_On, + title={On the reality of the quantum state}, + volume={8}, + ISSN={1745-2481}, + url={http://dx.doi.org/10.1038/nphys2309}, + DOI={10.1038/nphys2309}, + number={6}, + journal={Nature Physics}, + publisher={Springer Science and Business Media LLC}, + author={Pusey, Matthew F. and Barrett, Jonathan and Rudolph, Terry}, + year={2012}, + month={May}, pages={475-478} } + +#Last name begins with Q +@misc{Quantiki_EOF, + author = "Quantiki", + title = "Entanglement of Formation", + howpublished = {https://www.quantiki.org/wiki/entanglement-formation} + +} + +@misc{Quantiki_TrNorm, + author = "Quantiki", + title = "Trace norm", + howpublished = {https://www.quantiki.org/wiki/trace-norm} + +} + +@misc{Quantiki_TrDist, + author = "Quantiki", + title = "Trace distance", + howpublished = {https://www.quantiki.org/wiki/trace-distance} + +} + +#Last name begins with R +@article{Rana_2017_Log, + title = {Logarithmic coherence: Operational interpretation of ${\ensuremath{\ell}}_{1}$-norm coherence}, + author = {Rana, Swapan and Parashar, Preeti and Winter, Andreas and Lewenstein, Maciej}, + journal = {Phys. Rev. A}, + volume = {96}, + issue = {5}, + pages = {052336}, + numpages = {11}, + year = {2017}, + month = {Nov}, + publisher = {American Physical Society}, + doi = {10.1103/PhysRevA.96.052336}, + url = {https://link.aps.org/doi/10.1103/PhysRevA.96.052336} +} +@article{Werner_1989_QuantumStates, + title = {Quantum states with Einstein-Podolsky-Rosen correlations admitting a hidden-variable model}, + author = {Werner, Reinhard F.}, + journal = {Phys. Rev. A}, + volume = {40}, + issue = {8}, + pages = {4277--4281}, + numpages = {0}, + year = {1989}, + month = {Oct}, + publisher = {American Physical Society}, + doi = {10.1103/PhysRevA.40.4277}, + url = {https://link.aps.org/doi/10.1103/PhysRevA.40.4277} +} + + + +@misc{Rigetti_2022_Forest, + author = "Rigetti", + title = "Forest Benchmarking", + howpublished = {https://github.com/rigetti/forest-benchmarking} + +} + +@misc{Russo_2017_Extended, + title={Extended Nonlocal Games}, + author={Russo, Vincent}, + year={2017}, + eprint={1704.07375}, + archivePrefix={arXiv}, + primaryClass={quant-ph} +} + +#Last name begins with S +@misc{Seshadri_2021_Git, + author = "Seshadri, Akshay", + title = "Minimax Fidelity Estimation", + howpublished = {https://github.com/akshayseshadri/minimax-fidelity-estimation} + +} + +@misc{Seshadri_2021_Theory, + title={Theory of versatile fidelity estimation with confidence}, + author={Seshadri, Akshay and Ringbauer, Martin and Monz, Thomas and Becker, Stephen}, + year={2021}, + eprint={2112.07947}, + archivePrefix={arXiv}, + primaryClass={quant-ph} +} + + +@misc{Seshadri_2021_Versatile, + title={Versatile fidelity estimation with confidence}, + author={Seshadri, Akshay and Ringbauer, Martin and Blatt, Rainer and Monz, Thomas and Becker, Stephen}, + year={2021}, + eprint={2112.07925}, + archivePrefix={arXiv}, + primaryClass={quant-ph} +} + +@misc{SO_43884189, + author = "Stack Overflow Post", + title = "Check if a large matrix is diagonal matrix in python", + howpublished = {https://stackoverflow.com/questions/43884189/} + +} + +@article{Sych_2009_AComplete, +doi = {10.1088/1367-2630/11/1/013006}, +url = {https://dx.doi.org/10.1088/1367-2630/11/1/013006}, +year = {2009}, +month = {Jan}, +publisher = {}, +volume = {11}, +number = {1}, +pages = {013006}, +author = {Sych, Denis and Leuchs, Gerd}, +title = {A complete basis of generalized Bell states}, +journal = {New Journal of Physics}, +} + +#Last name begins with T + +#Last name begins with U + +#Last name begins with V + +#Last name begins with W +@misc{Watrous_2009_Semidefinite, + title={Semidefinite programs for completely bounded norms}, + author={Watrous, John}, + year={2009}, + eprint={0901.4709}, + archivePrefix={arXiv}, + primaryClass={quant-ph} +} + + +@misc{Watrous_2011_Lecture_Notes, + title={Theory of Quantum Information Lecture Notes}, + author={Watrous, John}, + year={2011}, + howpublished = {https://cs.uwaterloo.ca/~watrous/TQI-notes/} +} + + +@misc{Watrous_2012_Simpler, + title={Simpler semidefinite programs for completely bounded norms}, + author={Watrous, John}, + year={2012}, + eprint={1207.5726}, + archivePrefix={arXiv}, + primaryClass={quant-ph} +} + +@article{Wiesner_1983_Conjugate, +author = {Wiesner, Stephen}, +title = {Conjugate Coding}, +year = {1983}, +issue_date = {Winter-Spring 1983}, +publisher = {Association for Computing Machinery}, +address = {New York, NY, USA}, +volume = {15}, +number = {1}, +issn = {0163-5700}, +url = {https://doi.org/10.1145/1008908.1008920}, +doi = {10.1145/1008908.1008920}, +journal = {SIGACT News}, +month = {Jan}, +pages = {78-88}, +numpages = {11} +} + + + +@misc{WikiAsymmOp, + author = "Wikipedia", + title = "Anti-symmetric operator", + howpublished = {https://en.wikipedia.org/wiki/Anti-symmetric_operator} + +} + +@misc{WikiBellSt, + author = "Wikipedia", + title = "Bell State", + howpublished = {https://en.wikipedia.org/wiki/Bell_state} + +} + +@misc{WikiBraKet, + author = "Wikipedia", + title = "Bra-ket notation", + howpublished = {https://en.wikipedia.org/wiki/Bra%E2%80%93ket_notation} + +} + +@misc{WikiBrauer, + author = "Wikipedia", + title = "Brauer Algebra", + howpublished = {https://en.wikipedia.org/wiki/Brauer_algebra} + +} + +@misc{WikiBures, + author = "Wikipedia", + title = "Bures distance", + howpublished = {https://en.wikipedia.org/wiki/Bures_metric#Bures_distance} + +} + +@misc{WikiCirc, + author = "Wikipedia", + title = "Circulant matrix", + howpublished = {https://en.wikipedia.org/wiki/Circulant_matrix} + +} + +@misc{WikiCircLaw, + author = "Wikipedia", + title = "Circular law", + howpublished = {https://en.wikipedia.org/wiki/Circular_law} + +} + +@misc{WikiClock, + author = "Wikipedia", + title = "Generalizations of Pauli matrices", + howpublished = {https://en.wikipedia.org/wiki/Generalizations_of_Pauli_matrices} + +} + +@misc{WikiCNOT, + author = "Wikipedia", + title = "Controlled NOT gate", + howpublished = {https://en.wikipedia.org/wiki/Controlled_NOT_gate} + +} + +@misc{WikiComm, + author = "Wikipedia", + title = "Commuting matrices", + howpublished = {https://en.wikipedia.org/wiki/Commuting_matrices} + +} + +@misc{WikiConcurrence, + author = "Wikipedia", + title = "Concurrence (quantum computing)", + howpublished = {https://en.wikipedia.org/wiki/Concurrence_(quantum_computing)} + +} + +@misc{WikiDen, + author = "Wikipedia", + title = "Density Matrix", + howpublished = {https://en.wikipedia.org/wiki/Density_matrix} + +} + + + +@misc{WikiDepo, + author = "Wikipedia", + title = "Quantum Depolarizing Channel", + howpublished = {https://en.wikipedia.org/wiki/Quantum_depolarizing_channel} + +} + +@misc{WikiDFT, + author = "Wikipedia", + title = "{DFT} matrix", + howpublished = {https://en.wikipedia.org/wiki/DFT_matrix} + +} + +@misc{WikiDiag, + author = "Wikipedia", + title = "Diagonal matrix", + howpublished = {https://en.wikipedia.org/wiki/Diagonal_matrix} + +} + +@misc{WikiDiagDom, + author = "Wikipedia", + title = "Diagonally dominant matrix", + howpublished = {https://en.wikipedia.org/wiki/Diagonally_dominant_matrix} + +} + +@misc{WikiFidQuant, + author = "Wikipedia", + title = "Fidelity of quantum states", + howpublished = {https://en.wikipedia.org/wiki/Fidelity_of_quantum_states} + +} + +@misc{WikiGellMann, + author = "Wikipedia", + title = "Gell-{M}ann matrices", + howpublished = {https://en.wikipedia.org/wiki/Gell-Mann_matrices} + +} + +@misc{WikiGram, + author = "Wikipedia", + title = "Gram Matrix", + howpublished = {https://en.wikipedia.org/wiki/Gram_matrix} + +} + +@misc{WikiHadamard, + author = "Wikipedia", + title = "Hadamard transform", + howpublished = {https://en.wikipedia.org/wiki/Hadamard_transform} + +} + +@misc{WikiHerm, + author = "Wikipedia", + title = "Hermitian matrix", + howpublished = {https://en.wikipedia.org/wiki/Hermitian_matrix} + +} + + +@misc{WikiHilbSchOp, + author = "Wikipedia", + title = "Hilbert-Schmidt operator", + howpublished = {https://en.wikipedia.org/wiki/Hilbert%E2%80%93Schmidt_operator} + +} + + +@misc{WikiHolevo, + author = "Wikipedia", + title = "Holevo\'s Theorem", + howpublished = {https://en.wikipedia.org/wiki/Holevo%27s_theorem} + +} + +@misc{WikiIdemPot, + author = "Wikipedia", + title = "Idempotent matrix", + howpublished = {https://en.wikipedia.org/wiki/Idempotent_matrix} + +} + +@misc{WikiIden, + author = "Wikipedia", + title = "Identity matrix", + howpublished = {https://en.wikipedia.org/wiki/Identity_matrix} + +} + + +@misc{WikiInnerProd, + author = "Wikipedia", + title = "Inner product space", + howpublished = {https://en.wikipedia.org/wiki/Inner_product_space} + +} + +@misc{WikiNeg, + author = "Wikipedia", + title = "Negativity", + howpublished = {https://en.wikipedia.org/wiki/Negativity_(quantum_mechanics)} + +} + +@misc{WikiMajorization, + author = "Wikipedia", + title = "Majorization", + howpublished = {https://en.wikipedia.org/wiki/Majorization} + +} + +@misc{WikiMaxEnt, + author = "Wikipedia", + title = "Quantum entanglement", + howpublished = {https://en.wikipedia.org/wiki/Quantum_entanglement} + +} + +@misc{WikiMixedSt, + author = "Wikipedia", + title = "Quantum State - Mixed States", + howpublished = {https://en.wikipedia.org/wiki/Quantum_state#Mixed_states} + +} + +@misc{WikiMUB, + author = "Wikipedia", + title = "Mutually unbiased bases", + howpublished = {hhttps://en.wikipedia.org/wiki/Mutually_unbiased_bases} + +} + +@misc{WikiNorm, + author = "Wikipedia", + title = "Outer product", + howpublished = {https://en.wikipedia.org/wiki/Normal_matrix} + +} + + +@misc{WikiOrthog, + author = "Wikipedia", + title = "Orthogonality", + howpublished = {https://en.wikipedia.org/wiki/Orthogonality} + +} + +@misc{WikiOuterProd, + author = "Wikipedia", + title = "Normal matrix", + howpublished = {https://en.wikipedia.org/wiki/Outer_product} + +} + +@misc{WikiParPerm, + author = "Wikipedia", + title = "Parity of a permutation", + howpublished = {https://en.wikipedia.org/wiki/Parity_of_a_permutation} + +} + +@misc{WikiPauli, + author = "Wikipedia", + title = "Pauli matrices", + howpublished = {https://en.wikipedia.org/wiki/Pauli_matrices} + +} + +@misc{WikiPauliGen, + author = "Wikipedia", + title = "Generalizations of {P}auli matrices", + howpublished = {https://en.wikipedia.org/wiki/Generalizations_of_Pauli_matrices} + +} + +@misc{WikiPartialTr, + author = "Wikipedia", + title = "Partial Trace", + howpublished = {https://en.wikipedia.org/wiki/Partial_trace} + +} + +@misc{WikiPeresHorodecki, + author = "Wikipedia", + title = "Peres-Horodecki criterion", + howpublished = {https://en.wikipedia.org/wiki/Peres%E2%80%93Horodecki_criterion} + +} + +@misc{WikiPerm, + author = "Wikipedia", + title = "Permutation matrix", + howpublished = {https://en.wikipedia.org/wiki/Permutation_matrix} + +} + +@misc{WikiPosDef, + author = "Wikipedia", + title = "Definite matrix", + howpublished = {https://en.wikipedia.org/wiki/Definite_matrix} + +} + +@misc{WikiPOVM, + author = "Wikipedia", + title = "{POVM}", + howpublished = {https://en.wikipedia.org/wiki/POVM} + +} + + +@misc{WikiProjMat, + author = "Wikipedia", + title = "Projection matrix", + howpublished = {https://en.wikipedia.org/wiki/Projection_matrix} + +} + +@misc{WikiPureSt, + author = "Wikipedia", + title = "Quantum State - Pure States", + howpublished = {https://en.wikipedia.org/wiki/Quantum_state#Pure_states_of_wave_functions} + +} + +@misc{WikiPurity, + author = "Wikipedia", + title = "Purity (quantum mechanics)", + howpublished = {https://en.wikipedia.org/wiki/Purity_(quantum_mechanics)} + +} + +@misc{WikiQuantMeas, + author = "Wikipedia", + title = "Measurement in quantum mechanics", + howpublished = {https://en.wikipedia.org/wiki/Measurement_in_quantum_mechanics} + +} + + +@misc{WikiReductionCrit, + author = "Wikipedia", + title = "Reduction Criterion", + howpublished = {https://en.wikipedia.org/wiki/Reduction_criterion} + +} + +@misc{WikiScmidtDecomp, + author = "Wikipedia", + title = "Schmidt decomposition", + howpublished = {https://en.wikipedia.org/wiki/Schmidt_decomposition} + +} + +@misc{WikiSepSt, + author = "Wikipedia", + title = "Separable state", + howpublished = {https://en.wikipedia.org/wiki/Separable_state} + +} + +@misc{WikiSqMat, + author = "Wikipedia", + title = "Square matrix", + howpublished = {https://en.wikipedia.org/wiki/Square_matrix} + +} + +@misc{WikiSymMat, + author = "Wikipedia", + title = "Symmetric matrix", + howpublished = {https://en.wikipedia.org/wiki/Symmetric_matrix} + +} + +@misc{WikiTensorProd, + author = "Wikipedia", + title = "Tensor product", + howpublished = {https://en.wikipedia.org/wiki/Tensor_product} + +} + +@misc{WikiTotPosMat, + author = "Wikipedia", + title = "Totally positive matrix", + howpublished = {https://en.wikipedia.org/wiki/Totally_positive_matrix} + +} + +@misc{WikiUniMat, + author = "Wikipedia", + title = "Unitary matrix", + howpublished = {https://en.wikipedia.org/wiki/Unitary_matrix} + +} + +@misc{WikiUVonNeumann, + author = "Wikipedia", + title = "Von Neumann entropy", + howpublished = {https://en.wikipedia.org/wiki/Von_Neumann_entropy} + +} +#Last name begins with X + +#Last name begins with Y +@misc{Yard_2017_Lecture11, + author = "Yard, Jon", + title = "Introduction to Quantum Information Processing", + howpublished = {https://www.math.uwaterloo.ca/~jyard/qic710/F17/Qic710Lec11-2017.pdf} + +} + +@article{Yu_2012_Four, + title={Four Locally Indistinguishable Ququad-Ququad Orthogonal Maximally Entangled States}, + volume={109}, + ISSN={1079-7114}, + url={http://dx.doi.org/10.1103/PhysRevLett.109.020506}, + DOI={10.1103/physrevlett.109.020506}, + number={2}, + journal={Physical Review Letters}, + publisher={American Physical Society (APS)}, + author={Yu, Nengkun and Duan, Runyao and Ying, Mingsheng}, + year={2012}, + month={Jul} } + + +#Last name begins with Z \ No newline at end of file diff --git a/docs/books.bib b/docs/books.bib new file mode 100644 index 000000000..207427b59 --- /dev/null +++ b/docs/books.bib @@ -0,0 +1,66 @@ +#File for all book references +# To add a key, Lastname_year_abbreviatedtitle OR firstletteroftitle + +#Last name begins with A + + + + +#Last name begins with B + + +#Last name begins with C + +#Last name begins with D + +#Last name begins with E + +#Last name begins with F + +#Last name begins with G + +#Last name begins with H + +#Last name begins with I + +#Last name begins with J + +#Last name begins with K + +#Last name begins with L + +#Last name begins with M + +#Last name begins with N + +#Last name begins with O + + +#Last name begins with P + +#Last name begins with Q + +#Last name begins with R + +#Last name begins with S + +#Last name begins with T + +#Last name begins with U + +#Last name begins with V + +#Last name begins with W +@book{Watrous_2018_TQI, +place={Cambridge}, +title={The Theory of Quantum Information}, +DOI={10.1017/9781316848142}, +publisher={Cambridge University Press}, +author={Watrous, John}, +year={2018}} + +#Last name begins with X + +#Last name begins with Y + +#Last name begins with Z \ No newline at end of file diff --git a/docs/conf.py b/docs/conf.py index efc0082b9..aae7f5f5e 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -41,8 +41,14 @@ "sphinx.ext.viewcode", "sphinx.ext.githubpages", "sphinx.ext.napoleon", + "sphinxcontrib.bibtex", ] +bibtex_bibfiles = ["books.bib", "articles.bib"] +bibtex_default_style = "unsrt" +suppress_warnings = ["bibtex.duplicate_label", "bibtex.duplicate_citation"] +# we need to skip these warnigns because all the references appear twice, in a function docstring +# and on the references page. master_doc = "index" autosummary_generate = True autodoc_typehints = "none" diff --git a/docs/index.rst b/docs/index.rst index 0e1f9bc5f..4ffed2fdd 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -57,7 +57,7 @@ User Documentation :maxdepth: 2 :caption: Random Objects - random + rand .. toctree:: :maxdepth: 2 @@ -71,3 +71,12 @@ User Documentation :caption: Tutorials tutorials + + +References +------------------ + +.. toctree:: + :maxdepth: 2 + + references diff --git a/docs/references.rst b/docs/references.rst new file mode 100644 index 000000000..7c0faa759 --- /dev/null +++ b/docs/references.rst @@ -0,0 +1,11 @@ +References +========== +.. rubric:: Articles +.. bibliography:: articles.bib + :all: + :list: enumerated + +.. rubric:: Books +.. bibliography:: books.bib + :all: + :list: enumerated \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml index f28a76684..5ae24d0c3 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -61,8 +61,10 @@ coverage = "^5.5" mypy = "^1.3.0" coveralls = "^1.9" setuptools = ">65.5.1" -sphinx = "6.2.1" -sphinx_rtd_theme = "*" +sphinx = "7.2.6" +sphinx_rtd_theme = "2.0.0rc4" # this version is temporary due to docutils version incompatibility with +# sphinx, sphinx_rtd_theme and sphinxcontrib-bibtex +sphinxcontrib-bibtex = "2.6.1" sympy = "==1.12" diff --git a/setup.py b/setup.py index 2c5039dcb..c24d5210b 100644 --- a/setup.py +++ b/setup.py @@ -3,7 +3,17 @@ with open("README.md", "r") as fh: long_description = fh.read() -requirements = ["cvx", "cvxpy", "cvxopt", "numpy", "picos", "scipy", "scikit-image", "pytest", "pytest-cov"] +requirements = [ + "cvx", + "cvxpy", + "cvxopt", + "numpy", + "picos", + "scipy", + "scikit-image", + "pytest", + "pytest-cov", +] setuptools.setup( name="toqito", diff --git a/toqito/channel_metrics/channel_fidelity.py b/toqito/channel_metrics/channel_fidelity.py index d61f52ce6..0bb554fd1 100644 --- a/toqito/channel_metrics/channel_fidelity.py +++ b/toqito/channel_metrics/channel_fidelity.py @@ -7,7 +7,7 @@ def channel_fidelity(choi_1: np.ndarray, choi_2: np.ndarray) -> float: r""" - Compute the channel fidelity between two quantum channels [VW20]_. + Compute the channel fidelity between two quantum channels :cite:`Katariya_2021_Geometric`. Let :math:`\Phi : \text{L}(\mathcal{Y}) \rightarrow \text{L}(\mathcal{X})` and :math:`\Psi: \text{L}(\mathcal{Y}) \rightarrow \text{L}(\mathcal{X})` be quantum channels. Then @@ -17,7 +17,7 @@ def channel_fidelity(choi_1: np.ndarray, choi_2: np.ndarray) -> float: \sqrt{F}(\Phi, \Psi) := \text{inf}_{\rho} \sqrt{F}(\Phi(\rho), \Psi(\rho)) where :math:`\rho \in \text{D}(\mathcal{Z} \otimes \mathcal{X})` can be calculated by means of - the following semidefinite program (Proposition 50) in [VW20]_, + the following semidefinite program (Proposition 50) in :cite:`Katariya_2021_Geometric`, .. math:: \begin{align*} @@ -59,11 +59,11 @@ def channel_fidelity(choi_1: np.ndarray, choi_2: np.ndarray) -> float: >>> channel_fidelity(choi_1, choi_2) 0.5001368672503087 + References ========== - .. [VW20] Katariya, Vishal, and Mark M. Wilde. - "Geometric distinguishability measures limit quantum channel estimation and discrimination." - https://arxiv.org/abs/2004.10708 + .. bibliography:: + :filter: docname in docnames :raises ValueError: If matrices are not of equal dimension. :raises ValueError: If matrices are not square. diff --git a/toqito/channel_metrics/completely_bounded_spectral_norm.py b/toqito/channel_metrics/completely_bounded_spectral_norm.py index 653de2aba..faf2a1469 100644 --- a/toqito/channel_metrics/completely_bounded_spectral_norm.py +++ b/toqito/channel_metrics/completely_bounded_spectral_norm.py @@ -6,20 +6,14 @@ def completely_bounded_spectral_norm(phi: np.ndarray) -> float: - r""" - Compute the completely bounded spectral norm of a quantum channel. + r"""Compute the completely bounded spectral norm of a quantum channel. + + :cite:`Watrous_2009_Semidefinite, QETLAB_link`. References ========== - .. [WatSDP09]: Watrous, John. - "Semidefinite Programs for Completely Bounded Norms" - Theory of Computing, 2009 - http://theoryofcomputing.org/articles/v005a011/v005a011.pdf - - .. [NJ]: Nathaniel Johnston. QETLAB: - A MATLAB toolbox for quantum entanglement, version 0.9. - https://github.com/nathanieljohnston/QETLAB/blob/master/CBNorm.m - http://www.qetlab.com, January 12, 2016. doi:10.5281/zenodo.44637 + .. bibliography:: + :filter: docname in docnames :param phi: superoperator :return: The completely bounded spectral norm of the channel diff --git a/toqito/channel_metrics/completely_bounded_trace_norm.py b/toqito/channel_metrics/completely_bounded_trace_norm.py index c583a832d..eab155d63 100644 --- a/toqito/channel_metrics/completely_bounded_trace_norm.py +++ b/toqito/channel_metrics/completely_bounded_trace_norm.py @@ -12,23 +12,15 @@ def completely_bounded_trace_norm(phi: np.ndarray) -> float: Find the completely bounded trace norm of a quantum channel. Also known as the completely bounded diamond norm of a quantum - channel [WatCNorm18]_. The algorithm in p.11 of [WatSDP09] with - implementation in QETLAB [JohQET] is used. + channel (Section 3.3.2 of :cite:`Watrous_2018_TQI`). The algorithm in p.11 of :cite:`Watrous_2012_Simpler` with + implementation in QETLAB :cite:`QETLAB_link` is used. + References ========== - .. [WatCNorm18] : Watrous, John. - “The theory of quantum information.” Section 3.3.2: “The completely bounded trace norm”. - Cambridge University Press, 2018. - - .. [WatSDP09]: Watrous, John. - "Simpler semidefinite programs for completely bounded norms" - https://arxiv.org/pdf/1207.5726.pdf - - .. [JohQET]: Nathaniel Johnston. QETLAB: - A MATLAB toolbox for quantum entanglement, version 0.9. - https://github.com/nathanieljohnston/QETLAB/blob/master/DiamondNorm.m - http://www.qetlab.com, January 12, 2016. doi:10.5281/zenodo.44637 + .. bibliography:: + :filter: docname in docnames + :raises ValueError: If matrix is not square. :param phi: superoperator as choi matrix diff --git a/toqito/channel_metrics/diamond_norm.py b/toqito/channel_metrics/diamond_norm.py index 034d27b55..189f39b86 100644 --- a/toqito/channel_metrics/diamond_norm.py +++ b/toqito/channel_metrics/diamond_norm.py @@ -7,13 +7,15 @@ def diamond_norm(choi_1: np.ndarray, choi_2: np.ndarray) -> float: r""" Return the diamond norm distance between two quantum channels. - The calculation uses the simplified semidefinite program of Watrous in [CBN]_. + The calculation uses the simplified semidefinite program of Watrous in + :cite:`Watrous_2009_Semidefinite`. - This function has been adapted from: https://github.com/rigetti/forest-benchmarking + This function has been adapted from :cite:`Rigetti_2022_Forest` .. note:: This calculation becomes very slow for 4 or more qubits. + Examples ======== Consider the depolarizing and identity channels in a 2-dimensional space. The depolarizing channel parameter is set to 0.2: @@ -33,15 +35,12 @@ def diamond_norm(choi_1: np.ndarray, choi_2: np.ndarray) -> float: >>> dn = diamond_norm(choi_dephasing, choi_identity) >>> print("Diamond norm between dephasing and identity channels: ", dn) Diamond norm between depolarizing and identity channels: 0.3000024376929641 - + References ========== + .. bibliography:: + :filter: docname in docnames - .. [CBN] Semidefinite programs for completely bounded norms. - J. Watrous. - Theory of Computing 5, 11, pp. 217-238 (2009). - http://theoryofcomputing.org/articles/v005a011 - http://arxiv.org/abs/0901.4709 :raises ValueError: If matrices are not of equal dimension. :raises ValueError: If matrices are not square. diff --git a/toqito/channel_metrics/fidelity_of_separability.py b/toqito/channel_metrics/fidelity_of_separability.py index 33660ed7b..174c70fee 100644 --- a/toqito/channel_metrics/fidelity_of_separability.py +++ b/toqito/channel_metrics/fidelity_of_separability.py @@ -21,12 +21,12 @@ def fidelity_of_separability( solver_option: str = "cvxopt", ) -> float: r""" - Define the first benchmark introduced in Appendix I of [Phil23.1]_ . + Define the first benchmark introduced in Appendix I of :cite:`Philip_2023_Schrodinger` . If you would like to instead use the benchmark introduced in Appendix H, go to :obj:`toqito.state_metrics.fidelity_of_separability`. - In [Phil23.1]_ a variational quantum algorithm (VQA) is introduced to test + In :cite:`Philip_2023_Schrodinger` a variational quantum algorithm (VQA) is introduced to test the separability of a general bipartite state. The algorithm utilizes quantum steering between two separated systems such that the separability of the state is quantified. @@ -35,13 +35,13 @@ def fidelity_of_separability( optimization semidefinite programs (SDP) benchmarks were introduced to maximize the fidelity of separability subject to some state constraints (Positive Partial Transpose (PPT), symmetric extensions (k-extendibility - ) [Hay12.1]_ ). Entangled states do not have k-symmetric extensions. If an + ) :cite:`Hayden_2013_TwoMessage` ). Entangled states do not have k-symmetric extensions. If an extension exists, it cannot be assumed directly that the state is separable. This function approximites the fidelity of separability by maximizing over PPT channels & k-extendible entanglement breaking channels - i.e. an optimization problem over channels [TBWat18.1]_ . + i.e. an optimization problem over channels :cite:`Watrous_2018_TQI` . - The following expression (Equation (I4) from [Phil23.1]_ ) defines the + The following expression (Equation (I4) from :cite:`Philip_2023_Schrodinger` ) defines the constraints for approximating :math:`\frac{1}{2}(1+\widetilde{F}_s^2(\rho_{AB})) {:}=` @@ -72,7 +72,7 @@ def fidelity_of_separability( :math:`\mathcal{P}_{A^{\prime k}}` is the permutation operator over k-extensions :math:`A^{\prime k}`. - The other constraints are due to the PPT condition [Per96.1]_. + The other constraints are due to the PPT condition :cite:`Peres_1996_Separability`. Examples ========== @@ -100,24 +100,10 @@ def fidelity_of_separability( References ========== - .. [Hay12.1] Hayden, Patrick et.al. - "Two-message quantum interactive proofs and the quantum separability problem." - Proceedings of the 28th IEEE Conference on Computational Complexity, pages 156-167. - https://arxiv.org/abs/1211.6120 - - .. [Per96.1] Peres, Asher. - "Separability Criterion for Density Matrices" - https://arxiv.org/abs/quant-ph/9604005 - - .. [Phil23.1] Philip, Aby et.al. - "Quantum Steering Algorithm for Estimating Fidelity of Separability" - https://arxiv.org/abs/2303.07911 - - .. [TBWat18.1] Watrous, John. - “The Theory of Quantum Information” - Cambridge University Press, 2018 - + .. bibliography:: + :filter: docname in docnames + :param psi: the density matrix for the tripartite state of interest psi_{BAR} :param psi_dims: the dimensions of System A, B, & R in the input state density matrix. It is assumed that the first @@ -157,7 +143,7 @@ def fidelity_of_separability( # List of extenstion systems and dimension of the Choi matrix. sys_ext = list(range(2, 2 + k - 1)) - dim_choi = dim_r * (dim_a**k) + dim_choi = dim_r * (dim_a ** k) # Projection onto symmetric subspace on AA'. pi_sym = symmetric_projection(dim_a, 2) diff --git a/toqito/channel_ops/apply_channel.py b/toqito/channel_ops/apply_channel.py index 967cf7080..cd2ed7edb 100644 --- a/toqito/channel_ops/apply_channel.py +++ b/toqito/channel_ops/apply_channel.py @@ -10,8 +10,9 @@ def apply_channel(mat: np.ndarray, phi_op: np.ndarray | list[list[np.ndarray]]) -> np.ndarray: - r""" - Apply a quantum channel to an operator [WatAChan18]_. + r"""Apply a quantum channel to an operator. + + (Section: Representations and Characterizations of Channels of :cite:`Watrous_2018_TQI`). Specifically, an application of the channel is defined as @@ -85,10 +86,9 @@ def apply_channel(mat: np.ndarray, phi_op: np.ndarray | list[list[np.ndarray]]) References ========== - .. [WatAChan18] Watrous, John. - The theory of quantum information. - Section: Representations and characterizations of channels. - Cambridge University Press, 2018. + .. bibliography:: + :filter: docname in docnames + :raises ValueError: If matrix is not Choi matrix. :param mat: A matrix. diff --git a/toqito/channel_ops/choi_to_kraus.py b/toqito/channel_ops/choi_to_kraus.py index 228436d88..c88bcb6f4 100644 --- a/toqito/channel_ops/choi_to_kraus.py +++ b/toqito/channel_ops/choi_to_kraus.py @@ -12,7 +12,7 @@ def choi_to_kraus( choi_mat: np.ndarray, tol: float = 1e-9, dim: int | list[int] | np.ndarray = None ) -> list[np.ndarray] | list[list[np.ndarray]]: r""" - Compute a list of Kraus operators from the Choi matrix [Rigetti20]_. + Compute a list of Kraus operators from the Choi matrix from :cite:`Rigetti_2022_Forest`. Note that unlike the Choi or natural representation of operators, the Kraus representation is *not* unique. @@ -24,7 +24,7 @@ def choi_to_kraus( For completely positive maps the output is a single flat list of numpy arrays since the left and right Kraus maps are the same. - This function has been adapted from [Rigetti20]_ and QETLAB package. + This function has been adapted from :cite:`Rigetti_2022_Forest` and QETLAB :cite:`QETLAB_link`. Examples ======== @@ -88,8 +88,10 @@ def choi_to_kraus( References ========== - .. [Rigetti20] Forest Benchmarking (Rigetti). - https://github.com/rigetti/forest-benchmarking + .. bibliography:: + :filter: docname in docnames + + :param choi_mat: A Choi matrix :param tol: optional threshold parameter for eigenvalues/kraus ops to be discarded diff --git a/toqito/channel_ops/dual_channel.py b/toqito/channel_ops/dual_channel.py index c645c5cbc..28f8f2418 100644 --- a/toqito/channel_ops/dual_channel.py +++ b/toqito/channel_ops/dual_channel.py @@ -10,8 +10,9 @@ def dual_channel( phi_op: np.ndarray | list[np.ndarray] | list[list[np.ndarray]], dims: list[int] = None ) -> np.ndarray | list[list[np.ndarray]]: - r""" - Compute the dual of a map (quantum channel) [WatDChan18]_. + r"""Compute the dual of a map (quantum channel). + + (Section: Representations and Characterizations of Channels of :cite:`Watrous_2018_TQI`). The map can be represented as a Choi matrix, with optional specification of input and output dimensions. If the input channel maps :math:`M_{r,c}` to :math:`M_{x,y}` @@ -36,10 +37,9 @@ def dual_channel( References ========== - .. [WatDChan18] Watrous, John. - The theory of quantum information. - Section: Representations and characterizations of channels. - Cambridge University Press, 2018. + .. bibliography:: + :filter: docname in docnames + :raises ValueError: If matrices are not Choi matrix. :param phi_op: A superoperator. It should be provided either as a Choi matrix, diff --git a/toqito/channel_ops/kraus_to_choi.py b/toqito/channel_ops/kraus_to_choi.py index 5bb04a66b..3d16c879f 100644 --- a/toqito/channel_ops/kraus_to_choi.py +++ b/toqito/channel_ops/kraus_to_choi.py @@ -7,8 +7,9 @@ def kraus_to_choi(kraus_ops: list[list[np.ndarray]], sys: int = 2) -> np.ndarray: - r""" - Compute the Choi matrix of a list of Kraus operators [WatKraus18]_. + r"""Compute the Choi matrix of a list of Kraus operators. + + (Section: Kraus Representations of :cite:`Watrous_2018_TQI`). The Choi matrix of the list of Kraus operators, :code:`kraus_ops`. The default convention is that the Choi matrix is the result of applying the map to the second subsystem of the @@ -53,10 +54,9 @@ def kraus_to_choi(kraus_ops: list[list[np.ndarray]], sys: int = 2) -> np.ndarray References ========== - .. [WatKraus18] Watrous, John. - "The theory of quantum information." - Section: "Kraus representations". - Cambridge University Press, 2018. + .. bibliography:: + :filter: docname in docnames + :param kraus_ops: A list of Kraus operators. :param sys: The dimension of the system (default is 2). diff --git a/toqito/channel_ops/partial_channel.py b/toqito/channel_ops/partial_channel.py index 8abd25abc..23fb77b2d 100644 --- a/toqito/channel_ops/partial_channel.py +++ b/toqito/channel_ops/partial_channel.py @@ -16,7 +16,7 @@ def partial_channel( sys: int = 2, dim: list[int] | np.ndarray = None, ) -> np.ndarray: - r"""Apply channel to a subsystem of an operator [WatPMap18]_. + r"""Apply channel to a subsystem of an operator :cite:`Watrous_2018_TQI`. Applies the operator @@ -65,9 +65,9 @@ def partial_channel( References ========== - .. [WatPMap18] Watrous, John. - The theory of quantum information. - Cambridge University Press, 2018. + .. bibliography:: + :filter: docname in docnames + :raises ValueError: If Phi map is not provided as a Choi matrix or Kraus operators. diff --git a/toqito/channel_props/choi_rank.py b/toqito/channel_props/choi_rank.py index 58587205b..3ad14d5db 100644 --- a/toqito/channel_props/choi_rank.py +++ b/toqito/channel_props/choi_rank.py @@ -7,8 +7,9 @@ def choi_rank(phi: np.ndarray | list[list[np.ndarray]]) -> int: - r""" - Calculate the rank of the Choi representation of a quantum channel [WatChoiRank18]_. + r"""Calculate the rank of the Choi representation of a quantum channel. + + (Section 2.2: Quantum Channels from :cite:`Watrous_2018_TQI`). Examples ========== @@ -73,11 +74,8 @@ def choi_rank(phi: np.ndarray | list[list[np.ndarray]]) -> int: References ========== - - .. [WatChoiRank18] Watrous, John. - "The Theory of Quantum Information." - Section: "2.2 Quantum Channels". - Cambridge University Press, 2018. + .. bibliography:: + :filter: docname in docnames :raises ValueError: If matrix is not Choi. :param phi: Either a Choi matrix or a list of Kraus operators diff --git a/toqito/channel_props/is_completely_positive.py b/toqito/channel_props/is_completely_positive.py index aa4899b1d..0f045573d 100644 --- a/toqito/channel_props/is_completely_positive.py +++ b/toqito/channel_props/is_completely_positive.py @@ -13,8 +13,9 @@ def is_completely_positive( rtol: float = 1e-05, atol: float = 1e-08, ) -> bool: - r""" - Determine whether the given channel is completely positive [WatCP18]_. + r"""Determine whether the given channel is completely positive. + + (Section: Linear Maps Of Square Operators from :cite:`Watrous_2018_TQI`). A map :math:`\Phi \in \text{T} \left(\mathcal{X}, \mathcal{Y} \right)` is *completely positive* if it holds that @@ -75,10 +76,9 @@ def is_completely_positive( References ========== - .. [WatCP18] Watrous, John. - "The Theory of Quantum Information." - Section: "Linear maps of square operators". - Cambridge University Press, 2018. + .. bibliography:: + :filter: docname in docnames + :param phi: The channel provided as either a Choi matrix or a list of Kraus operators. :param rtol: The relative tolerance parameter (default 1e-05). diff --git a/toqito/channel_props/is_herm_preserving.py b/toqito/channel_props/is_herm_preserving.py index 7ce9e06be..84a3916fc 100644 --- a/toqito/channel_props/is_herm_preserving.py +++ b/toqito/channel_props/is_herm_preserving.py @@ -12,8 +12,9 @@ def is_herm_preserving( rtol: float = 1e-05, atol: float = 1e-08, ) -> bool: - r""" - Determine whether the given channel is Hermitian-preserving [WatH18]_. + r"""Determine whether the given channel is Hermitian-preserving. + + (Section: Linear Maps Of Square Operators from :cite:`Watrous_2018_TQI`). A map :math:`\Phi \in \text{T} \left(\mathcal{X}, \mathcal{Y} \right)` is *Hermitian-preserving* if it holds that @@ -61,10 +62,9 @@ def is_herm_preserving( References ========== - .. [WatH18] Watrous, John. - "The theory of quantum information." - Section: "Linear maps of square operators". - Cambridge University Press, 2018. + .. bibliography:: + :filter: docname in docnames + :param phi: The channel provided as either a Choi matrix or a list of Kraus operators. :param rtol: The relative tolerance parameter (default 1e-05). diff --git a/toqito/channel_props/is_positive.py b/toqito/channel_props/is_positive.py index 495737a5e..94989282a 100644 --- a/toqito/channel_props/is_positive.py +++ b/toqito/channel_props/is_positive.py @@ -12,8 +12,9 @@ def is_positive( rtol: float = 1e-05, atol: float = 1e-08, ) -> bool: - r""" - Determine whether the given channel is positive [WatPM18]_. + r"""Determine whether the given channel is positive. + + (Section: Linear Maps Of Square Operators from :cite:`Watrous_2018_TQI`). A map :math:`\Phi \in \text{T} \left(\mathcal{X}, \mathcal{Y} \right)` is *positive* if it holds that @@ -63,10 +64,9 @@ def is_positive( References ========== - .. [WatPM18] Watrous, John. - "The theory of quantum information." - Section: "Linear maps of square operators". - Cambridge University Press, 2018. + .. bibliography:: + :filter: docname in docnames + :param phi: The channel provided as either a Choi matrix or a list of Kraus operators. :param rtol: The relative tolerance parameter (default 1e-05). diff --git a/toqito/channel_props/is_quantum_channel.py b/toqito/channel_props/is_quantum_channel.py index dc4a487ab..76b85da84 100644 --- a/toqito/channel_props/is_quantum_channel.py +++ b/toqito/channel_props/is_quantum_channel.py @@ -12,8 +12,10 @@ def is_quantum_channel( rtol: float = 1e-05, atol: float = 1e-08, ) -> bool: - r""" - Determine whether the given input is a quantum channel [WatQC18]_. + r"""Determine whether the given input is a quantum channel. + + (Section 2.2.1: Definitions and Basic Notions Concerning Channels from + :cite:`Watrous_2018_TQI`). A map :math:`\Phi \in \text{T} \left(\mathcal{X}, \mathcal{Y} \right)` is a *quantum channel* for some choice of complex Euclidean spaces :math:`\mathcal{X}` @@ -40,10 +42,9 @@ def is_quantum_channel( References ========== - .. [WatQC18] Watrous, John. - "The Theory of Quantum Information." - Section: "2.2.1 Definitions and basic notions concerning channels". - Cambridge University Press, 2018. + .. bibliography:: + :filter: docname in docnames + :param phi: The channel provided as either a Choi matrix or a list of Kraus operators. :param rtol: The relative tolerance parameter (default 1e-05). diff --git a/toqito/channel_props/is_trace_preserving.py b/toqito/channel_props/is_trace_preserving.py index 1c0d1700c..c31202f52 100644 --- a/toqito/channel_props/is_trace_preserving.py +++ b/toqito/channel_props/is_trace_preserving.py @@ -16,7 +16,8 @@ def is_trace_preserving( dim: list[int] | np.ndarray = None, ) -> bool: r""" - Determine whether the given channel is trace-preserving [WatTP18]_. + Determine whether the given channel is trace-preserving (Section: Linear Maps Of Square Operators from + :cite:`Watrous_2018_TQI`). A map :math:`\Phi \in \text{T} \left(\mathcal{X}, \mathcal{Y} \right)` is *trace-preserving* if it holds that @@ -77,10 +78,9 @@ def is_trace_preserving( References ========== - .. [WatTP18] Watrous, John. - "The theory of quantum information." - Section: "Linear maps of square operators". - Cambridge University Press, 2018. + .. bibliography:: + :filter: docname in docnames + :param phi: The channel provided as either a Choi matrix or a list of Kraus operators. :param rtol: The relative tolerance parameter (default 1e-05). diff --git a/toqito/channel_props/is_unital.py b/toqito/channel_props/is_unital.py index 3185dcea6..74a26a70a 100644 --- a/toqito/channel_props/is_unital.py +++ b/toqito/channel_props/is_unital.py @@ -15,7 +15,8 @@ def is_unital( dim: int | list[int] | np.ndarray = None, ) -> bool: r""" - Determine whether the given channel is unital [WatUnital18]_. + Determine whether the given channel is unital (Chapter: Unital Channels And Majorization from + :cite:`Watrous_2018_TQI`). A map :math:`\Phi \in \text{T} \left(\mathcal{X}, \mathcal{Y} \right)` is *unital* if it holds that @@ -52,10 +53,9 @@ def is_unital( References ========== - .. [WatUnital18] Watrous, John. - "The theory of quantum information." - Chapter: Unital channels and majorization - Cambridge University Press, 2018. + .. bibliography:: + :filter: docname in docnames + :param phi: The channel provided as either a Choi matrix or a list of Kraus operators. :param rtol: The relative tolerance parameter (default 1e-05). diff --git a/toqito/channel_props/is_unitary.py b/toqito/channel_props/is_unitary.py index 91ab2cad3..c2938d903 100644 --- a/toqito/channel_props/is_unitary.py +++ b/toqito/channel_props/is_unitary.py @@ -8,8 +8,10 @@ def is_unitary(phi: np.ndarray | list[list[np.ndarray]]) -> bool: - r""" - Given a quantum channel, determine if it is unitary [WatIU18]_. + r"""Given a quantum channel, determine if it is unitary. + + (Section 2.2.1: Definitions and Basic Notions Concerning Channels from + :cite:`Watrous_2018_TQI`). Let :math:`\mathcal{X}` be a complex Euclidean space an let :math:`U \in U(\mathcal{X})` be a unitary operator. Then a unitary channel is defined as: @@ -58,10 +60,9 @@ def is_unitary(phi: np.ndarray | list[list[np.ndarray]]) -> bool: References ========== - .. [WatIU18] Watrous, John. - "The Theory of Quantum Information." - Section: "2.2.1 Definitions and basic notions concerning channels". - Cambridge University Press, 2018. + .. bibliography:: + :filter: docname in docnames + :param phi: The channel provided as either a Choi matrix or a list of Kraus operators. :return: :code:`True` if the channel is a unitary channel, and :code:`False` otherwise. diff --git a/toqito/channels/choi.py b/toqito/channels/choi.py index 007368a6b..430a92560 100644 --- a/toqito/channels/choi.py +++ b/toqito/channels/choi.py @@ -6,13 +6,13 @@ def choi(a_var: int = 1, b_var: int = 1, c_var: int = 0) -> np.ndarray: r""" - Produce the Choi channel or one of its generalizations [Choi92]_. + Produce the Choi channel or one of its generalizations :cite:`Choi_1992_Generalized`. The *Choi channel* is a positive map on 3-by-3 matrices that is capable of detecting some entanglement that the transpose map is not. The standard Choi channel defined with :code:`a=1`, :code:`b=1`, and :code:`c=0` is the Choi - matrix of the positive map defined in [Choi92]_. Many of these maps are capable of detecting + matrix of the positive map defined in :cite:`Choi_1992_Generalized`. Many of these maps are capable of detecting PPT entanglement. Examples @@ -92,10 +92,9 @@ def choi(a_var: int = 1, b_var: int = 1, c_var: int = 0) -> np.ndarray: References ========== - .. [Choi92] Cho, Sung Je, Seung-Hyeok Kye, and Sa Ge Lee. - "Generalized Choi maps in three-dimensional matrix algebra." - Linear algebra and its applications 171 (1992): 213-224. - https://www.sciencedirect.com/science/article/pii/002437959290260H + .. bibliography:: + :filter: docname in docnames + :param a_var: Default integer for standard Choi map. :param b_var: Default integer for standard Choi map. diff --git a/toqito/channels/dephasing.py b/toqito/channels/dephasing.py index ec173aafa..b076d5de7 100644 --- a/toqito/channels/dephasing.py +++ b/toqito/channels/dephasing.py @@ -5,8 +5,9 @@ def dephasing(dim: int, param_p: float = 0) -> np.ndarray: - r""" - Produce the partially dephasing channel [WatDeph18]_. + r"""Produce the partially dephasing channel. + + (Section: The Completely Dephasing Channel from :cite:`Watrous_2018_TQI`). The Choi matrix of the completely dephasing channel that acts on :code:`dim`-by-:code:`dim` matrices. @@ -73,10 +74,9 @@ def dephasing(dim: int, param_p: float = 0) -> np.ndarray: References ========== - .. [WatDeph18] Watrous, John. - "The theory of quantum information." - Section: "The completely dephasing channel". - Cambridge University Press, 2018. + .. bibliography:: + :filter: docname in docnames + :param dim: The dimensionality on which the channel acts. :param param_p: Default is 0. diff --git a/toqito/channels/depolarizing.py b/toqito/channels/depolarizing.py index 7b56703f7..8f3a43181 100644 --- a/toqito/channels/depolarizing.py +++ b/toqito/channels/depolarizing.py @@ -5,10 +5,12 @@ def depolarizing(dim: int, param_p: float = 0) -> np.ndarray: - r""" - Produce the partially depolarizing channel [WikDepo]_, [WatDepo18]_. + r"""Produce the partially depolarizing channel. + + (Section: Replacement Channels and the Completely Depolarizing Channel from + :cite:`Watrous_2018_TQI`). - The Choi matrix of the completely depolarizing channel that acts on + The Choi matrix of the completely depolarizing channel :cite:`WikiDepo` that acts on :code:`dim`-by-:code:`dim` matrices. The *completely depolarizing channel* is defined as @@ -77,14 +79,11 @@ def depolarizing(dim: int, param_p: float = 0) -> np.ndarray: References ========== - .. [WikDepo] Wikipedia: Quantum depolarizing channel - https://en.wikipedia.org/wiki/Quantum_depolarizing_channel - - .. [WatDepo18] Watrous, John. - "The theory of quantum information." - Section: "Replacement channels and the completely depolarizing channel". - Cambridge University Press, 2018. + .. bibliography:: + :filter: docname in docnames + + :param dim: The dimensionality on which the channel acts. :param param_p: Default 0. :return: The Choi matrix of the completely depolarizing channel. @@ -93,4 +92,4 @@ def depolarizing(dim: int, param_p: float = 0) -> np.ndarray: # Gives a sparse non-normalized state. psi = max_entangled(dim=dim, is_sparse=False, is_normalized=False) - return (1 - param_p) * np.identity(dim**2) / dim + param_p * (psi * psi.conj().T) + return (1 - param_p) * np.identity(dim ** 2) / dim + param_p * (psi * psi.conj().T) diff --git a/toqito/channels/partial_trace.py b/toqito/channels/partial_trace.py index 162b84ceb..f7b5863fa 100644 --- a/toqito/channels/partial_trace.py +++ b/toqito/channels/partial_trace.py @@ -16,7 +16,7 @@ def partial_trace( dim: int | list[int] = None, ) -> np.ndarray | Expression: r""" - Compute the partial trace of a matrix [WikPtrace]_. + Compute the partial trace of a matrix :cite:`WikiPartialTr`. The *partial trace* is defined as @@ -120,8 +120,9 @@ def partial_trace( References ========== - .. [WikPtrace] Wikipedia: Partial trace - https://en.wikipedia.org/wiki/Partial_trace + .. bibliography:: + :filter: docname in docnames + :raises ValueError: If matrix dimension is not equal to the number of subsystems. :param input_mat: A square matrix. diff --git a/toqito/channels/partial_transpose.py b/toqito/channels/partial_transpose.py index 6eded4be5..d4b4791fc 100644 --- a/toqito/channels/partial_transpose.py +++ b/toqito/channels/partial_transpose.py @@ -15,7 +15,7 @@ def partial_transpose( sys: list[int] | np.ndarray | int = None, dim: list[int] | np.ndarray = None, ) -> np.ndarray | Expression: - r"""Compute the partial transpose of a matrix [WikPtrans]_. + r"""Compute the partial transpose of a matrix :cite:`WikiPeresHorodecki`. The *partial transpose* is defined as @@ -104,8 +104,10 @@ def partial_transpose( References ========== - .. [WikPtrans] Wikipedia: Partial transpose - https://en.wikipedia.org/w/index.php?title=Partial_transpose + .. bibliography:: + :filter: docname in docnames + + :param rho: A matrix. :param sys: Scalar or vector specifying the size of the subsystems. :param dim: Dimension of the subsystems. If :code:`None`, all dimensions diff --git a/toqito/channels/realignment.py b/toqito/channels/realignment.py index be8f9d71a..00ae797ae 100644 --- a/toqito/channels/realignment.py +++ b/toqito/channels/realignment.py @@ -9,7 +9,7 @@ def realignment(input_mat: np.ndarray, dim: int | list[int] = None) -> np.ndarray: r""" - Compute the realignment of a bipartite operator [LAS08]_. + Compute the realignment of a bipartite operator :cite:`Lupo_2008_Bipartite`. Gives the realignment of the matrix :code:`input_mat`, where it is assumed that the number of rows and columns of :code:`input_mat` are both perfect squares and both subsystems have @@ -43,11 +43,9 @@ def realignment(input_mat: np.ndarray, dim: int | list[int] = None) -> np.ndarra References ========== - .. [LAS08] Lupo, Cosmo, Paolo, Aniello, and Scardicchio, Antonello. - "Bipartite quantum systems: on the realignment criterion and beyond." - Journal of Physics A: Mathematical and Theoretical - 41.41 (2008): 415301. - https://arxiv.org/abs/0802.2019 + .. bibliography:: + :filter: docname in docnames + :param input_mat: The input matrix. :param dim: Default has all equal dimensions. diff --git a/toqito/channels/reduction.py b/toqito/channels/reduction.py index 2a884cc06..dc2a1bc96 100644 --- a/toqito/channels/reduction.py +++ b/toqito/channels/reduction.py @@ -8,7 +8,7 @@ def reduction(dim: int, k: int = 1) -> np.ndarray: r""" - Produce the reduction map or reduction channel. + Produce the reduction map or reduction channel :cite:`WikiReductionCrit`. If :code:`k = 1`, this returns the Choi matrix of the reduction map which is a positive map on :code:`dim`-by-:code:`dim` matrices. For a different value of :code:`k`, this yields the @@ -37,10 +37,16 @@ def reduction(dim: int, k: int = 1) -> np.ndarray: [ 0., 0., 0., 0., 0., 0., 0., 1., 0.], [-1., 0., 0., 0., -1., 0., 0., 0., 0.]]) + + References + ========== + .. bibliography:: + :filter: docname in docnames + :param dim: A positive integer (the dimension of the reduction map). :param k: If this positive integer is provided, the script will instead return the Choi matrix of the following linear map: Phi(X) := K * Tr(X)I - X. :return: The reduction map. """ psi = max_entangled(dim, False, False) - return k * identity(dim**2) - psi * psi.conj().T + return k * identity(dim ** 2) - psi @ psi.conj().T diff --git a/toqito/helper/channel_dim.py b/toqito/helper/channel_dim.py index 70593ea3c..11ec3b29e 100644 --- a/toqito/helper/channel_dim.py +++ b/toqito/helper/channel_dim.py @@ -31,7 +31,12 @@ def channel_dim( instead of vectors. If COMPUTE_ENV_DIM is false and the PHI is a Choi matrix we avoid computing the rank of the Choi matrix. - This functions was adapted from QETLAB. + This functions was adapted from QETLAB :cite:`QETLAB_link`. + + References + ========== + .. bibliography:: + :filter: docname in docnames :param phi: A superoperator. It should be provided either as a Choi matrix, or as a (1d or 2d) list of numpy arrays whose entries are its Kraus operators. diff --git a/toqito/helper/cvx_kron.py b/toqito/helper/cvx_kron.py index 1ebf25140..d995b7bd2 100644 --- a/toqito/helper/cvx_kron.py +++ b/toqito/helper/cvx_kron.py @@ -16,8 +16,12 @@ def cvx_kron(expr_1: np.ndarray | Expression, expr_2: np.ndarray | Expression) - At most one of :code:`expr_1` and :code:`b` may be CVXPY Variable objects. - Kudos to Riley J. Murray for this function: - https://github.com/cvxgrp/cvxpy/issues/457 + Kudos to Riley J. Murray for this function :cite:`Riley_2022_CVXPYKron` + + References + ========== + .. bibliography:: + :filter: docname in docnames :param expr_1: 2D numpy ndarray, or a CVXPY Variable with expr_1.ndim == 2 :param expr_2: 2D numpy ndarray, or a CVXPY Variable with expr_2.ndim == 2 diff --git a/toqito/helper/expr_as_np_array.py b/toqito/helper/expr_as_np_array.py index 1fe1fab81..e82c65713 100644 --- a/toqito/helper/expr_as_np_array.py +++ b/toqito/helper/expr_as_np_array.py @@ -1,12 +1,11 @@ -"""cvxpy expression as np.array.""" +"""Cvxpy expression as np.array.""" import numpy as np from cvxpy.expressions.expression import Expression def expr_as_np_array(cvx_expr: Expression) -> np.ndarray: - """ - Convert cvxpy expression into a numpy array. + """Convert cvxpy expression into a numpy array. :param cvx_expr: The cvxpy expression to be converted. :return: The numpy array of the cvxpy expression. diff --git a/toqito/helper/np_array_as_expr.py b/toqito/helper/np_array_as_expr.py index 97595883e..7c2109774 100644 --- a/toqito/helper/np_array_as_expr.py +++ b/toqito/helper/np_array_as_expr.py @@ -6,8 +6,7 @@ def np_array_as_expr(np_arr: [np.ndarray]) -> Expression: - """ - Convert numpy array into a cvxpy expression. + """Convert numpy array into a cvxpy expression. :param np_arr: The numpy array to be converted. :return: The cvxpy expression of the numpy array. diff --git a/toqito/helper/npa_hierarchy.py b/toqito/helper/npa_hierarchy.py index d2c010c3a..2914c6927 100644 --- a/toqito/helper/npa_hierarchy.py +++ b/toqito/helper/npa_hierarchy.py @@ -128,7 +128,7 @@ def npa_constraints( # pylint: disable=too-many-locals assemblage: dict[tuple[int, int], cvxpy.Variable], k: int | str = 1, referee_dim: int = 1 ) -> list[cvxpy.constraints.constraint.Constraint]: r""" - Generate the constraints specified by the NPA hierarchy up to a finite level. + Generate the constraints specified by the NPA hierarchy up to a finite level :cite:`Navascues_2008_AConvergent`. You can determine the level of the hierarchy by a positive integer or a string of a form like "1+ab+aab", which indicates that an intermediate level of the hierarchy @@ -144,6 +144,11 @@ def npa_constraints( # pylint: disable=too-many-locals \langle i| \text{Tr}_{\mathcal{H}} \Big( \big( I_R \otimes A_a^x B_b^y \big) \sigma \Big) |j \rangle + References + ========== + .. bibliography:: + :filter: docname in docnames + :param assemblage: The commuting measurement assemblage operator. :param k: The level of the NPA hierarchy to use (default=1). :param referee_dim: The dimension of the referee's quantum system (default=1). diff --git a/toqito/helper/tests/test_npa_constraints.py b/toqito/helper/tests/test_npa_constraints.py index 12651aced..a89bbe21d 100644 --- a/toqito/helper/tests/test_npa_constraints.py +++ b/toqito/helper/tests/test_npa_constraints.py @@ -48,7 +48,6 @@ def cglmp_inequality(dim: int) -> tuple[dict[tuple[int, int], cvxpy.Variable], c return mat, i_b - @pytest.mark.parametrize("k", [2, "1+ab+aab+baa"]) def test_cglmp_inequality(k): """Test Collins-Gisin-Linden-Massar-Popescu inequality. @@ -62,7 +61,6 @@ def test_cglmp_inequality(k): np.testing.assert_equal(np.allclose(val, 2.914, atol=1e-3), True) - @pytest.mark.parametrize("k, expected_size", [("1+a", 9), ("1+ab", 25)]) def test_cglmp_dimension(k, expected_size): """Test matrix size in Collins-Gisin-Linden-Massar-Popescu inequality. diff --git a/toqito/helper/update_odometer.py b/toqito/helper/update_odometer.py index 36e4376e5..ca9ce5c91 100644 --- a/toqito/helper/update_odometer.py +++ b/toqito/helper/update_odometer.py @@ -23,7 +23,7 @@ def update_odometer( from 1 to 3, you could loop over a single variable going from 1 to 3^2 and set [i, j] = update_odometer([i, j], [3, 3]) at each step within the loop. - This function is adapted from QETLAB [QETOD]_. + This function is adapted from QETLAB :cite:`QETLAB_link`. Examples ========== @@ -41,10 +41,12 @@ def update_odometer( [2 0] [2 1] + References ========== - .. [QETOD] QETLAB: Update odometer function. - http://www.qetlab.com/update_odometer + .. bibliography:: + :filter: docname in docnames + :param old_ind: The initial vector. :param upper_lim: The upper limit on which to increase the odometer to. diff --git a/toqito/matrices/clock.py b/toqito/matrices/clock.py index a3267d0bf..b363120fa 100644 --- a/toqito/matrices/clock.py +++ b/toqito/matrices/clock.py @@ -6,9 +6,9 @@ def clock(dim: int) -> np.ndarray: r""" - Produce clock matrix [WikClock]_. + Produce clock matrix :cite:`WikiClock`. - Returns the clock matrix of dimension :code:`dim` described in [WikClock]_. + Returns the clock matrix of dimension :code:`dim` described in :cite:`WikiClock`. The clock matrix generates the following :code:`dim`-by-:code:`dim` matrix .. math:: @@ -45,8 +45,9 @@ def clock(dim: int) -> np.ndarray: References ========== - .. [WikClock] Wikipedia: Generalizations of Pauli matrices, - https://en.wikipedia.org/wiki/Generalizations_of_Pauli_matrices + .. bibliography:: + :filter: docname in docnames + :param dim: Dimension of the matrix. :return: :code:`dim`-by-:code:`dim` clock matrix. diff --git a/toqito/matrices/cnot.py b/toqito/matrices/cnot.py index 6f8473f67..8f5f69152 100644 --- a/toqito/matrices/cnot.py +++ b/toqito/matrices/cnot.py @@ -4,7 +4,7 @@ def cnot() -> np.ndarray: r""" - Produce the CNOT matrix [WikCNOT]_. + Produce the CNOT matrix :cite:`WikiCNOT`. The CNOT matrix is defined as @@ -29,8 +29,9 @@ def cnot() -> np.ndarray: References ========== - .. [WikCNOT] Wikipedia: Controlled NOT gate - https://en.wikipedia.org/wiki/Controlled_NOT_gate + .. bibliography:: + :filter: docname in docnames + :return: The CNOT matrix. """ diff --git a/toqito/matrices/fourier.py b/toqito/matrices/fourier.py index c65781112..730dd50b1 100644 --- a/toqito/matrices/fourier.py +++ b/toqito/matrices/fourier.py @@ -4,7 +4,7 @@ def fourier(dim: int) -> np.ndarray: r""" - Generate the Fourier transform matrix [WikDFT]_. + Generate the Fourier transform matrix :cite:`WikiDFT`. Generates the :code:`dim`-by-:code:`dim` unitary matrix that implements the quantum Fourier transform. @@ -45,9 +45,10 @@ def fourier(dim: int) -> np.ndarray: References ========== - .. [WikDFT] Wikipedia: DFT matrix, - https://en.wikipedia.org/wiki/DFT_matrix - + .. bibliography:: + :filter: docname in docnames + + :param dim: The size of the Fourier matrix. :return: The Fourier matrix of dimension :code:`dim`. """ diff --git a/toqito/matrices/gell_mann.py b/toqito/matrices/gell_mann.py index 2c3c9b358..47b9d718c 100644 --- a/toqito/matrices/gell_mann.py +++ b/toqito/matrices/gell_mann.py @@ -7,7 +7,7 @@ def gell_mann(ind: int, is_sparse: bool = False) -> np.ndarray | scipy.sparse.csr_matrix: r""" - Produce a Gell-Mann operator [WikGM]_. + Produce a Gell-Mann operator :cite:`WikiGellMann`. Generates the 3-by-3 Gell-Mann matrix indicated by the value of :code:`ind`. When :code:`ind = 0` gives the identity matrix, while values @@ -88,8 +88,10 @@ def gell_mann(ind: int, is_sparse: bool = False) -> np.ndarray | scipy.sparse.cs References ========== - .. [WikGM] Wikipedia: Gell-Mann matrices, - https://en.wikipedia.org/wiki/Gell-Mann_matrices + .. bibliography:: + :filter: docname in docnames + + :raises ValueError: Indices must be integers between 0 and 8. :param ind: An integer between 0 and 8 (inclusive). @@ -119,5 +121,5 @@ def gell_mann(ind: int, is_sparse: bool = False) -> np.ndarray | scipy.sparse.cs if is_sparse: gm_op_out = scipy.sparse.csr_matrix(gm_op) return gm_op_out - + return gm_op diff --git a/toqito/matrices/gen_gell_mann.py b/toqito/matrices/gen_gell_mann.py index eaeb3da69..57cd4a6cd 100644 --- a/toqito/matrices/gen_gell_mann.py +++ b/toqito/matrices/gen_gell_mann.py @@ -10,7 +10,7 @@ def gen_gell_mann( ind_1: int, ind_2: int, dim: int, is_sparse: bool = False ) -> np.ndarray | sparse.lil_matrix: r""" - Produce a generalized Gell-Mann operator [WikGM2]_. + Produce a generalized Gell-Mann operator :cite:`WikiGellMann`. Construct a :code:`dim`-by-:code:`dim` Hermitian operator. These matrices span the entire space of :code:`dim`-by-:code:`dim` matrices as @@ -59,8 +59,9 @@ def gen_gell_mann( References ========== - .. [WikGM2] Wikipedia: Gell-Mann matrices, - https://en.wikipedia.org/wiki/Gell-Mann_matrices + .. bibliography:: + :filter: docname in docnames + :param ind_1: A non-negative integer from 0 to :code:`dim-1` (inclusive). :param ind_2: A non-negative integer from 0 to :code:`dim-1` (inclusive). diff --git a/toqito/matrices/gen_pauli.py b/toqito/matrices/gen_pauli.py index d62ed7fe7..468030f2a 100644 --- a/toqito/matrices/gen_pauli.py +++ b/toqito/matrices/gen_pauli.py @@ -6,7 +6,7 @@ def gen_pauli(k_1: int, k_2: int, dim: int) -> np.ndarray: r""" - Produce generalized Pauli operator [WikGenPaul]_. + Produce generalized Pauli operator :cite:`WikiPauliGen`. Generates a :code:`dim`-by-:code:`dim` unitary operator. More specifically, it is the operator :math:`X^k_1 Z^k_2`, where :math:`X` and :math:`Z` are @@ -16,7 +16,8 @@ def gen_pauli(k_1: int, k_2: int, dim: int) -> np.ndarray: from 0 to :code:`dim-1`, inclusive. Note that the generalized Pauli operators are also known by the name of - "discrete Weyl operators". [WatrousLec6]_ + "discrete Weyl operators". (Lecture 6: Further Remarks On Measurements And Channels from + :cite:`Watrous_2011_Lecture_Notes`) Examples ========== @@ -61,11 +62,9 @@ def gen_pauli(k_1: int, k_2: int, dim: int) -> np.ndarray: References ========== - .. [WikGenPaul] Wikipedia: Generalizations of Pauli matrices - https://en.wikipedia.org/wiki/Generalizations_of_Pauli_matrices - - .. [WatrousLec6] Lecture 6: Further remarks on measurements and channels - https://cs.uwaterloo.ca/~watrous/LectureNotes/CS766.Fall2011/06.pdf + .. bibliography:: + :filter: docname in docnames + :param k_1: (a non-negative integer from 0 to :code:`dim-1` inclusive). :param k_2: (a non-negative integer from 0 to :code:`dim-1` inclusive). diff --git a/toqito/matrices/hadamard.py b/toqito/matrices/hadamard.py index 0600ed76d..90b302adb 100644 --- a/toqito/matrices/hadamard.py +++ b/toqito/matrices/hadamard.py @@ -4,7 +4,7 @@ def hadamard(n_param: int = 1) -> np.ndarray: r""" - Produce a :code:`2^{n_param}` dimensional Hadamard matrix [WikHad]_. + Produce a :code:`2^{n_param}` dimensional Hadamard matrix :cite:`WikiHadamard`. The standard Hadamard matrix that is often used in quantum information as a two-qubit quantum gate is defined as @@ -34,16 +34,18 @@ def hadamard(n_param: int = 1) -> np.ndarray: References ========== - .. [WikHad] Wikipedia: Hadamard transform - https://en.wikipedia.org/wiki/Hadamard_transform + .. bibliography:: + :filter: docname in docnames + + :param n_param: A non-negative integer (default = 1). :return: The Hadamard matrix of dimension :code:`2^{n_param}`. """ return 2 ** (-n_param / 2) * np.array( [ - [(-1) ** _hamming_distance(i & j) for i in range(2**n_param)] - for j in range(2**n_param) + [(-1) ** _hamming_distance(i & j) for i in range(2 ** n_param)] + for j in range(2 ** n_param) ] ) diff --git a/toqito/matrices/pauli.py b/toqito/matrices/pauli.py index bb456e037..cbffd3edb 100644 --- a/toqito/matrices/pauli.py +++ b/toqito/matrices/pauli.py @@ -12,7 +12,7 @@ def pauli( ind: int | str | list[int] | list[str], is_sparse: bool = False ) -> np.ndarray | sparse.csr_matrix: r""" - Produce a Pauli operator [WikPauli]_. + Produce a Pauli operator :cite:`WikiPauli`. Provides the 2-by-2 Pauli matrix indicated by the value of :code:`ind`. The variable :code:`ind = 1` gives the Pauli-X operator, :code:`ind = 2` gives @@ -79,9 +79,9 @@ def pauli( References ========== - .. [WikPauli] Wikipedia: Pauli matrices - https://en.wikipedia.org/wiki/Pauli_matrices - + .. bibliography:: + :filter: docname in docnames + :param ind: The index to indicate which Pauli operator to generate. :param is_sparse: Returns a sparse matrix if set to True and a non-sparse matrix if set to False. diff --git a/toqito/matrices/shift.py b/toqito/matrices/shift.py index 20304fb96..72deb84c7 100644 --- a/toqito/matrices/shift.py +++ b/toqito/matrices/shift.py @@ -4,9 +4,9 @@ def shift(dim: int) -> np.ndarray: r""" - Produce a :code:`dim`-by-:code:`dim` shift matrix [WikShift]_. + Produce a :code:`dim`-by-:code:`dim` shift matrix :cite:`WikiPauliGen`. - Returns the shift matrix of dimension :code:`dim` described in [WikShift]_. + Returns the shift matrix of dimension :code:`dim` described in :cite:`WikiPauliGen`. The shift matrix generates the following :code:`dim`-by-:code:`dim` matrix: .. math:: @@ -43,8 +43,9 @@ def shift(dim: int) -> np.ndarray: References ========== - .. [WikShift] Wikipedia: Generalizations of Pauli matrices - (https://en.wikipedia.org/wiki/Generalizations_of_Pauli_matrices. + .. bibliography:: + :filter: docname in docnames + :param dim: Dimension of the matrix. :return: :code:`dim`-by-:code:`dim` shift matrix. diff --git a/toqito/matrices/standard_basis.py b/toqito/matrices/standard_basis.py index 44ec16785..579746caf 100644 --- a/toqito/matrices/standard_basis.py +++ b/toqito/matrices/standard_basis.py @@ -17,8 +17,12 @@ def standard_basis(dim: int, flatten: bool = False) -> list[np.ndarray]: . |n> = (0, 0, 0, ..., 1)^T - This function was inspired by: - https://github.com/akshayseshadri/minimax-fidelity-estimation + This function was inspired by :cite:`Seshadri_2021_Git, Seshadri_2021_Theory, Seshadri_2021_Versatile` + + References + ========== + .. bibliography:: + :filter: docname in docnames :param dim: The dimension of the basis. :param flatten: If True, the basis is returned as a flattened list. diff --git a/toqito/matrix_ops/inner_product.py b/toqito/matrix_ops/inner_product.py index 2c4b8867b..f5a2190b6 100644 --- a/toqito/matrix_ops/inner_product.py +++ b/toqito/matrix_ops/inner_product.py @@ -4,7 +4,7 @@ def inner_product(v1: np.ndarray, v2: np.ndarray) -> float: r""" - Compute the inner product :math:`\langle v_1|v_2\rangle` of two vectors [WikInner]_. + Compute the inner product :math:`\langle v_1|v_2\rangle` of two vectors :cite:`WikiInnerProd`. The inner product is calculated as follows: @@ -55,8 +55,9 @@ def inner_product(v1: np.ndarray, v2: np.ndarray) -> float: References ========== - .. [WikInner] Wikipedia: Inner product space - https://en.wikipedia.org/wiki/Inner_product_space + .. bibliography:: + :filter: docname in docnames + :raises ValueError: Vector dimensions are mismatched. :param v1: v1 and v2, both vectors of dimensions :math:`(n,1)` where :math:`n>1`. diff --git a/toqito/matrix_ops/outer_product.py b/toqito/matrix_ops/outer_product.py index ba8cc86e9..83e3a5628 100644 --- a/toqito/matrix_ops/outer_product.py +++ b/toqito/matrix_ops/outer_product.py @@ -6,7 +6,7 @@ def outer_product(v1: np.ndarray, v2: np.ndarray) -> np.ndarray: r""" Compute the outer product :math:`|v_1\rangle\langle v_2|` of two vectors. - The outer product is calculated as follows [WikOuter]_: + The outer product is calculated as follows :cite:`WikiOuterProd` : .. math:: \left|\begin{pmatrix}a_1\\\vdots\\a_n\end{pmatrix}\right\rangle\left\langle\begin{pmatrix}b_1\\\vdots\\b_n\end{pmatrix}\right|=\begin{pmatrix}a_1\\\vdots\\a_n\end{pmatrix}\begin{pmatrix}b_1&\cdots&b_n\end{pmatrix}=\begin{pmatrix}a_1b_1&\cdots&a_1b_n\\\vdots&\ddots&\vdots\\a_1b_n&\cdots&a_nb_n\end{pmatrix} @@ -53,8 +53,9 @@ def outer_product(v1: np.ndarray, v2: np.ndarray) -> np.ndarray: References ========== - .. [WikOuter] Wikipedia: Outer Product - https://en.wikipedia.org/wiki/Outer_product + .. bibliography:: + :filter: docname in docnames + :raises ValueError: Vector dimensions are mismatched. :param v1: v1 and v2, both vectors of dimensions :math:`(n,1)` where :math:`n>1`. diff --git a/toqito/matrix_ops/tensor.py b/toqito/matrix_ops/tensor.py index 2270a49dd..612eac48a 100644 --- a/toqito/matrix_ops/tensor.py +++ b/toqito/matrix_ops/tensor.py @@ -4,7 +4,7 @@ def tensor(*args) -> np.ndarray: r""" - Compute the Kronecker tensor product [WikTensor]_. + Compute the Kronecker tensor product :cite:`WikiTensorProd`. Tensor two matrices or vectors together using the standard Kronecker operation provided from numpy. @@ -106,8 +106,9 @@ def tensor(*args) -> np.ndarray: References ========== - .. [WikTensor] Wikipedia: Tensor product - https://en.wikipedia.org/wiki/Tensor_product + .. bibliography:: + :filter: docname in docnames + :raises ValueError: Input must be a vector or matrix. :param args: Input to the tensor function is expected to be either: diff --git a/toqito/matrix_ops/unvec.py b/toqito/matrix_ops/unvec.py index 50a143b5e..32c041a7e 100644 --- a/toqito/matrix_ops/unvec.py +++ b/toqito/matrix_ops/unvec.py @@ -4,7 +4,7 @@ def unvec(vector: np.ndarray, shape: list[int] = None) -> np.ndarray: r""" - Perform the unvec operation on a vector to obtain a matrix [Rigetti2020]_. + Perform the unvec operation on a vector to obtain a matrix :cite:`Rigetti_2022_Forest`. Takes a column vector and transforms it into a :code:`shape[0]`-by-:code:`shape[1]` matrix. This operation is the inverse of :code:`vec` operation in :code:`toqito`. @@ -46,7 +46,7 @@ def unvec(vector: np.ndarray, shape: list[int] = None) -> np.ndarray: for all :math:`a` and :math:`b`. - This function has been adapted from [Rigetti20]_. + This function has been adapted from :cite:`Rigetti_2022_Forest`. Examples ========== @@ -74,8 +74,9 @@ def unvec(vector: np.ndarray, shape: list[int] = None) -> np.ndarray: References ========== - .. [Rigetti2020] Forest Benchmarking (Rigetti). - https://github.com/rigetti/forest-benchmarking + .. bibliography:: + :filter: docname in docnames + :param vector: A (:code:`shape[0] * shape[1]`)-by-1 numpy array. :param shape: The shape of the output matrix; by default, the matrix is assumed to be square. diff --git a/toqito/matrix_ops/vec.py b/toqito/matrix_ops/vec.py index e27ebf18b..5d6496929 100644 --- a/toqito/matrix_ops/vec.py +++ b/toqito/matrix_ops/vec.py @@ -4,7 +4,7 @@ def vec(mat: np.ndarray) -> np.ndarray: r""" - Perform the vec operation on a matrix [WATVEC]_. + Perform the vec operation on a matrix ( Section: The Operator-Vector Correspondence from :cite:`Watrous_2018_TQI`). Stacks the rows of the matrix on top of each other to obtain the "vec" representation of the matrix. @@ -81,10 +81,9 @@ def vec(mat: np.ndarray) -> np.ndarray: References ========== - .. [WATVEC] Watrous, John. - "The theory of quantum information." - Section: "The operator-vector correspondence". - Cambridge University Press, 2018. + .. bibliography:: + :filter: docname in docnames + :param mat: The input matrix. :return: The vec representation of the matrix. diff --git a/toqito/matrix_ops/vectors_from_gram_matrix.py b/toqito/matrix_ops/vectors_from_gram_matrix.py index 81ad7ac73..637769a7d 100644 --- a/toqito/matrix_ops/vectors_from_gram_matrix.py +++ b/toqito/matrix_ops/vectors_from_gram_matrix.py @@ -3,7 +3,7 @@ def vectors_from_gram_matrix(gram: np.ndarray) -> list[np.ndarray]: - r"""Obtain the corresponding ensemble of states from the Gram matrix [WikGram]_. + r"""Obtain the corresponding ensemble of states from the Gram matrix :cite:`WikiGram`. The function attempts to compute the Cholesky decomposition of the given Gram matrix. If the matrix is positive definite, the Cholesky decomposition is returned. If the matrix is not positive definite, the function falls back to @@ -30,8 +30,8 @@ def vectors_from_gram_matrix(gram: np.ndarray) -> list[np.ndarray]: References ========== - .. [WikGram] Wikipedia: Gram matrix - https://en.wikipedia.org/wiki/Gram_matrix + .. bibliography:: + :filter: docname in docnames :raises LinAlgError: If the Gram matrix is not symmetric. :raises LinAlgError: If the Gram matrix is not square.. diff --git a/toqito/matrix_ops/vectors_to_gram_matrix.py b/toqito/matrix_ops/vectors_to_gram_matrix.py index 2b76e431e..d3cc51ca4 100644 --- a/toqito/matrix_ops/vectors_to_gram_matrix.py +++ b/toqito/matrix_ops/vectors_to_gram_matrix.py @@ -3,7 +3,7 @@ def vectors_to_gram_matrix(vectors: list[np.ndarray]) -> np.ndarray: - r"""Construct the Gram matrix from a list of vectors [WikGram]_. + r"""Construct the Gram matrix from a list of vectors :cite:`WikiGram`. The Gram matrix is a matrix of inner products, where the entry G[i, j] is the inner product of vectors[i] and vectors[j]. This function computes the Gram matrix for a given list of vectors. @@ -26,8 +26,8 @@ def vectors_to_gram_matrix(vectors: list[np.ndarray]) -> np.ndarray: References ========== - .. [WikGram] Wikipedia: Gram matrix - https://en.wikipedia.org/wiki/Gram_matrix + .. bibliography:: + :filter: docname in docnames :raises ValueError: If the vectors are not all of the same length. :param vectors: A list of vectors (1D numpy arrays). All vectors must be of the same length. diff --git a/toqito/matrix_props/__init__.py b/toqito/matrix_props/__init__.py index 28afe2d00..b54c795dd 100644 --- a/toqito/matrix_props/__init__.py +++ b/toqito/matrix_props/__init__.py @@ -22,4 +22,3 @@ from toqito.matrix_props.trace_norm import trace_norm from toqito.matrix_props.is_diagonally_dominant import is_diagonally_dominant from toqito.matrix_props.is_totally_positive import is_totally_positive - diff --git a/toqito/matrix_props/is_block_positive.py b/toqito/matrix_props/is_block_positive.py index d88f27657..805e9a84b 100644 --- a/toqito/matrix_props/is_block_positive.py +++ b/toqito/matrix_props/is_block_positive.py @@ -16,7 +16,7 @@ def is_block_positive( rtol: float = 1e-5, ) -> bool: r""" - Check if matrix is block positive [1]_. + Check if matrix is block positive :cite:`Johnston_2012_Norms`. Examples ========== @@ -42,8 +42,9 @@ def is_block_positive( References ========== - .. [1] "N. Johnston. Norms and Cones in the Theory of Quantum Entanglement. PhD thesis" - arXiv:1207.1479 + .. bibliography:: + :filter: docname in docnames + :raises ValueError: Unable to determine block positive property. :param mat: A bipartite Hermitian operator. @@ -85,7 +86,7 @@ def is_block_positive( # We compute the S(k)-norm of this operator since # X k-block positive iff: # c >= S(k)-norm of(c*I - X) - # See Corollary 4.2.9. of [1]. + # See Corollary 4.2.9. of `:cite:`Johnston_2012_Norms`. c_mat = op_norm * np.eye(dim_xy) - mat lower_bound, upper_bound = sk_operator_norm(c_mat, k, dim, op_norm, effort) diff --git a/toqito/matrix_props/is_circulant.py b/toqito/matrix_props/is_circulant.py index a54df1efe..776bdedc5 100644 --- a/toqito/matrix_props/is_circulant.py +++ b/toqito/matrix_props/is_circulant.py @@ -4,7 +4,7 @@ def is_circulant(mat: np.ndarray) -> bool: r""" - Determine if matrix is circulant [WikCirc]_. + Determine if matrix is circulant :cite:`WikiCirc`. A circulant matrix is a square matrix in which all row vectors are composed of the same elements and each row vector is rotated one element to the right @@ -34,8 +34,9 @@ def is_circulant(mat: np.ndarray) -> bool: References ========== - .. [WikCirc] Wikipedia: Circulant matrices - https://en.wikipedia.org/wiki/Circulant_matrix + .. bibliography:: + :filter: docname in docnames + :param mat: Matrix to check the circulancy of. :return: Return `True` if :code:`mat` is circulant; `False` otherwise. diff --git a/toqito/matrix_props/is_commuting.py b/toqito/matrix_props/is_commuting.py index f1cb036ef..c85563e9a 100644 --- a/toqito/matrix_props/is_commuting.py +++ b/toqito/matrix_props/is_commuting.py @@ -4,7 +4,7 @@ def is_commuting(mat_1: np.ndarray, mat_2: np.ndarray) -> bool: r""" - Determine if two linear operators commute with each other [WikCom]_. + Determine if two linear operators commute with each other :cite:`WikiComm`. For any pair of operators :math:`X, Y \in \text{L}(\mathcal{X})`, the Lie bracket :math:`\left[X, Y\right] \in \text{L}(\mathcal{X})` is defined @@ -14,7 +14,7 @@ def is_commuting(mat_1: np.ndarray, mat_2: np.ndarray) -> bool: \left[X, Y\right] = XY - YX. It holds that :math:`\left[X,Y\right]=0` if and only if :math:`X` and - :math:`Y` commute [WatCom18]_. + :math:`Y` commute (Section: Lie Brackets And Commutants from :cite:`Watrous_2018_TQI`). Examples ========== @@ -66,13 +66,10 @@ def is_commuting(mat_1: np.ndarray, mat_2: np.ndarray) -> bool: References ========== - .. [WikCom] Wikipedia: Commuting matrices - https://en.wikipedia.org/wiki/Commuting_matrices + .. bibliography:: + :filter: docname in docnames + - .. [WatCom18] Watrous, John. - "The theory of quantum information." - Section: "Lie brackets and commutants". - Cambridge University Press, 2018. :param mat_1: First matrix to check. :param mat_2: Second matrix to check. diff --git a/toqito/matrix_props/is_density.py b/toqito/matrix_props/is_density.py index 4383eb697..74ff64f73 100644 --- a/toqito/matrix_props/is_density.py +++ b/toqito/matrix_props/is_density.py @@ -6,7 +6,7 @@ def is_density(mat: np.ndarray) -> bool: r""" - Check if matrix is a density matrix [WikDensity]_. + Check if matrix is a density matrix :cite:`WikiDen`. A matrix is a density matrix if its trace is equal to one and it has the property of being positive semidefinite (PSD). @@ -61,9 +61,9 @@ def is_density(mat: np.ndarray) -> bool: References ========== - .. [WikDensity] Wikipedia: Density matrix - https://en.wikipedia.org/wiki/Density_matrix - + .. bibliography:: + :filter: docname in docnames + :param mat: Matrix to check. :return: Return :code:`True` if matrix is a density matrix, and :code:`False` otherwise. diff --git a/toqito/matrix_props/is_diagonal.py b/toqito/matrix_props/is_diagonal.py index ad641896a..2fa5a9555 100644 --- a/toqito/matrix_props/is_diagonal.py +++ b/toqito/matrix_props/is_diagonal.py @@ -6,7 +6,7 @@ def is_diagonal(mat: np.ndarray) -> bool: r""" - Determine if a matrix is diagonal [WikDiag]_. + Determine if a matrix is diagonal :cite:`WikiDiag`. A matrix is diagonal if the matrix is square and if the diagonal of the matrix is non-zero, while the off-diagonal elements are all zero. @@ -22,7 +22,7 @@ def is_diagonal(mat: np.ndarray) -> bool: \end{pmatrix} \end{equation} - This quick implementation is given by Daniel F. from StackOverflow in [SODIA]_. + This quick implementation is given by Daniel F. from StackOverflow in :cite:`SO_43884189`. Examples ========== @@ -61,11 +61,10 @@ def is_diagonal(mat: np.ndarray) -> bool: References ========== - .. [WikDiag] Wikipedia: Diagonal matrix - https://en.wikipedia.org/wiki/Diagonal_matrix - - .. [SODIA] StackOverflow post - https://stackoverflow.com/questions/43884189/ + .. bibliography:: + :filter: docname in docnames + + :param mat: The matrix to check. :return: Returns :code:`True` if the matrix is diagonal diff --git a/toqito/matrix_props/is_diagonally_dominant.py b/toqito/matrix_props/is_diagonally_dominant.py index fc44f5e93..50735a1ce 100644 --- a/toqito/matrix_props/is_diagonally_dominant.py +++ b/toqito/matrix_props/is_diagonally_dominant.py @@ -6,7 +6,7 @@ def is_diagonally_dominant(mat: np.ndarray, is_strict: bool = True) -> bool: r""" - Check if matrix is diagnal dominant (DD) [WikDD]_. + Check if matrix is diagnal dominant (DD) :cite:`WikiDiagDom`. A matrix is diagonally dominant if the matrix is square and if for every row of the matrix, the magnitude of the diagonal entry in a row is greater @@ -50,8 +50,9 @@ def is_diagonally_dominant(mat: np.ndarray, is_strict: bool = True) -> bool: References ========== - .. [WikDD] Wikipedia: Diagonally dominant matrix. - https://en.wikipedia.org/wiki/Diagonally_dominant_matrix + .. bibliography:: + :filter: docname in docnames + :param mat: Matrix to check. :param is_strict: Whether the inequality is strict. diff --git a/toqito/matrix_props/is_hermitian.py b/toqito/matrix_props/is_hermitian.py index f609ae14a..81aafd319 100644 --- a/toqito/matrix_props/is_hermitian.py +++ b/toqito/matrix_props/is_hermitian.py @@ -6,7 +6,7 @@ def is_hermitian(mat: np.ndarray, rtol: float = 1e-05, atol: float = 1e-08) -> bool: r""" - Check if matrix is Hermitian [WikHerm]_. + Check if matrix is Hermitian :cite:`WikiHerm`. A Hermitian matrix is a complex square matrix that is equal to its own conjugate transpose. @@ -52,8 +52,10 @@ def is_hermitian(mat: np.ndarray, rtol: float = 1e-05, atol: float = 1e-08) -> b References ========== - .. [WikHerm] Wikipedia: Hermitian matrix. - https://en.wikipedia.org/wiki/Hermitian_matrix + .. bibliography:: + :filter: docname in docnames + + :param mat: Matrix to check. :param rtol: The relative tolerance parameter (default 1e-05). diff --git a/toqito/matrix_props/is_idempotent.py b/toqito/matrix_props/is_idempotent.py index 53b46777a..f5ece7c09 100644 --- a/toqito/matrix_props/is_idempotent.py +++ b/toqito/matrix_props/is_idempotent.py @@ -6,7 +6,7 @@ def is_idempotent(mat: np.ndarray, rtol: float = 1e-05, atol: float = 1e-8) -> bool: r""" - Check if matrix is the idempotent matrix [WikIdempotent]_. + Check if matrix is the idempotent matrix :cite:`WikiIdemPot`. An *idempotent matrix* is a square matrix, which, when multiplied by itself, yields itself. That is, the matrix :math:`A` is idempotent if and only if :math:`A^2 = A`. @@ -46,8 +46,9 @@ def is_idempotent(mat: np.ndarray, rtol: float = 1e-05, atol: float = 1e-8) -> b References ========== - .. [WikIdempotent] Wikipedia: Idempotent matrix - https://en.wikipedia.org/wiki/Idempotent_matrix + .. bibliography:: + :filter: docname in docnames + :param mat: Matrix to check. :param rtol: The relative tolerance parameter (default 1e-05). diff --git a/toqito/matrix_props/is_identity.py b/toqito/matrix_props/is_identity.py index 538a3e439..47389bbc5 100644 --- a/toqito/matrix_props/is_identity.py +++ b/toqito/matrix_props/is_identity.py @@ -6,7 +6,7 @@ def is_identity(mat: np.ndarray, rtol: float = 1e-05, atol: float = 1e-8) -> bool: r""" - Check if matrix is the identity matrix [WikIdentity]_. + Check if matrix is the identity matrix :cite:`WikiIden`. For dimension :math:`n`, the :math:`n \times n` identity matrix is defined as @@ -60,8 +60,9 @@ def is_identity(mat: np.ndarray, rtol: float = 1e-05, atol: float = 1e-8) -> boo References ========== - .. [WikIdentity] Wikipedia: Identity matrix - https://en.wikipedia.org/wiki/Identity_matrix + .. bibliography:: + :filter: docname in docnames + :param mat: Matrix to check. :param rtol: The relative tolerance parameter (default 1e-05). diff --git a/toqito/matrix_props/is_normal.py b/toqito/matrix_props/is_normal.py index 58a60281d..d2b6eb167 100644 --- a/toqito/matrix_props/is_normal.py +++ b/toqito/matrix_props/is_normal.py @@ -6,7 +6,7 @@ def is_normal(mat: np.ndarray, rtol: float = 1e-05, atol: float = 1e-08) -> bool: r""" - Determine if a matrix is normal [WikNormal]_. + Determine if a matrix is normal :cite:`WikiNorm`. A matrix is normal if it commutes with its adjoint @@ -62,8 +62,9 @@ def is_normal(mat: np.ndarray, rtol: float = 1e-05, atol: float = 1e-08) -> bool References ========== - .. [WikNormal] Wikipedia: Normal matrix. - https://en.wikipedia.org/wiki/Normal_matrix + .. bibliography:: + :filter: docname in docnames + :param mat: The matrix to check. :param rtol: The relative tolerance parameter (default 1e-05). diff --git a/toqito/matrix_props/is_permutation.py b/toqito/matrix_props/is_permutation.py index 50223566c..bc01d5bd7 100644 --- a/toqito/matrix_props/is_permutation.py +++ b/toqito/matrix_props/is_permutation.py @@ -4,7 +4,7 @@ def is_permutation(mat: np.ndarray) -> bool: r""" - Determine if a matrix is a permutation matrix [WikiPermutation]_. + Determine if a matrix is a permutation matrix :cite:`WikiPerm`. A matrix is a permutation matrix if each row and column has a single element of 1 and all others are 0. @@ -50,8 +50,9 @@ def is_permutation(mat: np.ndarray) -> bool: References ========== - .. [WikiPermutation] Wikipedia: Permutation matrix. - https://en.wikipedia.org/wiki/Permutation_matrix + .. bibliography:: + :filter: docname in docnames + :param mat: The matrix to check. :return: Returns :code:`True` if the matrix is a permutation matrix and :code:`False` otherwise. diff --git a/toqito/matrix_props/is_positive_definite.py b/toqito/matrix_props/is_positive_definite.py index 48f7fd46c..f1b1c8d64 100644 --- a/toqito/matrix_props/is_positive_definite.py +++ b/toqito/matrix_props/is_positive_definite.py @@ -6,7 +6,7 @@ def is_positive_definite(mat: np.ndarray) -> bool: r""" - Check if matrix is positive definite (PD) [WikPD]_. + Check if matrix is positive definite (PD) :cite:`WikiPosDef`. Examples ========== @@ -50,9 +50,10 @@ def is_positive_definite(mat: np.ndarray) -> bool: References ========== - .. [WikPD] Wikipedia: Definiteness of a matrix. - https://en.wikipedia.org/wiki/Definiteness_of_a_matrix - + .. bibliography:: + :filter: docname in docnames + + :param mat: Matrix to check. :return: Return :code:`True` if matrix is positive definite, and :code:`False` otherwise. """ diff --git a/toqito/matrix_props/is_positive_semidefinite.py b/toqito/matrix_props/is_positive_semidefinite.py index eed8c5633..785655a95 100644 --- a/toqito/matrix_props/is_positive_semidefinite.py +++ b/toqito/matrix_props/is_positive_semidefinite.py @@ -6,7 +6,7 @@ def is_positive_semidefinite(mat: np.ndarray, rtol: float = 1e-05, atol: float = 1e-08) -> bool: r""" - Check if matrix is positive semidefinite (PSD) [WikPSD]_. + Check if matrix is positive semidefinite (PSD) :cite:`WikiPosDef`. Examples ========== @@ -45,8 +45,9 @@ def is_positive_semidefinite(mat: np.ndarray, rtol: float = 1e-05, atol: float = References ========== - .. [WikPSD] Wikipedia: Definiteness of a matrix. - https://en.wikipedia.org/wiki/Definiteness_of_a_matrix + .. bibliography:: + :filter: docname in docnames + :param mat: Matrix to check. :param rtol: The relative tolerance parameter (default 1e-05). diff --git a/toqito/matrix_props/is_projection.py b/toqito/matrix_props/is_projection.py index b95adf58d..e0a91f70e 100644 --- a/toqito/matrix_props/is_projection.py +++ b/toqito/matrix_props/is_projection.py @@ -6,7 +6,7 @@ def is_projection(mat: np.ndarray, rtol: float = 1e-05, atol: float = 1e-08) -> bool: r""" - Check if matrix is a projection matrix [WikProj]_. + Check if matrix is a projection matrix :cite:`WikiProjMat`. A matrix is a projection matrix if it is positive semidefinite (PSD) and if @@ -54,8 +54,9 @@ def is_projection(mat: np.ndarray, rtol: float = 1e-05, atol: float = 1e-08) -> References ========== - .. [WikProj] Wikipedia: Projection matrix. - https://en.wikipedia.org/wiki/Projection_matrix + .. bibliography:: + :filter: docname in docnames + :param mat: Matrix to check. :param rtol: The relative tolerance parameter (default 1e-05). diff --git a/toqito/matrix_props/is_square.py b/toqito/matrix_props/is_square.py index c24bdb503..70a5f5796 100644 --- a/toqito/matrix_props/is_square.py +++ b/toqito/matrix_props/is_square.py @@ -4,7 +4,7 @@ def is_square(mat: np.ndarray) -> bool: r""" - Determine if a matrix is square [WikSquare]_. + Determine if a matrix is square :cite:`WikiSqMat`. A matrix is square if the dimensions of the rows and columns are equivalent. @@ -46,8 +46,9 @@ def is_square(mat: np.ndarray) -> bool: References ========== - .. [WikSquare] Wikipedia: Square matrix. - https://en.wikipedia.org/wiki/Square_matrix + .. bibliography:: + :filter: docname in docnames + :raises ValueError: If variable is not a matrix. :param mat: The matrix to check. diff --git a/toqito/matrix_props/is_symmetric.py b/toqito/matrix_props/is_symmetric.py index 9aca025d1..e6ab27b1c 100644 --- a/toqito/matrix_props/is_symmetric.py +++ b/toqito/matrix_props/is_symmetric.py @@ -6,7 +6,7 @@ def is_symmetric(mat: np.ndarray, rtol: float = 1e-05, atol: float = 1e-08) -> bool: r""" - Determine if a matrix is symmetric [WikSym]_. + Determine if a matrix is symmetric :cite:`WikiSymMat`. The following 3x3 matrix is an example of a symmetric matrix: @@ -56,8 +56,9 @@ def is_symmetric(mat: np.ndarray, rtol: float = 1e-05, atol: float = 1e-08) -> b References ========== - .. [WikSym] Wikipedia: Symmetric matrix - https://en.wikipedia.org/wiki/Symmetric_matrix + .. bibliography:: + :filter: docname in docnames + :param mat: The matrix to check. :param rtol: The relative tolerance parameter (default 1e-05). diff --git a/toqito/matrix_props/is_totally_positive.py b/toqito/matrix_props/is_totally_positive.py index deb5aba7c..4d360978f 100644 --- a/toqito/matrix_props/is_totally_positive.py +++ b/toqito/matrix_props/is_totally_positive.py @@ -5,7 +5,7 @@ def is_totally_positive(mat: np.ndarray, tol: float = 1e-6, sub_sizes: list | None = None): r""" - Determines whether a matrix is totally positive. + Determines whether a matrix is totally positive. :cite:`WikiTotPosMat` A totally positive matrix is a square matrix where all the minors are positive. Equivalently, the determinant of every square submatrix is a positive number. @@ -41,8 +41,9 @@ def is_totally_positive(mat: np.ndarray, tol: float = 1e-6, sub_sizes: list | No References ========== - .. [WikTotallyPositive] Wikipedia: Totally positive matrix. - https://en.wikipedia.org/wiki/Totally_positive_matrix + .. bibliography:: + :filter: docname in docnames + :param mat: Matrix to check. :param tol: The absolute tolerance parameter (default 1e-06). diff --git a/toqito/matrix_props/is_unitary.py b/toqito/matrix_props/is_unitary.py index 57e7c02c9..262c8f3da 100644 --- a/toqito/matrix_props/is_unitary.py +++ b/toqito/matrix_props/is_unitary.py @@ -6,7 +6,7 @@ def is_unitary(mat: np.ndarray, rtol: float = 1e-05, atol: float = 1e-08) -> bool: r""" - Check if matrix is unitary [WikUnitary]_. + Check if matrix is unitary :cite:`WikiUniMat`. A matrix is unitary if its inverse is equal to its conjugate transpose. @@ -66,8 +66,9 @@ def is_unitary(mat: np.ndarray, rtol: float = 1e-05, atol: float = 1e-08) -> boo References ========== - .. [WikUnitary] Wikipedia: Unitary matrix. - https://en.wikipedia.org/wiki/Unitary_matrix + .. bibliography:: + :filter: docname in docnames + :param mat: Matrix to check. :param rtol: The relative tolerance parameter (default 1e-05). diff --git a/toqito/matrix_props/kp_norm.py b/toqito/matrix_props/kp_norm.py index 4dad10351..247ffaa07 100644 --- a/toqito/matrix_props/kp_norm.py +++ b/toqito/matrix_props/kp_norm.py @@ -1,10 +1,12 @@ -"""kp-norm for matrices.""" +"""Kp-norm for matrices.""" import numpy as np def kp_norm(mat: np.ndarray, k: int, p: int) -> float: - """ - Compute the p-norm of the vector or the k-largest singular values of a matrix. + """Compute the kp_norm of vector or matrix. + + Calculate the p-norm of a vector or the k-largest singular values of a + matrix. :param mat: 2D numpy ndarray :param k: The number of singular values to take. diff --git a/toqito/matrix_props/majorizes.py b/toqito/matrix_props/majorizes.py index ce49b8583..ead7560de 100644 --- a/toqito/matrix_props/majorizes.py +++ b/toqito/matrix_props/majorizes.py @@ -6,7 +6,7 @@ def majorizes(a_var: np.ndarray | list[int], b_var: np.ndarray | list[int]) -> bool: r""" - Determine if one vector or matrix majorizes another. [WikMajorization]_. + Determine if one vector or matrix majorizes another :cite:`WikiMajorization`. Given :math:`a, b \in \mathbb{R}^d`, we say that :math:`a` **weakly majorizes** (or dominates) :math:`b` from below if and only if @@ -44,8 +44,9 @@ def majorizes(a_var: np.ndarray | list[int], b_var: np.ndarray | list[int]) -> b References ========== - .. [WikMajorization] Wikipedia: Majorization - https://en.wikipedia.org/wiki/Majorization + .. bibliography:: + :filter: docname in docnames + :param a_var: Matrix or vector provided as list or np.array. :param b_var: Matrix or vector provided as list or np.array. diff --git a/toqito/matrix_props/sk_norm.py b/toqito/matrix_props/sk_norm.py index 923abc774..f8274cc1e 100644 --- a/toqito/matrix_props/sk_norm.py +++ b/toqito/matrix_props/sk_norm.py @@ -24,7 +24,7 @@ def sk_operator_norm( # pylint: disable=too-many-locals effort: int = 2, ) -> float: r""" - Compute the S(k)-norm of a matrix [1]_. + Compute the S(k)-norm of a matrix :cite:`Johnston_2010_AFamily`. The :math:`S(k)`-norm of of a matrix :math:`X` is defined as: @@ -36,7 +36,7 @@ def sk_operator_norm( # pylint: disable=too-many-locals \text{Schmidt - rank}(|w\rangle) \leq k \Big\} - Since computing the exact value of S(k)-norm [2]_ is in the general case + Since computing the exact value of S(k)-norm :cite:`Johnston_2012_Norms` is in the general case an intractable problem, this function tries to find some good lower and upper bounds. You can control the amount of computation you want to devote to computing the bounds by `effort` input argument. Note that if @@ -64,11 +64,9 @@ def sk_operator_norm( # pylint: disable=too-many-locals References ========== - .. [1] "A Family of Norms With Applications In Quantum Information Theory" - Nathaniel Johnston, David W. Kribs - arXiv:0909.3907 - .. [2] "N. Johnston. Norms and Cones in the Theory of Quantum Entanglement. PhD thesis" - arXiv:1207.1479 + .. bibliography:: + :filter: docname in docnames + :raises ValueError: If dimension of the input matrix is not specified. :param mat: A matrix. @@ -186,7 +184,7 @@ def sk_operator_norm( # pylint: disable=too-many-locals ) # Use the upper bound of Proposition 4.2.11 of [3]. - upper_bound = min(upper_bound, kp_norm(realignment(mat, dim), k**2, 2)) + upper_bound = min(upper_bound, kp_norm(realignment(mat, dim), k ** 2, 2)) # Use the lower bound of Theorem 4.2.17 of [3]. if is_projection: @@ -204,7 +202,7 @@ def sk_operator_norm( # pylint: disable=too-many-locals lower_bound = max( lower_bound, (min(dim) - k) - * (rank + np.sqrt((prod_dim * rank - rank**2) / (prod_dim - 1))) + * (rank + np.sqrt((prod_dim * rank - rank ** 2) / (prod_dim - 1))) / (prod_dim * (min(dim) - 1)) + (k - 1) / (min(dim) - 1), ) @@ -215,10 +213,10 @@ def sk_operator_norm( # pylint: disable=too-many-locals # Use a randomized iterative method to try to improve the lower bound. if is_positive: - for _ in range(5**effort): + for _ in range(5 ** effort): lower_bound = max( lower_bound, - __lower_bound_sk_norm_randomized(mat, k, dim, tol**2), + __lower_bound_sk_norm_randomized(mat, k, dim, tol ** 2), ) # break out of the function if the target value has already been met diff --git a/toqito/matrix_props/trace_norm.py b/toqito/matrix_props/trace_norm.py index df7443f4e..de54fc67a 100644 --- a/toqito/matrix_props/trace_norm.py +++ b/toqito/matrix_props/trace_norm.py @@ -4,7 +4,7 @@ def trace_norm(rho: np.ndarray) -> float: r""" - Compute the trace norm of the state [WikTn]_. + Compute the trace norm of the state :cite:`Quantiki_TrNorm`. Also computes the operator 1-norm when inputting an operator. @@ -40,8 +40,9 @@ def trace_norm(rho: np.ndarray) -> float: References ========== - .. [WikTn] Quantiki: Trace norm - https://www.quantiki.org/wiki/trace-norm + .. bibliography:: + :filter: docname in docnames + :param rho: Density operator. :return: The trace norm of :code:`rho`. diff --git a/toqito/measurement_ops/measure.py b/toqito/measurement_ops/measure.py index 1828aeeb6..5456feac5 100644 --- a/toqito/measurement_ops/measure.py +++ b/toqito/measurement_ops/measure.py @@ -17,7 +17,7 @@ def measure(measurement: np.ndarray, state: np.ndarray) -> float: .. math:: \sum_{a \in \Sigma} \mu(a) = \mathbb{I}_{\mathcal{X}}. - Further information can be found here [WikMeas]_. + Further information can be found here :cite:`WikiQuantMeas`. Examples ========== @@ -63,8 +63,9 @@ def measure(measurement: np.ndarray, state: np.ndarray) -> float: References ========== - .. [WikMeas] Wikipedia: Measurement in quantum mechanics - https://en.wikipedia.org/wiki/Measurement_in_quantum_mechanics + .. bibliography:: + :filter: docname in docnames + :param measurement: The measurement to apply. :param state: The state to apply the measurement to. diff --git a/toqito/measurement_props/is_povm.py b/toqito/measurement_props/is_povm.py index fa898ee83..474457487 100644 --- a/toqito/measurement_props/is_povm.py +++ b/toqito/measurement_props/is_povm.py @@ -6,7 +6,7 @@ def is_povm(mat_list: list[np.ndarray]) -> bool: r""" - Determine if a list of matrices constitute a valid set of POVMs [WikPOVM]_. + Determine if a list of matrices constitute a valid set of POVMs :cite:`WikiPOVM`. A valid set of measurements are defined by a set of positive semidefinite operators @@ -85,8 +85,9 @@ def is_povm(mat_list: list[np.ndarray]) -> bool: References ========== - .. [WikPOVM] Wikipedia: POVM - https://en.wikipedia.org/wiki/POVM + .. bibliography:: + :filter: docname in docnames + :param mat_list: A list of matrices. :return: Return :code:`True` if set of matrices constitutes a set of diff --git a/toqito/nonlocal_games/extended_nonlocal_game.py b/toqito/nonlocal_games/extended_nonlocal_game.py index fa952b0e4..fe0d1f297 100644 --- a/toqito/nonlocal_games/extended_nonlocal_game.py +++ b/toqito/nonlocal_games/extended_nonlocal_game.py @@ -21,20 +21,14 @@ class ExtendedNonlocalGame: made by the referee, on its part of the shared quantum state, in addition to Alice and Bob's answers to the questions sent by the referee. - Extended nonlocal games were initially defined in [JMRW16]_ and more - information on these games can be found in [Russo17]_. + Extended nonlocal games were initially defined in :cite:`Johnston_2016_Extended` and more + information on these games can be found in :cite:`Russo_2017_Extended`. References ========== - .. [JMRW16] Nathaniel Johnston, Rajat Mittal, Vincent Russo, John Watrous - "Extended non-local games and monogamy-of-entanglement games", - Proceedings of the Royal Society A: Mathematical, Physical and - Engineering Sciences 472.2189 (2016), - https://arxiv.org/abs/1510.02083 - - .. [Russo17] Vincent Russo - "Extended nonlocal games" - https://arxiv.org/abs/1704.07375 + .. bibliography:: + :filter: docname in docnames + """ def __init__(self, prob_mat: np.ndarray, pred_mat: np.ndarray, reps: int = 1) -> None: @@ -65,18 +59,18 @@ def __init__(self, prob_mat: np.ndarray, pred_mat: np.ndarray, reps: int = 1) -> pred_mat2 = np.zeros( ( - dim_x**reps, - dim_y**reps, - num_alice_out**reps, - num_bob_out**reps, - num_alice_in**reps, - num_bob_in**reps, + dim_x ** reps, + dim_y ** reps, + num_alice_out ** reps, + num_bob_out ** reps, + num_alice_in ** reps, + num_bob_in ** reps, ) ) i_ind = np.zeros(reps, dtype=int) j_ind = np.zeros(reps, dtype=int) - for i in range(num_alice_in**reps): - for j in range(num_bob_in**reps): + for i in range(num_alice_in ** reps): + for j in range(num_bob_in ** reps): to_tensor = np.empty([reps, dim_x, dim_y, num_alice_out, num_bob_out]) for k in range(reps - 1, -1, -1): to_tensor[k] = pred_mat[:, :, :, :, i_ind[k], j_ind[k]] @@ -437,7 +431,7 @@ def commuting_measurement_value_upper_bound(self, k: int | str = 1) -> float: Compute an upper bound on the commuting measurement value of an extended nonlocal game. This function calculates an upper bound on the commuting measurement value by - using k-levels of the NPA hierarchy [NPA]_. The NPA hierarchy is a uniform family + using k-levels of the NPA hierarchy :cite:`Navascues_2008_AConvergent`. The NPA hierarchy is a uniform family of semidefinite programs that converges to the commuting measurement value of any extended nonlocal game. @@ -448,10 +442,8 @@ def commuting_measurement_value_upper_bound(self, k: int | str = 1) -> float: References ========== - .. [NPA] Miguel Navascues, Stefano Pironio, Antonio Acin, - "A convergent hierarchy of semidefinite programs characterizing the - set of quantum correlations." - https://arxiv.org/abs/0803.4290 + .. bibliography:: + :filter: docname in docnames :param k: The level of the NPA hierarchy to use (default=1). :return: The upper bound on the commuting strategy value of an extended nonlocal game. diff --git a/toqito/nonlocal_games/nonlocal_game.py b/toqito/nonlocal_games/nonlocal_game.py index 0e0daaf8c..ebd29711a 100644 --- a/toqito/nonlocal_games/nonlocal_game.py +++ b/toqito/nonlocal_games/nonlocal_game.py @@ -20,14 +20,13 @@ class NonlocalGame: are not allowed to communicate with each other once the game has started and who play cooperative against an adversary referred to as the referee. - The nonlocal game framework was originally introduced in [CHTW04_2]_. + The nonlocal game framework was originally introduced in :cite:`Cleve_2010_Consequences`. References ========== - .. [CHTW04_2] Cleve, Richard, Hoyer, Peter, Toner, Benjamin, and Watrous, John - "Consequences and limits of nonlocal strategies" - Computational Complexity 2004. Proceedings. 19th IEEE Annual Conference. - https://arxiv.org/abs/quant-ph/0404076 + .. bibliography:: + :filter: docname in docnames + """ def __init__(self, prob_mat: np.ndarray, pred_mat: np.ndarray, reps: int = 1) -> None: @@ -53,16 +52,16 @@ def __init__(self, prob_mat: np.ndarray, pred_mat: np.ndarray, reps: int = 1) -> pred_mat2 = np.zeros( ( - num_alice_out**reps, - num_bob_out**reps, - num_alice_in**reps, - num_bob_in**reps, + num_alice_out ** reps, + num_bob_out ** reps, + num_alice_in ** reps, + num_bob_in ** reps, ) ) i_ind = np.zeros(reps, dtype=int) j_ind = np.zeros(reps, dtype=int) - for i in range(num_alice_in**reps): - for j in range(num_bob_in**reps): + for i in range(num_alice_in ** reps): + for j in range(num_bob_in ** reps): to_tensor = np.empty([reps, num_alice_out, num_bob_out]) for k in range(reps - 1, -1, -1): to_tensor[k] = pred_mat[:, :, i_ind[k], j_ind[k]] @@ -115,7 +114,7 @@ def from_bcs_game(cls, constraints: list[np.ndarray], reps: int = 1) -> "Nonloca # Compute prediction matrix of outcomes given questions and answer pairs: # a: Alice's truth assignment to all variables in `c_x` # b: Bob's truth assignment for `v_y` in `c_x` - pred_mat = np.zeros((2**num_variables, 2, num_constraints, num_variables)) + pred_mat = np.zeros((2 ** num_variables, 2, num_constraints, num_variables)) for x_ques in range(num_constraints): for a_ans in range(pred_mat.shape[0]): # Convert to binary representation @@ -156,7 +155,7 @@ def classical_value(self) -> float: self.prob_mat[x_alice_in, y_bob_in] * self.pred_mat[:, :, x_alice_in, y_bob_in] ) p_win = float("-inf") - if num_alice_outputs**num_alice_inputs < num_bob_outputs**num_bob_inputs: + if num_alice_outputs ** num_alice_inputs < num_bob_outputs ** num_bob_inputs: self.pred_mat = np.transpose(self.pred_mat, (1, 0, 3, 2)) ( num_alice_outputs, @@ -172,7 +171,7 @@ def classical_value(self) -> float: # else: # parallel_threads = 5 - for i in range(num_alice_outputs**num_bob_inputs): + for i in range(num_alice_outputs ** num_bob_inputs): # Convert :code:`number` to the base :code:`base` with digits :code:`digits`. number = i base = num_bob_outputs @@ -196,7 +195,7 @@ def quantum_value_lower_bound( tol: float = 10e-6, ): r""" - Compute a lower bound on the quantum value of a nonlocal game [LD07]_. + Compute a lower bound on the quantum value of a nonlocal game :cite:`Liang_2007_Bounds`. Calculates a lower bound on the maximum value that the specified nonlocal game can take on in quantum mechanical settings where Alice and @@ -214,7 +213,7 @@ def quantum_value_lower_bound( number of times and keep the highest value obtained. The algorithm is based on the alternating projections algorithm as it - can be applied to Bell inequalities as shown in [LD07]_. + can be applied to Bell inequalities as shown in :cite:`Liang_2007_Bounds`. The alternating projection algorithm has also been referred to as the "see-saw" algorithm as it goes back and forth between the following two @@ -319,10 +318,9 @@ def quantum_value_lower_bound( References ========== - .. [LD07] Liang, Yeong-Cherng, and Andrew C. Doherty. - "Bounds on quantum correlations in Bell-inequality experiments." - Physical Review A 75.4 (2007): 042103. - https://arxiv.org/abs/quant-ph/0608128 + .. bibliography:: + :filter: docname in docnames + :param dim: The dimension of the quantum system that Alice and Bob have access to (default = 2). @@ -588,7 +586,7 @@ def commuting_measurement_value_upper_bound(self, k: int | str = 1) -> float: Compute an upper bound on the commuting measurement value of the nonlocal game. This function calculates an upper bound on the commuting measurement value by - using k-levels of the NPA hierarchy [NPA]_. The NPA hierarchy is a uniform family + using k-levels of the NPA hierarchy :cite:`Navascues_2008_AConvergent`. The NPA hierarchy is a uniform family of semidefinite programs that converges to the commuting measurement value of any nonlocal game. @@ -599,10 +597,8 @@ def commuting_measurement_value_upper_bound(self, k: int | str = 1) -> float: References ========== - .. [NPA] Miguel Navascues, Stefano Pironio, Antonio Acin, - "A convergent hierarchy of semidefinite programs characterizing the - set of quantum correlations." - https://arxiv.org/abs/0803.4290 + .. bibliography:: + :filter: docname in docnames :param k: The level of the NPA hierarchy to use (default=1). :return: The upper bound on the commuting strategy value of a nonlocal game. diff --git a/toqito/nonlocal_games/quantum_hedging.py b/toqito/nonlocal_games/quantum_hedging.py index efa3213e5..0c31744ef 100644 --- a/toqito/nonlocal_games/quantum_hedging.py +++ b/toqito/nonlocal_games/quantum_hedging.py @@ -11,7 +11,7 @@ class QuantumHedging: Calculate optimal winning probabilities for hedging scenarios. Calculate the maximal and minimal winning probabilities for quantum - hedging to occur in certain two-party scenarios [MW12]_, [AMR13]_. + hedging to occur in certain two-party scenarios :cite:`Arunachalam_2017_QuantumHedging, Molina_2012_Hedging`. Examples ========== @@ -28,7 +28,7 @@ class QuantumHedging: .. math:: v = \cos(\pi/8)|00\rangle + \sin(\pi/8)|11\rangle. - As was illustrated in [MW12]_, the hedging value of the above scenario is + As was illustrated in :cite:`Molina_2012_Hedging`, the hedging value of the above scenario is :math:`\cos(\pi/8)^2 \approx 0.8536` >>> from numpy import kron, cos, sin, pi, sqrt, isclose @@ -57,17 +57,10 @@ class QuantumHedging: References ========== - .. [MW12] Molina, Abel, and Watrous, John. - "Hedging bets with correlated quantum strategies." - Proceedings of the Royal Society A: - Mathematical, Physical and Engineering Sciences - 468.2145 (2012): 2614-2629. - https://arxiv.org/abs/1104.1140 - - .. [AMR13] Arunachalam, Srinivasan, Molina, Abel and Russo, Vincent. - "Quantum hedging in two-round prover-verifier interactions." - arXiv preprint arXiv:1310.7954 (2013). - https://arxiv.org/pdf/1310.7954.pdf + .. bibliography:: + :filter: docname in docnames + + """ def __init__(self, q_a: np.ndarray, num_reps: int) -> None: @@ -91,7 +84,7 @@ def __init__(self, q_a: np.ndarray, num_reps: int) -> None: # π(y1 ⊗ y2 ⊗ x1 ⊗ x2) = y1 ⊗ x1 ⊗ y2 ⊗ x2 # for all y1 ∈ Y1, y2 ∈ Y2, x1 ∈ X1, x2 ∈ X2.). l_1 = list(range(1, self._num_reps + 1)) - l_2 = list(range(self._num_reps + 1, self._num_reps**2 + 1)) + l_2 = list(range(self._num_reps + 1, self._num_reps ** 2 + 1)) if self._num_reps == 1: self._pperm = np.array([1]) else: @@ -123,10 +116,10 @@ def max_prob_outcome_a_primal(self) -> float: :return: The optimal maximal probability for obtaining outcome "a". """ - x_var = cvxpy.Variable((4**self._num_reps, 4**self._num_reps), PSD=True) + x_var = cvxpy.Variable((4 ** self._num_reps, 4 ** self._num_reps), PSD=True) objective = cvxpy.Maximize(cvxpy.trace(self._q_a.conj().T @ x_var)) constraints = [ - partial_trace(x_var, self._sys, self._dim) == np.identity(2**self._num_reps) + partial_trace(x_var, self._sys, self._dim) == np.identity(2 ** self._num_reps) ] problem = cvxpy.Problem(objective, constraints) @@ -153,10 +146,10 @@ def max_prob_outcome_a_dual(self) -> float: :return: The optimal maximal probability for obtaining outcome "a". """ - y_var = cvxpy.Variable((2**self._num_reps, 2**self._num_reps), hermitian=True) + y_var = cvxpy.Variable((2 ** self._num_reps, 2 ** self._num_reps), hermitian=True) objective = cvxpy.Minimize(cvxpy.trace(cvxpy.real(y_var))) - kron_var = cvxpy.kron(np.eye(2**self._num_reps), y_var) + kron_var = cvxpy.kron(np.eye(2 ** self._num_reps), y_var) if self._num_reps == 1: u_var = cvxpy.multiply(cvxpy.multiply(self._pperm, kron_var), self._pperm.conj().T) constraints = [cvxpy.real(u_var) >> self._q_a] @@ -191,10 +184,10 @@ def min_prob_outcome_a_primal(self) -> float: :return: The optimal minimal probability for obtaining outcome "a". """ - x_var = cvxpy.Variable((4**self._num_reps, 4**self._num_reps), PSD=True) + x_var = cvxpy.Variable((4 ** self._num_reps, 4 ** self._num_reps), PSD=True) objective = cvxpy.Minimize(cvxpy.trace(self._q_a.conj().T @ x_var)) constraints = [ - partial_trace(x_var, self._sys, self._dim) == np.identity(2**self._num_reps) + partial_trace(x_var, self._sys, self._dim) == np.identity(2 ** self._num_reps) ] problem = cvxpy.Problem(objective, constraints) @@ -221,10 +214,10 @@ def min_prob_outcome_a_dual(self) -> float: :return: The optimal minimal probability for obtaining outcome "a". """ - y_var = cvxpy.Variable((2**self._num_reps, 2**self._num_reps), hermitian=True) + y_var = cvxpy.Variable((2 ** self._num_reps, 2 ** self._num_reps), hermitian=True) objective = cvxpy.Maximize(cvxpy.trace(cvxpy.real(y_var))) - kron_var = cvxpy.kron(np.eye(2**self._num_reps), y_var) + kron_var = cvxpy.kron(np.eye(2 ** self._num_reps), y_var) if self._num_reps == 1: u_var = cvxpy.multiply(cvxpy.multiply(self._pperm, kron_var), self._pperm.conj().T) diff --git a/toqito/nonlocal_games/tests/test_extended_nonlocal_game.py b/toqito/nonlocal_games/tests/test_extended_nonlocal_game.py index c17bde21c..8f2a4298f 100644 --- a/toqito/nonlocal_games/tests/test_extended_nonlocal_game.py +++ b/toqito/nonlocal_games/tests/test_extended_nonlocal_game.py @@ -66,17 +66,17 @@ def moe_mub_4_in_3_out_game(): mub_0 = [e_0, e_1, e_2] mub_1 = [ (e_0 + e_1 + e_2) / np.sqrt(3), - (e_0 + eta**2 * e_1 + eta * e_2) / np.sqrt(3), - (e_0 + eta * e_1 + eta**2 * e_2) / np.sqrt(3), + (e_0 + eta ** 2 * e_1 + eta * e_2) / np.sqrt(3), + (e_0 + eta * e_1 + eta ** 2 * e_2) / np.sqrt(3), ] mub_2 = [ (e_0 + e_1 + eta * e_2) / np.sqrt(3), - (e_0 + eta**2 * e_1 + eta**2 * e_2) / np.sqrt(3), + (e_0 + eta ** 2 * e_1 + eta ** 2 * e_2) / np.sqrt(3), (e_0 + eta * e_1 + e_2) / np.sqrt(3), ] mub_3 = [ - (e_0 + e_1 + eta**2 * e_2) / np.sqrt(3), - (e_0 + eta**2 * e_1 + e_2) / np.sqrt(3), + (e_0 + e_1 + eta ** 2 * e_2) / np.sqrt(3), + (e_0 + eta ** 2 * e_1 + e_2) / np.sqrt(3), (e_0 + eta * e_1 + eta * e_2) / np.sqrt(3), ] diff --git a/toqito/nonlocal_games/tests/test_quantum_hedging.py b/toqito/nonlocal_games/tests/test_quantum_hedging.py index 043a19849..8bdb9a6fc 100644 --- a/toqito/nonlocal_games/tests/test_quantum_hedging.py +++ b/toqito/nonlocal_games/tests/test_quantum_hedging.py @@ -17,13 +17,13 @@ class TestQuantumHedging(unittest.TestCase): alpha = 1 / sqrt(2) theta = pi / 8 - w_var = alpha * cos(theta) * e_00 + sqrt(1 - alpha**2) * sin(theta) * e_11 + w_var = alpha * cos(theta) * e_00 + sqrt(1 - alpha ** 2) * sin(theta) * e_11 - l_1 = -alpha * sin(theta) * e_00 + sqrt(1 - alpha**2) * cos(theta) * e_11 + l_1 = -alpha * sin(theta) * e_00 + sqrt(1 - alpha ** 2) * cos(theta) * e_11 l_2 = alpha * sin(theta) * e_10 - l_3 = sqrt(1 - alpha**2) * cos(theta) * e_01 + l_3 = sqrt(1 - alpha ** 2) * cos(theta) * e_01 q_1 = w_var * w_var.conj().T q_0 = l_1 * l_1.conj().T + l_2 * l_2.conj().T + l_3 * l_3.conj().T diff --git a/toqito/nonlocal_games/xor_game.py b/toqito/nonlocal_games/xor_game.py index eea9999ed..25117d576 100644 --- a/toqito/nonlocal_games/xor_game.py +++ b/toqito/nonlocal_games/xor_game.py @@ -14,7 +14,7 @@ class XORGame: communicate during the game itself. The quantum value of an XOR game can be solved via the semidefinite program - from [CHTW04]_. + from :cite:`Cleve_2010_Consequences`. This function is adapted from the QETLAB package. @@ -24,7 +24,7 @@ class XORGame: The CHSH game The CHSH game is a two-player nonlocal game with the following probability - distribution and question and answer sets [CSUU08]_. + distribution and question and answer sets :cite:`Cleve_2008_Strong`. .. math:: \begin{equation} @@ -77,7 +77,7 @@ class XORGame: The odd cycle game - The odd cycle game is another XOR game [CHTW04]_. For this game, we can + The odd cycle game is another XOR game :cite:`Cleve_2010_Consequences`. For this game, we can specify the probability and predicate matrices as follows. >>> prob_mat = np.array( @@ -112,16 +112,10 @@ class XORGame: References ========== - .. [CSUU08] Richard Cleve, William Slofstra, Falk Unger, Sarvagya Upadhyay - "Strong parallel repetition theorem for quantum XOR proof systems", - 2008, - https://arxiv.org/abs/quant-ph/0608146 - - .. [CHTW04] Richard Cleve, Peter Hoyer, Ben Toner, John Watrous - "Consequences and limits of nonlocal strategies." - Proceedings. 19th IEEE Annual Conference on Computational Complexity, - IEEE, 2004. - https://arxiv.org/abs/quant-ph/0404076 + .. bibliography:: + :filter: docname in docnames + + """ def __init__( @@ -150,7 +144,7 @@ def __init__( q_0, q_1 = self.prob_mat.shape if tol is None: - self.tol = np.finfo(float).eps * q_0**2 * q_1**2 + self.tol = np.finfo(float).eps * q_0 ** 2 * q_1 ** 2 else: self.tol = tol @@ -179,7 +173,7 @@ def quantum_value(self) -> float: To obtain the quantum value of the XOR game, we calculate the following simplified dual problem of the semidefinite program from the set of - notes: https://cs.uwaterloo.ca/~watrous/CS867.Winter2017/Notes/06.pdf + notes: Lecture 6 of :cite:`Watrous_2011_Lecture_Notes` .. math:: \begin{equation} diff --git a/toqito/perms/antisymmetric_projection.py b/toqito/perms/antisymmetric_projection.py index 58fa9432d..254b68c0a 100644 --- a/toqito/perms/antisymmetric_projection.py +++ b/toqito/perms/antisymmetric_projection.py @@ -8,7 +8,7 @@ def antisymmetric_projection(dim: int, p_param: int = 2, partial: bool = False) -> sparse.lil_matrix: r""" - Produce the projection onto the antisymmetric subspace [WikAsym]_. + Produce the projection onto the antisymmetric subspace :cite:`WikiAsymmOp`. Produces the orthogonal projection onto the anti-symmetric subspace of :code:`p_param` copies of :code:`dim`-dimensional space. If :code:`partial = True`, then the antisymmetric projection (PA) isn't the @@ -66,15 +66,16 @@ def antisymmetric_projection(dim: int, p_param: int = 2, partial: bool = False) References ========== - .. [WikAsym] Wikipedia: Anti-symmetric operator - https://en.wikipedia.org/wiki/Anti-symmetric_operator + .. bibliography:: + :filter: docname in docnames + :param dim: The dimension of the local systems. :param p_param: Default value of 2. :param partial: Default value of 0. :return: Projection onto the antisymmetric subspace. """ - dimp = dim**p_param + dimp = dim ** p_param if p_param == 1: return sparse.eye(dim) diff --git a/toqito/perms/perfect_matchings.py b/toqito/perms/perfect_matchings.py index 3f1f436ab..5b51a746e 100644 --- a/toqito/perms/perfect_matchings.py +++ b/toqito/perms/perfect_matchings.py @@ -12,7 +12,7 @@ def perfect_matchings(num: list[int] | int | np.ndarray) -> np.ndarray: Returns all perfect matchings of a given list of objects. That is, it returns all ways of grouping an even number of objects into pairs. - This function is adapted from QETLAB. + This function is adapted from QETLAB. :cite:`QETLAB_link`. Examples ========== @@ -25,6 +25,11 @@ def perfect_matchings(num: list[int] | int | np.ndarray) -> np.ndarray: [1 3 2 4] [1 4 3 2]] + References + ========== + .. bibliography:: + :filter: docname in docnames + :param num: Either an even integer, indicating that you would like all perfect matchings of the integers 1,2, ... N, or a `list` or `np.array` containing an even number of distinct entries, indicating that you would like all perfect matchings of those entries. diff --git a/toqito/perms/perm_sign.py b/toqito/perms/perm_sign.py index 09748f372..317b5bef9 100644 --- a/toqito/perms/perm_sign.py +++ b/toqito/perms/perm_sign.py @@ -5,7 +5,7 @@ def perm_sign(perm: np.ndarray | list[int]) -> float: """ - Compute the "sign" of a permutation [WikParPerm]_. + Compute the "sign" of a permutation :cite:`WikiParPerm`. The sign (either -1 or 1) of the permutation :code:`perm` is :code:`-1**`inv`, where :code:`inv` is the number of inversions contained in :code:`perm`. @@ -39,8 +39,9 @@ def perm_sign(perm: np.ndarray | list[int]) -> float: References ========== - .. [WikParPerm] Wikipedia: Parity of a permutation - https://en.wikipedia.org/wiki/Parity_of_a_permutation + .. bibliography:: + :filter: docname in docnames + :param perm: The permutation vector to be checked. :return: The value 1 if the permutation is of even length and the value of diff --git a/toqito/perms/permutation_operator.py b/toqito/perms/permutation_operator.py index d2ef1522b..f83afd5b8 100644 --- a/toqito/perms/permutation_operator.py +++ b/toqito/perms/permutation_operator.py @@ -43,6 +43,7 @@ def permutation_operator( [0., 0., 1., 0.], [0., 1., 0., 0.], [0., 0., 0., 1.]] + :param dim: The dimensions of the subsystems to be permuted. :param perm: A permutation vector. diff --git a/toqito/perms/permute_systems.py b/toqito/perms/permute_systems.py index 5c47b4c5d..2b9a4e77b 100644 --- a/toqito/perms/permute_systems.py +++ b/toqito/perms/permute_systems.py @@ -129,6 +129,7 @@ def permute_systems( [49 53 50 54 51 55 52 56] [25 29 26 30 27 31 28 32] [57 61 58 62 59 63 60 64]] + :raises ValueError: If dimension does not match the number of subsystems. :param input_mat: The vector or matrix. diff --git a/toqito/perms/swap.py b/toqito/perms/swap.py index f6f50fc25..9dd78c634 100644 --- a/toqito/perms/swap.py +++ b/toqito/perms/swap.py @@ -95,6 +95,8 @@ def swap( >>> swap(test_vec) [1 3 2 4] + + :raises ValueError: If dimension does not match the number of subsystems. :param rho: A vector or matrix to have its subsystems swapped. :param sys: Default: [1, 2] diff --git a/toqito/perms/swap_operator.py b/toqito/perms/swap_operator.py index 786a5264f..1f999f9a9 100644 --- a/toqito/perms/swap_operator.py +++ b/toqito/perms/swap_operator.py @@ -49,6 +49,7 @@ def swap_operator(dim: list[int] | int, is_sparse: bool = False) -> np.ndarray: [0., 0., 0., 0., 0., 1., 0., 0., 0.], [0., 0., 0., 0., 0., 0., 0., 0., 1.]] + :param dim: The dimensions of the subsystems. :param is_sparse: Sparse if :code:`True` and non-sparse if :code:`False`. :return: The swap operator of dimension :code:`dim`. diff --git a/toqito/perms/symmetric_projection.py b/toqito/perms/symmetric_projection.py index d452f91e0..e497185a8 100644 --- a/toqito/perms/symmetric_projection.py +++ b/toqito/perms/symmetric_projection.py @@ -10,7 +10,7 @@ def symmetric_projection( dim: int, p_val: int = 2, partial: bool = False ) -> [np.ndarray, scipy.sparse.lil_matrix]: r""" - Produce the projection onto the symmetric subspace [CJKLZ14]_. + Produce the projection onto the symmetric subspace :cite:`Chen_2014_Symmetric`. For a complex Euclidean space :math:`\mathcal{X}` and a positive integer :math:`n`, the projection onto the symmetric subspace is given by @@ -66,11 +66,9 @@ def symmetric_projection( dim: int, p_val: int = 2, partial: bool = False ) -> [ References ========== - .. [CJKLZ14] J. Chen, Z. Ji, D. Kribs, N. Lütkenhaus, and B. Zeng. - "Symmetric extension of two-qubit states". - Physical Review A 90.3 (2014): 032318. - https://arxiv.org/abs/1310.3530 - E-print: arXiv:1310.3530 [quant-ph] + .. bibliography:: + :filter: docname in docnames + :param dim: The dimension of the local systems. :param p_val: Default value of 2. diff --git a/toqito/perms/unique_perms.py b/toqito/perms/unique_perms.py index 501ac05cc..6a52f5b62 100644 --- a/toqito/perms/unique_perms.py +++ b/toqito/perms/unique_perms.py @@ -30,6 +30,8 @@ def unique_perms(elements: list[int]): >>> len(list(unique_perms(vec_nums))) 4200 + + :param elements: List of integers. :return: The number of possible permutations possible. """ diff --git a/toqito/rand/random_density_matrix.py b/toqito/rand/random_density_matrix.py index e6626d772..291bd708a 100644 --- a/toqito/rand/random_density_matrix.py +++ b/toqito/rand/random_density_matrix.py @@ -72,6 +72,7 @@ def random_density_matrix( >>> is_density(bures_mat) True + :param dim: The number of rows (and columns) of the density matrix. :param is_real: Boolean denoting whether the returned matrix will have all real entries or not. diff --git a/toqito/rand/random_ginibre.py b/toqito/rand/random_ginibre.py index 4aa149f48..8724d29fe 100644 --- a/toqito/rand/random_ginibre.py +++ b/toqito/rand/random_ginibre.py @@ -4,14 +4,14 @@ def random_ginibre(dim_n: int, dim_m: int) -> np.ndarray: r""" - Generate a Ginibre random matrix [WIKCIRC]_. + Generate a Ginibre random matrix :cite:`WikiCircLaw`. Generates a random :code:`dim_n`-by-:code:`dim_m` Ginibre matrix. A *Ginibre random matrix* is a matrix with independent and identically distributed complex standard Gaussian entries. - Ginibre random matrices are used in the construction of Wishart-random POVMs [HMN20]_. + Ginibre random matrices are used in the construction of Wishart-random POVMs :cite:`Heinosaari_2020_Random`. Examples ========== @@ -25,13 +25,9 @@ def random_ginibre(dim_n: int, dim_m: int) -> np.ndarray: References ========== + .. bibliography:: + :filter: docname in docnames - .. [WIKCIRC] Wikipedia: Circular law - https://en.wikipedia.org/wiki/Circular_law - - .. [HMN20] Heinosaari, Teiko, Maria Anastasia Jivulescu, and Ion Nechita. - "Random positive operator valued measures." - Journal of Mathematical Physics 61.4 (2020): 042202. :param dim_n: The number of rows of the Ginibre random matrix. :param dim_m: The number of columns of the Ginibre random matrix. diff --git a/toqito/rand/random_povm.py b/toqito/rand/random_povm.py index 289f7e0fd..1cbf09596 100644 --- a/toqito/rand/random_povm.py +++ b/toqito/rand/random_povm.py @@ -4,7 +4,7 @@ def random_povm(dim: int, num_inputs: int, num_outputs: int) -> np.ndarray: """ - Generate random positive operator valued measurements (POVMs) [WIKPOVM]_. + Generate random positive operator valued measurements (POVMs) :cite:`WikiPOVM`. Examples ========== @@ -37,8 +37,10 @@ def random_povm(dim: int, num_inputs: int, num_outputs: int) -> np.ndarray: References ========== - .. [WIKPOVM] Wikipedia: POVM - https://en.wikipedia.org/wiki/POVM + .. bibliography:: + :filter: docname in docnames + + :param dim: The dimensions of the measurements. :param num_inputs: The number of inputs for the measurement. diff --git a/toqito/rand/random_state_vector.py b/toqito/rand/random_state_vector.py index f7bbca79c..8cdf4d212 100644 --- a/toqito/rand/random_state_vector.py +++ b/toqito/rand/random_state_vector.py @@ -28,6 +28,8 @@ def random_state_vector(dim: list[int] | int, is_real: bool = False, k_param: in >>> is_pure(dm) True + + :param dim: The number of rows (and columns) of the unitary matrix. :param is_real: Boolean denoting whether the returned matrix has real entries or not. Default is :code:`False`. diff --git a/toqito/rand/random_unitary.py b/toqito/rand/random_unitary.py index 722381ee1..148600c4d 100644 --- a/toqito/rand/random_unitary.py +++ b/toqito/rand/random_unitary.py @@ -4,7 +4,7 @@ def random_unitary(dim: list[int] | int, is_real: bool = False) -> np.ndarray: """ - Generate a random unitary or orthogonal matrix [MO09]_. + Generate a random unitary or orthogonal matrix :cite:`Ozols_2009_RandU`. Calculates a random unitary matrix (if :code:`is_real = False`) or a random real orthogonal matrix (if :code:`is_real = True`), uniformly distributed according to the Haar measure. @@ -61,10 +61,9 @@ def random_unitary(dim: list[int] | int, is_real: bool = False) -> np.ndarray: References ========== - .. [MO09] How to generate a random unitary matrix, - Maris Ozols - March 16, 2009, - home.lu.lv/~sd20008/papers/essays/Random%20unitary%20%5Bpaper%5D.pdf + .. bibliography:: + :filter: docname in docnames + :param dim: The number of rows (and columns) of the unitary matrix. :param is_real: Boolean denoting whether the returned matrix has real diff --git a/toqito/state_metrics/bures_angle.py b/toqito/state_metrics/bures_angle.py index 6979f6778..80735def6 100644 --- a/toqito/state_metrics/bures_angle.py +++ b/toqito/state_metrics/bures_angle.py @@ -6,7 +6,7 @@ def bures_angle(rho_1: np.ndarray, rho_2: np.ndarray, decimals: int = 10) -> float: r""" - Compute the Bures angle of two density matrices [WikBures]_. + Compute the Bures angle of two density matrices :cite:`WikiBures`. Calculate the Bures angle between two density matrices :code:`rho_1` and :code:`rho_2` defined by: @@ -52,8 +52,8 @@ def bures_angle(rho_1: np.ndarray, rho_2: np.ndarray, decimals: int = 10) -> flo References ========== - .. [WikBures] Wikipedia: Bures distance - https://en.wikipedia.org/wiki/Bures_metric#Bures_distance + .. bibliography:: + :filter: docname in docnames :raises ValueError: If matrices are not of equal dimension. :param rho_1: Density operator. diff --git a/toqito/state_metrics/bures_distance.py b/toqito/state_metrics/bures_distance.py index 3ae138d87..72de712ce 100644 --- a/toqito/state_metrics/bures_distance.py +++ b/toqito/state_metrics/bures_distance.py @@ -6,7 +6,7 @@ def bures_distance(rho_1: np.ndarray, rho_2: np.ndarray, decimals: int = 10) -> float: r""" - Compute the Bures distance of two density matrices [WikBures]_. + Compute the Bures distance of two density matrices :cite:`WikiBures`. Calculate the Bures distance between two density matrices :code:`rho_1` and :code:`rho_2` defined by: @@ -52,8 +52,9 @@ def bures_distance(rho_1: np.ndarray, rho_2: np.ndarray, decimals: int = 10) -> References ========== - .. [WikBures] Wikipedia: Bures metric - https://en.wikipedia.org/wiki/Bures_metric + .. bibliography:: + :filter: docname in docnames + :raises ValueError: If matrices are not of equal dimension. :param rho_1: Density operator. diff --git a/toqito/state_metrics/fidelity.py b/toqito/state_metrics/fidelity.py index 860cf3bea..a8a455691 100644 --- a/toqito/state_metrics/fidelity.py +++ b/toqito/state_metrics/fidelity.py @@ -8,7 +8,7 @@ def fidelity(rho: np.ndarray, sigma: np.ndarray) -> float: r""" - Compute the fidelity of two density matrices [WikFid]_. + Compute the fidelity of two density matrices :cite:`WikiFidQuant`. Calculate the fidelity between the two density matrices :code:`rho` and :code:`sigma`, defined by: @@ -54,8 +54,9 @@ def fidelity(rho: np.ndarray, sigma: np.ndarray) -> float: References ========== - .. [WikFid] Wikipedia: Fidelity of quantum states - https://en.wikipedia.org/wiki/Fidelity_of_quantum_states + .. bibliography:: + :filter: docname in docnames + :raises ValueError: If matrices are not density operators. :param rho: Density operator. diff --git a/toqito/state_metrics/fidelity_of_separability.py b/toqito/state_metrics/fidelity_of_separability.py index 70059ffaf..2e0b208e1 100644 --- a/toqito/state_metrics/fidelity_of_separability.py +++ b/toqito/state_metrics/fidelity_of_separability.py @@ -18,22 +18,27 @@ def fidelity_of_separability( solver_option: str = "cvxopt", ) -> float: r""" - Define the first benchmark introduced in Appendix H of [Phil23]_. + Define the first benchmark introduced in Appendix H of :cite:`Philip_2023_Schrodinger`. If you would like to instead use the benchmark introduced in Appendix I, go to :obj:`toqito.channel_metrics.fidelity_of_separability`. - In [Phil23]_ a variational quantum algorithm (VQA) is introduced to test the separability of a general bipartite - state. The algorithm utilizes quantum steering between two separated systems such that the separability of the state - is quantified. + In :cite:`Philip_2023_Schrodinger` a variational quantum algorithm (VQA) is introduced to test + the separability of a general bipartite state. The algorithm utilizes + quantum steering between two separated systems such that the separability + of the state is quantified. - Due to the limitations of currently available quantum computers, two optimization semidefinite programs (SDP) - benchmarks were introduced to maximize the fidelity of separability subject to some state constraints (Positive - Partial Transpose (PPT), symmetric extensions (k-extendibility ) [Hay12]_ ) This function approximates the fidelity - of separability by maximizing over PPT states & k-extendible states i.e. an optimization problem over states - [TBWat18]_ . + Due to the limitations of currently available quantum computers, two + optimization semidefinite programs (SDP) benchmarks were introduced to + maximize the fidelity of separability subject to some state constraints + (Positive Partial Transpose (PPT), symmetric extensions (k-extendibility + ) :cite:`Hayden_2013_TwoMessage` ) This function approximites the fidelity of separability by + maximizing over PPT states & k-extendible states i.e. an optimization + problem over states :cite:`Watrous_2018_TQI`. + + The following expression (Equation (H2) from :cite:`Philip_2023_Schrodinger` ) defines the + constraints for approxiamting - The following expression (Equation (H2) from [Phil23]_ ) defines the constraints for approximating :math:`\sqrt{\widetilde{F}_s^1}(\rho_{AB}) {:}=` .. math:: @@ -69,7 +74,7 @@ def fidelity_of_separability( :math:`B_1, B_2, \ldots , B_{k}` which has no effect on the k-extended state :math:`\sigma_{AB^{k}}`. - The other constraints are due to the PPT condition [Per96]_. + The other constraints are due to the PPT condition :cite:`Peres_1996_Separability`. Examples ========== @@ -96,22 +101,9 @@ def fidelity_of_separability( References ========== - .. [Hay12] Hayden, Patrick et.al. - "Two-message quantum interactive proofs and the quantum separability problem." - Proceedings of the 28th IEEE Conference on Computational Complexity, pages 156-167. - https://arxiv.org/abs/1211.6120 - - .. [Per96] Peres, Asher. - "Separability Criterion for Density Matrices" - https://arxiv.org/abs/quant-ph/9604005 - - .. [Phil23] Philip, Aby et.al. - "Quantum Steering Algorithm for Estimating Fidelity of Separability" - https://arxiv.org/abs/2303.07911 - - .. [TBWat18] Watrous, John. - “The Theory of Quantum Information” - Cambridge University Press, 2018 + .. bibliography:: + :filter: docname in docnames + :param input_state_rho: the density matrix for the bipartite state of interest. :param input_state_rho_dims: the dimensions of System A & B respectively in @@ -148,7 +140,7 @@ def fidelity_of_separability( # Extend the number of dimensions based on the level `k`. new dims for AB with k-extendibility in subsystem B dim_direct_sum_ab_k = [dim_a] + [dim_b] * (k) # new dims for a linear op acting on the space of sigma_ab_k - dim_op_sigma_ab_k = dim_a * dim_b**k + dim_op_sigma_ab_k = dim_a * dim_b ** k # A list of the symmetrically extended subsystems based on the level `k`. sub_sys_ext = list(range(2, 2 + k - 1)) @@ -187,4 +179,4 @@ def fidelity_of_separability( problem.add_constraint(picos.partial_transpose(sigma_ab_k, sys, dim_direct_sum_ab_k) >> 0) solution = problem.solve(solver=solver_option) - return solution.value**2 + return solution.value ** 2 diff --git a/toqito/state_metrics/helstrom_holevo.py b/toqito/state_metrics/helstrom_holevo.py index aebc58aaf..38bdcf6e8 100644 --- a/toqito/state_metrics/helstrom_holevo.py +++ b/toqito/state_metrics/helstrom_holevo.py @@ -6,10 +6,10 @@ def helstrom_holevo(rho: np.ndarray, sigma: np.ndarray) -> float: r""" - Compute the Helstrom-Holevo distance between density matrices [WikHeHo]_. + Compute the Helstrom-Holevo distance between density matrices :cite:`WikiHolevo`. - In general, the best success probability to discriminate two mixed states represented by :math:`\rho` and - :math:`\sigma` is given by [WikHeHo]_. + In general, the best success probability to discriminate two mixed states represented by + :math:`\rho` and :math:`\sigma` is given by :cite:`WikiHolevo`. .. math:: \frac{1}{2}+\frac{1}{2} \left(\frac{1}{2} \left|\rho - \sigma \right|_1\right). @@ -50,8 +50,9 @@ def helstrom_holevo(rho: np.ndarray, sigma: np.ndarray) -> float: References ========== - .. [WikHeHo] Wikipedia: Holevo's theorem. - https://en.wikipedia.org/wiki/Holevo%27s_theorem + .. bibliography:: + :filter: docname in docnames + :raises ValueError: If matrices are not density operators. :param rho: Density operator. diff --git a/toqito/state_metrics/hilbert_schmidt.py b/toqito/state_metrics/hilbert_schmidt.py index 8653bd9c6..ba8d2c522 100644 --- a/toqito/state_metrics/hilbert_schmidt.py +++ b/toqito/state_metrics/hilbert_schmidt.py @@ -6,7 +6,7 @@ def hilbert_schmidt(rho: np.ndarray, sigma: np.ndarray) -> float: r""" - Compute the Hilbert-Schmidt distance between two states [WikHS]_. + Compute the Hilbert-Schmidt distance between two states :cite:`WikiHilbSchOp`. The Hilbert-Schmidt distance between density operators :math:`\rho` and :math:`\sigma` is defined as @@ -29,8 +29,10 @@ def hilbert_schmidt(rho: np.ndarray, sigma: np.ndarray) -> float: References ========== - .. [WikHS] Wikipedia: Hilbert-Schmidt operator. - https://en.wikipedia.org/wiki/Hilbert%E2%80%93Schmidt_operator + .. bibliography:: + :filter: docname in docnames + + :raises ValueError: If matrices are not density operators. :param rho: An input matrix. diff --git a/toqito/state_metrics/hilbert_schmidt_inner_product.py b/toqito/state_metrics/hilbert_schmidt_inner_product.py index 05530666a..2e7a1ef85 100644 --- a/toqito/state_metrics/hilbert_schmidt_inner_product.py +++ b/toqito/state_metrics/hilbert_schmidt_inner_product.py @@ -4,7 +4,7 @@ def hilbert_schmidt_inner_product(a_mat: np.ndarray, b_mat: np.ndarray) -> complex: r""" - Compute the Hilbert-Schmidt inner product between two matrices [WikHSO]_. + Compute the Hilbert-Schmidt inner product between two matrices :cite:`WikiHilbSchOp`. The Hilbert-Schmidt inner product between :code:`a_mat` and :code:`b_mat` is defined as @@ -14,7 +14,7 @@ def hilbert_schmidt_inner_product(a_mat: np.ndarray, b_mat: np.ndarray) -> compl where :math:`|B\rangle = \text{vec}(B)` and :math:`\langle A|` is the dual vector to :math:`|A \rangle`. - Note: This function has been adapted from [Rigetti21]_. + Note: This function has been adapted from :cite:`Rigetti_2022_Forest`. Examples ========== @@ -29,10 +29,9 @@ def hilbert_schmidt_inner_product(a_mat: np.ndarray, b_mat: np.ndarray) -> compl References ========== - .. [WikHSO] Wikipedia: Hilbert-Schmidt operator. - https://en.wikipedia.org/wiki/Hilbert%E2%80%93Schmidt_operator - .. [Rigetti21] Forest Benchmarking (Rigetti). - https://github.com/rigetti/forest-benchmarking + .. bibliography:: + :filter: docname in docnames + :param a_mat: An input matrix provided as a numpy array. :param b_mat: An input matrix provided as a numpy array. diff --git a/toqito/state_metrics/matsumoto_fidelity.py b/toqito/state_metrics/matsumoto_fidelity.py index a6ec2218b..6026086c9 100644 --- a/toqito/state_metrics/matsumoto_fidelity.py +++ b/toqito/state_metrics/matsumoto_fidelity.py @@ -8,7 +8,7 @@ def matsumoto_fidelity(rho: np.ndarray, sigma: np.ndarray) -> float: r""" - Compute the Matsumoto fidelity of two density matrices [Mat10]_. + Compute the Matsumoto fidelity of two density matrices :cite:`Matsumoto_2010_Reverse`. Calculate the Matsumoto fidelity between the two density matrices :code:`rho` and :code:`sigma`, defined by: @@ -64,9 +64,9 @@ def matsumoto_fidelity(rho: np.ndarray, sigma: np.ndarray) -> float: References ========== - .. [Mat10] Keiji Matsumoto. - "Reverse test and quantum analogue of classical fidelity and generalized fidelity" - https://arxiv.org/abs/1006.0302 + .. bibliography:: + :filter: docname in docnames + :raises ValueError: If matrices are not of equal dimension. :param rho: Density operator. diff --git a/toqito/state_metrics/sub_fidelity.py b/toqito/state_metrics/sub_fidelity.py index a1a087796..915369007 100644 --- a/toqito/state_metrics/sub_fidelity.py +++ b/toqito/state_metrics/sub_fidelity.py @@ -6,7 +6,7 @@ def sub_fidelity(rho: np.ndarray, sigma: np.ndarray) -> float: r""" - Compute the sub fidelity of two density matrices [MPHUZSub08]_. + Compute the sub fidelity of two density matrices :cite:`Miszczak_2008_Sub`. The sub-fidelity is a measure of similarity between density operators. It is defined as @@ -53,10 +53,9 @@ def sub_fidelity(rho: np.ndarray, sigma: np.ndarray) -> float: References ========== - .. [MPHUZSub08] J. A. Miszczak, Z. Puchała, P. Horodecki, A. Uhlmann, K. Życzkowski - "Sub--and super--fidelity as bounds for quantum fidelity." - arXiv preprint arXiv:0805.2037 (2008). - https://arxiv.org/abs/0805.2037 + .. bibliography:: + :filter: docname in docnames + :raises ValueError: If matrices are not of equal dimension. :param rho: Density operator. diff --git a/toqito/state_metrics/trace_distance.py b/toqito/state_metrics/trace_distance.py index e9a0ccd29..fa7d436ac 100644 --- a/toqito/state_metrics/trace_distance.py +++ b/toqito/state_metrics/trace_distance.py @@ -14,7 +14,7 @@ def trace_distance(rho: np.ndarray, sigma: np.ndarray) -> float: \delta(\rho, \sigma) = \frac{1}{2} \left( \text{Tr}(\left| \rho - \sigma \right| \right). - More information on the trace distance can be found in [WIKTD]_. + More information on the trace distance can be found in :cite:`Quantiki_TrDist`. Examples ========== @@ -46,9 +46,9 @@ def trace_distance(rho: np.ndarray, sigma: np.ndarray) -> float: References ========== - .. [WIKTD] Quantiki: Trace distance - https://www.quantiki.org/wiki/trace-distance - + .. bibliography:: + :filter: docname in docnames + :raises ValueError: If matrices are not of density operators. :param rho: An input matrix. :param sigma: An input matrix. diff --git a/toqito/state_ops/pure_to_mixed.py b/toqito/state_ops/pure_to_mixed.py index 6331d783a..789ea5d0a 100644 --- a/toqito/state_ops/pure_to_mixed.py +++ b/toqito/state_ops/pure_to_mixed.py @@ -47,6 +47,8 @@ def pure_to_mixed(phi: np.ndarray) -> np.ndarray: [0. , 0. , 0. , 0. ], [0.5, 0. , 0. , 0.5]]) + + :raises ValueError: If matrix is not square. :param phi: A density matrix or a pure state vector. :return: density matrix representation of :code:`phi`, regardless of whether :code:`phi` is diff --git a/toqito/state_ops/schmidt_decomposition.py b/toqito/state_ops/schmidt_decomposition.py index 66f8da0e3..c780ecbbd 100644 --- a/toqito/state_ops/schmidt_decomposition.py +++ b/toqito/state_ops/schmidt_decomposition.py @@ -8,7 +8,7 @@ def schmidt_decomposition( rho: np.ndarray, dim: int | list[int] | np.ndarray = None, k_param: int = 0 ) -> tuple[np.ndarray, np.ndarray, np.ndarray]: r""" - Compute the Schmidt decomposition of a bipartite vector [WikSD]_. + Compute the Schmidt decomposition of a bipartite vector :cite:`WikiScmidtDecomp`. Examples ========== @@ -55,8 +55,9 @@ def schmidt_decomposition( References ========== - .. [WikSD] Wikipedia: Schmidt decomposition - https://en.wikipedia.org/wiki/Schmidt_decomposition + .. bibliography:: + :filter: docname in docnames + :raises ValueError: If matrices are not of equal dimension. :param rho: A bipartite quantum state to compute the Schmidt decomposition of. diff --git a/toqito/state_opt/optimal_clone.py b/toqito/state_opt/optimal_clone.py index 2c419e981..40def675f 100644 --- a/toqito/state_opt/optimal_clone.py +++ b/toqito/state_opt/optimal_clone.py @@ -16,7 +16,7 @@ def optimal_clone( strategy: bool = False, ) -> float | np.ndarray: r""" - Compute probability of counterfeiting quantum money [MVW12]_. + Compute probability of counterfeiting quantum money :cite:`Molina_2012_Optimal`. The primal problem for the :math:`n`-fold parallel repetition is given as follows: @@ -52,7 +52,7 @@ def optimal_clone( Examples ========== - Wiesner's original quantum money scheme [Wies83]_ was shown in [MVW12]_ to have an optimal + Wiesner's original quantum money scheme :cite:`Wiesner_1983_Conjugate` was shown in :cite:`Molina_2012_Optimal` to have an optimal probability of 3/4 for succeeding a counterfeiting attack. Specifically, in the single-qubit case, Wiesner's quantum money scheme corresponds to the @@ -90,17 +90,9 @@ def optimal_clone( References ========== - .. [MVW12] Abel Molina, Thomas Vidick, and John Watrous. - "Optimal counterfeiting attacks and generalizations for Wiesner’s - quantum money." - Conference on Quantum Computation, Communication, and Cryptography. - Springer, Berlin, Heidelberg, 2012. - https://arxiv.org/abs/1202.4010 - - .. [Wies83] Stephen Wiesner - "Conjugate coding." - ACM Sigact News 15.1 (1983): 78-88. - https://dl.acm.org/doi/pdf/10.1145/1008908.1008920 + .. bibliography:: + :filter: docname in docnames + :param states: A list of states provided as either matrices or vectors. :param probs: Respective list of probabilities each state is selected. @@ -167,7 +159,7 @@ def primal_problem(q_a: np.ndarray, pperm: np.ndarray, num_reps: int) -> float: dim = 2 * np.ones((1, num_spaces * num_reps)).astype(int).flatten() dim = dim.tolist() - x_var = cvxpy.Variable((8**num_reps, 8**num_reps), hermitian=True) + x_var = cvxpy.Variable((8 ** num_reps, 8 ** num_reps), hermitian=True) if num_reps == 1: objective = cvxpy.Maximize(cvxpy.trace(cvxpy.real(q_a.conj().T @ x_var))) else: @@ -175,7 +167,7 @@ def primal_problem(q_a: np.ndarray, pperm: np.ndarray, num_reps: int) -> float: cvxpy.trace(cvxpy.real(pperm @ q_a.conj().T @ pperm.conj().T @ x_var)) ) constraints = [ - partial_trace(x_var, sys, dim) == np.identity(2**num_reps), + partial_trace(x_var, sys, dim) == np.identity(2 ** num_reps), x_var >> 0, ] problem = cvxpy.Problem(objective, constraints) @@ -189,10 +181,10 @@ def dual_problem(q_a: np.ndarray, pperm: np.ndarray, num_reps: int) -> float: :return: The optimal value of performing a counterfeit attack. """ - y_var = cvxpy.Variable((2**num_reps, 2**num_reps), hermitian=True) + y_var = cvxpy.Variable((2 ** num_reps, 2 ** num_reps), hermitian=True) objective = cvxpy.Minimize(cvxpy.trace(cvxpy.real(y_var))) - kron_var = cvxpy.kron(cvxpy.kron(np.eye(2**num_reps), np.eye(2**num_reps)), y_var) + kron_var = cvxpy.kron(cvxpy.kron(np.eye(2 ** num_reps), np.eye(2 ** num_reps)), y_var) if num_reps == 1: constraints = [cvxpy.real(kron_var) >> q_a] diff --git a/toqito/state_opt/ppt_distinguishability.py b/toqito/state_opt/ppt_distinguishability.py index f67bc9303..59ba19225 100644 --- a/toqito/state_opt/ppt_distinguishability.py +++ b/toqito/state_opt/ppt_distinguishability.py @@ -14,12 +14,12 @@ def ppt_distinguishability( strategy: bool = False, ) -> float: r""" - Compute probability of optimally distinguishing a state via PPT measurements [COS13]_. + Compute probability of optimally distinguishing a state via PPT measurements :cite:`Cosentino_2013_PPT`. Implements the semidefinite program (SDP) whose optimal value is equal to the maximum probability of perfectly distinguishing orthogonal maximally entangled states using any PPT measurement; a measurement whose operators are positive under partial transpose. This SDP was - explicitly provided in [COS13]_. + explicitly provided in :cite:`Cosentino_2013_PPT`. One can specify the distinguishability method using the :code:`dist_method` argument. @@ -44,7 +44,7 @@ def ppt_distinguishability( \end{aligned} \end{equation} - It was illustrated in [YDY12]_ that for the following set of states + It was illustrated in :cite:`Yu_2012_Four` that for the following set of states .. math:: \begin{equation} @@ -57,7 +57,7 @@ def ppt_distinguishability( \end{equation} that the optimal probability of distinguishing via a PPT measurement should yield - :math:`7/8 \approx 0.875` as was proved in [YDY12]_. + :math:`7/8 \approx 0.875` as was proved in :cite:`Yu_2012_Four`. >>> from toqito.states import bell >>> from toqito.state_opt import ppt_distinguishability @@ -67,7 +67,7 @@ def ppt_distinguishability( >>> psi_2 = bell(3) >>> psi_3 = bell(1) >>> - >>> # YDY vectors from [YDY12]_. + >>> # YDY vectors from :cite:`Yu_2012_Four`. >>> x_1 = np.kron(psi_0, psi_0) >>> x_2 = np.kron(psi_1, psi_3) >>> x_3 = np.kron(psi_2, psi_3) @@ -86,17 +86,9 @@ def ppt_distinguishability( References ========== - .. [COS13] Cosentino, Alessandro. - "Positive-partial-transpose-indistinguishable states via semidefinite - programming." - Physical Review A 87.1 (2013): 012321. - https://arxiv.org/abs/1205.1031 - - .. [YDY12] Yu, Nengkun, Runyao Duan, and Mingsheng Ying. - "Four locally indistinguishable ququad-ququad orthogonal - maximally entangled states." - Physical review letters 109.2 (2012): 020506. - https://arxiv.org/abs/1107.3224 + .. bibliography:: + :filter: docname in docnames + :param states: A list of states provided as either matrices or vectors. :param dist_method: The method of distinguishing states. diff --git a/toqito/state_opt/state_distinguishability.py b/toqito/state_opt/state_distinguishability.py index 1d1c04720..5cf78cbb5 100644 --- a/toqito/state_opt/state_distinguishability.py +++ b/toqito/state_opt/state_distinguishability.py @@ -9,7 +9,7 @@ def state_distinguishability( states: list[np.ndarray], probs: list[float] = None, dist_method: str = "min-error" ) -> float: r""" - Compute probability of state distinguishability [ELD03]_. + Compute probability of state distinguishability :cite:`Eldar_2003_SDPApproach`. The "quantum state distinguishability" problem involves a collection of :math:`n` quantum states @@ -75,11 +75,9 @@ def state_distinguishability( References ========== - .. [ELD03] Eldar, Yonina C. - "A semidefinite programming approach to optimal unambiguous - discrimination of quantum states." - IEEE Transactions on information theory 49.2 (2003): 446-456. - https://arxiv.org/abs/quant-ph/0206093 + .. bibliography:: + :filter: docname in docnames + :param states: A list of states provided as either matrices or vectors. :param probs: Respective list of probabilities each state is selected. diff --git a/toqito/state_opt/state_exclusion.py b/toqito/state_opt/state_exclusion.py index e73661b44..234164bfb 100644 --- a/toqito/state_opt/state_exclusion.py +++ b/toqito/state_opt/state_exclusion.py @@ -51,8 +51,9 @@ def state_exclusion( \end{aligned} \end{equation} - The conclusive state exclusion SDP is written explicitly in [BJOP14]_. The problem of conclusive state exclusion was - also thought about under a different guise in [PBR12]_. + + The conclusive state exclusion SDP is written explicitly in :cite:`Bandyopadhyay_2014_Conclusive`. The problem of conclusive + state exclusion was also thought about under a different guise in :cite:`Pusey_2012_On`. Examples ========== @@ -82,15 +83,9 @@ def state_exclusion( References ========== - .. [PBR12] "On the reality of the quantum state" - Pusey, Matthew F., Barrett, Jonathan, and Rudolph, Terry. - Nature Physics 8.6 (2012): 475-478. - arXiv:1111.3328 - - .. [BJOP14] "Conclusive exclusion of quantum states" - Bandyopadhyay, Somshubhro, Jain, Rahul, Oppenheim, Jonathan, Perry, Christopher - Physical Review A 89.2 (2014): 022336. - arXiv:1306.4683 + .. bibliography:: + :filter: docname in docnames + :param vectors: A list of states provided as vectors. :param probs: Respective list of probabilities each state is selected. If no diff --git a/toqito/state_opt/symmetric_extension_hierarchy.py b/toqito/state_opt/symmetric_extension_hierarchy.py index 0d0937950..49c2de3e1 100644 --- a/toqito/state_opt/symmetric_extension_hierarchy.py +++ b/toqito/state_opt/symmetric_extension_hierarchy.py @@ -17,7 +17,7 @@ def symmetric_extension_hierarchy( dim: int | list[int] = None, ) -> float: r""" - Compute optimal value of the symmetric extension hierarchy SDP [Nav08]_. + Compute optimal value of the symmetric extension hierarchy SDP :cite:`Navascues_2008_Pure`. The probability of distinguishing a given set of states via PPT measurements serves as a natural upper bound to the value of obtaining via separable measurements. Due to the nature of separable @@ -25,10 +25,10 @@ def symmetric_extension_hierarchy( programming techniques. We can, however, construct a hierarchy of semidefinite programs that attains closer and closer - approximations at the separable value via the techniques described in [Nav08]. + approximations at the separable value via the techniques described in :cite:`Navascues_2008_Pure`. The mathematical form of this hierarchy implemented here is explicitly given from equation 4.55 - in [Cos15]_. + in :cite:`Cosentino_2015_QuantumState`. .. math:: @@ -63,7 +63,7 @@ def symmetric_extension_hierarchy( Examples ========== - It is known from [Cos15]_ that distinguishing three Bell states along with a resource state + It is known from :cite:`Cosentino_2015_QuantumState` that distinguishing three Bell states along with a resource state :math:`|\tau_{\epsilon}\rangle` via separable measurements has the following closed form .. math:: @@ -117,7 +117,7 @@ def symmetric_extension_hierarchy( >>> symmetric_extension_hierarchy(states=states, probs=None, level=2) 0.958305796189204 >>> - >>> # As proven in [Cos15]_, the true separable value of distinguishing the + >>> # As proven in :cite:`Cosentino_2015_QuantumState`, the true separable value of distinguishing the >>> # three Bell states is: >>> 1/3 * (2 + np.sqrt(1 - eps**2)) 0.9553418012614794 @@ -128,15 +128,9 @@ def symmetric_extension_hierarchy( References ========== - .. [Nav08] Navascués, Miguel. - "Pure state estimation and the characterization of entanglement." - Physical review letters 100.7 (2008): 070503. - https://arxiv.org/abs/0707.4398 - - .. [Cos15] Cosentino, Alessandro. - "Quantum State Local Distinguishability via Convex Optimization" - The University of Waterloo, Ph.D. Dissertation, 2015. - https://uwspace.uwaterloo.ca/handle/10012/9572 + .. bibliography:: + :filter: docname in docnames + :param states: A list of states provided as either matrices or vectors. :param probs: Respective list of probabilities each state is selected. diff --git a/toqito/state_opt/tests/test_ppt_distinguishability.py b/toqito/state_opt/tests/test_ppt_distinguishability.py index 88ed9c417..c630a39eb 100644 --- a/toqito/state_opt/tests/test_ppt_distinguishability.py +++ b/toqito/state_opt/tests/test_ppt_distinguishability.py @@ -250,7 +250,7 @@ def test_ppt_distinguishability_four_bell_states(): ] probs = [1 / 4, 1 / 4, 1 / 4, 1 / 4] - exp_res = 1 / 2 * (1 + np.sqrt(1 - eps**2)) + exp_res = 1 / 2 * (1 + np.sqrt(1 - eps ** 2)) primal_res = ppt_distinguishability(states, probs=probs, dist_method="min-error", strategy=True) dual_res = ppt_distinguishability(states, probs=probs, dist_method="min-error", strategy=False) diff --git a/toqito/state_opt/tests/test_symmetric_extension_hierarchy.py b/toqito/state_opt/tests/test_symmetric_extension_hierarchy.py index a25f86192..fdc0a34c6 100644 --- a/toqito/state_opt/tests/test_symmetric_extension_hierarchy.py +++ b/toqito/state_opt/tests/test_symmetric_extension_hierarchy.py @@ -53,7 +53,7 @@ def test_symmetric_extension_hierarchy_four_bell_with_resource_state_lvl_1(): # Level 1 of the hierarchy should be identical to the known PPT value # for this case. res = symmetric_extension_hierarchy(states=states, probs=None, level=1) - exp_res = 1 / 2 * (1 + np.sqrt(1 - eps**2)) + exp_res = 1 / 2 * (1 + np.sqrt(1 - eps ** 2)) np.testing.assert_equal(np.isclose(res, exp_res), True) @@ -84,7 +84,7 @@ def test_symmetric_extension_hierarchy_four_bell_with_resource_state(): ] res = symmetric_extension_hierarchy(states=states, probs=None, level=2) - exp_res = 1 / 2 * (1 + np.sqrt(1 - eps**2)) + exp_res = 1 / 2 * (1 + np.sqrt(1 - eps ** 2)) np.testing.assert_equal(np.isclose(res, exp_res), True) diff --git a/toqito/state_props/concurrence.py b/toqito/state_props/concurrence.py index 814a1b4b0..a79d8355c 100644 --- a/toqito/state_props/concurrence.py +++ b/toqito/state_props/concurrence.py @@ -6,7 +6,7 @@ def concurrence(rho: np.ndarray) -> float: r""" - Calculate the concurrence of a bipartite state [WikCon]_. + Calculate the concurrence of a bipartite state :cite:`WikiConcurrence`. The concurrence of a bipartite state :math:`\rho` is defined as @@ -65,8 +65,8 @@ def concurrence(rho: np.ndarray) -> float: References ========== - .. [WikCon] Wikipedia page for concurrence (quantum computing) - https://en.wikipedia.org/wiki/Concurrence_(quantum_computing) + .. bibliography:: + :filter: docname in docnames :raises ValueError: If system is not bipartite. :param rho: The bipartite system specified as a matrix. diff --git a/toqito/state_props/entanglement_of_formation.py b/toqito/state_props/entanglement_of_formation.py index 585ed9572..2b1c8e8f4 100644 --- a/toqito/state_props/entanglement_of_formation.py +++ b/toqito/state_props/entanglement_of_formation.py @@ -9,7 +9,7 @@ def entanglement_of_formation(rho: np.ndarray, dim: list[int] | int = None) -> float: r""" - Compute entanglement-of-formation of a bipartite quantum state [WikEOF]_. + Compute entanglement-of-formation of a bipartite quantum state :cite:`Quantiki_EOF`. Entanglement-of-formation is the entropy of formation of the bipartite quantum state :code:`rho`. Note that this function currently only supports @@ -46,8 +46,9 @@ def entanglement_of_formation(rho: np.ndarray, dim: list[int] | int = None) -> f References ========== - .. [WikEOF] Quantiki: Entanglement-of-formation - https://www.quantiki.org/wiki/entanglement-formation + .. bibliography:: + :filter: docname in docnames + :raises ValueError: If matrices have improper dimension. :param rho: A matrix or vector. @@ -98,8 +99,8 @@ def entanglement_of_formation(rho: np.ndarray, dim: list[int] | int = None) -> f if dim_x == 4: rho_c = concurrence(rho) - rho_c1 = (1 + np.sqrt(1 - rho_c**2)) / 2 - rho_c2 = (1 - np.sqrt(1 - rho_c**2)) / 2 + rho_c1 = (1 + np.sqrt(1 - rho_c ** 2)) / 2 + rho_c2 = (1 - np.sqrt(1 - rho_c ** 2)) / 2 rho_c1_log2 = 0 if rho_c1 == 0 else np.log2(rho_c1) rho_c2_log2 = 0 if rho_c2 == 0 else np.log2(rho_c2) diff --git a/toqito/state_props/has_symmetric_extension.py b/toqito/state_props/has_symmetric_extension.py index e66a20d24..e97b9474a 100644 --- a/toqito/state_props/has_symmetric_extension.py +++ b/toqito/state_props/has_symmetric_extension.py @@ -18,7 +18,7 @@ def has_symmetric_extension( tol: float = 1e-4, ) -> bool: r""" - Determine whether there exists a symmetric extension for a given quantum state. [DPS02]_. + Determine whether there exists a symmetric extension for a given quantum state :cite:`Doherty_2002_Distinguishing`. Determining whether an operator possesses a symmetric extension at some level :code:`level` can be used as a check to determine if the operator is entangled or not. @@ -30,7 +30,7 @@ def has_symmetric_extension( 2-qubit symmetric extension: - In [CJKLZB14]_, it was shown that a 2-qubit state :math:`\rho_{AB}` has a + In :cite:`Chen_2014_Symmetric`, it was shown that a 2-qubit state :math:`\rho_{AB}` has a symmetric extension if and only if .. math:: @@ -82,15 +82,9 @@ def has_symmetric_extension( References ========== - .. [DPS02] Doherty, Andrew C., Pablo A. Parrilo, and Federico M. Spedalieri. - "Distinguishing separable and entangled states." - Physical Review Letters 88.18 (2002): 187904. - https://arxiv.org/abs/quant-ph/0112007 - - .. [CJKLZB14] Chen, J., Ji, Z., Kribs, D., Lütkenhaus, N., & Zeng, B. - "Symmetric extension of two-qubit states." - Physical Review A 90.3 (2014): 032318. - https://arxiv.org/abs/1310.3530 + .. bibliography:: + :filter: docname in docnames + :raises ValueError: If dimension does not evenly divide matrix length. :param rho: A matrix or vector. diff --git a/toqito/state_props/in_separable_ball.py b/toqito/state_props/in_separable_ball.py index 315fc0bf6..e1e8fb6c7 100644 --- a/toqito/state_props/in_separable_ball.py +++ b/toqito/state_props/in_separable_ball.py @@ -4,11 +4,11 @@ def in_separable_ball(mat: np.ndarray) -> bool: r""" - Check whether an operator is contained in ball of separability [GB02]_. + Check whether an operator is contained in ball of separability :cite:`Gurvits_2002_Largest`. Determines whether :code:`mat` is contained within the ball of separable operators centered at the identity matrix (i.e. the maximally-mixed state). The size of this ball was derived in - [GB02]_. + :cite:`Gurvits_2002_Largest`. This function can be used as a method for separability testing of states in certain scenarios. @@ -52,10 +52,9 @@ def in_separable_ball(mat: np.ndarray) -> bool: References ========== - .. [GB02] Gurvits, Leonid, and Barnum, Howard. - "Largest separable balls around the maximally mixed bipartite quantum state." - Physical Review A 66.6 (2002): 062311. - https://arxiv.org/pdf/quant-ph/0204159.pdf + .. bibliography:: + :filter: docname in docnames + :param mat: A positive semidefinite matrix or a vector of the eigenvalues of a positive semidefinite matrix. @@ -80,5 +79,5 @@ def in_separable_ball(mat: np.ndarray) -> bool: mat = mat / np.trace(mat) # The following check relies on the fact that we scaled the matrix so that trace(mat) = 1. - # The following condition is then exactly the condition mentioned in [GB02]_. + # The following condition is then exactly the condition mentioned in :cite:`Gurvits_2002_Largest`. return np.linalg.norm(mat / np.linalg.norm(mat, "fro") ** 2 - np.eye(max_dim), "fro") <= 1 diff --git a/toqito/state_props/is_antidistinguishable.py b/toqito/state_props/is_antidistinguishable.py index bb6c7bd1d..43e39038c 100644 --- a/toqito/state_props/is_antidistinguishable.py +++ b/toqito/state_props/is_antidistinguishable.py @@ -5,10 +5,10 @@ def is_antidistinguishable(states: list[np.ndarray]) -> bool: r""" - Check whether a collection of vectors are antidistinguishable or not [TK18]_. + Check whether a collection of vectors are antidistinguishable or not :cite: `Heinosaari_2018_Antidistinguishability`. The ability to determine whether a set of quantum states are antidistinguishable can be obtained via the state - exclusion SDP [BJOP14]_ such that we ignore the associated probabilities with which the states are chosen from the set of + exclusion SDP :cite:`Bandyopadhyay_2014_Conclusive` such that we ignore the associated probabilities with which the states are chosen from the set of vectors. Examples @@ -47,15 +47,9 @@ def is_antidistinguishable(states: list[np.ndarray]) -> bool: References ========== - .. [TK18] Heinosaari, Teiko, and Oskari Kerppo. - "Antidistinguishability of pure quantum states." - Journal of Physics A: Mathematical and Theoretical 51.36 (2018): 365303. - https://arxiv.org/abs/1804.10457 + .. bibliography:: + :filter: docname in docnames - .. [BJOP14] Bandyopadhyay, Somshubhro, Jain, Rahul, Oppenheim, Jonathan, Perry, Christopher - "Conclusive exclusion of quantum states" - Physical Review A 89.2 (2014): 022336. - arXiv:1306.4683 :param states: A set of vectors consisting of quantum states to determine the antidistinguishability of. :return: :code:`True` if the vectors are antidistinguishable; :code:`False` otherwise. diff --git a/toqito/state_props/is_ensemble.py b/toqito/state_props/is_ensemble.py index 056c5a1f3..3d62e94a4 100644 --- a/toqito/state_props/is_ensemble.py +++ b/toqito/state_props/is_ensemble.py @@ -6,7 +6,7 @@ def is_ensemble(states: list[np.ndarray]) -> bool: r""" - Determine if a set of states constitute an ensemble [WatEns18]_. + Determine if a set of states constitute an ensemble (Section: Ensemble Of Quantum States from cite:`Watrous_2018_TQI`). An ensemble of quantum states is defined by a function @@ -44,10 +44,9 @@ def is_ensemble(states: list[np.ndarray]) -> bool: References ========== - .. [WatEns18] Watrous, John. - "The theory of quantum information." - Section: "Ensemble of quantum states". - Cambridge University Press, 2018. + .. bibliography:: + :filter: docname in docnames + :param states: The list of states to check. :return: :code:`True` if states form an ensemble and :code:`False` otherwise. diff --git a/toqito/state_props/is_mixed.py b/toqito/state_props/is_mixed.py index 3bfa7d6c1..38bb0be91 100644 --- a/toqito/state_props/is_mixed.py +++ b/toqito/state_props/is_mixed.py @@ -6,7 +6,7 @@ def is_mixed(state: np.ndarray) -> bool: r""" - Determine if a given quantum state is mixed [WikMix]_. + Determine if a given quantum state is mixed :cite:`WikiMixedSt`. A mixed state by definition is a state that is not pure. @@ -33,8 +33,9 @@ def is_mixed(state: np.ndarray) -> bool: References ========== - .. [WikMix] Wikipedia: Quantum state - Mixed states - https://en.wikipedia.org/wiki/Quantum_state#Mixed_states + .. bibliography:: + :filter: docname in docnames + :param state: The density matrix representing the quantum state. :return: :code:`True` if state is mixed and :code:`False` otherwise. diff --git a/toqito/state_props/is_mutually_orthogonal.py b/toqito/state_props/is_mutually_orthogonal.py index afe392830..05cd5dc3e 100644 --- a/toqito/state_props/is_mutually_orthogonal.py +++ b/toqito/state_props/is_mutually_orthogonal.py @@ -8,7 +8,7 @@ def is_mutually_orthogonal(vec_list: list[np.ndarray | list[float | Any]]) -> bool: r""" - Check if list of vectors are mutually orthogonal [WikOrthog]_. + Check if list of vectors are mutually orthogonal :cite:`WikiOrthog`. We say that two bases @@ -50,8 +50,9 @@ def is_mutually_orthogonal(vec_list: list[np.ndarray | list[float | Any]]) -> bo References ========== - .. [WikOrthog] Wikipedia: Orthogonality - https://en.wikipedia.org/wiki/Orthogonality + .. bibliography:: + :filter: docname in docnames + :raises ValueError: If at least two vectors are not provided. :param vec_list: The list of vectors to check. diff --git a/toqito/state_props/is_mutually_unbiased_basis.py b/toqito/state_props/is_mutually_unbiased_basis.py index f69355643..01fdc5565 100644 --- a/toqito/state_props/is_mutually_unbiased_basis.py +++ b/toqito/state_props/is_mutually_unbiased_basis.py @@ -70,8 +70,10 @@ def is_mutually_unbiased_basis(vectors: list[np.ndarray | list[float | Any]]) -> References ========== - .. [WikMUB] Wikipedia: Mutually unbiased bases - https://en.wikipedia.org/wiki/Mutually_unbiased_bases + .. bibliography:: + :filter: docname in docnames + + :raises ValueError: If at least two vectors are not provided. :param vectors: The list of vectors to check. diff --git a/toqito/state_props/is_npt.py b/toqito/state_props/is_npt.py index 2cc947418..bc18eff3f 100644 --- a/toqito/state_props/is_npt.py +++ b/toqito/state_props/is_npt.py @@ -8,19 +8,20 @@ def is_npt(mat: np.ndarray, sys: int = 2, dim: int | list[int] = None, tol: float = None) -> bool: r""" - Determine whether or not a matrix has negative partial transpose [WikPPT]_. + Determine whether or not a matrix has negative partial transpose :cite:`WikiPeresHorodecki`. Yields either :code:`True` or :code:`False`, indicating that :code:`mat` does or does not have negative partial transpose (within numerical error). The variable :code:`mat` is assumed to act - on bipartite space. [NPT]_ + on bipartite space. :cite:`DiVincenzo_2000_Evidence` A state has negative partial transpose if it does not have positive partial transpose. References ========== - .. [NPT] "Evidence for bound entangled states with negative partial transpose." - Physical Review A 61.6 (2000): 062312. + .. bibliography:: + :filter: docname in docnames + :param mat: A square matrix. :param sys: Scalar or vector indicating which subsystems the transpose diff --git a/toqito/state_props/is_ppt.py b/toqito/state_props/is_ppt.py index f0154a0a0..7cac07f32 100644 --- a/toqito/state_props/is_ppt.py +++ b/toqito/state_props/is_ppt.py @@ -9,7 +9,7 @@ def is_ppt(mat: np.ndarray, sys: int = 2, dim: int | list[int] = None, tol: float = None) -> bool: r""" - Determine whether or not a matrix has positive partial transpose [WikPPT]_. + Determine whether or not a matrix has positive partial transpose :cite:`WikiPeresHorodecki`. Yields either :code:`True` or :code:`False`, indicating that :code:`mat` does or does not have positive partial transpose (within numerical error). The variable :code:`mat` is assumed to act @@ -65,8 +65,9 @@ def is_ppt(mat: np.ndarray, sys: int = 2, dim: int | list[int] = None, tol: floa References ========== - .. [WikPPT] Quantiki: Positive partial transpose - https://www.quantiki.org/wiki/positive-partial-transpose + .. bibliography:: + :filter: docname in docnames + :param mat: A square matrix. :param sys: Scalar or vector indicating which subsystems the transpose diff --git a/toqito/state_props/is_product.py b/toqito/state_props/is_product.py index c2c0a09ee..5682b8338 100644 --- a/toqito/state_props/is_product.py +++ b/toqito/state_props/is_product.py @@ -9,7 +9,7 @@ def is_product(rho: np.ndarray, dim: int | list[int] | np.ndarray = None) -> bool | np.ndarray: r""" - Determine if a given vector is a product state [WikProdState]_. + Determine if a given vector is a product state :cite:`WikiSepSt`. If the input is deemed to be product, then the product decomposition is also returned. @@ -46,8 +46,10 @@ def is_product(rho: np.ndarray, dim: int | list[int] | np.ndarray = None) -> boo References ========== - .. [WikProdState] Wikipedia: Product state - https://en.wikipedia.org/wiki/Product_state + .. bibliography:: + :filter: docname in docnames + + :param rho: The vector or matrix to check. :param dim: The dimension of the input. :return: :code:`True` if :code:`rho` is a product vector and :code:`False` otherwise. diff --git a/toqito/state_props/is_pure.py b/toqito/state_props/is_pure.py index 50a4d3f8e..9ec8feb55 100644 --- a/toqito/state_props/is_pure.py +++ b/toqito/state_props/is_pure.py @@ -6,7 +6,7 @@ def is_pure(state: list[np.ndarray] | np.ndarray) -> bool: r""" - Determine if a given state is pure or list of states are pure [WikIsPure]_. + Determine if a given state is pure or list of states are pure :cite:`WikiPureSt`. A state is said to be pure if it is a density matrix with rank equal to 1. Equivalently, the state :math:`\rho` is pure if there exists a unit vector :math:`u` such that: @@ -59,8 +59,9 @@ def is_pure(state: list[np.ndarray] | np.ndarray) -> bool: References ========== - .. [WikIsPure] Wikipedia: Quantum state - Pure states - https://en.wikipedia.org/wiki/Quantum_state#Pure_states + .. bibliography:: + :filter: docname in docnames + :param state: The density matrix representing the quantum state or a list of density matrices representing quantum states. diff --git a/toqito/state_props/is_separable.py b/toqito/state_props/is_separable.py index 059fbbb22..b1a2bc2aa 100644 --- a/toqito/state_props/is_separable.py +++ b/toqito/state_props/is_separable.py @@ -16,7 +16,7 @@ def is_separable( state: np.ndarray, dim: None | int | list[int] = None, level: int = 2, tol: float = 1e-8 ) -> bool: r""" - Determine if a given state (given as a density matrix) is a separable state [WikSepState]_. + Determine if a given state (given as a density matrix) is a separable state :cite:`WikiSepSt`. Examples ========== @@ -54,8 +54,9 @@ def is_separable( References ========== - .. [WikSepState] Wikipedia: Separable state - https://en.wikipedia.org/wiki/Separable_state + .. bibliography:: + :filter: docname in docnames + :raises ValueError: If dimension is not specified. :param state: The matrix to check. @@ -135,7 +136,7 @@ def is_separable( # Another test that is strictly stronger than the realignment criterion. if trace_norm(realignment(state - np.kron(pt_state_alice, pt_state_bob), dim)) > np.sqrt( - 1 - np.trace(pt_state_alice**2 @ pt_state_bob**2) + 1 - np.trace(pt_state_alice ** 2 @ pt_state_bob ** 2) ): # Determined to be entangled by using Theorem 1 of reference. # C.-J. Zhang, Y.-S. Zhang, S. Zhang, and G.-C. Guo. @@ -152,7 +153,7 @@ def is_separable( # Check if X is separable from spectrum. if (lam[0] - lam[2 * max_dim - 1]) ** 2 <= 4 * lam[2 * max_dim - 2] * lam[ 2 * max_dim - ] + tol**2: + ] + tol ** 2: print("Determined to be separable by inspecting its eigenvalues.") print( "N. Johnston. Separability from spectrum for qubit-qudit states. Phys. Rev. A, 88:062330, 2013." @@ -176,7 +177,7 @@ def is_separable( # Check if X is a rank-1 perturbation of the identity, which is # necessarily separable if it's PPT, which we have already checked. - if lam[1] - lam[prod_dim - 1] < tol**2: + if lam[1] - lam[prod_dim - 1] < tol ** 2: # Determined to be separable by being a small rank-1 perturbation of the maximally-mixed state. # G. Vidal and R. Tarrach. Robustness of entanglement. # Phys. Rev. A, 59:141-155, 1999. diff --git a/toqito/state_props/l1_norm_coherence.py b/toqito/state_props/l1_norm_coherence.py index 8522d49f6..b956eae96 100644 --- a/toqito/state_props/l1_norm_coherence.py +++ b/toqito/state_props/l1_norm_coherence.py @@ -6,7 +6,7 @@ def l1_norm_coherence(rho: np.ndarray) -> float: r""" - Compute the l1-norm of coherence of a quantum state [RPWL17]_. + Compute the l1-norm of coherence of a quantum state :cite:`Rana_2017_Log`. The :math:`\ell_1`-norm of coherence of a quantum state :math:`\rho` is defined as @@ -41,10 +41,9 @@ def l1_norm_coherence(rho: np.ndarray) -> float: References ========== - .. [RPWL17] "Logarithmic coherence: Operational interpretation of 1-norm coherence" - Rana, Swapan, Parashar, Preeti, Winter, Andreas, Lewenstein, Maciej - Physical Review A 96.5 (2017): 052336. - https://arxiv.org/pdf/1612.09234.pdf + .. bibliography:: + :filter: docname in docnames + :param rho: A matrix or vector. :return: The l1-norm coherence of :code:`rho`. diff --git a/toqito/state_props/log_negativity.py b/toqito/state_props/log_negativity.py index 100fe32fa..843fe231d 100644 --- a/toqito/state_props/log_negativity.py +++ b/toqito/state_props/log_negativity.py @@ -10,7 +10,7 @@ def log_negativity(rho: np.ndarray, dim: list[int] | int = None) -> float: r""" - Compute the log-negativity of a bipartite quantum state [WikLogNeg]_. + Compute the log-negativity of a bipartite quantum state :cite:`WikiNeg`. The log-negativity of a subsystem can be defined in terms of a density matrix :math:`\rho`: @@ -38,8 +38,9 @@ def log_negativity(rho: np.ndarray, dim: list[int] | int = None) -> float: References ========== - .. [WikLogNeg] Wikipedia page for negativity (quantum mechanics): - https://en.wikipedia.org/wiki/Negativity_(quantum_mechanics) + .. bibliography:: + :filter: docname in docnames + :raises ValueError: If the input matrix is not a density matrix. :param rho: A density matrix of a pure state vector. diff --git a/toqito/state_props/negativity.py b/toqito/state_props/negativity.py index 3c8253d0f..f3922583e 100644 --- a/toqito/state_props/negativity.py +++ b/toqito/state_props/negativity.py @@ -10,7 +10,7 @@ def negativity(rho: np.ndarray, dim: list[int] | int = None) -> float: r""" - Compute the negativity of a bipartite quantum state [WikNeg]_. + Compute the negativity of a bipartite quantum state :cite:`WikiNeg`. The negativity of a subsystem can be defined in terms of a density matrix :math:`\rho`: @@ -39,8 +39,9 @@ def negativity(rho: np.ndarray, dim: list[int] | int = None) -> float: References ========== - .. [WikNeg] Wikipedia page for negativity (quantum mechanics): - https://en.wikipedia.org/wiki/Negativity_(quantum_mechanics) + .. bibliography:: + :filter: docname in docnames + :raises ValueError: If dimension of matrix is invalid. :param rho: A density matrix of a pure state vector. diff --git a/toqito/state_props/purity.py b/toqito/state_props/purity.py index 29a53e8dd..03f3cd753 100644 --- a/toqito/state_props/purity.py +++ b/toqito/state_props/purity.py @@ -6,7 +6,7 @@ def purity(rho: np.ndarray) -> float: r""" - Compute the purity of a quantum state [WikPurity]_. + Compute the purity of a quantum state :cite:`WikiPurity`. The negativity of a subsystem can be defined in terms of a density matrix :math:`\rho`: The purity of a quantum state :math:`\rho` is defined as @@ -46,8 +46,9 @@ def purity(rho: np.ndarray) -> float: References ========== - .. [WikPurity] Wikipedia page for purity (quantum mechanics): - https://en.wikipedia.org/wiki/Purity_(quantum_mechanics) + .. bibliography:: + :filter: docname in docnames + :raises ValueError: If matrix is not density operator. :param rho: A density matrix of a pure state vector. diff --git a/toqito/state_props/schmidt_rank.py b/toqito/state_props/schmidt_rank.py index 21a4cbcb4..7a5171ad0 100644 --- a/toqito/state_props/schmidt_rank.py +++ b/toqito/state_props/schmidt_rank.py @@ -8,7 +8,7 @@ def schmidt_rank(rho: np.ndarray, dim: int | list[int] | np.ndarray = None) -> float: r""" - Compute the Schmidt rank [WikSR]_. + Compute the Schmidt rank :cite:`WikiScmidtDecomp`. For complex Euclidean spaces :math:`\mathcal{X}` and :math:`\mathcal{Y}`, a pure state :math:`u \in \mathcal{X} \otimes \mathcal{Y}` possesses an expansion of the form: @@ -74,8 +74,9 @@ def schmidt_rank(rho: np.ndarray, dim: int | list[int] | np.ndarray = None) -> f References ========== - .. [WikSR] Wikipedia: Schmidt rank - https://en.wikipedia.org/wiki/Schmidt_decomposition#Schmidt_rank_and_entanglement + .. bibliography:: + :filter: docname in docnames + :param rho: A bipartite vector or matrix to have its Schmidt rank computed. :param dim: A 1-by-2 vector or matrix. diff --git a/toqito/state_props/sk_vec_norm.py b/toqito/state_props/sk_vec_norm.py index a79b1e580..dd5e42bcc 100644 --- a/toqito/state_props/sk_vec_norm.py +++ b/toqito/state_props/sk_vec_norm.py @@ -8,7 +8,7 @@ def sk_vector_norm(rho: np.ndarray, k: int = 1, dim: int | list[int] = None) -> float: r""" - Compute the S(k)-norm of a vector [NJDK09]_. + Compute the S(k)-norm of a vector :cite:`Johnston_2010_AFamily`. The :math:`S(k)`-norm of of a vector :math:`|v \rangle` is defined as: @@ -41,9 +41,9 @@ def sk_vector_norm(rho: np.ndarray, k: int = 1, dim: int | list[int] = None) -> References ========== - .. [NJDK09] "A Family of Norms With Applications In Quantum Information Theory" - Nathaniel Johnston, David W. Kribs - https://arxiv.org/abs/0909.3907 + .. bibliography:: + :filter: docname in docnames + :param rho: A vector. :param k: An int. diff --git a/toqito/state_props/tests/test_concurrence.py b/toqito/state_props/tests/test_concurrence.py index c19e18788..17409c2d8 100644 --- a/toqito/state_props/tests/test_concurrence.py +++ b/toqito/state_props/tests/test_concurrence.py @@ -9,21 +9,27 @@ e_0, e_1 = np.array([[1], [0]]), np.array([[0], [1]]) -@pytest.mark.parametrize("rho, expected_result", [ - # Concurrence of maximally entangled Bell state. - (bell(0) @ bell(0).conj().T, 1), - # Concurrence of a product state is zero. - (np.kron(e_0, e_1) @ np.kron(e_0, e_1).conj().T, 0), -]) +@pytest.mark.parametrize( + "rho, expected_result", + [ + # Concurrence of maximally entangled Bell state. + (bell(0) @ bell(0).conj().T, 1), + # Concurrence of a product state is zero. + (np.kron(e_0, e_1) @ np.kron(e_0, e_1).conj().T, 0), + ], +) def test_concurrence(rho, expected_result): res = concurrence(rho) np.testing.assert_equal(np.isclose(res, expected_result), True) -@pytest.mark.parametrize("rho", [ - # Tests for invalid dimension inputs. - (np.identity(5)), -]) +@pytest.mark.parametrize( + "rho", + [ + # Tests for invalid dimension inputs. + (np.identity(5)), + ], +) def test_concurrence_invalid_input(rho): with np.testing.assert_raises(ValueError): concurrence(rho) diff --git a/toqito/state_props/tests/test_entanglement_of_formation.py b/toqito/state_props/tests/test_entanglement_of_formation.py index e95b7bad5..d8ae1c567 100644 --- a/toqito/state_props/tests/test_entanglement_of_formation.py +++ b/toqito/state_props/tests/test_entanglement_of_formation.py @@ -9,24 +9,30 @@ e_0, e_1 = np.array([[1], [0]]), np.array([[0], [1]]) -@pytest.mark.parametrize("rho, dim, expected_result", [ - # The entanglement-of-formation on a Bell state. - (bell(0) @ bell(0).conj().T, None, 1), - # The entanglement-of-formation on a maximally mixed. - (max_mixed(4, False) @ max_mixed(4, False).conj().T, None, 0), -]) +@pytest.mark.parametrize( + "rho, dim, expected_result", + [ + # The entanglement-of-formation on a Bell state. + (bell(0) @ bell(0).conj().T, None, 1), + # The entanglement-of-formation on a maximally mixed. + (max_mixed(4, False) @ max_mixed(4, False).conj().T, None, 0), + ], +) def test_entanglement_of_formation(rho, dim, expected_result): np.testing.assert_equal(np.isclose(entanglement_of_formation(rho, dim), expected_result), True) -@pytest.mark.parametrize("rho, dim", [ - # Invalid local dimension for entanglement_of_formation. - (np.identity(4), 3), - # Not presently known how to calculate for mixed states. - (3 / 4 * e_0 * e_0.conj().T + 1 / 4 * e_1 * e_1.conj().T, None), - # Invalid non-square matrix for entanglement_of_formation. - (np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12]]), None), -]) +@pytest.mark.parametrize( + "rho, dim", + [ + # Invalid local dimension for entanglement_of_formation. + (np.identity(4), 3), + # Not presently known how to calculate for mixed states. + (3 / 4 * e_0 @ e_0.conj().T + 1 / 4 * e_1 @ e_1.conj().T, None), + # Invalid non-square matrix for entanglement_of_formation. + (np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12]]), None), + ], +) def test_entanglement_of_formation_invalid(rho, dim): """Ensures that an integer above 4 is error-checked.""" with np.testing.assert_raises(ValueError): diff --git a/toqito/state_props/tests/test_has_symmetric_extension.py b/toqito/state_props/tests/test_has_symmetric_extension.py index fd9cc4b80..9c54c9759 100644 --- a/toqito/state_props/tests/test_has_symmetric_extension.py +++ b/toqito/state_props/tests/test_has_symmetric_extension.py @@ -6,30 +6,44 @@ from toqito.states import bell -@pytest.mark.parametrize("rho, level, dim, ppt, expected_result", [ - # Check whether 2-qubit state has a symmetric extension. - (np.array([[1, 0, 0, -1], [0, 1, 1 / 2, 0], [0, 1 / 2, 1, 0], [-1, 0, 0, 1]]), 2, None, True, True), - # Check whether state has level-1 symmetric extension.""" - (np.identity(4), 1, None, False, True), - # Entangled state should not have symmetric extension for some level.""" - (bell(0) @ bell(0).conj().T, 1, None, True, False), - # Entangled state should not have symmetric extension for some level (level-2). - (bell(0) @ bell(0).conj().T, 2, None, True, False), - # Provide dimension of system as list. - (bell(0) @ bell(0).conj().T, 2, [2, 2], True, False), - # Entangled state should not have non-PPT-symmetric extension for some level (level-2). - (bell(0) @ bell(0).conj().T, 2, 2, False, False), - # Entangled state should not have PPT-symmetric extension for some level (level-2).""" - (bell(0) @ bell(0).conj().T, 2, 2, True, False), -]) +@pytest.mark.parametrize( + "rho, level, dim, ppt, expected_result", + [ + # Check whether 2-qubit state has a symmetric extension. + ( + np.array([[1, 0, 0, -1], [0, 1, 1 / 2, 0], [0, 1 / 2, 1, 0], [-1, 0, 0, 1]]), + 2, + None, + True, + True, + ), + # Check whether state has level-1 symmetric extension.""" + (np.identity(4), 1, None, False, True), + # Entangled state should not have symmetric extension for some level.""" + (bell(0) @ bell(0).conj().T, 1, None, True, False), + # Entangled state should not have symmetric extension for some level (level-2). + (bell(0) @ bell(0).conj().T, 2, None, True, False), + # Provide dimension of system as list. + (bell(0) @ bell(0).conj().T, 2, [2, 2], True, False), + # Entangled state should not have non-PPT-symmetric extension for some level (level-2). + (bell(0) @ bell(0).conj().T, 2, 2, False, False), + # Entangled state should not have PPT-symmetric extension for some level (level-2).""" + (bell(0) @ bell(0).conj().T, 2, 2, True, False), + ], +) def test_has_symmetric_extension(rho, level, dim, ppt, expected_result): - np.testing.assert_equal(has_symmetric_extension(rho=rho, level=level, dim=dim, ppt=ppt), expected_result) + np.testing.assert_equal( + has_symmetric_extension(rho=rho, level=level, dim=dim, ppt=ppt), expected_result + ) -@pytest.mark.parametrize("rho, level, dim, ppt", [ - # Check whether 2-qubit state has a symmetric extension. - (np.identity(6), 1, 4, True), -]) +@pytest.mark.parametrize( + "rho, level, dim, ppt", + [ + # Check whether 2-qubit state has a symmetric extension. + (np.identity(6), 1, 4, True), + ], +) def test_has_symmetric_extension_invalid_dim(rho, level, dim, ppt): """Tests for invalid dimension inputs.""" with np.testing.assert_raises(ValueError): diff --git a/toqito/state_props/tests/test_in_separable_ball.py b/toqito/state_props/tests/test_in_separable_ball.py index cd3bad7be..99d0b5215 100644 --- a/toqito/state_props/tests/test_in_separable_ball.py +++ b/toqito/state_props/tests/test_in_separable_ball.py @@ -7,15 +7,24 @@ random_u_mat = random_unitary(4) -@pytest.mark.parametrize("rho, expected_result", [ - # Test matrix in separable ball returns True. - (random_u_mat @ np.diag(np.array([1, 1, 1, 0])) / 3 @ random_u_mat.conj().T, True), - # Test matrix not in separable ball returns False. - (random_u_mat @ np.diag(np.array([1.01, 1, 0.99, 0])) / 3 @ random_u_mat.conj().T, False), - # Test for case when trace of matrix is less than the largest dim.""" - (np.zeros((4, 4)), False), - # Test eigenvalues of matrix not in separable ball returns False. - (np.linalg.eigvalsh(random_u_mat @ np.diag(np.array([1.01, 1, 0.99, 0])) / 3 @ random_u_mat.conj().T), False), -]) + +@pytest.mark.parametrize( + "rho, expected_result", + [ + # Test matrix in separable ball returns True. + (random_u_mat @ np.diag(np.array([1, 1, 1, 0])) / 3 @ random_u_mat.conj().T, True), + # Test matrix not in separable ball returns False. + (random_u_mat @ np.diag(np.array([1.01, 1, 0.99, 0])) / 3 @ random_u_mat.conj().T, False), + # Test for case when trace of matrix is less than the largest dim.""" + (np.zeros((4, 4)), False), + # Test eigenvalues of matrix not in separable ball returns False. + ( + np.linalg.eigvalsh( + random_u_mat @ np.diag(np.array([1.01, 1, 0.99, 0])) / 3 @ random_u_mat.conj().T + ), + False, + ), + ], +) def test_in_separable_ball(rho, expected_result): np.testing.assert_equal(in_separable_ball(rho), expected_result) diff --git a/toqito/state_props/tests/test_is_ensemble.py b/toqito/state_props/tests/test_is_ensemble.py index d04a80c97..e231daf0f 100644 --- a/toqito/state_props/tests/test_is_ensemble.py +++ b/toqito/state_props/tests/test_is_ensemble.py @@ -5,11 +5,14 @@ from toqito.state_props import is_ensemble -@pytest.mark.parametrize("states, expected_result", [ - # Test if valid ensemble returns True. - ([np.array([[0.5, 0], [0, 0]]), np.array([[0, 0], [0, 0.5]])], True), - # Test if non-valid (non-PSD) ensemble returns False. - ([np.array([[0.5, 0], [0, 0]]), np.array([[-1, -1], [-1, -1]])], False), -]) +@pytest.mark.parametrize( + "states, expected_result", + [ + # Test if valid ensemble returns True. + ([np.array([[0.5, 0], [0, 0]]), np.array([[0, 0], [0, 0.5]])], True), + # Test if non-valid (non-PSD) ensemble returns False. + ([np.array([[0.5, 0], [0, 0]]), np.array([[-1, -1], [-1, -1]])], False), + ], +) def test_is_ensemble(states, expected_result): np.testing.assert_equal(is_ensemble(states), expected_result) diff --git a/toqito/state_props/tests/test_is_mixed.py b/toqito/state_props/tests/test_is_mixed.py index d459dc867..f1dc95a6f 100644 --- a/toqito/state_props/tests/test_is_mixed.py +++ b/toqito/state_props/tests/test_is_mixed.py @@ -8,9 +8,12 @@ e_0, e_1 = np.array([[1], [0]]), np.array([[0], [1]]) -@pytest.mark.parametrize("states, expected_result", [ - # Return True for mixed quantum state. - (3/4 * e_0 @ e_0.conj().T + 1/4 * e_1 @ e_1.conj().T, True), -]) +@pytest.mark.parametrize( + "states, expected_result", + [ + # Return True for mixed quantum state. + (3 / 4 * e_0 @ e_0.conj().T + 1 / 4 * e_1 @ e_1.conj().T, True), + ], +) def test_is_mixed(states, expected_result): np.testing.assert_equal(is_mixed(states), expected_result) diff --git a/toqito/state_props/tests/test_is_mutually_orthogonal.py b/toqito/state_props/tests/test_is_mutually_orthogonal.py index 241ca794b..f5ec487c5 100644 --- a/toqito/state_props/tests/test_is_mutually_orthogonal.py +++ b/toqito/state_props/tests/test_is_mutually_orthogonal.py @@ -6,38 +6,44 @@ from toqito.states import bell -@pytest.mark.parametrize("states, expected_result", [ - # Return True for orthogonal Bell vectors. - ([bell(0), bell(1), bell(2), bell(3)], True), - # Return False for non-orthogonal vectors. - ([np.array([1, 0]), np.array([1, 1])], False), - # Orthogonal vectors in R^2 - ([np.array([1, 0]), np.array([0, 1])], True), - # Orthogonal vectors in R^2 - ([np.array([1, 0, 0]), np.array([0, 1, 0]), np.array([0, 0, 1])], True), - # Orthogonal complex-valued vectors - ([np.array([[1], [1j]]), np.array([[1j], [1]])], True), - # Vectors with zero elements. - ([np.array([[0], [0]]), np.array([[1], [0]])], True), - # Colinear vectors. - ([np.array([[1], [2]]), np.array([2, 4])], False), - # Vectors that are theoretically orthogonal but due to numerical precision issues might not be exactly orthogonal. - ([np.array([[1], [np.sqrt(2)]]), np.array([[-np.sqrt(2)], [1]])], True), -]) +@pytest.mark.parametrize( + "states, expected_result", + [ + # Return True for orthogonal Bell vectors. + ([bell(0), bell(1), bell(2), bell(3)], True), + # Return False for non-orthogonal vectors. + ([np.array([1, 0]), np.array([1, 1])], False), + # Orthogonal vectors in R^2 + ([np.array([1, 0]), np.array([0, 1])], True), + # Orthogonal vectors in R^2 + ([np.array([1, 0, 0]), np.array([0, 1, 0]), np.array([0, 0, 1])], True), + # Orthogonal complex-valued vectors + ([np.array([[1], [1j]]), np.array([[1j], [1]])], True), + # Vectors with zero elements. + ([np.array([[0], [0]]), np.array([[1], [0]])], True), + # Colinear vectors. + ([np.array([[1], [2]]), np.array([2, 4])], False), + # Vectors that are theoretically orthogonal but due to numerical precision issues might not be exactly orthogonal. + ([np.array([[1], [np.sqrt(2)]]), np.array([[-np.sqrt(2)], [1]])], True), + ], +) def test_is_mutually_orthogonal(states, expected_result): np.testing.assert_equal(is_mutually_orthogonal(states), expected_result) -@pytest.mark.parametrize("states", [ - # Tests for invalid input len. - ([np.array([1, 0])]), - # Single vector should raise error. - ([np.array([[1], [2], [3]])]), - # Vectors of differing lengths. - ([np.array([[1], [0]]), np.array([[1], [0], [1]])]), - # Empty vector. - ([]), -]) +@pytest.mark.parametrize( + "states", + [ + # Tests for invalid input len. + ([np.array([1, 0])]), + # Single vector should raise error. + ([np.array([[1], [2], [3]])]), + # Vectors of differing lengths. + ([np.array([[1], [0]]), np.array([[1], [0], [1]])]), + # Empty vector. + ([]), + ], +) def test_is_mutually_orthogonal_basis_invalid_input(states): with np.testing.assert_raises(ValueError): is_mutually_orthogonal(states) diff --git a/toqito/state_props/tests/test_is_mutually_unbiased_basis.py b/toqito/state_props/tests/test_is_mutually_unbiased_basis.py index 02c2b2a2a..9b39714d8 100644 --- a/toqito/state_props/tests/test_is_mutually_unbiased_basis.py +++ b/toqito/state_props/tests/test_is_mutually_unbiased_basis.py @@ -73,3 +73,4 @@ ]) def test_is_mutually_unbiased(states, expected_result): np.testing.assert_equal(is_mutually_unbiased_basis(states), expected_result) + diff --git a/toqito/state_props/tests/test_is_npt.py b/toqito/state_props/tests/test_is_npt.py index e704b2f24..7531e6330 100644 --- a/toqito/state_props/tests/test_is_npt.py +++ b/toqito/state_props/tests/test_is_npt.py @@ -6,19 +6,22 @@ from toqito.states import bell, horodecki -@pytest.mark.parametrize("mat, sys, dim, tol, expected_result", [ - # Check that non-NPT matrix returns False with sys specified. - (np.identity(9), 2, None, None, False), - # Check that non-NPT matrix returns False with dim and sys specified. - (np.identity(9), 2, np.round(np.sqrt(9)), None, False), - # Check that non-NPT matrix returns False. - (np.identity(9), 2, np.round(np.sqrt(9)), None, False), - # Check that non-NPT matrix with tolerance returns False. - (np.identity(9), 2, np.round(np.sqrt(9)), 1e-10, False), - # Entangled state of dimension 2 will violate NPT criterion. - (bell(2) @ bell(2).conj().T, 2, None, None, True), - # Horodecki state is an example of an entangled NPT state. - (horodecki(0.5, [3, 3]), 2, None, None, False), -]) +@pytest.mark.parametrize( + "mat, sys, dim, tol, expected_result", + [ + # Check that non-NPT matrix returns False with sys specified. + (np.identity(9), 2, None, None, False), + # Check that non-NPT matrix returns False with dim and sys specified. + (np.identity(9), 2, np.round(np.sqrt(9)), None, False), + # Check that non-NPT matrix returns False. + (np.identity(9), 2, np.round(np.sqrt(9)), None, False), + # Check that non-NPT matrix with tolerance returns False. + (np.identity(9), 2, np.round(np.sqrt(9)), 1e-10, False), + # Entangled state of dimension 2 will violate NPT criterion. + (bell(2) @ bell(2).conj().T, 2, None, None, True), + # Horodecki state is an example of an entangled NPT state. + (horodecki(0.5, [3, 3]), 2, None, None, False), + ], +) def test_is_npt(mat, sys, dim, tol, expected_result): np.testing.assert_equal(is_npt(mat=mat, sys=sys, dim=dim, tol=tol), expected_result) diff --git a/toqito/state_props/tests/test_is_ppt.py b/toqito/state_props/tests/test_is_ppt.py index a2893f2e7..70950b6b6 100644 --- a/toqito/state_props/tests/test_is_ppt.py +++ b/toqito/state_props/tests/test_is_ppt.py @@ -6,17 +6,20 @@ from toqito.states import bell, horodecki -@pytest.mark.parametrize("mat, sys, dim, tol, expected_result", [ - # Check that PPT matrix returns True. - (np.identity(9), 2, None, None, True), - # Check that PPT matrix returns True with dim and sys specified. - (np.identity(9), 2, [3], None, True), - # Check that PPT matrix returns True. - (np.identity(9), 2, [3], 1e-10, True), - # Entangled state of dimension 2 will violate PPT criterion. - (bell(2) @ bell(2).conj().T, 2, None, None, False), - # Horodecki state is an example of an entangled PPT state. - (horodecki(0.5, [3, 3]), 2, None, None, True) -]) +@pytest.mark.parametrize( + "mat, sys, dim, tol, expected_result", + [ + # Check that PPT matrix returns True. + (np.identity(9), 2, None, None, True), + # Check that PPT matrix returns True with dim and sys specified. + (np.identity(9), 2, [3], None, True), + # Check that PPT matrix returns True. + (np.identity(9), 2, [3], 1e-10, True), + # Entangled state of dimension 2 will violate PPT criterion. + (bell(2) @ bell(2).conj().T, 2, None, None, False), + # Horodecki state is an example of an entangled PPT state. + (horodecki(0.5, [3, 3]), 2, None, None, True), + ], +) def test_is_ppt(mat, sys, dim, tol, expected_result): np.testing.assert_equal(is_ppt(mat=mat, sys=sys, dim=dim, tol=tol), expected_result) diff --git a/toqito/state_props/tests/test_is_product.py b/toqito/state_props/tests/test_is_product.py index 79694d186..2ec471e51 100644 --- a/toqito/state_props/tests/test_is_product.py +++ b/toqito/state_props/tests/test_is_product.py @@ -9,24 +9,31 @@ e_0, e_1 = np.array([[1], [0]]), np.array([[0], [1]]) -@pytest.mark.parametrize("rho, dim, expected_result", [ - # Check that is_product_vector returns False for an entangled state. - (max_entangled(3), None, False), - # Check that dimension argument as list is supported. - (max_entangled(4), [4, 4], False), - # Check that dimension argument as list is supported. - (max_entangled(4), [2, 2, 2, 2], False), - # Check that is_product_vector returns True for a separable state. - (1 / 2 * (np.kron(e_0, e_0) - np.kron(e_0, e_1) - np.kron(e_1, e_0) + np.kron(e_1, e_1)), None, True), - # Check to ensure that pure state living in C^2 x C^2 x C^2 is product. - (1 / np.sqrt(2) * np.array([1, 0, 0, 0, 1, 0, 0, 0]), [2, 2, 2], True), - # Check to ensure that a separable density matrix is product. - (np.identity(4), None, True), - # Check to ensure that an entangled density matrix is not product. - (bell(0) @ bell(0).conj().T, None, False), - # Check to ensure that an entangled density matrix is not product (with dimension). - (bell(0) @ bell(0).conj().T, [2, 2], False), -]) +@pytest.mark.parametrize( + "rho, dim, expected_result", + [ + # Check that is_product_vector returns False for an entangled state. + (max_entangled(3), None, False), + # Check that dimension argument as list is supported. + (max_entangled(4), [4, 4], False), + # Check that dimension argument as list is supported. + (max_entangled(4), [2, 2, 2, 2], False), + # Check that is_product_vector returns True for a separable state. + ( + 1 / 2 * (np.kron(e_0, e_0) - np.kron(e_0, e_1) - np.kron(e_1, e_0) + np.kron(e_1, e_1)), + None, + True, + ), + # Check to ensure that pure state living in C^2 x C^2 x C^2 is product. + (1 / np.sqrt(2) * np.array([1, 0, 0, 0, 1, 0, 0, 0]), [2, 2, 2], True), + # Check to ensure that a separable density matrix is product. + (np.identity(4), None, True), + # Check to ensure that an entangled density matrix is not product. + (bell(0) @ bell(0).conj().T, None, False), + # Check to ensure that an entangled density matrix is not product (with dimension). + (bell(0) @ bell(0).conj().T, [2, 2], False), + ], +) def test_is_product(rho, dim, expected_result): ipv, _ = is_product(rho=rho, dim=dim) np.testing.assert_equal(ipv, expected_result) diff --git a/toqito/state_props/tests/test_is_pure.py b/toqito/state_props/tests/test_is_pure.py index 6fe9d66fc..bad127a33 100644 --- a/toqito/state_props/tests/test_is_pure.py +++ b/toqito/state_props/tests/test_is_pure.py @@ -9,15 +9,24 @@ e_0, e_1, e_2 = np.array([[1], [0], [0]]), np.array([[0], [1], [0]]), np.array([[0], [0], [1]]) -@pytest.mark.parametrize("state, expected_result", [ - # Ensure that pure Bell state returns True. - (bell(0) @ bell(0).conj().T, True), - # Check that list of pure states returns True. - ([e_0 @ e_0.conj().T, e_1 @ e_1.conj().T, e_2 @ e_2.conj().T], True), - # Check that non-pure state returns False. - (np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]]), False), - # Check that list of non-pure states return False. - ([np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]]), np.array([[1, 2, 3], [10, 11, 12], [7, 8, 9]])], False), -]) +@pytest.mark.parametrize( + "state, expected_result", + [ + # Ensure that pure Bell state returns True. + (bell(0) @ bell(0).conj().T, True), + # Check that list of pure states returns True. + ([e_0 @ e_0.conj().T, e_1 @ e_1.conj().T, e_2 @ e_2.conj().T], True), + # Check that non-pure state returns False. + (np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]]), False), + # Check that list of non-pure states return False. + ( + [ + np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]]), + np.array([[1, 2, 3], [10, 11, 12], [7, 8, 9]]), + ], + False, + ), + ], +) def test_is_pure_state(state, expected_result): np.testing.assert_equal(is_pure(state), expected_result) diff --git a/toqito/state_props/tests/test_is_separable.py b/toqito/state_props/tests/test_is_separable.py index c06624ed3..9984c249c 100644 --- a/toqito/state_props/tests/test_is_separable.py +++ b/toqito/state_props/tests/test_is_separable.py @@ -83,10 +83,10 @@ def test_entangled_cross_norm_realignment_criterion(): p_var, a_var, b_var = 0.4, 0.8, 0.64 rho = np.array( [ - [p_var * a_var**2, 0, 0, p_var * a_var * b_var], - [0, (1 - p_var) * a_var**2, (1 - p_var) * a_var * b_var, 0], - [0, (1 - p_var) * a_var * b_var, (1 - p_var) * a_var**2, 0], - [p_var * a_var * b_var, 0, 0, p_var * a_var**2], + [p_var * a_var ** 2, 0, 0, p_var * a_var * b_var], + [0, (1 - p_var) * a_var ** 2, (1 - p_var) * a_var * b_var, 0], + [0, (1 - p_var) * a_var * b_var, (1 - p_var) * a_var ** 2, 0], + [p_var * a_var * b_var, 0, 0, p_var * a_var ** 2], ] ) np.testing.assert_equal(is_separable(rho), False) diff --git a/toqito/state_props/tests/test_log_negativity.py b/toqito/state_props/tests/test_log_negativity.py index 4ebeef804..cc1b81857 100644 --- a/toqito/state_props/tests/test_log_negativity.py +++ b/toqito/state_props/tests/test_log_negativity.py @@ -5,22 +5,35 @@ from toqito.state_props import log_negativity -@pytest.mark.parametrize("rho, dim, expected_result", [ - # Test for log_negativity on rho. - (np.array([[1 / 2, 0, 0, 1 / 2], [0, 0, 0, 0], [0, 0, 0, 0], [1 / 2, 0, 0, 1 / 2]]), None, 1), - # Test for log_negativity on rho (with dimension). - (np.array([[1 / 2, 0, 0, 1 / 2], [0, 0, 0, 0], [0, 0, 0, 0], [1 / 2, 0, 0, 1 / 2]]), 2, 1), -]) +@pytest.mark.parametrize( + "rho, dim, expected_result", + [ + # Test for log_negativity on rho. + ( + np.array([[1 / 2, 0, 0, 1 / 2], [0, 0, 0, 0], [0, 0, 0, 0], [1 / 2, 0, 0, 1 / 2]]), + None, + 1, + ), + # Test for log_negativity on rho (with dimension). + (np.array([[1 / 2, 0, 0, 1 / 2], [0, 0, 0, 0], [0, 0, 0, 0], [1 / 2, 0, 0, 1 / 2]]), 2, 1), + ], +) def test_log_negativity(rho, dim, expected_result): np.testing.assert_allclose(log_negativity(rho, dim), expected_result) -@pytest.mark.parametrize("rho, dim", [ - # Invalid dim parameters. - (np.array([[1 / 2, 0, 0, 1 / 2], [0, 0, 0, 0], [0, 0, 0, 0], [1 / 2, 0, 0, 1 / 2]]), 5), - # Invalid dim parameters as list. - (np.array([[1 / 2, 0, 0, 1 / 2], [0, 0, 0, 0], [0, 0, 0, 0], [1 / 2, 0, 0, 1 / 2]]), [2, 5]), -]) +@pytest.mark.parametrize( + "rho, dim", + [ + # Invalid dim parameters. + (np.array([[1 / 2, 0, 0, 1 / 2], [0, 0, 0, 0], [0, 0, 0, 0], [1 / 2, 0, 0, 1 / 2]]), 5), + # Invalid dim parameters as list. + ( + np.array([[1 / 2, 0, 0, 1 / 2], [0, 0, 0, 0], [0, 0, 0, 0], [1 / 2, 0, 0, 1 / 2]]), + [2, 5], + ), + ], +) def test_log_negativity_invalid_input(rho, dim): with np.testing.assert_raises(ValueError): log_negativity(rho, dim) diff --git a/toqito/state_props/tests/test_negativity.py b/toqito/state_props/tests/test_negativity.py index b3f0d64d0..8347d5055 100644 --- a/toqito/state_props/tests/test_negativity.py +++ b/toqito/state_props/tests/test_negativity.py @@ -5,22 +5,39 @@ from toqito.state_props import negativity -@pytest.mark.parametrize("rho, dim, expected_result", [ - # Test for log_negativity on rho. - (np.array([[1 / 2, 0, 0, 1 / 2], [0, 0, 0, 0], [0, 0, 0, 0], [1 / 2, 0, 0, 1 / 2]]), None, 1 / 2), - # Test for negativity on rho for dimension as integer. - (np.array([[1 / 2, 0, 0, 1 / 2], [0, 0, 0, 0], [0, 0, 0, 0], [1 / 2, 0, 0, 1 / 2]]), 2, 1 / 2), -]) +@pytest.mark.parametrize( + "rho, dim, expected_result", + [ + # Test for log_negativity on rho. + ( + np.array([[1 / 2, 0, 0, 1 / 2], [0, 0, 0, 0], [0, 0, 0, 0], [1 / 2, 0, 0, 1 / 2]]), + None, + 1 / 2, + ), + # Test for negativity on rho for dimension as integer. + ( + np.array([[1 / 2, 0, 0, 1 / 2], [0, 0, 0, 0], [0, 0, 0, 0], [1 / 2, 0, 0, 1 / 2]]), + 2, + 1 / 2, + ), + ], +) def test_negativity(rho, dim, expected_result): np.testing.assert_allclose(negativity(rho, dim), expected_result) -@pytest.mark.parametrize("rho, dim", [ - # Invalid dim parameters. - (np.array([[1 / 2, 0, 0, 1 / 2], [0, 0, 0, 0], [0, 0, 0, 0], [1 / 2, 0, 0, 1 / 2]]), 5), - # Invalid dim parameters as list. - (np.array([[1 / 2, 0, 0, 1 / 2], [0, 0, 0, 0], [0, 0, 0, 0], [1 / 2, 0, 0, 1 / 2]]), [2, 5]), -]) +@pytest.mark.parametrize( + "rho, dim", + [ + # Invalid dim parameters. + (np.array([[1 / 2, 0, 0, 1 / 2], [0, 0, 0, 0], [0, 0, 0, 0], [1 / 2, 0, 0, 1 / 2]]), 5), + # Invalid dim parameters as list. + ( + np.array([[1 / 2, 0, 0, 1 / 2], [0, 0, 0, 0], [0, 0, 0, 0], [1 / 2, 0, 0, 1 / 2]]), + [2, 5], + ), + ], +) def test_negativity_invalid_input(rho, dim): with np.testing.assert_raises(ValueError): negativity(rho, dim) diff --git a/toqito/state_props/tests/test_purity.py b/toqito/state_props/tests/test_purity.py index e45a59880..9b28a700b 100644 --- a/toqito/state_props/tests/test_purity.py +++ b/toqito/state_props/tests/test_purity.py @@ -6,20 +6,26 @@ from toqito.states import werner -@pytest.mark.parametrize("rho, expected_result", [ - # Test for identity matrix. - (np.identity(4) / 4, 1 / 4), - # Test purity of mixed Werner state. - (werner(2, 1 / 4), 0.2653), -]) +@pytest.mark.parametrize( + "rho, expected_result", + [ + # Test for identity matrix. + (np.identity(4) / 4, 1 / 4), + # Test purity of mixed Werner state. + (werner(2, 1 / 4), 0.2653), + ], +) def test_purity(rho, expected_result): np.testing.assert_allclose(purity(rho), expected_result, atol=4) -@pytest.mark.parametrize("rho", [ - # Test purity on non-density matrix. - (np.array([[1, 2], [3, 4]])), -]) +@pytest.mark.parametrize( + "rho", + [ + # Test purity on non-density matrix. + (np.array([[1, 2], [3, 4]])), + ], +) def test_purity_invalid(rho): with np.testing.assert_raises(ValueError): purity(rho) diff --git a/toqito/state_props/tests/test_schmidt_rank.py b/toqito/state_props/tests/test_schmidt_rank.py index 5c792b0ee..e9a71c2e3 100644 --- a/toqito/state_props/tests/test_schmidt_rank.py +++ b/toqito/state_props/tests/test_schmidt_rank.py @@ -9,32 +9,39 @@ e_0, e_1 = np.array([[1], [0]]), np.array([[0], [1]]) -@pytest.mark.parametrize("rho, dim, expected_result", [ - # Computing the Schmidt rank of the entangled Bell state should yield a value greater than 1. - (bell(0), None, 2), - # Computing the Schmidt rank of Bell state with dim 1. - (bell(0), 1, 1), - # Computing the Schmidt rank of Bell state with list as argument for dims. - (bell(0), [2, 2], 2), - # Computing the Schmidt rank of a separable state should yield a value equal to 1. - (1 / 2 * (np.kron(e_0, e_0) - np.kron(e_0, e_1) - np.kron(e_1, e_0) + np.kron(e_1, e_1)), None, 1), - # Computing Schmidt rank of separable density matrix should be 1. - (np.identity(4), None, 1), - # Computing Schmidt rank of separable density matrix should be 1. - (np.identity(16), None, 1), - # Computing Schmidt rank of first Bell density matrices should be 4. - (bell(0) @ bell(0).conj().T, None, 4), - # Computing Schmidt rank of second Bell density matrices should be 4. - (bell(1) @ bell(1).conj().T, None, 4), - # Computing Schmidt rank of third Bell density matrices should be 4. - (bell(2) @ bell(2).conj().T, None, 4), - # Computing Schmidt rank of fourth Bell density matrices should be 4. - (bell(3) @ bell(3).conj().T, None, 4), - # Computing Schmidt rank of first Bell density matrices should be 4 (dimension as integer). - (bell(0) @ bell(0).conj().T, 2, 4), - # Computing Schmidt rank of first Bell density matrices should be 4 (dimension as list). - (bell(0) @ bell(0).conj().T, [2, 2], 4), -]) +@pytest.mark.parametrize( + "rho, dim, expected_result", + [ + # Computing the Schmidt rank of the entangled Bell state should yield a value greater than 1. + (bell(0), None, 2), + # Computing the Schmidt rank of Bell state with dim 1. + (bell(0), 1, 1), + # Computing the Schmidt rank of Bell state with list as argument for dims. + (bell(0), [2, 2], 2), + # Computing the Schmidt rank of a separable state should yield a value equal to 1. + ( + 1 / 2 * (np.kron(e_0, e_0) - np.kron(e_0, e_1) - np.kron(e_1, e_0) + np.kron(e_1, e_1)), + None, + 1, + ), + # Computing Schmidt rank of separable density matrix should be 1. + (np.identity(4), None, 1), + # Computing Schmidt rank of separable density matrix should be 1. + (np.identity(16), None, 1), + # Computing Schmidt rank of first Bell density matrices should be 4. + (bell(0) @ bell(0).conj().T, None, 4), + # Computing Schmidt rank of second Bell density matrices should be 4. + (bell(1) @ bell(1).conj().T, None, 4), + # Computing Schmidt rank of third Bell density matrices should be 4. + (bell(2) @ bell(2).conj().T, None, 4), + # Computing Schmidt rank of fourth Bell density matrices should be 4. + (bell(3) @ bell(3).conj().T, None, 4), + # Computing Schmidt rank of first Bell density matrices should be 4 (dimension as integer). + (bell(0) @ bell(0).conj().T, 2, 4), + # Computing Schmidt rank of first Bell density matrices should be 4 (dimension as list). + (bell(0) @ bell(0).conj().T, [2, 2], 4), + ], +) def test_schmidt_rank_bell_state(rho, dim, expected_result): np.testing.assert_allclose(schmidt_rank(rho, dim), expected_result) @@ -49,6 +56,7 @@ def test_schmidt_rank_entangled_state(): ) np.testing.assert_equal(schmidt_rank(phi) == 2, True) + def test_schmidt_rank_singlet_state(): """ Computing the Schmidt rank of the entangled singlet state should yield diff --git a/toqito/state_props/tests/test_von_neumann_entropy.py b/toqito/state_props/tests/test_von_neumann_entropy.py index c1be71c87..0de5d0b4c 100644 --- a/toqito/state_props/tests/test_von_neumann_entropy.py +++ b/toqito/state_props/tests/test_von_neumann_entropy.py @@ -6,20 +6,26 @@ from toqito.states import bell, max_mixed -@pytest.mark.parametrize("rho, expected_result", [ - # Entangled state von Neumann entropy should be zero. - (bell(0) @ bell(0).conj().T, 0), - # Von Neumann entropy of the maximally mixed state should be one. - (max_mixed(2, is_sparse=False), 1), -]) +@pytest.mark.parametrize( + "rho, expected_result", + [ + # Entangled state von Neumann entropy should be zero. + (bell(0) @ bell(0).conj().T, 0), + # Von Neumann entropy of the maximally mixed state should be one. + (max_mixed(2, is_sparse=False), 1), + ], +) def test_von_neumann_entropy(rho, expected_result): np.testing.assert_allclose(von_neumann_entropy(rho), expected_result, atol=1e-5) -@pytest.mark.parametrize("rho", [ - # Test von Neumann entropy on non-density matrix. - (np.array([[1, 2], [3, 4]])), -]) +@pytest.mark.parametrize( + "rho", + [ + # Test von Neumann entropy on non-density matrix. + (np.array([[1, 2], [3, 4]])), + ], +) def test_von_neumann_invalid_input(rho): with np.testing.assert_raises(ValueError): von_neumann_entropy(rho) diff --git a/toqito/state_props/von_neumann_entropy.py b/toqito/state_props/von_neumann_entropy.py index 395052d9e..84f5ccdc0 100644 --- a/toqito/state_props/von_neumann_entropy.py +++ b/toqito/state_props/von_neumann_entropy.py @@ -6,7 +6,8 @@ def von_neumann_entropy(rho: np.ndarray) -> float: r""" - Compute the von Neumann entropy of a density matrix [WikVent]_. [WatVec]_. + Compute the von Neumann entropy of a density matrix :cite:`WikiUVonNeumann`, + Section: "Definitions Of Quantum Entropic Functions" from :cite:`Watrous_2018_TQI`). Let :math:`P \in \text{Pos}(\mathcal{X})` be a positive semidefinite operator, for a complex Euclidean space :math:`\mathcal{X}`. Then one defines the *von Neumann entropy* as @@ -73,13 +74,9 @@ def von_neumann_entropy(rho: np.ndarray) -> float: References ========== - .. [WikVent] Wikipedia: Von Neumann entropy - https://en.wikipedia.org/wiki/Von_Neumann_entropy - - .. [WatVec] Watrous, John. - "The theory of quantum information." - Section: "Definitions of quantum entropic functions". - Cambridge University Press, 2018. + .. bibliography:: + :filter: docname in docnames + :param rho: Density operator. :return: The von Neumann entropy of :code:`rho`. diff --git a/toqito/states/basis.py b/toqito/states/basis.py index 63df9f5a0..9dab9e067 100644 --- a/toqito/states/basis.py +++ b/toqito/states/basis.py @@ -5,7 +5,7 @@ def basis(dim: int, pos: int) -> np.ndarray: r""" - Obtain the ket of dimension :code:`dim` [WikKet]_. + Obtain the ket of dimension :code:`dim` :cite:`WikiBraKet`. Examples ========== @@ -34,8 +34,9 @@ def basis(dim: int, pos: int) -> np.ndarray: References ========== - .. [WikKet] Wikipedia page for bra–ket notation: - https://en.wikipedia.org/wiki/Bra%E2%80%93ket_notation + .. bibliography:: + :filter: docname in docnames + :raises ValueError: If the input position is not in the range [0, dim - 1]. :param dim: The dimension of the column vector. diff --git a/toqito/states/bell.py b/toqito/states/bell.py index 2952fc6fa..d19fedd69 100644 --- a/toqito/states/bell.py +++ b/toqito/states/bell.py @@ -6,7 +6,7 @@ def bell(idx: int) -> np.ndarray: r""" - Produce a Bell state [WikBell]_. + Produce a Bell state :cite:`WikiBellSt`. Returns one of the following four Bell states depending on the value of :code:`idx`: @@ -42,8 +42,10 @@ def bell(idx: int) -> np.ndarray: References ========== - .. [WikBell] Wikipedia: Bell state - https://en.wikipedia.org/wiki/Bell_state + .. bibliography:: + :filter: docname in docnames + + :raises ValueError: If :code:`idx` is not an integer. :param idx: A parameter in [0, 1, 2, 3] diff --git a/toqito/states/brauer.py b/toqito/states/brauer.py index 06754bebc..d5553c44f 100644 --- a/toqito/states/brauer.py +++ b/toqito/states/brauer.py @@ -8,7 +8,7 @@ def brauer(dim: int, p_val: int) -> np.ndarray: r""" - Produce all Brauer states [WikBrauer]_. + Produce all Brauer states :cite:`WikiBrauer`. Produce a matrix whose columns are all of the (unnormalized) "Brauer" states: states that are the :code:`p_val`-fold tensor product of the standard maximally-entangled pure state on :code:`dim` local dimensions. There are many such @@ -50,8 +50,9 @@ def brauer(dim: int, p_val: int) -> np.ndarray: References ========== - .. [WikBrauer] Wikipedia: Brauer algebra - https://en.wikipedia.org/wiki/Brauer_algebra + .. bibliography:: + :filter: docname in docnames + :param dim: Dimension of each local subsystem :param p_val: Half of the number of parties (i.e., the state that this function computes will diff --git a/toqito/states/breuer.py b/toqito/states/breuer.py index 1d1ae642f..964d894b6 100644 --- a/toqito/states/breuer.py +++ b/toqito/states/breuer.py @@ -7,10 +7,11 @@ def breuer(dim: int, lam: float) -> np.ndarray: r""" - Produce a Breuer state [HPBreuer]_. + Produce a Breuer state :cite:`Breuer_2006_Optimal`. - Gives a Breuer bound entangled state for two qudits of local dimension :code:`dim`, with the :code:`lam` parameter - describing the weight of the singlet component as described in [HPBreuer]_. + Gives a Breuer bound entangled state for two qudits of local dimension :code:`dim`, with the + :code:`lam` parameter describing the weight of the singlet component as described in + :cite:`Breuer_2006_Optimal`. This function was adapted from the QETLAB package. @@ -29,8 +30,9 @@ def breuer(dim: int, lam: float) -> np.ndarray: References ========== - .. [HPBreuer] H-P. Breuer. Optimal entanglement criterion for mixed quantum states. - E-print: arXiv:quant-ph/0605036, 2006. + .. bibliography:: + :filter: docname in docnames + :raises ValueError: Dimension must be greater than or equal to 1. :param dim: Dimension of the Breuer state. diff --git a/toqito/states/chessboard.py b/toqito/states/chessboard.py index f47c49f5c..c049d8baa 100644 --- a/toqito/states/chessboard.py +++ b/toqito/states/chessboard.py @@ -4,11 +4,12 @@ def chessboard(mat_params: list[float], s_param: float = None, t_param: float = None) -> np.ndarray: r""" - Produce a chessboard state [BP00]_. + Produce a chessboard state :cite:`Dur_2000_ThreeQubits`. + + Generates the chessboard state defined in :cite:`Dur_2000_ThreeQubits`. Note that, for certain choices of + :code:`s_param` and :code:`t_param`, this state will not have positive partial transpose, and + thus may not be bound entangled. - Generates the chessboard state defined in [BP00]_. Note that, for certain choices of :code:`s_param` and - :code:`t_param`, this state will not have positive partial transpose, and thus may not be bound entangled. - Examples ========== @@ -37,12 +38,11 @@ def chessboard(mat_params: list[float], s_param: float = None, t_param: float = References ========== - .. [BP00] Three qubits can be entangled in two inequivalent ways. - D. Bruss and A. Peres - Phys. Rev. A, 61:30301(R), 2000 - arXiv: 991.1056 + .. bibliography:: + :filter: docname in docnames + - :param mat_params: Parameters of the chessboard state as defined in [BP00]_. + :param mat_params: Parameters of the chessboard state as defined in :cite:`Dur_2000_ThreeQubits`. :param s_param: Default is :code:`np.conj(mat_params[2]) / np.conj(mat_params[5])`. :param t_param: Default is :code:`t_param = mat_params[0] * mat_params[3] / mat_params[4]`. :return: A chessboard state. diff --git a/toqito/states/domino.py b/toqito/states/domino.py index be47d0ab3..b38e27c9b 100644 --- a/toqito/states/domino.py +++ b/toqito/states/domino.py @@ -6,7 +6,7 @@ def domino(idx: int) -> np.ndarray: r""" - Produce a domino state [CBDOM99]_, [UPB99]_. + Produce a domino state :cite:`Bennett_1999_QuantumNonlocality, Bennett_1999_UPB`. The orthonormal product basis of domino states is given as @@ -73,15 +73,9 @@ def domino(idx: int) -> np.ndarray: References ========== - .. [CBDOM99] Bennett, Charles H., et al. - Quantum nonlocality without entanglement. - Phys. Rev. A, 59:1070–1091, Feb 1999. - https://arxiv.org/abs/quant-ph/9804053 - - .. [UPB99] Bennett, Charles H., et al. - "Unextendible product bases and bound entanglement." - Physical Review Letters 82.26 (1999): 5385. - https://arxiv.org/abs/quant-ph/9808030 + .. bibliography:: + :filter: docname in docnames + :raises ValueError: Invalid value for :code:`idx`. :param idx: A parameter in [0, 1, 2, 3, 4, 5, 6, 7, 8] diff --git a/toqito/states/gen_bell.py b/toqito/states/gen_bell.py index f4bbb4c4b..338025998 100644 --- a/toqito/states/gen_bell.py +++ b/toqito/states/gen_bell.py @@ -7,19 +7,21 @@ def gen_bell(k_1: int, k_2: int, dim: int) -> np.ndarray: r""" - Produce a generalized Bell state [DL09]_. + Produce a generalized Bell state :cite:`Sych_2009_AComplete`. Produces a generalized Bell state. Note that the standard Bell states can be recovered as: - ```py - bell(0) : gen_bell(0, 0, 2) + .. code-block:: python + :linenos: + + bell(0) : gen_bell(0, 0, 2) - bell(1) : gen_bell(0, 1, 2) + bell(1) : gen_bell(0, 1, 2) - bell(2) : gen_bell(1, 0, 2) + bell(2) : gen_bell(1, 0, 2) - bell(3) : gen_bell(1, 1, 2) - ``` + bell(3) : gen_bell(1, 1, 2) + Examples ========== @@ -89,9 +91,9 @@ def gen_bell(k_1: int, k_2: int, dim: int) -> np.ndarray: References ========== - .. [DL09] Sych, Denis, and Gerd Leuchs. - "A complete basis of generalized Bell states." - New Journal of Physics 11.1 (2009): 013006. + .. bibliography:: + :filter: docname in docnames + :param k_1: An integer 0 <= k_1 <= n. :param k_2: An integer 0 <= k_2 <= n. diff --git a/toqito/states/ghz.py b/toqito/states/ghz.py index f9d98820f..de8d724f4 100644 --- a/toqito/states/ghz.py +++ b/toqito/states/ghz.py @@ -6,10 +6,11 @@ def ghz(dim: int, num_qubits: int, coeff: list[int] = None) -> sparse: r""" - Generate a (generalized) GHZ state [GHZ07]_. + Generate a (generalized) GHZ state :cite:`Greenberger_2007_Going`. - Returns a :code:`num_qubits`-partite GHZ state acting on :code:`dim` local dimensions, described in [GHZ07]_. For - example, :code:`ghz(2, 3)` returns the standard 3-qubit GHZ state on qubits. The output of this function is sparse. + Returns a :code:`num_qubits`-partite GHZ state acting on :code:`dim` local dimensions, described + in :cite:`Greenberger_2007_Going`. For example, :code:`ghz(2, 3)` returns the standard 3-qubit GHZ state on qubits. + The output of this function is sparse. For a system of :code:`num_qubits` qubits (i.e., :code:`dim = 2`), the GHZ state can be written as @@ -60,9 +61,9 @@ def ghz(dim: int, num_qubits: int, coeff: list[int] = None) -> sparse: References ========== - .. [GHZ07] Going beyond Bell's theorem. - D. Greenberger and M. Horne and A. Zeilinger. - E-print: [quant-ph] arXiv:0712.0921. 2007. + .. bibliography:: + :filter: docname in docnames + :raises ValueError: Number of qubits is not a positive integer. :param dim: The local dimension. @@ -88,9 +89,9 @@ def ghz(dim: int, num_qubits: int, coeff: list[int] = None) -> sparse: # than naively tensoring things together. dim_sum = 1 for i in range(1, num_qubits): - dim_sum += dim**i + dim_sum += dim ** i - ret_ghz_state = sparse.lil_matrix((dim**num_qubits, 1)) + ret_ghz_state = sparse.lil_matrix((dim ** num_qubits, 1)) for i in range(1, dim + 1): ret_ghz_state[(i - 1) * dim_sum] = coeff[i - 1] return ret_ghz_state diff --git a/toqito/states/gisin.py b/toqito/states/gisin.py index e89694a7e..46325199b 100644 --- a/toqito/states/gisin.py +++ b/toqito/states/gisin.py @@ -4,9 +4,9 @@ def gisin(lambda_var: float, theta: float) -> np.ndarray: r""" - Produce a Gisin state [GIS96]_. + Produce a Gisin state :cite:`Gisin_1996_Hidden`. - Returns the Gisin state described in [GIS96]_. Specifically, the Gisin state can be defined as: + Returns the Gisin state described in :cite:`Gisin_1996_Hidden`. Specifically, the Gisin state can be defined as: .. math:: \begin{equation} @@ -42,9 +42,9 @@ def gisin(lambda_var: float, theta: float) -> np.ndarray: References ========== - .. [GIS96] N. Gisin. - Hidden quantum nonlocality revealed by local filters. - (http://dx.doi.org/10.1016/S0375-9601(96)80001-6). 1996. + .. bibliography:: + :filter: docname in docnames + :raises ValueError: If :code:`lambda_var` is not a real number. :param lambda_var: A real parameter in [0, 1]. diff --git a/toqito/states/horodecki.py b/toqito/states/horodecki.py index dde03ec36..db5e4e6a3 100644 --- a/toqito/states/horodecki.py +++ b/toqito/states/horodecki.py @@ -4,7 +4,7 @@ def horodecki(a_param: float, dim: list[int] = None) -> np.ndarray: r""" - Produce a Horodecki state [HOR]_, [CHR]_. + Produce a Horodecki state :cite:`Horodecki_1997_Separability, Chruscinski_2011_OnTheSymmetry`. Returns the Horodecki state in either :math:`(3 \otimes 3)`-dimensional space or :math:`(2 \otimes 4)`-dimensional space, depending on the dimensions in the 1-by-2 vector :code:`dim`. @@ -51,9 +51,9 @@ def horodecki(a_param: float, dim: list[int] = None) -> np.ndarray: \end{equation} .. note:: - Refer to [CHR]_ (specifically equations (1) and (2)) for more information on this state and its properties. The - 3x3 Horodecki state is defined explicitly in Section 4.1 of [HOR]_ and the 2x4 Horodecki state is defined - explicitly in Section 4.2 of [HOR]_. + Refer to :cite:`Chruscinski_2011_OnTheSymmetry` (specifically equations (1) and (2)) for more information on this state + and its properties. The 3x3 Horodecki state is defined explicitly in Section 4.1 of :cite:`Horodecki_1997_Separability` + and the 2x4 Horodecki state is defined explicitly in Section 4.2 of :cite:`Horodecki_1997_Separability`. Examples ========== @@ -104,14 +104,10 @@ def horodecki(a_param: float, dim: list[int] = None) -> np.ndarray: References ========== - .. [HOR] P. Horodecki. - Separability criterion and inseparable mixed states with positive - partial transpose. - arXiv: 970.3004. - - .. [CHR] K. Chruscinski. - On the symmetry of the seminal Horodecki state. - arXiv: 1009.4385. + .. bibliography:: + :filter: docname in docnames + + """ if a_param < 0 or a_param > 1: raise ValueError("Invalid: Argument A_PARAM must be in the interval [0, 1].") @@ -122,7 +118,7 @@ def horodecki(a_param: float, dim: list[int] = None) -> np.ndarray: if np.array_equal(dim, np.array([3, 3])): n_a_param = 1 / (8 * a_param + 1) b_param = (1 + a_param) / 2 - c_param = np.sqrt(1 - a_param**2) / 2 + c_param = np.sqrt(1 - a_param ** 2) / 2 horo_state = n_a_param * np.array( [ @@ -142,7 +138,7 @@ def horodecki(a_param: float, dim: list[int] = None) -> np.ndarray: if np.array_equal(dim, np.array([2, 4])): n_a_param = 1 / (7 * a_param + 1) b_param = (1 + a_param) / 2 - c_param = np.sqrt(1 - a_param**2) / 2 + c_param = np.sqrt(1 - a_param ** 2) / 2 horo_state = n_a_param * np.array( [ diff --git a/toqito/states/isotropic.py b/toqito/states/isotropic.py index 41987bfcd..d32b5ce61 100644 --- a/toqito/states/isotropic.py +++ b/toqito/states/isotropic.py @@ -6,7 +6,7 @@ def isotropic(dim: int, alpha: float) -> np.ndarray: r""" - Produce a isotropic state [HH99]_. + Produce a isotropic state :cite:`Horodecki_1998_Reduction`. Returns the isotropic state with parameter :code:`alpha` acting on (:code:`dim`-by-:code:`dim`)-dimensional space. The isotropic state has the following form @@ -50,9 +50,9 @@ def isotropic(dim: int, alpha: float) -> np.ndarray: References ========== - .. [HH99] Horodecki, Michał, and Paweł Horodecki. - "Reduction criterion of separability and limits for a class of - distillation protocols." Physical Review A 59.6 (1999): 4206. + .. bibliography:: + :filter: docname in docnames + :param dim: The local dimension. :param alpha: The parameter of the isotropic state. diff --git a/toqito/states/max_entangled.py b/toqito/states/max_entangled.py index faef5aec8..642c4b635 100644 --- a/toqito/states/max_entangled.py +++ b/toqito/states/max_entangled.py @@ -5,7 +5,7 @@ def max_entangled(dim: int, is_sparse: bool = False, is_normalized: bool = True) -> [np.ndarray, sp.sparse.dia_matrix]: r""" - Produce a maximally entangled bipartite pure state [WikEnt]_. + Produce a maximally entangled bipartite pure state :cite:`WikiMaxEnt`. Produces a maximally entangled pure state as above that is sparse if :code:`is_sparse = True` and is full if :code:`is_sparse = False`. The pure state is normalized to have Euclidean norm 1 if :code:`is_normalized = True`, @@ -45,8 +45,9 @@ def max_entangled(dim: int, is_sparse: bool = False, is_normalized: bool = True) References ========== - .. [WikEnt] Wikipedia: Quantum entanglement - https://en.wikipedia.org/wiki/Quantum_entanglement + .. bibliography:: + :filter: docname in docnames + :param dim: Dimension of the entangled state. :param is_sparse: `True` if vector is spare and `False` otherwise. @@ -54,7 +55,7 @@ def max_entangled(dim: int, is_sparse: bool = False, is_normalized: bool = True) :return: The maximally entangled state of dimension :code:`dim`. """ mat = sp.sparse.identity(dim) if is_sparse else np.identity(dim) - psi = np.reshape(mat, (dim**2, 1)) + psi = np.reshape(mat, (dim ** 2, 1)) if is_normalized: psi = psi / np.sqrt(dim) return psi diff --git a/toqito/states/max_mixed.py b/toqito/states/max_mixed.py index 456ad2c53..d905a42d0 100644 --- a/toqito/states/max_mixed.py +++ b/toqito/states/max_mixed.py @@ -6,7 +6,7 @@ def max_mixed(dim: int, is_sparse: bool = False) -> [np.ndarray, sparse.dia_matrix]: r""" - Produce the maximally mixed state [AAR6]_. + Produce the maximally mixed state :cite:`Aaronson_2018_MaxMixed`. Produces the maximally mixed state on of :code:`dim` dimensions. The maximally mixed state is defined as @@ -57,8 +57,9 @@ def max_mixed(dim: int, is_sparse: bool = False) -> [np.ndarray, sparse.dia_matr References ========== - .. [AAR6] Scott Aaronson: Lecture 6, Thurs Feb 2: Mixed States - https://www.scottaaronson.com/qclec/6.pdf + .. bibliography:: + :filter: docname in docnames + :param dim: Dimension of the entangled state. :param is_sparse: `True` if vector is spare and `False` otherwise. diff --git a/toqito/states/singlet.py b/toqito/states/singlet.py index ebed14132..a1ce04154 100644 --- a/toqito/states/singlet.py +++ b/toqito/states/singlet.py @@ -6,7 +6,7 @@ def singlet(dim: int) -> np.ndarray: r""" - Produce a generalized singlet state acting on two n-dimensional systems [Gsinglet]_. + Produce a generalized singlet state acting on two n-dimensional systems :cite:`Cabello_2002_NParticle`. Examples ========== @@ -63,11 +63,10 @@ def singlet(dim: int) -> np.ndarray: References ========== - .. [Gsinglet] Cabello, Adan, - "N-particle N-level singlet states: Some properties and applications". - Phys. Rev. Lett., 89 (2002): 100402. - + .. bibliography:: + :filter: docname in docnames + :param dim: The dimension of the generalized singlet state. :return: The singlet state of dimension `dim`. """ - return (np.identity(dim**2) - swap_operator([dim, dim])) / ((dim**2) - dim) + return (np.identity(dim ** 2) - swap_operator([dim, dim])) / ((dim ** 2) - dim) diff --git a/toqito/states/tests/test_basis.py b/toqito/states/tests/test_basis.py index 97b486209..67152f783 100644 --- a/toqito/states/tests/test_basis.py +++ b/toqito/states/tests/test_basis.py @@ -5,14 +5,17 @@ from toqito.states import basis -@pytest.mark.parametrize("dim, pos, expected_result", [ - # Test for `|0>`. - (2, 0, np.array([[1], [0]])), - # Test for `|1>`. - (2, 1, np.array([[0], [1]])), - # Test for `|0000>`. - (4, 0, np.array([[1], [0], [0], [0]])), -]) +@pytest.mark.parametrize( + "dim, pos, expected_result", + [ + # Test for `|0>`. + (2, 0, np.array([[1], [0]])), + # Test for `|1>`. + (2, 1, np.array([[0], [1]])), + # Test for `|0000>`. + (4, 0, np.array([[1], [0], [0], [0]])), + ], +) def test_basis(dim, pos, expected_result): np.testing.assert_array_equal(basis(dim, pos), expected_result) diff --git a/toqito/states/tests/test_bell.py b/toqito/states/tests/test_bell.py index cd6447163..74c017d2f 100644 --- a/toqito/states/tests/test_bell.py +++ b/toqito/states/tests/test_bell.py @@ -7,26 +7,32 @@ e_0, e_1 = np.array([[1], [0]]), np.array([[0], [1]]) -@pytest.mark.parametrize("bell_idx, expected_result", [ - # 1/sqrt(2) * (|00> + |11>) - (0, 1 / np.sqrt(2) * (np.kron(e_0, e_0) + np.kron(e_1, e_1))), - # 1/sqrt(2) * (|00> - |11>) - (1, 1 / np.sqrt(2) * (np.kron(e_0, e_0) - np.kron(e_1, e_1))), - # 1/sqrt(2) * (|01> + |10>) - (2, 1 / np.sqrt(2) * (np.kron(e_0, e_1) + np.kron(e_1, e_0))), - # 1/sqrt(2) * (|01> - |10>) - (3, 1 / np.sqrt(2) * (np.kron(e_0, e_1) - np.kron(e_1, e_0))), -]) +@pytest.mark.parametrize( + "bell_idx, expected_result", + [ + # 1/sqrt(2) * (|00> + |11>) + (0, 1 / np.sqrt(2) * (np.kron(e_0, e_0) + np.kron(e_1, e_1))), + # 1/sqrt(2) * (|00> - |11>) + (1, 1 / np.sqrt(2) * (np.kron(e_0, e_0) - np.kron(e_1, e_1))), + # 1/sqrt(2) * (|01> + |10>) + (2, 1 / np.sqrt(2) * (np.kron(e_0, e_1) + np.kron(e_1, e_0))), + # 1/sqrt(2) * (|01> - |10>) + (3, 1 / np.sqrt(2) * (np.kron(e_0, e_1) - np.kron(e_1, e_0))), + ], +) def test_bell(bell_idx, expected_result): np.testing.assert_array_equal(bell(bell_idx), expected_result) -@pytest.mark.parametrize("bell_idx", [ - # Invalid index. - (4), - # Invalid index. - (10), -]) +@pytest.mark.parametrize( + "bell_idx", + [ + # Invalid index. + (4), + # Invalid index. + (10), + ], +) def test_bell_invalid(bell_idx): """Ensures that an integer above 3 is error-checked.""" with np.testing.assert_raises(ValueError): diff --git a/toqito/states/tests/test_brauer.py b/toqito/states/tests/test_brauer.py index be75de0f7..e5c22a9f0 100644 --- a/toqito/states/tests/test_brauer.py +++ b/toqito/states/tests/test_brauer.py @@ -26,9 +26,12 @@ ) -@pytest.mark.parametrize("dim, p_val, expected_result", [ - # Generate Brauer states on 4 qubits. - (2, 2, brauer_2_2), -]) +@pytest.mark.parametrize( + "dim, p_val, expected_result", + [ + # Generate Brauer states on 4 qubits. + (2, 2, brauer_2_2), + ], +) def test_brauer(dim, p_val, expected_result): np.testing.assert_array_equal(brauer(dim, p_val), expected_result) diff --git a/toqito/states/tests/test_breuer.py b/toqito/states/tests/test_breuer.py index c0db8c2d5..1065f82f7 100644 --- a/toqito/states/tests/test_breuer.py +++ b/toqito/states/tests/test_breuer.py @@ -5,18 +5,24 @@ from toqito.states import breuer -@pytest.mark.parametrize("dim, lam, expected_result", [ - # Generate Breuer state of dimension 4 with weight 0.1. - (2, 0.1, np.array([[0.3, 0, 0, 0], [0, 0.2, 0.1, 0], [0, 0.1, 0.2, 0], [0, 0, 0, 0.3]])), -]) +@pytest.mark.parametrize( + "dim, lam, expected_result", + [ + # Generate Breuer state of dimension 4 with weight 0.1. + (2, 0.1, np.array([[0.3, 0, 0, 0], [0, 0.2, 0.1, 0], [0, 0.1, 0.2, 0], [0, 0, 0, 0.3]])), + ], +) def test_breuer(dim, lam, expected_result): np.testing.assert_allclose(breuer(dim, lam), expected_result) -@pytest.mark.parametrize("dim, lam", [ - # Ensures that an odd dimension if not accepted. - (3, 0.1) -]) +@pytest.mark.parametrize( + "dim, lam", + [ + # Ensures that an odd dimension if not accepted. + (3, 0.1) + ], +) def test_breuer_invalid(dim, lam): with np.testing.assert_raises(ValueError): breuer(dim, lam) diff --git a/toqito/states/tests/test_domino.py b/toqito/states/tests/test_domino.py index 6e9d21b1f..fd77b3ea0 100644 --- a/toqito/states/tests/test_domino.py +++ b/toqito/states/tests/test_domino.py @@ -7,26 +7,29 @@ e_0, e_1, e_2 = np.array([[1], [0], [0]]), np.array([[0], [1], [0]]), np.array([[0], [0], [1]]) -@pytest.mark.parametrize("idx, expected_result", [ - # Domino with index = 0. - (0, np.kron(e_1, e_1)), - # Domino with index = 1. - (1, np.kron(e_0, 1 / np.sqrt(2) * (e_0 + e_1))), - # Domino with index = 2. - (2, np.kron(e_0, 1 / np.sqrt(2) * (e_0 - e_1))), - # Domino with index = 3. - (3, np.kron(e_2, 1 / np.sqrt(2) * (e_1 + e_2))), - # Domino with index = 4. - (4, np.kron(e_2, 1 / np.sqrt(2) * (e_1 - e_2))), - # Domino with index = 5. - (5, np.kron(1 / np.sqrt(2) * (e_1 + e_2), e_0)), - # Domino with index = 6. - (6, np.kron(1 / np.sqrt(2) * (e_1 - e_2), e_0)), - # Domino with index = 7. - (7, np.kron(1 / np.sqrt(2) * (e_0 + e_1), e_2)), - # Domino with index = 8. - (8, np.kron(1 / np.sqrt(2) * (e_0 - e_1), e_2)), -]) +@pytest.mark.parametrize( + "idx, expected_result", + [ + # Domino with index = 0. + (0, np.kron(e_1, e_1)), + # Domino with index = 1. + (1, np.kron(e_0, 1 / np.sqrt(2) * (e_0 + e_1))), + # Domino with index = 2. + (2, np.kron(e_0, 1 / np.sqrt(2) * (e_0 - e_1))), + # Domino with index = 3. + (3, np.kron(e_2, 1 / np.sqrt(2) * (e_1 + e_2))), + # Domino with index = 4. + (4, np.kron(e_2, 1 / np.sqrt(2) * (e_1 - e_2))), + # Domino with index = 5. + (5, np.kron(1 / np.sqrt(2) * (e_1 + e_2), e_0)), + # Domino with index = 6. + (6, np.kron(1 / np.sqrt(2) * (e_1 - e_2), e_0)), + # Domino with index = 7. + (7, np.kron(1 / np.sqrt(2) * (e_0 + e_1), e_2)), + # Domino with index = 8. + (8, np.kron(1 / np.sqrt(2) * (e_0 - e_1), e_2)), + ], +) def test_domino(idx, expected_result): np.testing.assert_array_equal(domino(idx), expected_result) diff --git a/toqito/states/tests/test_gen_bell.py b/toqito/states/tests/test_gen_bell.py index 3196ddf5d..3c4a69536 100644 --- a/toqito/states/tests/test_gen_bell.py +++ b/toqito/states/tests/test_gen_bell.py @@ -5,16 +5,18 @@ from toqito.states import bell, gen_bell -@pytest.mark.parametrize("k_1, k_2, dim, expected_result", [ - # Generalized Bell state for k_1 = k_2 = 0 and dim = 2. - (0, 0, 2, bell(0) @ bell(0).conj().T), - # Generalized Bell state for k_1 = 0, k_2 = 1 and dim = 2. - (0, 1, 2, bell(1) @ bell(1).conj().T), - # Generalized Bell state for k_1 = 1, k_2 = 0 and dim = 2. - (1, 0, 2, bell(2) @ bell(2).conj().T), - # Generalized Bell state for k_1 = 1, k_2 = 1 and dim = 2. - (1, 1, 2, bell(3) @ bell(3).conj().T), - -]) +@pytest.mark.parametrize( + "k_1, k_2, dim, expected_result", + [ + # Generalized Bell state for k_1 = k_2 = 0 and dim = 2. + (0, 0, 2, bell(0) @ bell(0).conj().T), + # Generalized Bell state for k_1 = 0, k_2 = 1 and dim = 2. + (0, 1, 2, bell(1) @ bell(1).conj().T), + # Generalized Bell state for k_1 = 1, k_2 = 0 and dim = 2. + (1, 0, 2, bell(2) @ bell(2).conj().T), + # Generalized Bell state for k_1 = 1, k_2 = 1 and dim = 2. + (1, 1, 2, bell(3) @ bell(3).conj().T), + ], +) def test_gen_bell(k_1, k_2, dim, expected_result): np.testing.assert_allclose(gen_bell(k_1, k_2, dim), expected_result) diff --git a/toqito/states/tests/test_ghz.py b/toqito/states/tests/test_ghz.py index 95fcb32ff..956a12b26 100644 --- a/toqito/states/tests/test_ghz.py +++ b/toqito/states/tests/test_ghz.py @@ -10,10 +10,13 @@ ghz_2_3 = 1 / np.sqrt(2) * (tensor(e_0, e_0, e_0) + tensor(e_1, e_1, e_1)) -@pytest.mark.parametrize("dim, num_qubits, coeff, expected_res", [ - # Produces the 3-qubit GHZ state: `1/sqrt(2) * (|000> + |111>)`. - (2, 3, None, ghz_2_3), -]) +@pytest.mark.parametrize( + "dim, num_qubits, coeff, expected_res", + [ + # Produces the 3-qubit GHZ state: `1/sqrt(2) * (|000> + |111>)`. + (2, 3, None, ghz_2_3), + ], +) def test_ghz(dim, num_qubits, coeff, expected_res): res = ghz(dim, num_qubits, coeff).toarray() np.testing.assert_allclose(res, expected_res) @@ -45,14 +48,17 @@ def test_ghz_4_7(): np.testing.assert_allclose(res, expected_res) -@pytest.mark.parametrize("dim, num_qubits, coeff", [ - # Invalid dimensions. - (0, 2, None), - # Invalid qubits. - (2, 0, None), - # Invalid coefficients. - (2, 3, [1, 2, 3, 4, 5]), -]) +@pytest.mark.parametrize( + "dim, num_qubits, coeff", + [ + # Invalid dimensions. + (0, 2, None), + # Invalid qubits. + (2, 0, None), + # Invalid coefficients. + (2, 3, [1, 2, 3, 4, 5]), + ], +) def test_ghz_invalid_input(dim, num_qubits, coeff): """Tests for invalid dimensions.""" with np.testing.assert_raises(ValueError): diff --git a/toqito/states/tests/test_horodecki.py b/toqito/states/tests/test_horodecki.py index 4e9e86fd4..0d124e7a6 100644 --- a/toqito/states/tests/test_horodecki.py +++ b/toqito/states/tests/test_horodecki.py @@ -64,14 +64,17 @@ def test_horodecki_state_2_4(): np.testing.assert_allclose(res, expected_res, atol=0.2) -@pytest.mark.parametrize("a_param, dim", [ - # Invalid a_param (negative).""" - (-5, None), - # Invalid a_param.""" - (5, None), - # Tests for invalid dimension inputs. - (0.5, [3, 4]), -]) +@pytest.mark.parametrize( + "a_param, dim", + [ + # Invalid a_param (negative).""" + (-5, None), + # Invalid a_param.""" + (5, None), + # Tests for invalid dimension inputs. + (0.5, [3, 4]), + ], +) def test_horodecki_invalid(a_param, dim): """Tests for invalid a_param and dimension inputs.""" with np.testing.assert_raises(ValueError): diff --git a/toqito/states/tests/test_isotropic.py b/toqito/states/tests/test_isotropic.py index 9fe553af2..03514c7f8 100644 --- a/toqito/states/tests/test_isotropic.py +++ b/toqito/states/tests/test_isotropic.py @@ -3,17 +3,20 @@ from toqito.states import isotropic -iso_dim_3_alpha_half = np.array([ - [0.22222222, 0, 0, 0, 0.16666667, 0, 0, 0, 0.16666667], - [0, 0.05555556, 0, 0, 0, 0, 0, 0, 0], - [0, 0, 0.05555556, 0, 0, 0, 0, 0, 0], - [0, 0, 0, 0.05555556, 0, 0, 0, 0, 0], - [0.16666667, 0, 0, 0, 0.22222222, 0, 0, 0, 0.16666667], - [0, 0, 0, 0, 0, 0.05555556, 0, 0, 0], - [0, 0, 0, 0, 0, 0, 0.05555556, 0, 0], - [0, 0, 0, 0, 0, 0, 0, 0.05555556, 0], - [0.16666667, 0, 0, 0, 0.16666667, 0, 0, 0, 0.22222222], -]) +iso_dim_3_alpha_half = np.array( + [ + [0.22222222, 0, 0, 0, 0.16666667, 0, 0, 0, 0.16666667], + [0, 0.05555556, 0, 0, 0, 0, 0, 0, 0], + [0, 0, 0.05555556, 0, 0, 0, 0, 0, 0], + [0, 0, 0, 0.05555556, 0, 0, 0, 0, 0], + [0.16666667, 0, 0, 0, 0.22222222, 0, 0, 0, 0.16666667], + [0, 0, 0, 0, 0, 0.05555556, 0, 0, 0], + [0, 0, 0, 0, 0, 0, 0.05555556, 0, 0], + [0, 0, 0, 0, 0, 0, 0, 0.05555556, 0], + [0.16666667, 0, 0, 0, 0.16666667, 0, 0, 0, 0.22222222], + ] +) + def test_isotropic_qutrit(): """Generate a qutrit isotropic state with `alpha` = 1/2.""" diff --git a/toqito/states/tests/test_max_entangled.py b/toqito/states/tests/test_max_entangled.py index 051a41166..087276a77 100644 --- a/toqito/states/tests/test_max_entangled.py +++ b/toqito/states/tests/test_max_entangled.py @@ -8,12 +8,15 @@ e_0, e_1 = np.array([[1], [0]]), np.array([[0], [1]]) -@pytest.mark.parametrize("dim, is_sparse, is_normalized, expected_res", [ - # Generate maximally entangled state: `1/sqrt(2) * (|00> + |11>)`.""" - (2, False, True, 1 / np.sqrt(2) * (np.kron(e_0, e_0) + np.kron(e_1, e_1))), - # Generate maximally entangled state: `|00> + |11>`. - (2, False, False, 1 * (np.kron(e_0, e_0) + np.kron(e_1, e_1))), -]) +@pytest.mark.parametrize( + "dim, is_sparse, is_normalized, expected_res", + [ + # Generate maximally entangled state: `1/sqrt(2) * (|00> + |11>)`.""" + (2, False, True, 1 / np.sqrt(2) * (np.kron(e_0, e_0) + np.kron(e_1, e_1))), + # Generate maximally entangled state: `|00> + |11>`. + (2, False, False, 1 * (np.kron(e_0, e_0) + np.kron(e_1, e_1))), + ], +) def test_max_entangled(dim, is_sparse, is_normalized, expected_res): res = max_entangled(dim=dim, is_sparse=is_sparse, is_normalized=is_normalized) np.testing.assert_allclose(res, expected_res) diff --git a/toqito/states/tests/test_tile.py b/toqito/states/tests/test_tile.py index 187ba6ee6..3de5fd380 100644 --- a/toqito/states/tests/test_tile.py +++ b/toqito/states/tests/test_tile.py @@ -8,27 +8,33 @@ e_0, e_1, e_2 = np.array([[1], [0], [0]]), np.array([[0], [1], [0]]), np.array([[0], [0], [1]]) -@pytest.mark.parametrize("tile_idx, expected_result", [ - # |\psi_0 \rangle = \frac{1}{\sqrt{2}} |0 \rangle \left(|0\rangle - |1\rangle \right). - (0, 1 / np.sqrt(2) * np.kron(e_0, (e_0 - e_1))), - # |\psi_1\rangle = \frac{1}{\sqrt{2}} \left(|0\rangle - |1\rangle \right) |2\rangle - (1, 1 / np.sqrt(2) * np.kron((e_0 - e_1), e_2)), - # |\psi_2\rangle = \frac{1}{\sqrt{2}} |2\rangle \left(|1\rangle - |2\rangle \right) - (2, 1 / np.sqrt(2) * np.kron(e_2, (e_1 - e_2))), - # |\psi_3\rangle = \frac{1}{\sqrt{2}} \left(|1\rangle - |2\rangle \right) |0\rangle - (3, 1 / np.sqrt(2) * np.kron((e_1 - e_2), e_0)), - # |\psi_4\rangle = \frac{1}{3} \left(|0\rangle + |1\rangle + - # |2\rangle)\right) \left(|0\rangle + |1\rangle + |2\rangle. - (4, 1 / 3 * np.kron((e_0 + e_1 + e_2), (e_0 + e_1 + e_2))), -]) +@pytest.mark.parametrize( + "tile_idx, expected_result", + [ + # |\psi_0 \rangle = \frac{1}{\sqrt{2}} |0 \rangle \left(|0\rangle - |1\rangle \right). + (0, 1 / np.sqrt(2) * np.kron(e_0, (e_0 - e_1))), + # |\psi_1\rangle = \frac{1}{\sqrt{2}} \left(|0\rangle - |1\rangle \right) |2\rangle + (1, 1 / np.sqrt(2) * np.kron((e_0 - e_1), e_2)), + # |\psi_2\rangle = \frac{1}{\sqrt{2}} |2\rangle \left(|1\rangle - |2\rangle \right) + (2, 1 / np.sqrt(2) * np.kron(e_2, (e_1 - e_2))), + # |\psi_3\rangle = \frac{1}{\sqrt{2}} \left(|1\rangle - |2\rangle \right) |0\rangle + (3, 1 / np.sqrt(2) * np.kron((e_1 - e_2), e_0)), + # |\psi_4\rangle = \frac{1}{3} \left(|0\rangle + |1\rangle + + # |2\rangle)\right) \left(|0\rangle + |1\rangle + |2\rangle. + (4, 1 / 3 * np.kron((e_0 + e_1 + e_2), (e_0 + e_1 + e_2))), + ], +) def test_tile(tile_idx, expected_result): np.testing.assert_array_equal(tile(tile_idx), expected_result) -@pytest.mark.parametrize("tile_idx", [ - # Invalid idx. - (5, 1 / np.sqrt(2) * np.kron(e_0, (e_0 - e_1))), -]) +@pytest.mark.parametrize( + "tile_idx", + [ + # Invalid idx. + (5, 1 / np.sqrt(2) * np.kron(e_0, (e_0 - e_1))), + ], +) def test_tile_invalid(tile_idx): """Ensures that an integer above 4 is error-checked.""" with np.testing.assert_raises(ValueError): diff --git a/toqito/states/tests/test_w_state.py b/toqito/states/tests/test_w_state.py index ddfc77a21..314909706 100644 --- a/toqito/states/tests/test_w_state.py +++ b/toqito/states/tests/test_w_state.py @@ -36,12 +36,15 @@ def test_w_state_generalized(): np.testing.assert_allclose(res, expected_res, atol=0.2) -@pytest.mark.parametrize("idx, coeff", [ - # Number of qubits needs to be greater than 2. - (1, None), - # Length of coefficient list needs to be equal to number of qubits. - (4, [1, 2, 3]), -]) +@pytest.mark.parametrize( + "idx, coeff", + [ + # Number of qubits needs to be greater than 2. + (1, None), + # Length of coefficient list needs to be equal to number of qubits. + (4, [1, 2, 3]), + ], +) def test_w_state_invalid(idx, coeff): with np.testing.assert_raises(ValueError): w_state(idx, coeff) diff --git a/toqito/states/tile.py b/toqito/states/tile.py index da59eb47b..8c181d95e 100644 --- a/toqito/states/tile.py +++ b/toqito/states/tile.py @@ -6,7 +6,7 @@ def tile(idx: int) -> np.ndarray: r""" - Produce a Tile state [UPBTile99]_. + Produce a Tile state :cite:`Bennett_1999_UPB`. The Tile states constitute five states on 3-by-3 dimensional space that form a UPB (unextendible product basis). @@ -51,10 +51,9 @@ def tile(idx: int) -> np.ndarray: References ========== - .. [UPBTile99] Bennett, Charles H., et al. - "Unextendible product bases and bound entanglement." - Physical Review Letters 82.26 (1999): 5385. - https://arxiv.org/abs/quant-ph/9808030 + .. bibliography:: + :filter: docname in docnames + :raises ValueError: Invalid value for :code:`idx`. :param idx: A parameter in [0, 1, 2, 3, 4] diff --git a/toqito/states/trine.py b/toqito/states/trine.py index 421ea57c2..38a868203 100644 --- a/toqito/states/trine.py +++ b/toqito/states/trine.py @@ -6,7 +6,7 @@ def trine() -> list[np.ndarray]: r""" - Produce the set of trine states [YardQIP]_. + Produce the set of trine states (Slide 6 of :cite:`Yard_2017_Lecture11`). The trine states are formally defined as: @@ -30,10 +30,8 @@ def trine() -> list[np.ndarray]: References ========== - .. [YardQIP] Yard, Jon - Introduction to Quantum Information Processing"" - (Slide 6) - https://www.math.uwaterloo.ca/~jyard/qic710/F17/Qic710Lec11-2017.pdf + .. bibliography:: + :filter: docname in docnames :return: Vector of trine states. """ diff --git a/toqito/states/w_state.py b/toqito/states/w_state.py index 4b5ffd653..034ec3292 100644 --- a/toqito/states/w_state.py +++ b/toqito/states/w_state.py @@ -6,9 +6,9 @@ def w_state(num_qubits: int, coeff: list[int] = None) -> np.ndarray: r""" - Produce a W-state [DVC00]_. + Produce a W-state :cite:`Dur_2000_ThreeQubits`. - Returns the W-state described in [DVC00]. The W-state on `num_qubits` qubits is defined by: + Returns the W-state described in :cite:`Dur_2000_ThreeQubits`. The W-state on `num_qubits` qubits is defined by: .. math:: |W \rangle = \frac{1}{\sqrt{num\_qubits}} @@ -68,9 +68,9 @@ def w_state(num_qubits: int, coeff: list[int] = None) -> np.ndarray: References ========== - .. [DVC00] Three qubits can be entangled in two inequivalent ways. - W. Dur, G. Vidal, and J. I. Cirac. - E-print: arXiv:quant-ph/0005115, 2000. + .. bibliography:: + :filter: docname in docnames + :raises ValueError: The number of qubits must be greater than or equal to 1. :param num_qubits: An integer representing the number of qubits. @@ -88,9 +88,9 @@ def w_state(num_qubits: int, coeff: list[int] = None) -> np.ndarray: "of length equal to `num_qubits`." ) - ret_w_state = sparse.csr_matrix((2**num_qubits, 1)).toarray() + ret_w_state = sparse.csr_matrix((2 ** num_qubits, 1)).toarray() for i in range(num_qubits): - ret_w_state[2**i] = coeff[num_qubits - i - 1] + ret_w_state[2 ** i] = coeff[num_qubits - i - 1] return np.around(ret_w_state, 4) diff --git a/toqito/states/werner.py b/toqito/states/werner.py index c46921bbe..a95527d66 100644 --- a/toqito/states/werner.py +++ b/toqito/states/werner.py @@ -7,7 +7,7 @@ def werner(dim: int, alpha: float | list[float]) -> np.ndarray: r""" - Produce a Werner state [Wer89]_. + Produce a Werner state :cite:`Werner_1989_QuantumStates`. A Werner state is a state of the following form @@ -78,9 +78,8 @@ def werner(dim: int, alpha: float | list[float]) -> np.ndarray: References ========== - .. [Wer89] R. F. Werner. - Quantum states with Einstein-Podolsky-Rosen correlations admitting a - hidden-variable model. Phys. Rev. A, 40(8):4277–4281. 1989 + .. bibliography:: + :filter: docname in docnames :raises ValueError: Alpha vector does not have the correct length. :param dim: The dimension of the Werner state.