403Webshell
Server IP : 217.160.0.135  /  Your IP : 216.73.217.85
Web Server : Apache
System : Linux www 6.18.52-i1-ampere #1203 SMP Mon Sep 14 18:29:59 CEST 2026 aarch64
User : sws1074145052 ( 1074145052)
PHP Version : 8.3.32
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /lib/python3/dist-packages/scipy/sparse/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /lib/python3/dist-packages/scipy/sparse/__pycache__/_lil.cpython-311.pyc
�

d�cxG���dZdZddgZddlmZddlZddlmZm	Z	dd	l
mZmZm
Z
dd
lmZmZmZmZmZmZmZddlmZGd�dee��Zdd
�Zd�ZdS)z"List of Lists sparse matrix class
zrestructuredtext en�
lil_matrix�isspmatrix_lil�)�bisect_leftN�)�spmatrix�
isspmatrix)�
IndexMixin�	INT_TYPES�_broadcast_arrays)�getdtype�isshape�isscalarlike�
upcast_scalar�get_index_dtype�check_shape�check_reshape_kwargs)�
_csparsetoolsc�,�eZdZdZdZd)d�Zd�Zd�Zd�Zd	�Z	d*d
�Z
d�Zej
je
_ejje_d�Z
d
�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Z d �Z!d!�Z"d"�Z#ej#je#_d#�Z$ej$je$_d$�Z%ej%je%_d+d%�Z&ej&je&_d,d&�Z'ej'je'_d-d'�Z(ej(je(_d-d(�Z)ej)je)_dS).ra Row-based LIst of Lists sparse matrix

    This is a structure for constructing sparse matrices incrementally.
    Note that inserting a single item can take linear time in the worst case;
    to construct a matrix efficiently, make sure the items are pre-sorted by
    index, per row.

    This can be instantiated in several ways:
        lil_matrix(D)
            with a dense matrix or rank-2 ndarray D

        lil_matrix(S)
            with another sparse matrix S (equivalent to S.tolil())

        lil_matrix((M, N), [dtype])
            to construct an empty matrix with shape (M, N)
            dtype is optional, defaulting to dtype='d'.

    Attributes
    ----------
    dtype : dtype
        Data type of the matrix
    shape : 2-tuple
        Shape of the matrix
    ndim : int
        Number of dimensions (this is always 2)
    nnz
        Number of stored values, including explicit zeros
    data
        LIL format data array of the matrix
    rows
        LIL format row index array of the matrix

    Notes
    -----
    Sparse matrices can be used in arithmetic operations: they support
    addition, subtraction, multiplication, division, and matrix power.

    Advantages of the LIL format
        - supports flexible slicing
        - changes to the matrix sparsity structure are efficient

    Disadvantages of the LIL format
        - arithmetic operations LIL + LIL are slow (consider CSR or CSC)
        - slow column slicing (consider CSC)
        - slow matrix vector products (consider CSR or CSC)

    Intended Usage
        - LIL is a convenient format for constructing sparse matrices
        - once a matrix has been constructed, convert to CSR or
          CSC format for fast arithmetic and matrix vector operations
        - consider using the COO format when constructing large matrices

    Data Structure
        - An array (``self.rows``) of rows, each of which is a sorted
          list of column indices of non-zero elements.
        - The corresponding nonzero values are stored in similar
          fashion in ``self.data``.


    �lilNFc�v�tj|��t||t���|_t|��r�t
|��r|r|���}n|���}|�|�	|d���}t|j��|_|j|_|j
|_
|j|_dSt|t ��r�t#|��r�|�t%d���|\}}t||f��|_t'j|ft*���|_
t'j|ft*���|_t-|��D]}g|j
|<g|j|<�dSt/d���	|�|��}|�||������}t|j��|_|j|_|j
|_
|j|_dS#t.$r}	t/d��|	�d}	~	wwxYw)N)�defaultF��copyzinvalid use of shape parameter��dtypez)unrecognized lil_matrix constructor usagezunsupported matrix type)r�__init__r�floatrrrr�tolil�astyper�shape�_shape�rows�data�
isinstance�tupler
�
ValueError�np�empty�object�range�	TypeError�_ascontainer�_csr_container)
�self�arg1r rr�A�M�N�i�es
          �3/usr/lib/python3/dist-packages/scipy/sparse/_lil.pyrzlil_matrix.__init__Ss'����$�����e�T�5�9�9�9��
