+
    nDj~                        R t Rt. ROt^ RIHt ^ RIt^ RIHt ^RI	H
t
 ^RIHtHt ^R	IHt ^R
IHtHtHtHt ^RIHtHtHtHtHtHt ^RIHt ^RIHtHtH t H!t!H"t"H#t#H$t$  ! R R]]4      t%R t& ! R R]%]4      t' ! R R]
]%4      t(R# )z"Compressed Block Sparse Row formatzrestructuredtext en	bsr_array
bsr_matrix)warnN)copy_if_needed)spmatrix)_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                     a  ] tR t^t o RtR RR/R lltR!R lt]V 3R lR l4       tR"R lt	]
P                  P                  ]	n        R"R	 lt]
P                  P                  ]n        R
 tR#R lt]
P                  P                  ]n        R tR tR tR tR tR tR$R lt]
P*                  P                  ]n        R%R lt]
P,                  P                  ]n        R%R lt]
P.                  P                  ]n        R!R lt]
P0                  P                  ]n        R&R lt]
P2                  P                  ]n        R$R lt]
P4                  P                  ]n        R tR tR tR tR&R ltR!R lt R%R lt!Rt"V t#R# )'	_bsr_basebsrNmaxprintc                  \         P                  ! WVR 7       \        V4      '       d   VP                  V P                  8X  d   V'       d   VP	                  4       pMVP                  VR7      pVP                  VP                  VP                  VP                  3w  V n        V n        V n        V n	        EM\        V\        4      '       Ed    \        V4      '       Ed   \        V4      V n	        V P                  w  rxVf   RpM*\        V4      '       g   \        RV 24      h\        V4      p\         P"                  ! RV,           \%        V\&        R7      4      V n        Vw  rWy,          ^ 8w  g   W,          ^ 8w  d   \        R4      hV P)                  \+        Wy,          W,          W4      R7      p\         P"                  ! ^ VR7      V n        \         P"                  ! Wy,          ^,           VR7      V n        EM\-        V4      ^8X  do   V P/                  WVR7      pVP                  VR7      pVP                  VP                  VP                  VP                  3w  V n        V n        V n        V n	        EM3\-        V4      ^8X  EdX   Vw  rp^pVe   \+        V4      pVe   \+        V\+        V4      4      pV P)                  VV3VR	R
7      pV'       g   \0        p\         P2                  ! WVR7      V n        \         P2                  ! VWKR7      V n        \5        WVR7      V n        V P                  P6                  ^8w  d#   \        RV P                  P                   24      hVew   \        V4      '       g   \        RV 24      h\        V4      V P                  P                  R,          8w  d-   \        RV RV P                  P                  R,           24      hM\        R4      h \         P8                  ! V4      p\        T \<        4      '       d+   TP6                  ^8w  d   \        RTP6                   R24      hT P/                  YR7      P                  TR7      pTP                  TP                  TP                  TP                  3w  T n        T n        T n        T n	        Ve   \        V4      V n	        MxV P                  fk    \-        V P                  4      ^,
          pV P                  P+                  4       ^,           pV P>                  w  r\        Wy,          W,          34      V n	        V P                  f    Vf   \        R4      h\        V4      V n	        Ve6   V P                  PA                  \%        W0P                  4      RR7      V n        V PC                  RR7       R#   \:         d    p\        RT P                   R24      ThRp?ii ; i  \:         d   p\        R4      ThRp?ii ; i))r   	blocksizeNzinvalid blocksize=)defaultz#shape must be multiple of blocksizemaxvaldtype)r'   shapeT)r%   check_contents)copyr'   z*BSR data must be 3-dimensional, got shape=   NNzmismatching blocksize=z vs z(unrecognized bsr_array constructor usagezunrecognized form for z_matrix constructorzBSR arrays don't support zD input. Use 2Dz!unable to infer matrix dimensionszneed to infer shapeFr*   )
