Ë
    ÏÍ:j«2  ã                   ó¬   — d Z dZg d¢ZddlZddlmZ ddlmZm	Z	 ddl
mZmZ dd	lmZ dd
lmZ  G d„ de«      Zd„ Z G d„ dee	«      Z G d„ dee«      Zy)z&Compressed Sparse Column matrix formatzrestructuredtext en)Ú	csc_arrayÚ
csc_matrixÚisspmatrix_cscé    Né   )Úspmatrix)Ú_spbaseÚsparray)Ú	csr_tocscÚ	expandptr)Úupcast)Ú
_cs_matrixc                   óL  — e Zd ZdZdd„Zej                  j                  e_        d„ Zdd„Zej                  j                  e_        dd„Z	ej                  j                  e	_        d„ Z
ej                  j                  e
_        d„ Zd	„ Zd
„ Zd„ Zd„ Zd„ Zd„ Zd„ Zed„ «       Zy)Ú	_csc_baseÚcscNc                 ó²   — |�|dk7  rt        d«      ‚| j                  \  }}| j                  | j                  | j                  | j
                  f||f|¬«      S )N)r   r   zvSparse arrays/matrices do not support an 'axes' parameter because swapping dimensions is the only logical permutation.©Úcopy)Ú
ValueErrorÚshapeÚ_csr_containerÚdataÚindicesÚindptr)ÚselfÚaxesr   ÚMÚNs        úf/home/mcse/projects/srt_converter/srt-converter-venv/lib/python3.12/site-packages/scipy/sparse/_csc.pyÚ	transposez_csc_base.transpose   sm   € ØÐ ¨¢Üð Ló Mð Mð �z‰z‰ˆˆ1à×"Ñ" D§I¡I¨t¯|©|Ø$(§K¡Kð$1Ø34°a°&¸tð #ó Eð 	Eó    c              #   ó@   K  — | j                  «       E d {  –—†  y 7 Œ­w©N)Útocsr)r   s    r   Ú__iter__z_csc_base.__iter__!   s   è ø€ Ø—:‘:“<×Òús   ‚–—c                 ó*   — |r| j                  «       S | S r"   r   )r   r   s     r   Útocscz_csc_base.tocsc$   s   € ÙØ—9‘9“;ÐàˆKr    c           
      óp  — | j                   \  }}| j                  | j                  | j                  ft	        | j
                  |«      ¬«      }t        j                  |dz   |¬«      }t        j                  | j
                  |¬«      }t        j                  | j
                  t        | j                  «      ¬«      }t        ||| j                  j                  |d¬«      | j                  j                  |d¬«      | j                  |||«       | j                  |||f| j                   d¬«      }d|_        |S )N)Úmaxvalr   ©ÚdtypeFr   )r   r   T)r   Ú_get_index_dtyper   r   ÚmaxÚnnzÚnpÚemptyr   r*   r
   Úastyper   r   Úhas_sorted_indices)	r   r   r   r   Ú	idx_dtyper   r   r   ÚAs	            r   r#   z_csc_base.tocsr,   s	  € Ø�j‰j‰ˆˆ!Ø×)Ñ)¨4¯;©;¸¿¹Ð*EÜ+.¨t¯x©x¸Ó+;ð *ó =ˆ	ä—‘˜!˜a™% yÔ1ˆÜ—(‘(˜4Ÿ8™8¨9Ô5ˆÜ�x‰x˜Ÿ™¬¨t¯z©zÓ(:Ô;ˆä�!�QØ—+‘+×$Ñ$ Y°UÐ$Ó;Ø—,‘,×%Ñ% i°eÐ%Ó<Ø—)‘)ØØØô	ð ×ÑØ�7˜FÐ#Ø—*‘* 5ð  ó 
