コード例 #1
0
ファイル: test_is_pure.py プロジェクト: sgmenda/toqito
    def test_is_pure_list(self):
        """Check that list of pure states returns True."""
        e_0, e_1, e_2 = ket(3, 0), ket(3, 1), ket(3, 2)

        e0_dm = e_0 * e_0.conj().T
        e1_dm = e_1 * e_1.conj().T
        e2_dm = e_2 * e_2.conj().T

        self.assertEqual(is_pure([e0_dm, e1_dm, e2_dm]), True)
コード例 #2
0
ファイル: is_mixed.py プロジェクト: sgmenda/toqito
def is_mixed(state: np.ndarray) -> bool:
    r"""
    Determine if a given quantum state is mixed [WIKMIX]_.

    A mixed state by definition is a state that is not pure.

    Examples
    ==========

    Consider the following density matrix

    .. math::
        \rho =  \begin{pmatrix}
                    \frac{3}{4} & 0 \\
                    0 & \frac{1}{4}
                \end{pmatrix} \text{D}(\mathcal{X}).

    Calculating the rank of $\rho$ yields that the $\rho$ is a mixed state. This
    can be confirmed in `toqito` as follows:

    >>> from toqito.core.ket import ket
    >>> from toqito.states.properties.is_mixed import is_mixed
    >>> e_0, e_1 = ket(2, 0), ket(2, 1)
    >>> rho = 3 / 4 * e_0 * e_0.conj().T + 1 / 4 * e_1 * e_1.conj().T
    >>> is_mixed(rho)
    True

    References
    ==========
    .. [WIKMIX] Wikipedia: Quantum state - Mixed states
        https://en.wikipedia.org/wiki/Quantum_state#Mixed_states

    :param state: The density matrix representing the quantum state.
    :return: True if state is mixed and False otherwise.
    """
    return not is_pure(state)
コード例 #3
0
ファイル: test_is_pure.py プロジェクト: sgmenda/toqito
 def test_is_not_pure_list(self):
     """Check that list of non-pure states return False."""
     rho = np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]])
     sigma = np.array([[1, 2, 3], [10, 11, 12], [7, 8, 9]])
     self.assertEqual(is_pure([rho, sigma]), False)
コード例 #4
0
ファイル: test_is_pure.py プロジェクト: sgmenda/toqito
 def test_is_not_pure_state(self):
     """Check that non-pure state returns False."""
     rho = np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]])
     self.assertEqual(is_pure(rho), False)
コード例 #5
0
ファイル: test_is_pure.py プロジェクト: sgmenda/toqito
 def test_is_pure_state(self):
     """Ensure that pure Bell state returns True."""
     rho = bell(0) * bell(0).conj().T
     self.assertEqual(is_pure(rho), True)
コード例 #6
0
 def test_random_complex_state_purity(self):
     """Check that complex state vector from random state vector is pure."""
     vec = random_state_vector(2)
     mat = vec.conj().T * vec
     self.assertEqual(is_pure(mat), True)
コード例 #7
0
 def test_random_real_state_purity_with_k_param(self):
     """Check that real state vector with k_param > 0."""
     vec = random_state_vector(2, True, 1)
     mat = vec.conj().T * vec
     self.assertEqual(is_pure(mat), False)
コード例 #8
0
 def test_random_complex_state_purity_with_k_param_dim_list(self):
     """Check that complex state vector with k_param > 0 and dim list."""
     vec = random_state_vector([2, 2], False, 1)
     mat = vec.conj().T * vec
     self.assertEqual(is_pure(mat), False)