full_check)r,   r,       )"r   __init__r
   formatr*   tobsrindptrindicesdata_shape
isinstancetupler   r   r(   
ValueErrornpzerosr   float_get_index_dtypemaxlen_coo_containerr   arrayr   ndimasarray	Exceptionr   r"   astypecheck_format)selfarg1r(   r'   r*   r"   r   MNRC	idx_dtypecoor   r6   r5   r4   r%   es   &&&&&&$            K/data/cameron/venvs/s3viz/lib/python3.14/site-packages/scipy/sparse/_bsr.pyr1   _bsr_base.__init__   s   d8<D>>{{dkk)dyy{zzIz6T\\499dkkA=DKty$+ U##t}})$/jj$ %I"9--(+=i[)IJJ %i 0IHHTI%5xu7UV	Ea<AEa<$%JKK !11QT149N1O	!xx; hhqtaxyATa))$5)Iii)i4JJSXXszzEAT\49dk Ta*.' $ ZF( Y8F 117F2CFAE 2 G	)D!xx)L hhvDJ#D5A	99>>Q&$DTYY__DUV  ("9--(+=i[)IJJY'499??2+>>(4YK"499??2#6"79 
 !!KLLMzz$' $((TYY!^ #<TYYK!WXX&&t&9??)?TDT\\499dkkA=DKty$+ %e,DKzz!9DKK(1,A((*Q.A ..CA"-qs13i"8DK::} !677)%0		((%)C%(PDIU+E  M !9$(KK=0C"E FKLMM$ ! Q$%HIqPQs0   0V6 =W# 6W WW #W?.W::W?c                    V P                   w  r#V P                  w  rEV P                  P                  P                  R8w  d0   \        RV P                  P                  P                   R2^R7       V P                  P                  P                  R8w  d0   \        RV P                  P                  P                   R2^R7       V P                  P                  ^8w  g   V P                  P                  ^8w  d   \        R4      hV P                  P                  ^8w  d   \        R4      h\        V P                  4      W$,          ^,           8w  d3   \        R\        V P                  4       R	W$,          ^,            R24      hV P                  ^ ,          ^ 8w  d   \        R
4      h\        V P                  4      \        V P                  4      8w  d   \        R4      hV P                  R,          \        V P                  4      8  d   \        R4      hV P                  4        V'       Ed`   V P                  ^ 8  d   V P                  P                  4       W5,          8  d1   \        RW5,           RV P                  P                  4        R24      hV P                  P                  4       ^ 8  d   \        R4      h\         P"                  ! V P                  4      P                  4       ^ 8  d   \        R4      hV P%                  V P                  V P                  34      p\         P&                  ! V P                  VR7      V n        \         P&                  ! V P                  VR7      V n        \)        V P                  4      V n
        R# R# )a  Check whether the array/matrix respects the BSR format.

Parameters
----------
full_check : bool, optional
    If `True`, run rigorous check, scanning arrays for valid values.
    Note that activating those check might copy arrays for casting,
    modifying indices and index pointers' inplace.
    If `False`, run basic checks on attributes. O(1) operations.
    Default is `True`.
iz$indptr array has non-integer dtype ())
stacklevelz%indices array has non-integer dtype (z!indices, and indptr should be 1-Dzdata should be 3-Dzindex pointer size (z) should be (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 < z
 (now max z column index values must be >= 0z8index pointer values must form a non-decreasing sequencer&   N)r(   r"   r4   r'   kindr   namer5   rC   r:   r6   r@   prunennzr?   minr;   diffr>   rD   r   )rH   r.   rJ   rK   rL   rM   rN   s   &&     rQ   rG   _bsr_base.check_format   s    jjnn ;;!!S(78I8I8N8N7OqQ<<""c)89K9K9P9P8QQRS <<!T[[%5%5%:@AA99>>Q122 q(&s4;;'7&8adQhZqQ  KKNa@AA TYY/IJJKKOc$,,// D E E 	

:xx!|<<##%-$8$T\\%5%5%7$8;  <<##%)$%GHH774;;'++-1$ &B C C --t||T[[.IJI**T[[	BDK::dll)DDL!$)),DI#     c                    < V ^8  d   QhRS[ /# )   return)r9   )r2   __classdict__s   "rQ   __annotate___bsr_base.__annotate__   s     # #5 #r_   c                <    V P                   P                  R,          # )zBlock size of the matrix.r+   )r6   r(   )rH   s   &rQ   r"   _bsr_base.blocksize   s     yyr""r_   c                    Ve   \        R4      hV P                  w  r#\        V P                  R,          4      V,          V,          # )Nz6_getnnz over an axis is not implemented for BSR formatrW   )NotImplementedErrorr"   intr4   )rH   axisrL   rM   s   &&  rQ   _getnnz_bsr_base._getnnz   sB    % '7 8 8~~4;;r?#a'!++r_   c                    Ve!   V P                  4       P                  VR7      # \        P                  ! V P                  4       4      # )Nrk   )tocsrcount_nonzeror;   _deduped_data)rH   rk   s   &&rQ   rq   _bsr_base.count_nonzero   s<    ::<--4-88 2 2 455r_   c                   \         V P                  ,          w  r\        V \        4      '       d   R MRpRP	                  R V P
                   4       4      pRV RV RV P                   RV P                   RV R	V P                   R
2# )rB   matrixxc              3   8   "   T F  p\        V4      x  K  	  R # 5iN)str).0rv   s   & rQ   	<genexpr>%_bsr_base.__repr__.<locals>.<genexpr>   s     4^SVV^s   <z sparse z of dtype 'z'
	with z stored elements (blocksize=z) and shape >)	r   r2   r8   r   joinr"   r'   r[   r(   )rH   _fmt
sparse_clsbs   &    rQ   __repr___bsr_base.__repr__   s    $++& *4 9 9Wx
HH4T^^44uHZLDJJ< @hhZ;A3l4::,VWY	
r_   c                   V P                   w  r#W) 8:  g   W8  d-   \        P                  ! ^ V P                  P                  R7      # V P
                  w  rE\        P                  ! \        V\        V^ 4      ,           V\        V^ 4      ,
          4      \        V P                  4      R7      p\        P                  ! WV,          W5,          WEV P                  V P                  \        P                  ! V P                  4      V4	       V# r0   r&   )r(   r;   emptyr6   r'   r"   r<   r\   r?   r   r   bsr_diagonalr4   r5   ravel)rH   krowscolsrL   rM   ys   &&     rQ   diagonal_bsr_base.diagonal   s    ZZ
:88ATYY__55~~HHSAq	)4#a)+;<!$**-/!!!QY	1"&++t||"$((499"5q	: r_   c                    \         hrx   ri   )rH   keys   &&rQ   __getitem___bsr_base.__getitem__      !!r_   c                    \         hrx   r   )rH   r   vals   &&&rQ   __setitem___bsr_base.__setitem__  r   r_   c                D    V P                  R R7      P                  V4      # Fr-   )tocoo
_add_dense)rH   others   &&rQ   r   _bsr_base._add_dense  s    zzuz%0077r_   c                ^   V P                   w  r#V P                  w  rE\        P                  ! V P                   ^ ,          \	        V P
                  VP
                  4      R7      p\        W$,          W5,          WEV P                  V P                  V P                  P                  4       W4	       V# r   )r(   r"   r;   r<   r   r'   r   r4   r5   r6   r   )rH   r   rJ   rK   rL   rM   results   &&     rQ   _matmul_vector_bsr_base._matmul_vector  su    jjnn$**Q-vdjj%++/NO14qKKtyy'8	 r_   c                   V P                   w  r#V P                  w  rEVP                  ^,          p\        P                  ! WF3\	        V P
                  VP
                  4      R7      p\        WB,          WS,          WbVV P                  V P                  V P                  P                  4       VP                  4       VP                  4       4
       V# )r,   r&   )r"   r(   r;   r<   r   r'   r   r4   r5   r6   r   )rH   r   rL   rM   rJ   rK   n_vecsr   s   &&      rQ   _matmul_multivector_bsr_base._matmul_multivector  s    nnjjQ1*F4::ekk,JKAD!$1T\\499??+<v||~	/ r_   c                   V P                   w  r#VP                   w  rEV P                  w  rgVP                  R 8X  d   VP                  ^,          pM^pVP                  R8X  d   V^8X  d   VP                  Wx3RR7      pMVP                  Wx3R7      pV P	                  V P
                  V P                  VP
                  VP                  34      p	W&,          p
WX,          p\        WV P
                  P                  V	RR7      V P                  P                  V	RR7      VP
                  P                  V	RR7      VP                  P                  V	RR7      4      pV P	                  V P
                  V P                  VP
                  VP                  3VR7      p	\        P                  ! V P
                  P                   V	R7      p\        P                  ! WR7      p\        P                  ! Wh,          V,          \        V P                  VP                  4      R7      p\        WWWV P
                  P                  V	RR7      V P                  P                  V	RR7      \        P                  ! V P                  4      VP
                  P                  V	RR7      VP                  P                  V	RR7      \        P                  ! VP                  4      VVV4       VP!                  R	Wh4      pV P#                  WV3W%3Wh3R7      # )
r   csrF)r"   r*   r!   r-   r$   r&   )r(   r"   rW   )r(   r"   r2   r3   r>   r4   r5   r   rF   r;   r   r   r'   r   r   r6   reshape_bsr_container)rH   r   rJ   K1K2rK   rL   nrM   rN   n_brown_bcolbnnzr4   r5   r6   s   &&              rQ   _matmul_sparse_bsr_base._matmul_sparse*  s|   

nn <<5 "AA<<5 Q!VKK1%eK<EKK1%K0E))4;;+0<<+H I	  !%!3!3IE!3!J!%!4!4YU!4!K!&!4!4YU!4!K!&!5!5ie!5!L	N ))4;;+0<<+H15 * 7	 $++++9=((41xxDtzz%++(FG4A;;%%ie%<<<&&yu&=88DII&<<&&yu&===''	'>88EJJ'		 ||Bq# ""F#A6aV # 
 	
r_   c                    VR V P                   39  d!   V P                  4       P                  VR7      # V'       d   V P                  4       # V # )Nr!   )r"   rp   r3   r*   )rH   r"   r*   s   &&&rQ   r3   _bsr_base.tobsrd  sA    T4>>22::<%%	%::99;Kr_   c                t   V P                   w  r#V P                  w  rEV P                  pV P                  V P                  V P
                  3\        Wc4      R 7      p\        P                  ! V^,           VR7      p\        P                  ! WgR7      p	\        P                  ! V\        V P                  4      R7      p
\        W$,          W5,          WEV P                  P                  VRR7      V P
                  P                  VRR7      V P                  VV	V
4
       V P                  WV3V P                   R7      # )r$   r&   Fr-   r(   )r(   r"   r[   r>   r4   r5   r?   r;   r   r   r'   r   rF   r6   _csr_container)rH   r*   rJ   rK   rL   rM   r[   rN   r4   r5   r6   s   &&         rQ   rp   _bsr_base.tocsrn  s    zz~~hh))4;;*E14S * >	!a%y1((30xx6$**#56!&&++$$YU$;,,%%ie%<))	 ""D6#:$**"MMr_   c                F    V P                  R R7      P                  VR7      # r   )rp   tocsc)rH   r*   s   &&rQ   r   _bsr_base.tocsc  s!    zzuz%+++66r_   c                   V P                   w  r#V P                  w  rE\        P                  ! V P                  4      pVP
                  P                  \        P
                  ! \        P                  4      P                  8  dK   VP                  \        P                  4      p\        P                  ! Wv8g  4      '       d   \        R 4      hTpV P                  \        W#4      R7      pV\        P                  ! W$,          VR7      ,          P                  V4      p	V	P                  WE,          4      P                  RWE4      p	V	\        P                   ! \        P                  ! WHR7      P                  R^4      ^V34      ,          p	V	P                  R4      p	WPP"                  ,          P                  VRR7      P                  WE,          4      P                  RWE4      p
V
\        P                   ! \        P                  ! WXR7      V^34      ,          p
V
P                  R4      p
V P$                  P                  R4      pV'       d   VP'                  4       pV P)                  WV
33V P                   R7      # )zMatrix too big to convertr$   r&   Fr-   r   rW   )r(   r"   r;   r]   r4   r'   itemsizeintprF   anyr:   r>   r?   arangerepeatr   tiler5   r6   r*   rA   )rH   r*   rJ   rK   rL   rM   indptr_diffindptr_diff_limitedrN   rowcolr6   s   &&          rQ   r   _bsr_base.tocoo  s   jjnnggdkk*%%(9(B(BB"-"4"4RWW"=vv)899 !<==-K))Q);	299QT33;;KHjjo%%b-rwwryy4<<RBQqEJJkk"oLL (((?qsGGBqO 	rwwryy4qe<<kk"oyy  $99;D"":djj # 
 	
