
    `i	                     D    d dl Z d dlZd dlmZ d ZddZddZd Zd ZdS )	    N)sparsec                     t          |            t          j        | d          } |                                  | j        dk    }| j        |         | j        |         | j        |         fS )a  Returns the indices and values of the nonzero elements of a matrix

    Args:
        A (cupy.ndarray or cupyx.scipy.sparse.spmatrix): Matrix whose nonzero
            elements are desired.

    Returns:
        tuple of cupy.ndarray:
            It returns (``I``, ``J``, ``V``). ``I``, ``J``, and ``V`` contain
            respectively the row indices, column indices, and values of the
            nonzero matrix entries.

    .. seealso:: :func:`scipy.sparse.find`
    Tcopyr   )_check_A_typer   
coo_matrixsum_duplicatesdatarowcol)Anz_masks     o/home/jaya/work/projects/VOICE-AGENT/VIET/agent-env/lib/python3.11/site-packages/cupyx/scipy/sparse/_extract.pyfindr      sc     !!$'''AfkG5>15>16'?::    c                     t          |            t          j        | d          } | j        |z   | j        k    }t          | |                              |          S )a  Returns the lower triangular portion of a matrix in sparse format

    Args:
        A (cupy.ndarray or cupyx.scipy.sparse.spmatrix): Matrix whose lower
            triangular portion is desired.
        k (integer): The top-most diagonal of the lower triangle.
        format (string): Sparse format of the result, e.g. 'csr', 'csc', etc.

    Returns:
        cupyx.scipy.sparse.spmatrix:
            Lower triangular portion of A in sparse format.

    .. seealso:: :func:`scipy.sparse.tril`
    Fr   r   r   r   r   r   _masked_cooasformatr   kformatmasks       r   trilr      W     !!%(((A519Dq$((000r   c                     t          |            t          j        | d          } | j        |z   | j        k    }t          | |                              |          S )a  Returns the upper triangular portion of a matrix in sparse format

    Args:
        A (cupy.ndarray or cupyx.scipy.sparse.spmatrix): Matrix whose upper
            triangular portion is desired.
        k (integer): The bottom-most diagonal of the upper triangle.
        format (string): Sparse format of the result, e.g. 'csr', 'csc', etc.

    Returns:
        cupyx.scipy.sparse.spmatrix:
            Upper triangular portion of A in sparse format.

    .. seealso:: :func:`scipy.sparse.triu`
    Fr   r   r   s       r   triur   2   r   r   c                     t          | t          j                  s5t          j        j                            |           sd}t          |          d S d S )Nz5A must be cupy.ndarray or cupyx.scipy.sparse.spmatrix)
isinstancecupyndarraycupyxscipyr   
isspmatrix	TypeError)r   msgs     r   r   r   G   sU    q$,'' 5;+=+H+H+K+K Enn   r   c                     | j         |         }| j        |         }| j        |         }t          j        |||ff| j        | j                  S )N)shapedtype)r   r   r
   r   r   r(   r)   )r   r   r   r   r
   s        r   r   r   M   sH    
%+C
%+C6$<DdS#J/qwagNNNNr   )r   N)	r    r"   cupyx.scipyr   r   r   r   r   r    r   r   <module>r,      s           ; ; ;,1 1 1 1*1 1 1 1*  O O O O Or   