��d���&	#��d�#�#�
!��
!��I�I�K�K����J�J�L�L��� ��H�H�U��H�/�/��%�a�g�.�.�D�K���D�J���D�I���D�I�I�I�
��U�
#�
#�	#��t�}�}�
M��$�$�%E�F�F�F����1�)�1�a�&�1�1����H�a�T��8�8�8��	��H�a�T��8�8�8��	��q���&�&�A�#%�D�I�a�L�#%�D�I�a�L�L�&�&� � K�L�L�L�

#��%�%�d�+�+���'�'���'�7�7�=�=�?�?��)�!�'�2�2����W��
��F��	��F��	�	�	���
B�
B�
B�� 9�:�:��A�����
B���s�H�
H8�#H3�3H8c�"�||z|dd�dd�f<|S�N��r.�others  r5�__iadd__zlil_matrix.__iadd__�� ���5�L��Q�Q�Q�q�q�q�S�	���c�"�||z
|dd�dd�f<|Sr7r8r9s  r5�__isub__zlil_matrix.__isub__�r<r=c�N�t|��r||z|dd�dd�f<|StSr7�r�NotImplementedr9s  r5�__imul__zlil_matrix.__imul__��6������	"��u��D����1�1�1��I��K�!�!r=c�N�t|��r||z|dd�dd�f<|StSr7rAr9s  r5�__itruediv__zlil_matrix.__itruediv__�rDr=c�z�|�td�|jD����S|dkr|dz
}|dkrGtj|jdtj���}|jD]}||xxdz
cc<�|S|dkr/tjd�|jD��tj���Std���)Nc�,�g|]}t|����Sr8��len��.0�rowvalss  r5�
<listcomp>z%lil_matrix.getnnz.<locals>.<listcomp>�s��>�>�>���G���>�>�>r=r�rrc�,�g|]}t|����Sr8rIrKs  r5rNz%lil_matrix.getnnz.<locals>.<listcomp>�s��C�C�C�g�S��\�\�C�C�Cr=zaxis out of bounds)	�sumr#r'�zerosr �intpr"�arrayr&)r.�axis�out�rows    r5�getnnzzlil_matrix.getnnz�s����<��>�>�D�I�>�>�>�?�?�?��!�8�8��A�I�D��1�9�9��(�4�:�a�=���8�8�8�C��y�
�
���C����A�
������J�
�Q�Y�Y��8�C�C���C�C�C�2�7�S�S�S�S��1�2�2�2r=c�>�td�|jD����S)Nc3�>K�|]}tj|��V��dSr7)r'�
count_nonzerorKs  r5�	<genexpr>z+lil_matrix.count_nonzero.<locals>.<genexpr>�s-����F�F��2�#�G�,�,�F�F�F�F�F�Fr=)rQr#)r.s r5r[zlil_matrix.count_nonzero�s!���F�F�D�I�F�F�F�F�F�Fr=c
���d}t|j��D]S\}}t|��D]>\}}|dt||f���dt|j||���d�z
}�?�T|dd�S)N�z  �	�
���)�	enumerater"�strr#)r.�valr3rW�pos�js      r5�__str__zlil_matrix.__str__�s�������	�*�*�	L�	L�F�A�s�#�C�.�.�
L�
L���Q���s�A�q�6�{�{�{�{�C��	�!��S�8I�4J�4J�4J�4J�K�K���
L��3�B�3�x�r=c��|�d|jdf|j���}|j||jd<|j||jd<|S)z;Returns a view of the 'i'th row (without copying).
        rrr)�_lil_containerr rr"r#)r.r3�news   r5�
getrowviewzlil_matrix.getrowview�sP���!�!�1�d�j��m�"4�D�J�!�G�G���i��l������i��l������
r=c��|j\}}|dkr||z
}|dks||krtd���|�d|f|j���}|j|dd�|jd<|j|dd�|jd<|S)z)Returns a copy of the 'i'th row.
        rzrow index out of boundsrrN)r �
