+
    Y°³j   ã                   ód   € R t Rt. R	Ot^ RIt^ RIHt ^RIHtHt ^RI	H
t
Ht R tR
R ltR
R ltR# )z.Functions to extract parts of sparse matrices
zrestructuredtext enN)Úwarn)Ú	coo_arrayÚ
coo_matrix)ÚsparrayÚspmatrixc                óÊ   € \        V RR7      p V P                  4        V P                  ^ 8g  pV P                  V,          V P                  V,          V P                  V,          3# )a  Return the indices and values of the nonzero elements of a matrix.

Parameters
----------
A : dense or sparse array or matrix
    Matrix whose nonzero elements are desired.

Returns
-------
(I,J,V) : tuple of arrays
    I,J, and V contain the row indices, column indices, and values
    of the nonzero entries.


Examples
--------
>>> from scipy.sparse import csr_array, find
>>> A = csr_array([[7.0, 8.0, 0],[0, 0, 9.0]])
>>> find(A)
(array([0, 0, 1], dtype=int32),
 array([0, 1, 2], dtype=int32),
 array([ 7.,  8.,  9.]))

T©Úcopy)r   Úsum_duplicatesÚdataÚrowÚcol)ÚAÚnz_masks   & ÚV/home/luca/screen-checking/.venv/lib/python3.14/site-packages/scipy/sparse/_extract.pyÚfindr      sN   € ô4 	�!˜$Ô€AØ×ÑÔà�f‰f˜‰k€GØ�5‰5��>˜1Ÿ5™5 �>¨1¯6©6°'­?Ð:Ð:ó    c                ó  € \        V \        4      '       d   \        pM[\        V \        4      '       d   \        pM>Rp\
        P                  P                  \        4      3p\        V\        VR7       \        pV! V RR7      p V P                  V,           V P                  8¬  pV P                  V,          pV P                  V,          pV P                  V,          p	V! W—V33V P                  V P                  R7      p
V
P!                  V4      # )aÁ  Return the lower triangular portion of a sparse array or matrix.

Returns the elements on or below the k-th diagonal of A.
    - k = 0 corresponds to the main diagonal
    - k > 0 is above the main diagonal
    - k < 0 is below the main diagonal

.. warning::

    `tril` is switching to the sparse array interface.

    For the case where no input arrays are sparse, this function is
    switching to returning a sparse array instead of sparse matrix.
    Control the sparse return class by making at least one input sparse,
    e.g., ``tril(coo_matrix(A))``, or ``tril(coo_array(A))``.
    That removes any deprecation warnings as well.
    For more general information about sparrays, see
    :ref:`Migration from spmatrix to sparray <migration_to_sparray>`.
    Handling of this no sparse input case will change no earlier than v1.20.

Parameters
----------
A : dense or sparse array or matrix
    Matrix whose lower trianglar portion is desired.
k : int : optional
    The top-most diagonal of the lower triangle.
format : str
    Sparse format of the result, e.g. format="csr", etc.

Returns
-------
L : sparse matrix
    Lower triangular portion of A in sparse format.

See Also
--------
triu : upper triangle in sparse format

Examples
--------
>>> from scipy.sparse import csr_array, tril
>>> A = csr_array([[1, 2, 0, 0, 3], [4, 5, 0, 6, 7], [0, 0, 8, 9, 0]],
...               dtype='int32')
>>> A.toarray()
array([[1, 2, 0, 0, 3],
       [4, 5, 0, 6, 7],
       [0, 0, 8, 9, 0]], dtype=int32)
>>> tril(A).toarray()
array([[1, 0, 0, 0, 0],
       [4, 5, 0, 0, 0],
       [0, 0, 8, 0, 0]], dtype=int32)
>>> tril(A).nnz
4
>>> tril(A, k=1).toarray()
array([[1, 2, 0, 0, 0],
       [4, 5, 0, 0, 0],
       [0, 0, 8, 9, 0]], dtype=int32)
>>> tril(A, k=-1).toarray()
array([[0, 0, 0, 0, 0],
       [4, 0, 0, 0, 0],
       [0, 0, 0, 0, 0]], dtype=int32)
>>> tril(A, format='csc')
<Compressed Sparse Column sparse array of dtype 'int32'
    with 4 stored elements and shape (3, 5)>

ay  `tril` is switching to the sparse array interface.

        For the case where input arrays are numpy arrays, this function is
        switching to returning a sparse array instead of sparse matrix.
        Recover the sparse matrix return value by making one input a sparse matrix.
        For example, tril(coo_matrix(A)).
        Avoid this message for sparse array output by using tril(coo_array(A)).
        For more information, see the spmatrix to sparray migration guide
        https://docs.scipy.org/doc/scipy/reference/sparse.migration_to_sparray.html

        This function will be changed no earlier than v1.20.
        ©ÚcategoryÚskip_file_prefixesFr   ©ÚshapeÚdtype©Ú
isinstancer   r   r   r   ÚosÚpathÚdirnameÚ__file__r   ÚDeprecationWarningr   r   r   r   r   Úasformat©r   ÚkÚformatÚ
coo_sparseÚmsgÚprefixesÚmaskr   r   r   Únew_coos   &&&        r   Útrilr*   0   sÒ   € ôF �!”W×ÒÜ‰
Ü	�A”x×	 Ò	 Ü‰
ðˆô —G‘G—O‘O¤HÓ-Ð/ˆÜˆSÔ-À(ÕKäˆ
ñ 	�1˜5Ô!€AØ�5‰5�1�9˜Ÿ™Ñ€Dà
�%‰%��+€CØ
�%‰%��+€CØ�6‰6�$�<€DÙ˜$ c 
Ð+°1·7±7À!Ç'Á'ÔJ€GØ×Ñ˜FÓ#Ð#r   c                ó  € \        V \        4      '       d   \        pM[\        V \        4      '       d   \        pM>Rp\
        P                  P                  \        4      3p\        V\        VR7       \        pV! V RR7      p V P                  V,           V P                  8*  pV P                  V,          pV P                  V,          pV P                  V,          p	V! W—V33V P                  V P                  R7      p
V
P!                  V4      # )a	  Return the upper triangular portion of a sparse array or matrix.

Returns the elements on or above the k-th diagonal of A.
    - k = 0 corresponds to the main diagonal
    - k > 0 is above the main diagonal
    - k < 0 is below the main diagonal

.. warning::

    `triu` is switching to the sparse array interface.

    For the case where no input arrays are sparse, this function is
    switching to returning a sparse array instead of sparse matrix.
    Control the sparse return class by making at least one input sparse,
    e.g., ``triu(coo_matrix(A))``, or ``triu(coo_array(A))``.
    That removes any deprecation warnings as well.
    For more general information about sparrays, see
    :ref:`Migration from spmatrix to sparray <migration_to_sparray>`.
    Handling of this no sparse input case will change no earlier than v1.20.

Parameters
----------
A : dense or sparse array or matrix
    Matrix whose upper trianglar portion is desired.
k : int : optional
    The bottom-most diagonal of the upper triangle.
format : str
    Sparse format of the result, e.g. format="csr", etc.

Returns
-------
L : sparse array or matrix
    Upper triangular portion of A in sparse format.
    Sparse array if A is a sparse array, otherwise matrix.

See Also
--------
tril : lower triangle in sparse format

Examples
--------
>>> from scipy.sparse import csr_array, triu
>>> A = csr_array([[1, 2, 0, 0, 3], [4, 5, 0, 6, 7], [0, 0, 8, 9, 0]],
...                dtype='int32')
>>> A.toarray()
array([[1, 2, 0, 0, 3],
       [4, 5, 0, 6, 7],
       [0, 0, 8, 9, 0]], dtype=int32)
>>> triu(A).toarray()
array([[1, 2, 0, 0, 3],
       [0, 5, 0, 6, 7],
       [0, 0, 8, 9, 0]], dtype=int32)
>>> triu(A).nnz
8
>>> triu(A, k=1).toarray()
array([[0, 2, 0, 0, 3],
       [0, 0, 0, 6, 7],
       [0, 0, 0, 9, 0]], dtype=int32)
>>> triu(A, k=-1).toarray()
array([[1, 2, 0, 0, 3],
       [4, 5, 0, 6, 7],
       [0, 0, 8, 9, 0]], dtype=int32)
>>> triu(A, format='csc')
<Compressed Sparse Column sparse array of dtype 'int32'
    with 8 stored elements and shape (3, 5)>

ay  `triu` is switching to the sparse array interface.

        For the case where input arrays are numpy arrays, this function is
        switching to returning a sparse array instead of sparse matrix.
        Recover the sparse matrix return value by making one input a sparse matrix.
        For example, triu(coo_matrix(A)).
        Avoid this message for sparse array output by using triu(coo_array(A)).
        For more information, see the spmatrix to sparray migration guide
        https://docs.scipy.org/doc/scipy/reference/sparse.migration_to_sparray.html

        This function will be changed no earlier than v1.20.
        r   Fr   r   r   r"   s   &&&        r   Útriur,   ”   sÒ   € ôH �!”W×ÒÜ‰
Ü	�A”x×	 Ò	 Ü‰
ðˆô —G‘G—O‘O¤HÓ-Ð/ˆÜˆSÔ-À(ÕKäˆ
ñ 	�1˜5Ô!€AØ�5‰5�1�9˜Ÿ™Ñ€Dà
�%‰%��+€CØ
�%‰%��+€CØ�6‰6�$�<€DÙ˜$ c 
Ð+°1·7±7À!Ç'Á'ÔJ€GØ×Ñ˜FÓ#Ð#r   )r   r*   r,   )é    N)Ú__doc__Ú__docformat__Ú__all__r   Úwarningsr   Ú_coor   r   Ú_baser   r   r   r*   r,   © r   r   Ú<module>r5      s5   ðñð &€â
"€ã 	Ý ç 'ß $ò;ôBa$öHb$r   