Beispiel #1
0
def test_is_pure_list():
    """Check that list of pure states returns True."""
    e_0, e_1, e_2 = basis(3, 0), basis(3, 1), basis(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

    np.testing.assert_equal(is_pure([e0_dm, e1_dm, e2_dm]), True)
Beispiel #2
0
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} \in \text{D}(\mathcal{X}).

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

    >>> from toqito.states import basis
    >>> from toqito.state_props import is_mixed
    >>> e_0, e_1 = basis(2, 0), basis(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: :code:`True` if state is mixed and :code:`False` otherwise.
    """
    return not is_pure(state)
Beispiel #3
0
def test_is_pure_state():
    """Ensure that pure Bell state returns True."""
    rho = bell(0) * bell(0).conj().T
    np.testing.assert_equal(is_pure(rho), True)
Beispiel #4
0
def test_is_pure_not_pure_list():
    """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]])
    np.testing.assert_equal(is_pure([rho, sigma]), False)
Beispiel #5
0
def test_is_pure_not_pure_state():
    """Check that non-pure state returns False."""
    rho = np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]])
    np.testing.assert_equal(is_pure(rho), False)
def test_random_state_vector_complex_state_purity():
    """Check that complex state vector from random state vector is pure."""
    vec = random_state_vector(2)
    mat = vec.conj().T * vec
    np.testing.assert_equal(is_pure(mat), True)
def test_random_state_vector_real_state_purity_with_k_param():
    """Check that real state vector with k_param > 0."""
    vec = random_state_vector(2, True, 1)
    mat = vec.conj().T * vec
    np.testing.assert_equal(is_pure(mat), False)
def test_random_state_vector_complex_state_purity_k_param_dim_list():
    """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
    np.testing.assert_equal(is_pure(mat), False)