IndexErrorrirr"r#)r.r3r1r2rjs     r5�getrowzlil_matrix.getrow�s����z���1��q�5�5�
��F�A��q�5�5�A��F�F��6�7�7�7��!�!�1�a�&��
�!�;�;���i��l�1�1�1�o������i��l�1�1�1�o������
r=c��t|t��rSt|��dkr@t|dt��r%t|dt��r
|j|�Stj||��S)NrOrr)r$r%rJr
�_get_intXintr	�__getitem__)r.�keys  r5rqzlil_matrix.__getitem__�ss���s�E�"�"�	+�s�3�x�x�1�}�}��3�q�6�9�-�-�(5��3�q�6�9�-�-�(5�%�4�$�c�*�*��%�d�C�0�0�0r=c��	tj|��}n/#tttf$r}td��|�d}~wwxYw|jdvrtd���|S)Nz
invalid index)rrOzIndex dimension must be <= 2)r'�asarrayr&r+�MemoryErrorrm�ndim)r.�idxr2�xr4s     r5�
_asindiceszlil_matrix._asindices�sm��	5��
�3���A�A���I�{�3�	5�	5�	5��_�-�-�1�4�����	5�����6�����;�<�<�<��s��A�>�Ac��tj|jd|jd|j|j||��}|j�|��S�Nrr)r�lil_get1r r"r#r�type)r.rW�col�vs    r5rpzlil_matrix._get_intXint�sE���"�4�:�a�=�$�*�Q�-���#'�9�c�3�
8�
8���z���q�!�!�!r=c��t|�|jd���}|�|t	||dz����Sr{)r*�indicesr �_get_row_ranges�slice�r.rWr~s   r5�_get_sliceXintzlil_matrix._get_sliceXint�sB���S�[�[���A��/�/�0���#�#�C��s�C��E�):�):�;�;�;r=c�x�|���}|�|t||dz����S)Nr)�squeezer�r�r�s   r5�_get_arrayXintzlil_matrix._get_arrayXint�s3���k�k�m�m���#�#�C��s�C��E�):�):�;�;�;r=c�0�|�|f|��Sr7�r�r�s   r5�_get_intXslicezlil_matrix._get_intXslice�s���#�#�S�F�C�0�0�0r=c�|�t|�|jd���}|�||��S�Nr)r*r�r r�r�s   r5�_get_sliceXslicezlil_matrix._get_sliceXslice�s4���S�[�[���A��/�/�0���#�#�C��-�-�-r=c�.�|�||��Sr7r�r�s   r5�_get_arrayXslicezlil_matrix._get_arrayXslice�s���#�#�C��-�-�-r=c�f�tj||jd���}|�||��S)Nr)r�ndmin)r'rTr�_get_columnXarrayr�s   r5�_get_intXarrayzlil_matrix._get_intXarray�s0���h�s�#�)�1�5�5�5���%�%�c�3�/�/�/r=c��tj|�|jd���}|�||��Sr�)r'�aranger�r r�r�s   r5�_get_sliceXarrayzlil_matrix._get_sliceXarray�s6���i����T�Z��]�3�3�4���%�%�c�3�/�/�/r=c�h�t|dd�df|��\}}|�||��Sr7)r�_get_arrayXarrayr�s   r5r�zlil_matrix._get_columnXarray�s7��$�S����4��[�#�6�6���S��$�$�S�#�.�.�.r=c
�(�ttjt||����\}}|�|j|j���}tj|jd|jd|j	|j
|j	|j
||��|S�Nrrr)�mapr'�
atleast_2d�_prepare_index_for_memoryviewrir rr�
lil_fancy_getr"r#)r.rWr~r3rfrjs      r5r�zlil_matrix._get_arrayXarrays����2�=�"?��S�"I�"I�J�J���1��!�!�!�'���!�<�<���#�D�J�q�M�4�:�a�=�$(�I�t�y�$'�H�c�h�$%�q�	*�	*�	*��
r=c
�t�|�|jd��\}}}t|||��}t|��}|�t|��|f|j���}t
j|jd|jd|j|j	|j|j	|||||��|S)a�
        Fast path for indexing in the case where column index is slice.

        This gains performance improvement over brute force by more
        efficient skipping of zeros, by accessing the elements
        column-wise in order.

        Parameters
        ----------
        rows : sequence or range
            Rows indexed. If range, must be within valid bounds.
        col_slice : slice
            Columns indexed

        rrr)