r_   c                F    V P                  R R7      P                  WR7      # )Fr-   )orderout)r   toarray)rH   r   r   s   &&&rQ   r   _bsr_base.toarray  s!    zzuz%--E-CCr_   c                   Ve   VR8w  d   \        R4      hV P                  w  r4V P                  w  rVV P                  W4,          ,          pV P                  ^ 8X  d"   V P	                  We3WC3V P
                  VR7      # \        P                  ! Wd,          ^,           V P                  P
                  R7      p\        P                  ! WpP                  P
                  R7      p	\        P                  ! WtV3V P                  P
                  R7      p
\        WS,          Wd,          W4V P                  V P                  V P                  P                  4       WV
P                  4       4
       V P	                  WV3We3VR7      # )NzoSparse matrices do not support an 'axes' parameter because swapping dimensions is the only logical permutation.)r"   r'   r*   r&   )r(   r*   )r,   r0   )r:   r"   r(   r[   r   r'   r;   r   r4   r5   r6   r   r   )rH   axesr*   rL   rM   rJ   rK   NBLKr4   r5   r6   s   &&&        rQ   	transpose_bsr_base.transpose  s5    L M M ~~zzxx!#88q=&&v!-1ZZd ' D D !$($++*;*;<((4||'9'9:xx!DIIOO<adAD!kk4<<1Btzz|	5 ""D6#:*+d # < 	<r_   c                   V P                   '       g   R# V P                  w  rV P                  w  r4V P                  ^ 8g  P	                  RW,          4      P                  ^R7      pVP                  4       ^ ,          pV P                  V,          V P                  R\        V4      % \        P                  ! W1,          WB,          V P                  V P                  V4       V P                  4        R# )zRemove zero elements in-place.Nro   rW   )r[   r"   r(   r6   r   sumnonzeror@   r   csr_eliminate_zerosr4   r5   rZ   )rH   rL   rM   rJ   rK   masknonzero_blockss   &      rQ   eliminate_zeros_bsr_base.eliminate_zeros  s     xxxnnjj		Q''13/333;**.))N*C		&3~&' 	((qtT[[)-t	=