ˆð  $ˆÔØˆr    c                 ó”  — | j                  | j                  «      \  }}| j                  }t        j                  t        |«      | j                  j                  ¬«      }t        || j                  |«       | j                  ||f«      \  }}| j                  dk7  }||   }||   }t        j                  |d¬«      }||   }||   }||fS )Nr)   r   Ú	mergesort)Úkind)Ú_swapr   r   r.   r/   Úlenr*   r   r   r   Úargsort)	r   Ú	major_dimÚ	minor_dimÚminor_indicesÚmajor_indicesÚrowÚcolÚnz_maskÚinds	            r   Únonzeroz_csc_base.nonzeroE   s¸   € ð
  $Ÿz™z¨$¯*©*Ó5Ñˆ	�9ØŸ™ˆÜŸ™¤ ]Ó!3¸4¿<¹<×;MÑ;MÔNˆÜ�)˜TŸ[™[¨-Ô8Ø—:‘:˜}¨mÐ<Ó=‰ˆˆSð —)‘)˜q‘.ˆØ�'‰lˆØ�'‰lˆô �j‰j˜ ;Ô/ˆØ�#‰hˆØ�#‰hˆà�Cˆxˆr    c                 ó¼   — | j                   \  }}t        |«      }|dk  r||z  }|dk  s||k\  rt        d|› d�«      ‚| j                  |¬«      j	                  «       S )z]Returns a copy of row i of the matrix, as a (1 x n)
        CSR matrix (row vector).
        r   úindex (ú) out of range©Úminor)r   ÚintÚ
IndexErrorÚ_get_submatrixr#   ©r   Úir   r   s       r   Ú_getrowz_csc_base._getrow^   sh   € ð �z‰z‰ˆˆ1Ü�‹FˆØˆqŠ5Ø�‰FˆAØˆqŠ5�A˜’FÜ˜w q c¨Ð8Ó9Ð9Ø×"Ñ"¨Ð"Ó+×1Ñ1Ó3Ð3r    c                 ó¢   — | j                   \  }}t        |«      }|dk  r||z  }|dk  s||k\  rt        d|› d�«      ‚| j                  |d¬«      S )zcReturns a copy of column i of the matrix, as a (m x 1)
        CSC matrix (column vector).
        r   rD   rE   T)Úmajorr   )r   rH   rI   rJ   rK   s       r   Ú_getcolz_csc_base._getcolj   sa   € ð �z‰z‰ˆˆ1Ü�‹FˆØˆqŠ5Ø�‰FˆAØˆqŠ5�A˜’FÜ˜w q c¨Ð8Ó9Ð9Ø×"Ñ"¨°Ð"Ó6Ð6r    c                 óD   — | j                  |«      j                  |¬«      S )NrF   )Ú_major_index_fancyrJ   ©r   r>   r?   s      r   Ú_get_intXarrayz_csc_base._get_intXarrayv   s!   € Ø×&Ñ& sÓ+×:Ñ:ÀÐ:ÓEÐEr    c                 óˆ   — |j                   dv r| j                  ||d¬«      S | j                  |«      j                  |¬«      S )N©r   NT©rO   rG   r   rF   )ÚsteprJ   Ú_major_slicerS   s      r   Ú_get_intXslicez_csc_base._get_intXslicey   sE   € Ø�8‰8�yÑ Ø×&Ñ&¨S¸À$Ð&ÓGÐGØ× Ñ  Ó%×4Ñ4¸3Ð4Ó?Ð?r    c                 óˆ   — |j                   dv r| j                  ||d¬«      S | j                  |¬«      j                  |«      S )NrV   TrW   ©rO   )rX   rJ   Ú_minor_slicerS   s      r   Ú_get_sliceXintz_csc_base._get_sliceXint~   sE   € Ø�8‰8�yÑ Ø×&Ñ&¨S¸À$Ð&ÓGÐGØ×"Ñ"¨Ð"Ó-×:Ñ:¸3Ó?Ð?r    c                 óB   — | j                  |«      j                  |«      S r"   )rR   r]   rS   s      r   Ú_get_sliceXarrayz_csc_base._get_sliceXarrayƒ   s   € Ø×&Ñ& sÓ+×8Ñ8¸Ó=Ð=r    c                 óœ   — | j                  |¬«      j                  |«      }|j                  dkD  r|j                  |j                  «      S |S )Nr\   r   )rJ   Ú_minor_index_fancyÚndimÚreshaper   )r   r>   r?   Úress       r   Ú_get_arrayXintz_csc_base._get_arrayXint†   sC   € Ø×!Ñ!¨Ð!Ó,×?Ñ?ÀÓDˆØ�8‰8�aŠ<Ø—;‘;˜sŸy™yÓ)Ð)Øˆ
