
    9=ed                     `   d Z dZg dZddlmZ ddl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mZmZmZ ddlmZmZmZmZmZmZ ddlmZ ddlmZmZmZm Z m!Z!m"Z"m#Z#  G d dee          Z$d Z% G d de$e          Z&e$j         e&_          G d dee$          Z' e	e$j                   e'_         dS )z"Compressed Block Sparse Row formatzrestructuredtext en)	bsr_array
bsr_matrixisspmatrix_bsr    )warnN   )spmatrix_array_doc_to_matrix)_data_matrix_minmax_mixin)
_cs_matrix)issparse_formats_spbasesparray)isshapegetdtypegetdata	to_nativeupcastcheck_shape)_sparsetools)
bsr_matvecbsr_matvecscsr_matmat_maxnnz
bsr_matmatbsr_transposebsr_sort_indices	bsr_tocsrc                      e Zd ZdZdZd dZd!dZd Z ee	          Z	d"d
Z
ej
        j        e
_        d Zd#dZej        j        e_        d Zd Zd Zd Zd Zd Zd$dZd%dZej        j        e_        d%dZej        j        e_        d!dZd&dZej        j        e_        d$dZej        j        e_        d Zd Zd Zd Zd&dZd!dZdS )'	_bsr_baseaZ  Block Sparse Row format sparse array.

    This can be instantiated in several ways:
        bsr_array(D, [blocksize=(R,C)])
            where D is a dense matrix or 2-D ndarray.

        bsr_array(S, [blocksize=(R,C)])
            with another sparse array S (equivalent to S.tobsr())

        bsr_array((M, N), [blocksize=(R,C), dtype])
            to construct an empty sparse array with shape (M, N)
            dtype is optional, defaulting to dtype='d'.

        bsr_array((data, ij), [blocksize=(R,C), shape=(M, N)])
            where ``data`` and ``ij`` satisfy ``a[ij[0, k], ij[1, k]] = data[k]``

        bsr_array((data, indices, indptr), [shape=(M, N)])
            is the standard BSR representation where the block column
            indices for row i are stored in ``indices[indptr[i]:indptr[i+1]]``
            and their corresponding block 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
    ----------
    dtype : dtype
        Data type of the array
    shape : 2-tuple
        Shape of the array
    ndim : int
        Number of dimensions (this is always 2)
    nnz
        Number of stored values, including explicit zeros
    data
        Data array
    indices
        BSR format index array
    indptr
        BSR format index pointer array
    blocksize
        Block size
    has_sorted_indices
        Whether indices are sorted

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

    **Summary of BSR format**

    The Block Compressed Row (BSR) format is very similar to the Compressed
    Sparse Row (CSR) format. BSR is appropriate for sparse matrices with dense
    sub matrices like the last example below.  Block matrices often arise in
    vector-valued finite element discretizations. In such cases, BSR is
    considerably more efficient than CSR and CSC for many sparse arithmetic
    operations.

    **Blocksize**

    The blocksize (R,C) must evenly divide the shape of the sparse array (M,N).
    That is, R and C must satisfy the relationship ``M % R = 0`` and
    ``N % C = 0``.

    If no blocksize is specified, a simple heuristic is applied to determine
    an appropriate blocksize.

    **Canonical Format**

    In canonical format, there are no duplicate blocks and indices are sorted
    per row.

    Examples
    --------
    >>> from scipy.sparse import bsr_array
    >>> import numpy as np
    >>> bsr_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, 0, 1, 2, 2, 2])
    >>> col = np.array([0, 2, 2, 0, 1, 2])
    >>> data = np.array([1, 2, 3 ,4, 5, 6])
    >>> bsr_array((data, (row, col)), shape=(3, 3)).toarray()
    array([[1, 0, 2],
           [0, 0, 3],
           [4, 5, 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]).repeat(4).reshape(6, 2, 2)
    >>> bsr_array((data,indices,indptr), shape=(6, 6)).toarray()
    array([[1, 1, 0, 0, 2, 2],
           [1, 1, 0, 0, 2, 2],
           [0, 0, 0, 0, 3, 3],
           [0, 0, 0, 0, 3, 3],
           [4, 4, 5, 5, 6, 6],
           [4, 4, 5, 5, 6, 6]])

    bsrNFc                 
   t          j        |            t          |          rT|j        | j        k    r|r|                                }n|                    |          }|                     |           nt          |t                    rt          |          rt          |          | _        | j        \  }}|d}n0t          |          st          d|z            t          |          }t          j        d|z   t!          |t"                              | _        |\  }}	||z  dk    s	||	z  dk    rt          d          |                     t)          ||z  ||	z  ||	                    }
t          j        d|
	          | _        t          j        ||z  d
z   |
	          | _        nRt/          |          dk    rA|                     |                     |||                              |                     nt/          |          dk    r[|\  }}}d
}|t)          |          }|t)          |t)          |                    }|                     ||f|d          }
t          j        |||
          | _        t          j        |||
          | _        t5          |||          | _        | j        j        dk    r,t          d                    | j        j                            |{t          |          st          d|           t          |          | j        j        d
d          k    r5t          d                    || j        j        d
d                              nt          d          	 t          j        |          }n*# t:          $ r}t          d| j        z            |d }~ww xY w|                     ||	                              |          }|                     |           |t          |          | _        n| j        }	 t/          | j                  d
z
  }| j                                        d
z   }| j        \  }}	t          ||z  ||	z  f          | _        n"# t:          $ r}t          d          |d }~ww xY w| j        %|t          d          t          |          | _        |!| j                            |d          | _        |                      d           d S )N	blocksize)r   r   zinvalid blocksize=%sr   )defaultr   z#shape must be multiple of blocksizemaxvaldtyper      )r*   shape   T)r(   check_contents)copyr*   z,BSR data must be 3-dimensional, got shape={}zinvalid blocksize=zmismatching blocksize={} vs {}z(unrecognized bsr_array constructor usagez+unrecognized form for %s_matrix constructorz!unable to infer matrix dimensionszneed to infer shapeFr/   )
full_check)!r
   __init__r   formatr/   tobsr	_set_self
isinstancetupler   r   _shaper,   
ValueErrornpzerosr   floatdata_get_index_dtypemaxindicesindptrlen_coo_containerarrayr   ndimasarray	Exceptionr$   astypecheck_format)selfarg1r,   r*   r/   r$   MNRC	idx_dtyper=   r@   rA   r(   es                   1lib/python3.11/site-packages/scipy/sparse/_bsr.pyr2   z_bsr_base.__init__   sS   d###D>> M	!{dk))d)yy{{zzIz66NN4    U## F	!t}} :M)$//j!$ %II"9-- M()?))KLLL %i 0 0IHTI%5xu7U7U7UVV	!Ea<<AEa<<$%JKKK !11QT1a4A9N9N1OO	!x;;; hq!taxyAAATa''E'GGMM"+ N      Ta*.'w $ ZZF( Y88F 117F2CFAE 2 G G	!xd)LLL hvD	JJJ#Dt5AAA	9>Q&&$FMM IO. ./ / / ("9-- K()Ii)I)IJJJY''49?122+>>>()I)P)P%tyqrr':*< *< = = = !!KLLLGz$'' G G G  "137;"? @ @EFGG &&E '  eie((  NN4   %e,,DKKz!9DK((1,A((**Q.A .CAa"-qs1Q3i"8"8DKK	 ! Q Q Q$%HIIqPQ :} !6777)%00	((U(;;DIU+++++s0   N 
O$N<<O#3Q= =
RRRTc                    | j         \  }}| j        \  }}| j        j        j        dk    r!t          d| j        j        j        z             | j        j        j        dk    r!t          d| j        j        j        z             |                     | j        | j        f          }t          j
        | j        |          | _        t          j
        | j        |          | _        t          | j                  | _        | j        j        dk    s| j        j        dk    rt          d          | j        j        dk    rt          d          t          | j                  ||z  dz   k    r,t          d	t          | j                  ||z  dz   fz            | j        d
         d
k    rt          d          t          | j                  t          | j                  k    rt          d          | j        d         t          | j                  k    rt          d          |                                  |r| j        d
k    r| j                                        ||z  k    r.t          d||z  | j                                        fz            | j                                        d
k     rt          d          t          j        | j                                                  d
k     rt          d          dS dS dS )zcheck whether the matrix format is valid

            *Parameters*:
                full_check:
                    True  - rigorous check, O(N) operations : default
                    False - basic check, O(1) operations

        iz'indptr array has non-integer dtype (%s)z(indices array has non-integer dtype (%s)r)   r   z!indices, and indptr should be 1-Dr-   zdata should be 3-Dz&index pointer size (%d) should be (%d)r   z!index pointer should start with 0z*indices and data should have the same sizezQLast value of index pointer should be less than the size of index and data arraysz-column index values must be < %d (now max %d)z column index values must be >= 0z8index pointer values must form a non-decreasing sequenceN)r,   r$   rA   r*   kindr   namer@   r>   r:   rF   r   r=   rE   r9   rB   prunennzr?   mindiff)rJ   r1   rL   rM   rN   rO   rP   s          rR   rI   z_bsr_base.check_format   s    j!n! ;!S((:k',- . . .<"c));l(-. / / / ))4<*EFF	jI>>>z$,i@@@di((	 <!!T[%5%:%:@AAA9>Q1222 1q((E!$T[!1!11a4!8 <= > > >KNa@AAA TY//IJJJKOc$,//// D E E E 	

 		Cx!||<##%%A--$%TXY[\X\^b^j^n^n^p^pWq%qrrr<##%%))$%GHHH74;''++--11$ &B C C C		C 		C|
 21    c                 *    | j         j        dd          S )Nr   )r=   r,   )rJ   s    rR   _get_blocksizez_bsr_base._get_blocksize)  s    yqrr""r\   )fgetc                 x    |t          d          | j        \  }}t          | j        d         |z  |z            S )Nz6_getnnz over an axis is not implemented for BSR formatrU   )NotImplementedErrorr$   intrA   )rJ   axisrN   rO   s       rR   _getnnzz_bsr_base._getnnz-  sH    % '7 8 8 8n!4;r?Q&*+++r\   c                     t           | j                 d         }d| j        | j        j        | j        fz   | j        z   |fz   z  S )Nr   z\<%dx%d sparse matrix of type '%s'
	with %d stored elements (blocksize = %dx%d) in %s format>)r   r3   r,   r*   typerY   r$   )rJ   r3   s     rR   __repr__z_bsr_base.__repr__6  sI    $+&q)Ntz99DNJ 	r\   r   c                    | j         \  }}|| k    s||k    r t          j        d| j        j                  S | j        \  }}t          j        t          |t          |d          z   |t          |d          z
            t          | j                            }t          j        |||z  ||z  ||| j        | j        t          j        | j                  |	  	         |S Nr   r)   )r,   r:   emptyr=   r*   r$   r;   rZ   r?   r   r   bsr_diagonalrA   r@   ravel)rJ   krowscolsrN   rO   ys          rR   diagonalz_bsr_base.diagonal=  s    Z
d::d8ATY_5555~1HSAq		)4#a))+;<<!$*--/ / /!!TQY	1a"&+t|"$(49"5"5q	: 	: 	: r\   c                     t           Nra   )rJ   keys     rR   __getitem__z_bsr_base.__getitem__O      !!r\   c                     t           rs   rt   )rJ   ru   vals      rR   __setitem__z_bsr_base.__setitem__R  rw   r\   c                 T    |                      d                              |          S NFr0   )tocoo
_add_dense)rJ   others     rR   r~   z_bsr_base._add_denseY  s$    zzuz%%00777r\   c                    | j         \  }}| j        \  }}t          j        | j         d         t	          | j        |j                            }t          ||z  ||z  ||| j        | j        | j	        
                                ||	  	         |S ri   )r,   r$   r:   r;   r   r*   r   rA   r@   r=   rl   )rJ   r   rL   rM   rN   rO   results          rR   _mul_vectorz_bsr_base._mul_vector\  s    j!n!$*Q-vdj%+/N/NOOO1a4Aq!Kty'8'86	 	 	 r\   c                 n   | j         \  }}| j        \  }}|j        d         }t          j        ||ft	          | j        |j                            }t          ||z  ||z  |||| j        | j        | j	        
                                |
                                |
                                
  
         |S )Nr   r)   )r$   r,   r:   r;   r   r*   r   rA   r@   r=   rl   )rJ   r   rN   rO   rL   rM   n_vecsr   s           rR   _mul_multivectorz_bsr_base._mul_multivectorh  s    n!j!Q1V*F4:ek,J,JKKKAqD!Q$1T\49??+<+<v||~~	/ 	/ 	/ r\   c                 H   | j         \  }}|j         \  }}| j        \  }}|j        dk    r|j        d         }nd}|j        dk    r |dk    r|                    ||fd          }n|                    ||f          }|                     | j        | j        |j        |j        f          }	t          ||z  ||z  | j                            |	          | j                            |	          |j                            |	          |j                            |	                    }
|                     | j        | j        |j        |j        f|
          }	t          j
        | j        j         |	          }t          j
        |
|	          }t          j
        ||z  |
z  t          | j        |j                            }t          |
||z  ||z  |||| j                            |	          | j                            |	          t          j        | j                  |j                            |	          |j                            |	          t          j        |j                  |||           |                    d	||          }|                     |||f||f||f
          S )Nr!   r   csrF)r$   r/   r#   r'   r)   rU   )r,   r$   )r,   r$   r3   r4   r>   rA   r@   r   rH   r:   rj   r   r*   r   rl   r=   reshape_bsr_container)rJ   r   rL   K1K2rM   rN   nrO   rP   bnnzrA   r@   r=   s                 rR   _mul_sparse_matrixz_bsr_base._mul_sparse_matrixu  s   
2An! <5  "AAA<5  Q!VVKK1Q%eK<<EEKK1Q%K00E))4;+0<+H I I	 !Aq!t!%!3!3I!>!>!%!4!4Y!?!?!&!4!4Y!?!?!&!5!5i!@!@	B B ))4;+0<+H15 * 7 7	 $++9===(4y111x!Dtz%+(F(FGGG4Aq!tQ1;%%i00<&&y118DI&&<&&y11=''	228EJ''		 		 		 ||Bq## ""7F#Aq6aV # 
 
 	
r\   c                     |d| j         fvr(|                                                     |          S |r|                                 S | S )a  Convert this matrix into Block Sparse Row Format.

        With copy=False, the data/indices may be shared between this
        matrix and the resultant bsr_array.

        If blocksize=(R, C) is provided, it will be used for determining
        block size of the bsr_array.
        Nr#   )r$   tocsrr4   r/   )rJ   r$   r/   s      rR   r4   z_bsr_base.tobsr  sP     T4>222::<<%%	%::: 	99;;Kr\   c                 4   | j         \  }}| j        \  }}| j        }|                     | j        | j        ft          ||                    }t          j        |dz   |          }t          j        ||          }	t          j        |t          | j
                            }
t          ||z  ||z  ||| j                            |d          | j                            |d          | j        ||	|

  
         |                     |
|	|f| j                   S )Nr'   r   r)   Fr0   r,   )r,   r$   rY   r>   rA   r@   r?   r:   rj   r   r*   r   rH   r=   _csr_container)rJ   r/   rL   rM   rN   rO   rY   rP   rA   r@   r=   s              rR   r   z_bsr_base.tocsr  s   z1~1h))4;*E14S! * > >	!a%y111(3i000x6$*#5#5666!q&q&Q+$$YU$;;,%%ie%<<)	 	 	 ""D'6#:$*"MMMr\   c                 V    |                      d                              |          S r|   )r   tocsc)rJ   r/   s     rR   r   z_bsr_base.tocsc  s'    zzuz%%+++666r\   c                    | j         \  }}| j        \  }}t          j        | j                  }|j        j        t          j        t          j                  j        k    rH|                    t          j                  }t          j	        ||k              rt          d          |}|                     t          ||                    }|t          j        ||z  |          z                      |          }	|	                    ||z                                d||          }	|	t          j        t          j        ||                              dd          d|f          z  }	|	                    d          }	|| j        z                      |d                              ||z                                d||          }
|
t          j        t          j        ||          |df          z  }
|
                    d          }
| j                            d          }|r|                                }|                     ||	|
ff| j                   S )	zConvert this matrix to COOrdinate format.

        When copy=False the data array will be shared between
        this matrix and the resultant coo_matrix.
        zMatrix too big to convertr'   r)   rU   r   Fr0   r   )r,   r$   r:   r[   rA   r*   itemsizeintprH   anyr9   r>   r?   arangerepeatr   tiler@   r=   r/   rC   )rJ   r/   rL   rM   rN   rO   indptr_diffindptr_diff_limitedrP   rowcolr=   s               rR   r}   z_bsr_base.tocoo  s    j!n!gdk**%(9(9(BBB"-"4"4RW"="=v)[899 > !<===-K))Q);;	29QT3333;;KHHjj1oo%%b1--rwry)444<<RBBQqEJJJkk"oo4<''	'>>EEacJJRRSUVWXYZZrwry)444qe<<<kk"ooy  $$ 	99;;D""C:dj # 
 
 	
r\   c                 X    |                      d                              ||          S )NFr0   )orderout)r}   toarray)rJ   r   r   s      rR   r   z_bsr_base.toarray  s)    zzuz%%--Es-CCCr\   c                 n   |t          d          | j        \  }}| j        \  }}| j        ||z  z  }| j        dk    r"|                     ||f||f| j        |          S t          j        ||z  dz   | j        j                  }t          j        || j	        j                  }	t          j        |||f| j
        j                  }
t          ||z  ||z  ||| j        | j	        | j
                                        ||	|
                                
  
         |                     |
|	|f||f|          S )NzoSparse matrices do not support an 'axes' parameter because swapping dimensions is the only logical permutation.r   )r$   r*   r/   r   r)   )r,   r/   )r9   r$   r,   rY   r   r*   r:   rj   rA   r@   r=   r   rl   )rJ   axesr/   rN   rO   rL   rM   NBLKrA   r@   r=   s              rR   	transposez_bsr_base.transpose  s[    L M M M ~1z1x!A#8q==&&1v!Q-1Zd ' D D D !Q$($+*;<<<(4t|'9:::xq!DIO<<<adAqD!Qk4<1B1Bgtzz||	5 	5 	5 ""D'6#:*+Qd # < < 	<r\   c                    | j         sdS | j        \  }}| j        \  }}| j        dk                        d||z                                d          }|                                d         }| j        |         | j        dt          |          <   t          j	        ||z  ||z  | j
        | j        |           |                                  dS )zRemove zero elements in-place.Nr   rU   r   )rc   )rY   r$   r,   r=   r   sumnonzerorB   r   csr_eliminate_zerosrA   r@   rX   )rJ   rN   rO   rL   rM   masknonzero_blockss          rR   eliminate_zerosz_bsr_base.eliminate_zeros"  s     x 	Fn!j!	Q''1Q3//333;;**.)N*C	&3~&&&' 	(Aq!tT[)-t	= 	= 	=

r\   c                     | j         rdS |                                  | j        \  }}| j        \  }}||z  }d}d}t	          |          D ]}|}	| j        |dz            }|	|k     r| j        |	         }
| j        |	         }|	dz  }	|	|k     r=| j        |	         |
k    r,|| j        |	         z  }|	dz  }	|	|k     r| j        |	         |
k    ,|
| j        |<   || j        |<   |dz  }|	|k     || j        |dz   <   |                                  d| _         dS )zkEliminate duplicate matrix entries by adding them together

        The is an *in place* operation
        Nr   r   T)	has_canonical_formatsort_indicesr$   r,   rangerA   r@   r=   rX   )rJ   rN   rO   rL   rM   n_rowrY   row_endrT   jjjxs               rR   sum_duplicatesz_bsr_base.sum_duplicates6  sP   
 $ 	F~1z1 Qu 	# 	#ABk!A#&Gw,,L$IbMa7llt|B'71'<'<2&A!GB 7llt|B'71'<'< %&S!!"	#q w,,  #DK!

$(!!!r\   c           
          | j         rdS | j        \  }}| j        \  }}t          ||z  ||z  ||| j        | j        | j                                                   d| _         dS )z3Sort the indices of this matrix *in place*
        NT)has_sorted_indicesr$   r,   r   rA   r@   r=   rl   )rJ   rN   rO   rL   rM   s        rR   r   z_bsr_base.sort_indicesW  sj     " 	Fn!j!Aq!tQ4;diooFWFWXXX"&r\   c                    | j         \  }}| j        \  }}t          | j                  ||z  dz   k    rt	          d          | j        d         }t          | j                  |k     rt	          d          t          | j                  |k     rt	          d          | j        d|         | _        | j        d|         | _        dS )z9 Remove empty space after all non-zero elements.
        r   z index pointer has invalid lengthrU   z"indices array has too few elementszdata array has too few elementsN)r$   r,   rB   rA   r9   r@   r=   )rJ   rN   rO   rL   rM   r   s         rR   rX   z_bsr_base.pruned  s     n!j!t{q!tax''?@@@{2t|t##ABBBty>>D  >???Iete$	|ETE*r\   c                    |                      || j                  }t          t          | j        |z   | j        z             }| j        \  }}t          | j                  t          |j                  z   }|                     | j        | j	        |j        |j	        f|          }	t          j        | j        j        |	          }
t          j        ||	          }g d}||v r't          j        ||z  |z  t          j                  }n4t          j        ||z  |z  t          | j        |j                            } || j        d         |z  | j        d         |z  ||| j                            |	          | j	                            |	          | j        |j                            |	          |j	                            |	          t          j        |j                  |
||           |
d         }|d|         }|d||z  |z           }||d	z  k     r(|                                }|                                }|                    d||          }|                      |||
f| j        
          S )z5Apply the binary operation fn to two sparse matrices.r#   r'   r)   )_ne__lt__gt__le__ge_r   r   rU   Nr+   r   )	__class__r$   getattrr   r3   rB   r=   r>   rA   r@   r:   rj   r,   bool_r   r*   rH   rl   r/   r   )rJ   r   opin_shape	out_shapefnrN   rO   max_bnnzrP   rA   r@   bool_opsr=   actual_bnnzs                  rR   _binoptz_bsr_base._binopty  sI   
 u?? \4;#3dk#ABBn!ty>>C
OO3))4;+0<+H19 * ; ;	 $++9===(89555;;;>>8AaCL999DD8AaCLtz%+0N0NOOOD
4:a=!TZ]A-q!;i((<y))9<y))=	**8EJ		 		 		 Rj,;,'$QqS_$%!##llnnG99;;D||Bq##~~tWf5TZ~HHHr\   c                 
   |rS|                      || j                                        | j                                        f| j        |j                  S |                      || j        | j        f| j        |j                  S )zReturns a matrix with the same sparsity structure as self,
        but with different data.  By default the structure arrays
        (i.e. .indptr and .indices) are copied.
        )r,   r*   )r   r@   r/   rA   r,   r*   )rJ   r=   r/   s      rR   
_with_dataz_bsr_base._with_data  s    
  	F>>4(9(9(;(;DK<L<L<N<N"O)-$* " F F F >>4T["A)-$* " F F Fr\   )NNFN)Trs   r%   )NF)F)NN) __name__
__module____qualname____doc___formatr2   rI   r^   propertyr$   rd   r   rg   rq   rv   rz   r~   r   r   r   r4   r   r   r}   r   r   r   r   r   rX   r   r    r\   rR   r    r       sV       d dJ Gj, j, j, j,X8C 8C 8C 8C|# # #n---I, , , , o-GO  
 
 
 
 '/H" " "" " "8 8 8
 
 
  2
 2
 2
p    N N N N* M)EM7 7 7 7 M)EM#
 #
 #
 #
JD D D D o-GO< < < <2  )1I  () ) )B' ' '+ + +*.I .I .I .Ib
F 
F 
F 
F 
F 
Fr\   r    c                 ,    t          | t                    S )a  Is `x` of a bsr_matrix type?

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

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

    Examples
    --------
    >>> from scipy.sparse import bsr_array, bsr_matrix, csr_matrix, isspmatrix_bsr
    >>> isspmatrix_bsr(bsr_matrix([[5]]))
    True
    >>> isspmatrix_bsr(bsr_array([[5]]))
    False
    >>> isspmatrix_bsr(csr_matrix([[5]]))
    False
    )r6   r   )r   s    rR   r   r     s    . a$$$r\   c                       e Zd ZdS )r   Nr   r   r   r   r\   rR   r   r             Dr\   r   c                       e Zd ZdS )r   Nr   r   r\   rR   r   r     r   r\   r   )(r   __docformat____all__warningsr   numpyr:   _matrixr   r	   _datar
   r   _compressedr   _baser   r   r   r   _sputilsr   r   r   r   r   r    r   r   r   r   r   r   r   r   r    r   r   r   r   r\   rR   <module>r      s*   ( (%
7
7
7           3 3 3 3 3 3 3 3 . . . . . . . . # # # # # # 7 7 7 7 7 7 7 7 7 7 7 7$ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $      & & & & & & & & & & & & & & & & & &
]
F ]
F ]
F ]
F ]
F
M ]
F ]
F ]
FN% % %6	 	 	 	 		7 	 	 	 %	 	 	 	 	 	9 	 	 	 *))*;<<
   r\   