r�r r*rJrirr�lil_get_row_rangesr"r#)	r.r"�	col_slice�j_start�j_stop�j_stride�	col_range�njrjs	         r5r�zlil_matrix._get_row_rangess��� %.�$5�$5�d�j��m�$D�$D�!�����'�6�8�4�4�	�
��^�^���!�!�3�t�9�9�b�/���!�D�D���(���A���
�1�
�)-��D�I�),��3�8�)-�)0�&�(�B�		H�	H�	H��
r=c	�z�tj|jd|jd|j|j|||��dSr{)r�
lil_insertr r"r#)r.rWr~rxs    r5�_set_intXintzlil_matrix._set_intXint)s@��� ���A���
�1�
�t�y�!%��C��a�	9�	9�	9�	9�	9r=c	���ttjt|||����\}}}t	j|jd|jd|j|j|||��dSr{)	r�r'r�r�r�
lil_fancy_setr r"r#)r.rWr~rxr3rfs      r5�_set_arrayXarrayzlil_matrix._set_arrayXarray-se���b�m�%B�3��Q�%O�%O�P�P���1�a��#�D�J�q�M�4�:�a�=�$(�I�t�y�$%�q�!�	-�	-�	-�	-�	-r=c���|j|jkr�t|t��rq|td��kr^t|t��rI|td��kr6|�||j���}|j|_|j|_dStj|�	��|j���}t||��\}}|�|||��dS)Nr)r r$r�rirr"r#r'rt�toarrayrr�)r.rWr~rx�_s     r5�_set_arrayXarray_sparsez"lil_matrix._set_arrayXarray_sparse3s���
�G�t�z�!�!��3��&�&�
"�+.�%��+�+�+=�+=��3��&�&�,>�+.�%��+�+�+=�+=��#�#�A�T�Z�#�8�8�A���D�I���D�I��F��J�q�y�y�{�{�$�*�5�5�5�� ��C�(�(���1����c�3��*�*�*�*�*r=c��t|t��r�t|��dkr�t|dt��rrt|dt��rW|j�|��}|jdkrtd���|�|d|d|��Stj
|||��dS)NrOrrz&Trying to assign a sequence to an item)r$r%rJr
rr}�sizer&r�r	�__setitem__)r.rrrxs   r5r�zlil_matrix.__setitem__As����s�E�"�"�	8�s�3�x�x�1�}�}��3�q�6�9�-�-�(5��3�q�6�9�-�-�(5��
����"�"�A��v��z�z� �!I�J�J�J��$�$�S��V�S��V�Q�7�7�7���t�S�!�,�,�,�,�,r=c�4���dkr"|�|j|j���}nnt|j���}|���}|�|��}t
|j��D]\}}�fd�|D��|j|<�|S)Nrrc���g|]}|�z��Sr8r8�rLrdr:s  �r5rNz*lil_matrix._mul_scalar.<locals>.<listcomp>X����<�<�<�S�s�5�y�<�<�<r=)rir rrrrrbr#)r.r:rj�	res_dtyperfrMs `    r5�_mul_scalarzlil_matrix._mul_scalarMs�����A�:�:��%�%�d�j��
�%�C�C�C�C�%�d�j�%�8�8�I��)�)�+�+�C��*�*�Y�'�'�C�'���1�1�
=�
=�
��7�<�<�<�<�G�<�<�<�������
r=c����t���rF|���}t|j��D]\}}�fd�|D��|j|<�|S|����zS)Nc���g|]}|�z��Sr8r8r�s  �r5rNz*lil_matrix.__truediv__.<locals>.<listcomp>`r�r=)rrrbr#�tocsr)r.r:rjrfrMs `   r5�__truediv__zlil_matrix.__truediv__[sv�������	(��)�)�+�+�C�'���1�1�
=�
=�
��7�<�<�<�<�G�<�<�<�������J��:�:�<�<�%�'�'r=c
���|j\}}|�|j|j���}tj|||j|j|j|jt|��d|d|��|Sr�)r rirrr�r"r#r*)r.r1r2rjs    r5rzlil_matrix.copyesk���z���1��!�!�$�*�D�J�!�?�?���(��A�t�y�$�)�),��3�8�U�1�X�X�)*�A�q�!�	5�	5�	5��
r=c��t||j��}t|��\}}||jkr|r|���S|S|�||j���}|dkrj|jd}t
|j��D]G\}}	t
|	��D]2\}
}tj	||z|z|��\}}
|||f|||
f<�3�Hn�|dkrk|jd}t
|j��D]H\}}	t
|	��D]3\}
}tj	|||zz||��\}}
|||f|||
f<�4�Intd���|S)Nr�Cr�Frz'order' must be 'C' or 'F')rr rrrirrbr"r'�
unravel_indexr&)r.�args�kwargsr �orderrrj�ncolsr3rWr~rf�new_r�new_c�nrowss               r5�reshapezlil_matrix.reshapeps����D�$�*�-�-��*�6�2�2���t��D�J����
��y�y�{�{�"����!�!�%�t�z�!�:�:���C�<�<��J�q�M�E�#�D�I�.�.�
3�
3���3�'��n�n�3�3�F�C��#%�#3�A��I��M�5�#I�#I�L�E�5�(,�Q��T�
�C��u��%�%�3�
3��c�\�\��J�q�M�E�#�D�I�.�.�
3�
3���3�'��n�n�3�3�F�C��#%�#3�A��E�	�M�5�%�#P�#P�L�E�5�(,�Q��T�
�C��u��%�%�3�
3�
�9�:�:�:��
r=c��t|��}|\}}|j\}}||kr)|jd|�|_|jd|�|_nk||kret	j|j|��|_t	j|j|��|_t
||��D]}g|j|<g|j|<�||kr:t|j|j��D]\}}t||��}	||	d�=||	d�=� ||_	dSr7)
rr r"r#r'�resizer*�ziprr!)
r.r �new_M�new_Nr1r2r3rWr#�truncs
          r5r�zlil_matrix.resize�s���E�"�"�����u��z���1��1�9�9��	�&�5�&�)�D�I��	�&�5�&�)�D�I�I�
�Q�Y�Y��	�$�)�U�3�3�D�I��	�$�)�U�3�3�D�I��1�e�_�_�
"�
"��!��	�!��!��	�!����1�9�9� ���D�I�6�6�
!�
!�	��T�#�C��/�/������K�����L�L�����r=c��|�||��}t|j��D]2\}}t|��D]\}}|j|||||f<��3|Sr7)�_process_toarray_argsrbr"r#)r.r�rV�dr3rWrerfs        r5r�zlil_matrix.toarray�sq���&�&�u�c�2�2����	�*�*�	,�	,�F�A�s�#�C�.�.�
,�
,���Q��)�A�,�s�+��!�Q�$���
,��r=c��|�|����|d����d���S)NrF)�axesr)r��	transposer)r.r�rs   r5r�zlil_matrix.transpose�s;���z�z�t�z�$�$�.�.�D�u�.�E�E�K�K�QV�K�W�W�Wr=c�2�|r|���S|Sr7r)r.rs  r5rzlil_matrix.tolil�s���	��9�9�;�;���Kr=c��|j\}}|dks|dkr|�||f|j���S||ztjtj��jkrktj}tj|dz|���}d|d<tj	|j
|dd���tj||���|d}n�t|���}tj||���}tj	|j
|��|�
tj���}tt
||�����}tj|dz|���}d|d<tj|||dd����tj||���}tj||j���}	tj|j
|��tj|j|	��|�|	||f|j���S)	Nrrr)rVra)�maxval)rrV)r )r r-rr'�iinfo�int32�maxr(r�lil_get_lengthsr"�cumsumrrQ�int64�lil_flatten_to_arrayr#)
r.rr1r2�	idx_dtype�indptr�nnz�lengthsr�r#s
          r5r�zlil_matrix.tocsr�s����z���1���6�6�Q�!�V�V��&�&��1�v�T�Z�&�@�@�@�
