a
    Re                     @   s*   d dl mZmZ G dd dZdd ZdS )   )	isintlikeisscalarlikec                   @   s   e Zd ZdZdZedd Zedd Zedd Zed	d
 Z	edd Z
edd Zedd Zdd Zdd Zdd Zdd Zdd ZeeeddZdd Zdd  Zd!d" Zd,d$d%Zd&d' Zd(d) Zd*d+ Zd#S )-spmatrixzThis class provides a base class for all sparse matrix classes.

    It cannot be instantiated.  Most of the work is provided by subclasses.
    Fc                 C   s   ddl m} |S )Nr   )
bsr_matrix)Z_bsrr   )selfr    r   H/var/www/sunrise/env/lib/python3.9/site-packages/scipy/sparse/_matrix.py_bsr_container   s    zspmatrix._bsr_containerc                 C   s   ddl m} |S )Nr   )
coo_matrix)Z_coor
   )r   r
   r   r   r   _coo_container   s    zspmatrix._coo_containerc                 C   s   ddl m} |S )Nr   )
csc_matrix)Z_cscr   )r   r   r   r   r   _csc_container   s    zspmatrix._csc_containerc                 C   s   ddl m} |S )Nr   )
csr_matrix)Z_csrr   )r   r   r   r   r   _csr_container   s    zspmatrix._csr_containerc                 C   s   ddl m} |S )Nr   )
dia_matrix)Z_diar   )r   r   r   r   r   _dia_container   s    zspmatrix._dia_containerc                 C   s   ddl m} |S )Nr   )
dok_matrix)Z_dokr   )r   r   r   r   r   _dok_container$   s    zspmatrix._dok_containerc                 C   s   ddl m} |S )Nr   )
lil_matrix)Z_lilr   )r   r   r   r   r   _lil_container)   s    zspmatrix._lil_containerc                 C   s
   |  |S N)Z_mul_dispatchr   otherr   r   r   __mul__/   s    zspmatrix.__mul__c                 C   s
   |  |S r   )Z_rmul_dispatchr   r   r   r   __rmul__2   s    zspmatrix.__rmul__c                 C   s   | j \}}||krtdt|rt|}|dk r:td|dkr\ddlm} ||| jdS |dkrl|  S | 	|d }|d r| | | S || S t
|rtdtS )	Nzsparse matrix is not square    zexponent must be >= 0r   )eye)dtype   zexponent must be an integer)shape	TypeErrorr   int
ValueErrorZ
_constructr   r   copy__pow__r   NotImplemented)r   r   MNr   tmpr   r   r   r$   6   s&    
zspmatrix.__pow__c                 C   s"   | j |dd| j}|j| _dS )z$Set the shape of the matrix in-placeF)r#   N)ZreshapeZasformatformat__dict__)r   r   Znew_selfr   r   r   	set_shapeS   s    zspmatrix.set_shapec                 C   s   | j S )zGet the shape of the matrix)Z_shaper   r   r   r   	get_shapeZ   s    zspmatrix.get_shapezShape of the matrix)fgetfsetdocc                 C   s   |   S )z6Upcast array to a floating point format (if necessary))Z	_asfptyper,   r   r   r   asfptypea   s    zspmatrix.asfptypec                 C   s   |   S )z3Maximum number of elements to display when printed.)Z_getmaxprintr,   r   r   r   getmaxprinte   s    zspmatrix.getmaxprintc                 C   s   | j S )zMatrix storage format)r)   r,   r   r   r   	getformati   s    zspmatrix.getformatNc                 C   s   | j |dS )zNumber of stored values, including explicit zeros.

        Parameters
        ----------
        axis : None, 0, or 1
            Select between the number of values across the whole array, in
            each column, or in each row.
        )axis)Z_getnnz)r   r4   r   r   r   getnnzm   s    	zspmatrix.getnnzc                 C   s   |    S )zReturn the Hermitian transpose of this array.

        See Also
        --------
        numpy.matrix.getH : NumPy's implementation of `getH` for matrices
        )	conjugateZ	transposer,   r   r   r   getHx   s    zspmatrix.getHc                 C   s
   |  |S )zeReturns a copy of column j of the array, as an (m x 1) sparse
        array (column vector).
        )Z_getcol)r   jr   r   r   getcol   s    zspmatrix.getcolc                 C   s
   |  |S )z^Returns a copy of row i of the array, as a (1 x n) sparse
        array (row vector).
        )Z_getrow)r   ir   r   r   getrow   s    zspmatrix.getrow)N)__name__
__module____qualname____doc__Z	_is_arraypropertyr	   r   r   r   r   r   r   r   r   r$   r+   r-   r   r1   r2   r3   r5   r7   r9   r;   r   r   r   r   r      s>   







	r   c                 C   s    | d u rd S |  dd ddS )Nzsparse arrayszsparse matriceszsparse arrayzsparse matrix)replace)Zdocstrr   r   r   _array_doc_to_matrix   s    rB   N)Z_sputilsr   r   r   rB   r   r   r   r   <module>   s    