r_   c                   V P                   '       d   R# V P                  4        V P                  w  rV P                  w  r4W1,          p^ p^ p\	        V4       F  pTp	V P
                  V^,           ,          pW8  d   V P                  V	,          p
V P                  V	,          pV	^,          p	W8  d=   V P                  V	,          V
8X  d%   WP                  V	,          ,          pV	^,          p	KB  WP                  V&   WP                  V&   V^,          pK  W`P
                  V^,           &   K  	  V P                  4        RV n         R# )zbEliminate duplicate array/matrix entries by adding them together.

The is an *in place* operation
NT)	has_canonical_formatsort_indicesr"   r(   ranger4   r5   r6   rZ   )rH   rL   rM   rJ   rK   n_rowr[   row_endrT   jjjrv   s   &           rQ   sum_duplicates_bsr_base.sum_duplicates  s   
 $$$~~zz uABkk!A#&G,LL$IIbMalt||B'71'<2&A!GB$%S!!"		#q"KK!  	

$(!r_   c           
        V P                   '       d   R# V P                  w  rV P                  w  r4\        W1,          WB,          WV P                  V P
                  V P                  P                  4       4       RV n         R# )z:Sort the indices of this array/matrix *in place*.
        NT)has_sorted_indicesr"   r(   r   r4   r5   r6   r   )rH   rL   rM   rJ   rK   s   &    rQ   r   _bsr_base.sort_indices  sZ     """nnjjqtQ4;;diiooFWX"&r_   c                   V P                   w  rV P                  w  r4\        V P                  4      W1,          ^,           8w  d   \	        R4      hV P                  R,          p\        V P
                  4      V8  d   \	        R4      h\        V P                  4      V8  d   \	        R4      hV P                  RV V n        V P
                  RV V n        R# )z8Remove empty space after all non-zero elements.
        z index pointer has invalid lengthz"indices array has too few elementszdata array has too few elementsNrW   )r"   r(   r@   r4   r:   r5   r6   )rH   rL   rM   rJ   rK   r   s   &     rQ   rZ   _bsr_base.prune  s     nnjjt{{qtax'?@@{{2t||t#ABBtyy>D >??IIet$	||ET*r_   c                   V P                  WP                  R7      p\        \        V P                  V,           V P                  ,           4      pV P                  w  rg\        V P                  4      \        VP                  4      ,           pV P                  V P                  V P                  VP                  VP                  3VR7      p	\        P                  ! V P                  P                  V	R7      p
\        P                  ! WR7      p. ROpW,9   d5   \        P                  ! Wg,          V,          \        P                  R7      pMC\        P                  ! Wg,          V,          \        V P                  VP                  4      R7      pV! V P                  ^ ,          V,          V P                  ^,          V,          WgV P                  P!                  V	RR7      V P                  P!                  V	RR7      V P                  VP                  P!                  V	RR7      VP                  P!                  V	RR7      \        P"                  ! VP                  4      V
VV4       V
R	,          pVRV pVRWg,          V,           pW^,          8  d!   VP%                  4       pVP%                  4       pVP'                  R	Wg4      pV P                  WV
3V P                  R7      # )
z5Apply the binary operation fn to two sparse matrices.r!   r$   r&   Fr-   Nr   )_ne__lt__gt__le__ge_rW   )	__class__r"   getattrr   r2   r@   r6   r>   r4   r5   r;   r   r(   bool_r   r'   rF   r   r*   r   )rH   r   opin_shape	out_shapefnrL   rM   max_bnnzrN   r4   r5   bool_opsr6   actual_bnnzs   &&&&&          rQ   _binopt_bsr_base._binopt'  s!   
 u? \4;;#3dkk#ABnntyy>C

O3))4;;+0<<+H19 * ;	 $++++9=((85;>88ACL9D88ACLtzz%++0NOD
4::a=!TZZ]A-q;;ie4<<yu599<<yu5==	688EJJ		 Rj,;'$QS_%!#llnG99;D||Bq#~~tf5TZZ~HHr_   c                B   V'       d[   V P                  WP                  P                  4       V P                  P                  4       3V P                  VP
                  R7      # V P                  WP                  V P                  3V P                  VP
                  R7      # )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   r5   r*   r4   r(   r'   )rH   r6   r*   s   &&&rQ   
_with_data_bsr_base._with_dataX  s    
 >>4(9(9(;DKK<L<L<N"O)-$** " F F >>4T[["A)-$** " F Fr_   c                0    \         P                  ! WV4      # rx   )r   _broadcast_to)rH   r(   r*   s   &&&rQ   r  _bsr_base._broadcast_tok  s    $$T$77r_   )r7   r6   r   r   r5   r4   )NNFN)Trx   r/   )NF)F)NN)$__name__
__module____qualname____firstlineno___formatr1   rG   propertyr"   rl   r   __doc__rq   r   r   r   r   r   r   r   r   r3   rp   r   r   r   r   r   r   r   rZ   r   r   r  __static_attributes____classdictcell__)rc   s   @rQ   r   r      sh    Gs,-1s,j?-H # #, oo--GO6
 $1199M

 ''//H""8
4
t MM))EMN* MM))EM7 MM))EM
@ MM))EMD oo--GO<2  ))11I()B'+*.Ib
F&8 8r_   r   c                "    \        V \        4      # )a2  Is `x` of a bsr_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 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
)r8   r   )rv   s   &rQ   isspmatrix_bsrr  o  s    @ a$$r_   c                       ] tR tRtRtRtR# )r   i  a  
Block Sparse Row format sparse array.

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

    bsr_array(S, [blocksize=(R,C)])
        with another sparse array or matrix 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
----------
data : ndarray
    BSR format data array of the array
indices : ndarray
    BSR format index array of the array
indptr : ndarray
    BSR format index pointer array of the array
blocksize : 2-tuple of integers
    Block size (R, C)
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. 'bsr'
nnz : int
    Number of values stored in the array
size : int
    Number of values stored in the array
T : bsr_array
    The transpose of the array
mT : bsr_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.

**Summary of BSR format**

The Block Sparse 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. Such sparse 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.

**Limitations**

Block Sparse Row format sparse arrays do not support slicing.

Examples
--------
>>> import numpy as np
>>> from scipy.sparse import bsr_array
>>> 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]])

 Nr  r  r  r  r	  r
  r  r_   rQ   r   r     s    sr_   c                       ] tR tRtRtRtR# )r   i
  a  
Block Sparse Row format sparse 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:
    bsr_matrix(D, [blocksize=(R,C)])
        where D is a 2-D ndarray.

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

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

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

    bsr_matrix((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 matrix dimensions are inferred from the index arrays.

Attributes
----------
data : ndarray
    BSR format data array of the matrix
indices : ndarray
    BSR format index array of the matrix
indptr : ndarray
    BSR format index pointer array of the matrix
blocksize : 2-tuple of integers
    Block size (R, C)
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. 'bsr'
nnz : int
    Number of values stored in the matrix
size : int
    Number of values stored in the matrix
T : bsr_matrix
    The transpose of the matrix
mT : bsr_matrix
    The matrix transpose

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

**Summary of BSR format**

The Block Sparse 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. Such sparse 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 matrix (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.

**Limitations**

Block Sparse Row format sparse matrices do not support slicing.

Examples
--------
>>> import numpy as np
>>> from scipy.sparse import bsr_matrix
>>> bsr_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, 0, 1, 2, 2, 2])
>>> col = np.array([0, 2, 2, 0, 1, 2])
>>> data = np.array([1, 2, 3 ,4, 5, 6])
>>> bsr_matrix((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_matrix((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]])

r  Nr  r  r_   rQ   r   r   
  s    |r_   )r   r   r  ))r	  __docformat____all__warningsr   numpyr;   scipy._lib._utilr   _matrixr   _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_   rQ   <module>r     s~    (%
7   +  . # 7 7$ $ & & &
T	8
M T	8n %Ht	7 tn}9 }r_   