r    c                 óB   — | j                  |«      j                  |«      S r"   )rY   rb   rS   s      r   Ú_get_arrayXslicez_csc_base._get_arrayXsliceŒ   s   € Ø× Ñ  Ó%×8Ñ8¸Ó=Ð=r    c                 ó   — | d   | d   fS )zBswap the members of x if this is a column-oriented matrix
        r   r   © ©Úxs    r   r7   z_csc_base._swap‘   s   € ð �‰t�Q�q‘TˆzÐr    )NF)F)Ú__name__Ú
__module__Ú__qualname__Ú_formatr   r   Ú__doc__r$   r&   r#   rB   r   rM   rP   rT   rZ   r^   r`   rf   rh   Ústaticmethodr7   rj   r    r   r   r      s±   „ Ø€Gó	Eð  ×)Ñ)×1Ñ1€IÔò óð —M‘M×)Ñ)€E„Móð. —M‘M×)Ñ)€E„Mòð. !×(Ñ(×0Ñ0€G„Oò
4ò
7òFò@ò
@ò
>òò>ð
 ñó ñr    r   c                 ó"   — t        | t        «      S )a”  Is `x` of csc_matrix type?

    .. warning::

       SciPy sparse is shifting from a sparse matrix interface to a sparse
       array interface. In the next few releases we expect to deprecate the
       sparse matrix interface. For documentation of the matrix
       interface, see the :ref:`spmatrix interface docs <spmatrix_api>`.
       For guidance on converting existing code to sparse arrays, see
       :ref:`Migration from spmatrix to sparray <migration_to_sparray>`.

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

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

    Examples
    --------
    >>> from scipy.sparse import csc_array, csc_matrix, coo_matrix, isspmatrix_csc
    >>> isspmatrix_csc(csc_matrix([[5]]))
    True
    >>> isspmatrix_csc(csc_array([[5]]))
    False
    >>> isspmatrix_csc(coo_matrix([[5]]))
    False
    )Ú
