
    bie	                         d dl mZmZ d dlZd dlmZ d dlmZ d dl	m
Z
 d dlmZ d dlmZ 	 dded	eeef   d
ed   fdZy)    )LiteralTupleN)kron)partial_trace)hermitian_wrap)quantum_rel_entr)
Expressionrhodimssys)r      c                 t   t        |      dk7  rddt        |       dz   }t        |      |dk(  r.t        t        j                  |d         t        | ||            }nB|dk(  r.t        t        | ||      t        j                  |d               }nt        d| d      t        |      }t        | ||       S )	a	  
    Returns (an approximation of) the quantum conditional entropy for a bipartite state,
    conditioning on system :math:`\texttt{sys}.`

    Formally, if :math:`N` is the von Neumann entropy function and
    :math:`\operatorname{tr}_{\texttt{sys}}` is the partial trace operator over subsystem
    :math:`\texttt{sys},` the returned expression represents

    .. math::
        N(\rho) - N(\operatorname{tr}_{\texttt{sys}}(\rho)).

    Parameters
    ----------
    rho : Expression
        A Hermitian matrix of order :math:`\texttt{dims[0]}\cdot\texttt{dims[1]}.`

    dims : tuple
        The dimensions of the two subsystems that definte :math:`\rho` as a bipartite state.

    sys : int
        The subsystem on which to condition in evaluating the conditional quantum entropy.

    quad_approx : Tuple[int, int]
        quad_approx[0] is the number of quadrature nodes and quad_approx[1] is the number of scaling
        points in the quadrature scheme from https://arxiv.org/abs/1705.00812.

    Notes
    -----
    This function does not assume :math:`\operatorname{tr}(ho)=1,` which would be required
    for most uses of this function in the context of quantum information theory. See 
    https://en.wikipedia.org/wiki/Conditional_quantum_entropy for more information. 
       zEThis function is only defined for a tensor product of two subsystems,zbut z0 subsystems were implied from the value of dims.r   r   z(Argument sys must be either 0 or 1; got .)len
ValueErrorr   npeyer   r   r   )r
   r   r   quad_approxerrcomposite_args         X/home/cdr/jupyterlab/.venv/lib/python3.12/site-packages/cvxpy/atoms/quantum_cond_entr.pyquantum_cond_entrr      s    F 4yA~U
s4ykIJKo
axFF47O]3c:
 
#tS)266$q'?
 CC5JKK"=1MS-===    )r   )   r   )typingr   r   numpyr   cvxpy.atoms.affine.kronr    cvxpy.atoms.affine.partial_tracer   cvxpy.atoms.affine.wrapsr   cvxpy.atoms.quantum_rel_entrr   cvxpy.expressions.expressionr	   intr    r   r   <module>r%      sJ    !  ( : 3 9 3 V\2>2> %c3h2>6=dm2>r   