�Q�3�"�(�2�8�$�$�(�(�(���I��X�a�!�e�9�5�5�5�F��F�1�I��)�$�)�V�A�B�B�Z�@�@�@��I�f�&�)�)�)�)���*�C�C�'�q�1�1�1�I��h�q�	�2�2�2�G��)�$�)�W�=�=�=��+�+�B�H�+�-�-�C�'�s�1�c�{�{�;�;�;�I��X�a�!�e�9�5�5�5�F��F�1�I��I�g�Y�F�1�2�2�J�?�?�?�?��(�3�i�0�0�0���x��4�:�.�.�.���*�4�9�g�>�>�>��*�4�9�d�;�;�;��"�"�D�'�6�#:�$�*�"�M�M�Mr=)NNFr7)NN)NF)F)*�__name__�
__module__�__qualname__�__doc__�formatrr;r?rCrFrXr[rrgrkrnrqryrpr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rr�r�r�r�rr�r8r=r5rrs�������<�<�z�F�+#�+#�+#�+#�Z������"�"�"�"�"�"�
3�
3�
3�
3�G�G�G��_�,�F�N�$�2�:�M�����������1�1�1����"�"�"�
<�<�<�<�<�<�1�1�1�.�.�.�.�.�.�0�0�0�0�0�0�/�/�/�
������:9�9�9�-�-�-�+�+�+�
-�
-�
-����(�(�(�����=�(�D�L����<�&�.�G�O����.�_�,�F�N������&�.�G�O�X�X�X�X�!�*�2�I�������N�*�E�M�N�N�N�N�@�N�*�E�M�M�Mr=c�*�|j|jkr|�|j��}n*|j|jkr|�|j��}|jjr|jtjtjfvr|�tj��}|jjr|jtjtjfvr|�tj��}|�%|jjs|���}|||fS||fS)a
    Convert index and data arrays to form suitable for passing to the
    Cython fancy getset routines.

    The conversions are necessary since to (i) ensure the integer
    index arrays are in one of the accepted types, and (ii) to ensure
    the arrays are writable so that Cython memoryview support doesn't
    choke on them.

    Parameters
    ----------
    i, j
        Index arrays
    x : optional
        Data arrays

    Returns
    -------
    i, j, x
        Re-formatted arrays (x is omitted, if input was None)

    )	rr�flags�	writeabler'r�r�rSr)r3rfrxs   r5r�r��s���.	�w�����
�H�H�Q�W�����	
��1�7�	�	�
�H�H�Q�W�����7�������"�(�/C� C� C�
�H�H�R�W�����7�������"�(�/C� C� C�
�H�H�R�W�����}��w� �	������A��!�Q�w���!�t�r=c�X�ddlm}t|t��pt||��S)a�Is x of lil_matrix type?

    Parameters
    ----------
    x
        object to check for being a lil matrix

    Returns
    -------
    bool
        True if x is a lil matrix, False otherwise

    Examples
    --------
    >>> from scipy.sparse import lil_matrix, isspmatrix_lil
    >>> isspmatrix_lil(lil_matrix([[5]]))
    True

    >>> from scipy.sparse import lil_matrix, csr_matrix, isspmatrix_lil
    >>> isspmatrix_lil(csr_matrix([[5]]))
    False
    r)�	lil_array)�_arraysr�r$r)rxr�s  r5rrs5��.#�"�"�"�"�"��a��$�$�@�
�1�i�(@�(@�@r=r7)r��
__docformat__�__all__�bisectr�numpyr'�_baserr�_indexr	r
r�_sputilsrr
rrrrrr^rrr�rr8r=r5�<module>r�s[����&�
��)�
*������������'�'�'�'�'�'�'�'�<�<�<�<�<�<�<�<�<�<�K�K�K�K�K�K�K�K�K�K�K�K�K�K�K�K�K�K�������L+�L+�L+�L+�L+��:�L+�L+�L+�^&�&�&�&�RA�A�A�A�Ar=

Youez - 2016 - github.com/yon3zu
LinuXploit