isinstancer   rk   s    r   r   r   ˜   s   € ô@ �aœÓ$Ð$r    c                   ó   — e Zd ZdZy)r   aê  
    Compressed Sparse Column array.

    This can be instantiated in several ways:
        csc_array(D)
            where D is a 2-D ndarray

        csc_array(S)
            with another sparse array or matrix S (equivalent to S.tocsc())

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

        csc_array((data, (row_ind, col_ind)), [shape=(M, N)])
            where ``data``, ``row_ind`` and ``col_ind`` satisfy the
            relationship ``a[row_ind[k], col_ind[k]] = data[k]``.

        csc_array((data, indices, indptr), [shape=(M, N)])
            is the standard CSC representation where the row indices for
            column i are stored in ``indices[indptr[i]:indptr[i+1]]``
            and their corresponding values are stored in
            ``data[indptr[i]:indptr[i+1]]``.  If the shape parameter is
            not supplied, the array dimensions are inferred from
            the index arrays.

    Attributes
    ----------
    data : ndarray
        CSC format data array of the array
    indices : ndarray
        CSC format index array of the array
    indptr : ndarray
        CSC format index pointer array of the array
    has_sorted_indices : bool
        Whether indices are sorted
    has_canonical_format : bool
        Whether indices are sorted and no duplicate entries exist
    dtype : dtype
        Data type of the array
    shape : 2-tuple
        Shape of the array
    ndim : int
        Number of dimensions (this is always 2)
    format : str
        Three letter code for the format of the array storage, e.g. 'csc'
    nnz : int
        Number of values stored in the array
    size : int
        Number of values stored in the array
    T : csc_array
        The transpose of the array
    mT : csc_array
        The matrix transpose of the array

    Notes
    -----

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

    Advantages of the CSC format
        - efficient arithmetic operations CSC + CSC, CSC * CSC, etc.
        - efficient column slicing
        - fast matrix vector products (CSR, BSR may be faster)

    Disadvantages of the CSC format
      - slow row slicing operations (consider CSR)
      - changes to the sparsity structure are expensive (consider LIL or DOK)

    Canonical format
      - Within each column, indices are sorted by row.
      - There are no duplicate entries.

    Examples
    --------

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

    >>> row = np.array([0, 2, 2, 0, 1, 2])
    >>> col = np.array([0, 0, 1, 2, 2, 2])
    >>> data = np.array([1, 2, 3, 4, 5, 6])
    >>> csc_array((data, (row, col)), shape=(3, 3)).toarray()
    array([[1, 0, 4],
           [0, 0, 5],
           [2, 3, 6]])

    >>> indptr = np.array([0, 2, 3, 6])
    >>> indices = np.array([0, 2, 2, 0, 1, 2])
    >>> data = np.array([1, 2, 3, 4, 5, 6])
    >>> csc_array((data, indices, indptr), shape=(3, 3)).toarray()
    array([[1, 0, 4],
           [0, 0, 5],
           [2, 3, 6]])

    N©rm   rn   ro   rq   rj   r    r   r   r   ¼   s   „ òdr    r   c                   ó   — e Zd ZdZy)r   a¸  
    Compressed Sparse Column matrix.

    .. warning::

       SciPy sparse is shifting from a sparse matrix interface to a sparse
       array interface. In the next few releases we expect to deprecate the
       sparse matrix interface. For documentation of the matrix
       interface, see the :ref:`spmatrix interface docs <spmatrix_api>`.
       For guidance on converting existing code to sparse arrays, see
       :ref:`Migration from spmatrix to sparray <migration_to_sparray>`.

    This can be instantiated in several ways:
        csc_matrix(D)
            where D is a 2-D ndarray

        csc_matrix(S)
            with another sparse array or matrix S (equivalent to S.tocsc())

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

        csc_matrix((data, (row_ind, col_ind)), [shape=(M, N)])
            where ``data``, ``row_ind`` and ``col_ind`` satisfy the
            relationship ``a[row_ind[k], col_ind[k]] = data[k]``.

        csc_matrix((data, indices, indptr), [shape=(M, N)])
            is the standard CSC representation where the row indices for
            column i are stored in ``indices[indptr[i]:indptr[i+1]]``
            and their corresponding values are stored in
            ``data[indptr[i]:indptr[i+1]]``.  If the shape parameter is
            not supplied, the matrix dimensions are inferred from
            the index arrays.

    Attributes
    ----------
    data : ndarray
        CSC format data array of the matrix
    indices : ndarray
        CSC format index array of the matrix
    indptr : ndarray
        CSC format index pointer array of the matrix
    has_sorted_indices : bool
        Whether indices are sorted
    has_canonical_format : bool
        Whether indices are sorted and no duplicate entries exist
    dtype : dtype
        Data type of the matrix
    shape : 2-tuple
        Shape of the matrix
    ndim : int
        Number of dimensions (this is always 2)
    format : str
        Three letter code for the format of the matrix storage, e.g. 'csc'
    nnz : int
        Number of values stored in the matrix
    size : int
        Number of values stored in the matrix
    T : csc_matrix
        The transpose of the matrix
    mT : csc_matrix
        The matrix transpose

    Notes
    -----

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

    Advantages of the CSC format
        - efficient arithmetic operations CSC + CSC, CSC * CSC, etc.
        - efficient column slicing
        - fast matrix vector products (CSR, BSR may be faster)

    Disadvantages of the CSC format
      - slow row slicing operations (consider CSR)
      - changes to the sparsity structure are expensive (consider LIL or DOK)

    Canonical format
      - Within each column, indices are sorted by row.
      - There are no duplicate entries.

    Examples
    --------

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

    >>> row = np.array([0, 2, 2, 0, 1, 2])
    >>> col = np.array([0, 0, 1, 2, 2, 2])
    >>> data = np.array([1, 2, 3, 4, 5, 6])
    >>> csc_matrix((data, (row, col)), shape=(3, 3)).toarray()
    array([[1, 0, 4],
           [0, 0, 5],
           [2, 3, 6]])

    >>> indptr = np.array([0, 2, 3, 6])
    >>> indices = np.array([0, 2, 2, 0, 1, 2])
    >>> data = np.array([1, 2, 3, 4, 5, 6])
    >>> csc_matrix((data, indices, indptr), shape=(3, 3)).toarray()
    array([[1, 0, 4],
           [0, 0, 5],
           [2, 3, 6]])

    Nrv   rj   r    r   r   r   $  s   „ òmr    r   )rq   Ú__docformat__Ú__all__Únumpyr.   Ú_matrixr   Ú_baser   r	   Ú_sparsetoolsr
   r   Ú_sputilsr   Ú_compressedr   r   r   r   r   rj   r    r   ú<module>r€      s\   ðÙ ,Ø%€â
7€ó å ß #ß .Ý å #ôD�
ô DòN %ôHe�	˜7ô eôPn�˜9õ nr    