+
    Y°³jºO  ã                   óº   € R t Rt. ROt^ RIt^RIHt ^RIHtH	t	 ^RI
HtHtHtHtHt ^RIHt ^R	IHt  ! R
 R]4      tR t ! R R]]	4      t ! R R]]4      tR# )z#Compressed Sparse Row matrix formatzrestructuredtext enÚ	csr_arrayÚ
csr_matrixN)Úspmatrix)Ú_spbaseÚsparray)Ú	csr_tocscÚ	csr_tobsrÚcsr_count_blocksÚget_csr_submatrixÚcsr_sample_values)Úupcast)Ú
_cs_matrixc                   ó  a a€ ] tR t^t o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V 3R llt]P                  P                  ]n        RR lt]P                  P                  ]n        RR lt]P                  P                  ]n        ]R 4       tR	 tR
 tR tR tR tR tR tR tR tR tR tR tR tR tRtVtV ;t # )Ú	_csr_baseÚcsrc                ó  € Ve   VR8w  d   \        R4      hV P                  ^8X  d   V'       d   V P                  4       # T # V P                  w  r4V P	                  V P
                  V P                  V P                  3WC3VR7      # )NzvSparse arrays/matrices do not support an 'axes' parameter because swapping dimensions is the only logical permutation.©ÚshapeÚcopy)é   é    )Ú
ValueErrorÚndimr   r   Ú_csc_containerÚdataÚindicesÚindptr)ÚselfÚaxesr   ÚMÚNs   &&&  ÚR/home/luca/screen-checking/.venv/lib/python3.14/site-packages/scipy/sparse/_csr.pyÚ	transposeÚ_csr_base.transpose   s‡   € ØÒ ¨¤Üð Ló Mð Mð �9‰9˜Œ>ß"&�4—9‘9“;Ð0¨DÐ0Ø�z‰z‰ˆØ×"Ñ" D§I¡I¨t¯|©|Ø$(§K¡Kð$1Ø9:¸ÀTð #ó Kð 	Kó    c                óä  € V P                   ^8w  d   \        R4      hV P                  V P                  V P                  R7      pV P                  4        V P                  V P                  V P                  rTpVP                  VP                  rv\        V P                  ^ ,          4       FB  pW8,          p	W8^,           ,          p
WIV
 P                  4       Wh&   WYV
 P                  4       Wx&   KD  	  V# )é   z.Cannot convert a 1d sparse array to lil format©Údtype)r   r   Ú_lil_containerr   r(   Úsum_duplicatesr   r   r   ÚrowsÚrangeÚtolist)r   r   ÚlilÚptrÚindÚdatr+   r   ÚnÚstartÚends   &&         r!   ÚtolilÚ_csr_base.tolil$   sÀ   € Ø�9‰9˜Œ>ÜÐMÓNÐNØ×!Ñ! $§*¡*°D·J±JÐ!Ó?ˆà×ÑÔØ—k‘k $§,¡,¨t¯y©y�ˆØ—X‘X˜sŸx™xˆdä�t—z‘z !•}Ö%ˆAØ•FˆEØ˜•c•(ˆCØ �n×+Ñ+Ó-ˆD‰GØ �n×+Ñ+Ó-ˆD‹Gñ	 &ð ˆ
r$   c                ó6   € V'       d   V P                  4       # V # ©N©r   )r   r   s   &&r!   ÚtocsrÚ_csr_base.tocsr7   s   € ßØ—9‘9“;ÐàˆKr$   c                óJ   <€ \         SV `  VR 7      pV P                  Vn        V# )r9   )ÚsuperÚtocooÚhas_canonical_format)r   r   ÚAÚ	__class__s   && €r!   r>   Ú_csr_base.tocoo?   s(   ø€ Ü‰G‰M˜tˆMÓ$ˆð "&×!:Ñ!:ˆÔØˆr$   c           
     ó®  € V P                   ^8w  d   \        R4      hV P                  w  r#V P                  V P                  V P
                  3\        V P                  V4      R7      p\        P                  ! V^,           VR7      p\        P                  ! V P                  VR7      p\        P                  ! V P                  \        V P                  4      R7      p\        W#V P                  P                  VRR7      V P
                  P                  VRR7      V P                  VVV4       V P                  WvV3V P                  R7      pRVn        V# )r&   z.Cannot convert a 1d sparse array to csc format©Úmaxvalr'   Fr9   ©r   T)r   r   r   Ú_get_index_dtyper   r   ÚmaxÚnnzÚnpÚemptyr   r(   r   Úastyper   r   Úhas_sorted_indices)	r   r   r   r    Ú	idx_dtyper   r   r   r@   s	   &&       r!   ÚtocscÚ_csr_base.tocscI   s  € Ø�9‰9˜Œ>ÜÐMÓNÐNØ�z‰z‰ˆØ×)Ñ)¨4¯;©;¸¿¹Ð*EÜ+.¨t¯x©x¸Ó+;ð *ó =ˆ	ä—’˜!˜a�% yÔ1ˆÜ—(’(˜4Ÿ8™8¨9Ô5ˆÜ�xŠx˜Ÿ™¬¨t¯z©zÓ(:Ô;ˆä�!Ø—+‘+×$Ñ$ Y°UÐ$Ó;Ø—,‘,×%Ñ% i°eÐ%Ó<Ø—)‘)ØØØô	ð ×Ñ °Ð 7¸t¿z¹zÐÓJˆØ#ˆÔØˆr$   c                ó0  € V P                   ^8w  d   \        R4      hVf   ^RIHp V P	                  V! V 4      R7      # VR8X  dR   V P
                  P                  R^^4      V P                  V P                  3pV P                  W@P                  VR7      # Vw  rVV P                  w  rxV^8  g"   V^8  g   Wu,          ^ 8w  g   W†,          ^ 8w  d   \        RV 24      h\        WxWVV P                  V P                  4      p	V P                  V P                  V P                  3\        W†,          V	4      R7      p
\        P                  ! Wu,          ^,           V
R7      p\        P                  ! WšR7      p\        P                   ! W•V3V P"                  R7      p\%        WxWVV P                  P'                  V
RR	7      V P                  P'                  V
RR	7      V P
                  W¼VP)                  4       4
       V P                  WÜV3V P                  R
7      # )r&   z.Cannot convert a 1d sparse array to bsr format)Úestimate_blocksize)Ú	blocksizer   zinvalid blocksize rD   r'   Fr9   rF   )r   r   éÿÿÿÿ)r   r   Ú_spfuncsrR   Útobsrr   Úreshaper   r   Ú_bsr_containerr   r	   rG   rH   rJ   rK   Úzerosr(   r   rL   Úravel)r   rS   r   rR   Úarg1ÚRÚCr   r    ÚblksrN   r   r   r   s   &&&           r!   rV   Ú_csr_base.tobsra   s¾  € Ø�9‰9˜Œ>ÜÐMÓNÐNØÒÝ4Ø—:‘:Ñ(:¸4Ó(@�:ÓAÐAà˜%ÔØ—I‘I×%Ñ% b¨¨1Ó-¨d¯l©l¸4¿;¹;ÐGˆDØ×&Ñ& t·:±:ÀDÐ&ÓIÐIð ‰CˆAØ—*‘*‰CˆAà�1Œu˜˜Aœ ¥¨!¤¨q­u¸¬zÜ Ð#5°i°[Ð!AÓBÐBä# A¨¨D¯K©K¸¿¹ÓEˆDà×-Ñ-¨t¯{©{¸D¿L¹LÐ.IÜ/2°1µ4¸«ð .ó @ˆIä—X’X˜a�d 1�f¨IÔ6ˆFÜ—h’h˜tÔ5ˆGÜ—8’8˜T A˜J¨d¯j©jÔ9ˆDä�a˜AØ—k‘k×(Ñ(¨¸Ð(Ó?Ø—l‘l×)Ñ)¨)¸%Ð)Ó@Ø—i‘iØ t§z¡z£|ô	5ð ×&Ñ&Ø Ð'¨t¯z©zð 'ó ð r$   c                ó   € V # )zBswap the members of x if this is a column-oriented matrix
        © ©Úxs   &r!   Ú_swapÚ_csr_base._swap‰   s	   € ð ˆr$   c              #  óü  "  € V P                   ^8X  d    V P                  P                  ^ 4      p^ p\        V P                  V P
                  4       F.  w  r4\        W2,
          4       F  pVx € K	  	  Vx € V^,           pK0  	  \        V P                  ^ ,          V,
          4       F  pVx € K	  	  R# \        P                  ! ^V P                  P                  R7      p\        V \        4      '       d   V P                  R,          M^V P                  ^,          3p^ pV P                  R,           FD  p	W˜,
          V^&   V P                  W‰ p
V P
                  W‰ pV P                  WºV3VRR7      x € T	pKF  	  R# 5i)r   Nr'   :r   NNTr   )r   r(   ÚtypeÚzipr   r   r,   r   rJ   rY   r   Ú
isinstancer   rA   )r   ÚzeroÚuÚvÚdÚ_r   r   Úi0Úi1r   r   s   &           r!   Ú__iter__Ú_csr_base.__iter__�   s-  é € Ø�9‰9˜Œ>Ø—:‘:—?‘? 1Ó%ˆDØˆAÜ˜DŸL™L¨$¯)©)Ö4‘�Ü˜q�už�AØ”Jñ &à’Ø˜•E’ñ	 5ô
 ˜4Ÿ:™: a�=¨1Õ,Ö-�Ø”
ñ .áä—’˜! 4§;¡;×#4Ñ#4Ô5ˆä",¨T´7×";Ò";�—
‘
˜2–À!ÀTÇZÁZÐPQÅ]ÐASˆØˆØ—+‘+˜b—/�/ˆBØ�ˆF�1‰IØ—l‘l 2Ð)ˆGØ—9‘9˜RÐ#ˆDØ—.‘. $°Ð!8ÀÈD�.ÓQÒQØŠBó "ùs   ‚E:E<c                óÜ  € V P                   ^8X  d=   VR9  d   \        RV R24      hV P                  ^V P                  ^ ,          3RR7      # V P                  w  r#\	        V4      pV^ 8  d	   W,          pV^ 8  g   W8¼  d   \        RV R24      h\        W#V P                  V P                  V P                  W^,           ^ V4	      w  rEpV P                  WeV3^V3V P                  RR7      # )zMReturns a copy of row i of the matrix, as a (1 x n)
CSR matrix (row vector).
úindex (ú) out of rangeTr9   F©r   r(   r   )r   rT   )r   Ú
IndexErrorrW   r   Úintr
   r   r   r   rA   r(   ©r   Úir   r    r   r   r   s   &&     r!   Ú_getrowÚ_csr_base._getrow§   sç   € ð �9‰9˜Œ>Ø˜ÔÜ  7¨1¨#¨^Ð!<Ó=Ð=Ø—<‘<  D§J¡J¨q¥MÐ 2¸�<Ó>Ð>à�z‰z‰ˆÜ�‹FˆØˆqŒ5Ø�FˆAØˆqŒ5�A”FÜ˜w q c¨Ð8Ó9Ð9Ü 1Ø�$—+‘+˜tŸ|™|¨T¯Y©Y¸¸q½5À!ÀQó!HÑˆ˜à�~‰~˜t¨fÐ5¸aÀ¸VØ$(§J¡J°Uð ó <ð 	<r$   c                óz  € V P                   ^8X  d   \        R4      hV P                  w  r#\        V4      pV^ 8  d	   W,          pV^ 8  g   W8¼  d   \	        RV R24      h\        W#V P                  V P                  V P                  ^ W!V^,           4	      w  rEpV P                  WeV3V^3V P                  RR7      # )zLReturns a copy of column i. A (m x 1) sparse array (column vector).
        z4getcol not provided for 1d arrays. Use indexing A[j]rt   ru   Frv   )r   r   r   rx   rw   r
   r   r   r   rA   r(   ry   s   &&     r!   Ú_getcolÚ_csr_base._getcol»   s·   € ð �9‰9˜Œ>ÜÐSÓTÐTØ�z‰z‰ˆÜ�‹FˆØˆqŒ5Ø�FˆAØˆqŒ5�A”FÜ˜w q c¨Ð8Ó9Ð9Ü 1Ø�$—+‘+˜tŸ|™|¨T¯Y©Y¸¸1ÀÀQÅó!HÑˆ˜à�~‰~˜t¨fÐ5¸aÀ¸VØ$(§J¡J°Uð ó <ð 	<r$   c                óê   € \         P                  ! V P                  V8H  4      pVP                  '       d   V P                  V^ ,          ,          # V P                  P
                  P                  ^ 4      # )r   )rJ   Úflatnonzeror   Úsizer   r(   rg   )r   ÚidxÚspots   && r!   Ú_get_intÚ_csr_base._get_intË   sN   € Ü�~Š~˜dŸl™l¨cÑ1Ó2ˆØ�9�9ˆ9Ø—9‘9˜T !�WÕ%Ð%Ø�y‰y�‰×#Ñ# AÓ&Ð&r$   c                óò   € V\        R 4      8X  d   V P                  4       # VP                  R9   d7   V P                  ^ VRR7      pVP	                  VP
                  R,          4      # V P                  V4      # )NTr9   ©r   NrT   )Úslicer   ÚstepÚ_get_submatrixrW   r   Ú_minor_slice)r   rƒ   Úrets   && r!   Ú
_get_sliceÚ_csr_base._get_sliceÑ   se   € Ø”%˜“+ÔØ—9‘9“;ÐØ�8‰8�yÔ Ø×%Ñ% a¨°4Ð%Ó8ˆCØ—;‘;˜sŸy™y¨�}Ó-Ð-Ø× Ñ  Ó%Ð%r$   c                óÀ  € V P                  V P                  4      p\        P                  ! WR 7      pVP                  ^ 8X  d   V P                  . V P                  R 7      # ^V P                  ^ ,          rC\        P                  ! WR 7      p\        P                  ! WR 7      p\        P                  ! VP                  V P                  R 7      p\        W4V P                  V P                  V P                  VP                  WVV4	       VP                  ^ ,          ^8”  d   VP                  MVP                  ^ ,          3pV P                  VP                  V4      4      # )r'   )rG   r   rJ   Úasarrayr‚   rA   r(   r   Ú
zeros_likerK   r   r   r   rW   )	r   rƒ   rN   r   r    ÚrowÚcolÚvalÚ	new_shapes	   &&       r!   Ú
_get_arrayÚ_csr_base._get_arrayÙ   sî   € Ø×)Ñ)¨$¯,©,Ó7ˆ	Ü�jŠj˜Ô.ˆØ�8‰8�qŒ=Ø—>‘> "¨D¯J©J�>Ó7Ð7à�$—*‘*˜Q•-ˆ1Ü�mŠm˜CÔ1ˆÜ�jŠj˜Ô.ˆÜ�hŠh�s—x‘x t§z¡zÔ2ˆÜ˜! §¡¨T¯\©\¸4¿9¹9ØŸ(™( C¨cô	3ð "%§¡¨1¥°Ô!1�C—I’I¸¿	¹	À!½°ˆ	Ø�~‰~˜cŸk™k¨)Ó4Ó5Ð5r$   c                óB   € V P                  V4      P                  V4      # r8   )r{   Ú_minor_index_fancy©r   r“   r”   s   &&&r!   Ú_get_intXarrayÚ_csr_base._get_intXarrayé   s   € Ø�|‰|˜CÓ ×3Ñ3°CÓ8Ð8r$   c                ó  € VP                   R9   d   V P                  WRR7      # V P                  w  r4VP                  V4      w  rVpV P                  W^,            w  r‰V P                  W‰ p
V P
                  W‰ pV^ 8”  d   W¥8¬  W¦8  ,          pMW¥8*  W¦8„  ,          p\        V4      ^8”  d   WÊV,
          V,          ^ 8H  ,          pW¬,          V,
          V,          p
W¼,          p\        P                  ! ^ \        V
4      .4      pV^ 8  d"   VRRR1,          p\        V
RRR1,          4      p
^\        ^ \        \        P                  ! \        We,
          4      V,          4      4      4      3pV P                  WºV3VV P                  RR7      # )r   NTr9   Frv   rˆ   rT   )rŠ   r‹   r   r   r   r   ÚabsrJ   ÚarrayÚlenrH   rx   ÚceilÚfloatrA   r(   )r   r“   r”   r   r    r3   ÚstopÚstrideÚiiÚjjÚrow_indicesÚrow_datar0   Ú
row_indptrr   s   &&&            r!   Ú_get_intXsliceÚ_csr_base._get_intXsliceì   sg  € Ø�8‰8�yÔ Ø×&Ñ& s°dÐ&Ó;Ð;ð �z‰z‰ˆØ!Ÿk™k¨!›nÑˆ�Và—‘˜S Q¥Ð'‰ˆØ—l‘l 2Ð)ˆØ—9‘9˜RÐ#ˆà�AŒ:ØÑ'¨KÑ,>Õ?‰CàÑ'¨KÑ,>Õ?ˆCäˆv‹;˜Œ?Ø %Õ'¨6Õ1°QÑ6Õ6ˆCà"Õ'¨%Õ/°FÕ:ˆØ•=ˆÜ—X’X˜q¤# kÓ"2Ð3Ó4ˆ
à�AŒ:Ø¡ " •~ˆHÜ˜k©$¨B¨$Õ/Ó0ˆKà”C˜œ3œrŸwšw¤u¨T­\Ó':¸VÕ'CÓDÓEÓFÐGˆØ�~‰~˜x°jÐAÈØ$(§J¡J°Uð ó <ð 	<r$   c                óŒ   € VP                   R9   d   V P                  WRR7      # V P                  V4      P                  VR7      # )r   Tr9   ©Úminorrˆ   )rŠ   r‹   Ú_major_slicer›   s   &&&r!   Ú_get_sliceXintÚ_csr_base._get_sliceXint  sC   € Ø�8‰8�yÔ Ø×&Ñ& s°dÐ&Ó;Ð;Ø× Ñ  Ó%×4Ñ4¸3Ð4Ó?Ð?r$   c                óB   € V P                  V4      P                  V4      # r8   )r°   rš   r›   s   &&&r!   Ú_get_sliceXarrayÚ_csr_base._get_sliceXarray  s   € Ø× Ñ  Ó%×8Ñ8¸Ó=Ð=r$   c                ó    € V P                  V4      P                  VR 7      pVP                  ^8”  d   VP                  VP                  4      # V# )r®   )Ú_major_index_fancyr‹   r   rW   r   )r   r“   r”   Úress   &&& r!   Ú_get_arrayXintÚ_csr_base._get_arrayXint  sC   € Ø×%Ñ% cÓ*×9Ñ9ÀÐ9ÓDˆØ�8‰8�aŒ<Ø—;‘;˜sŸy™yÓ)Ð)Øˆ
r$   c                óð   € VP                   R9  dF   \        P                  ! VP                  V P                  ^,          4      !  pV P                  W4      # V P                  V4      P                  VR7      # )r   r®   rˆ   )rŠ   rJ   Úaranger   r   Ú_get_arrayXarrayr·   r‹   r›   s   &&&r!   Ú_get_arrayXsliceÚ_csr_base._get_arrayXslice  s]   € Ø�8‰8˜9Ô$Ü—)’)˜SŸ[™[¨¯©°A­Ó7Ñ8ˆCØ×(Ñ(¨Ó2Ð2Ø×&Ñ& sÓ+×:Ñ:ÀÐ:ÓEÐEr$   c                ó*   € V P                  ^ W4       R# )r   N)Ú	_set_many©r   rƒ   rc   s   &&&r!   Ú_set_intÚ_csr_base._set_int!  s   € Ø�‰�q˜#Ö!r$   c                ó’   € \         P                  ! W!P                  4      pV P                  \         P                  ! V4      W4       R # r8   )rJ   Úbroadcast_tor   rÁ   r’   rÂ   s   &&&r!   Ú
_set_arrayÚ_csr_base._set_array$  s+   € Ü�OŠO˜AŸy™yÓ)ˆØ�‰”r—}’} SÓ)¨3Ö2r$   ra   )r   r&   )NF)F)NT)!Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú_formatÚ	_allow_ndr"   r   Ú__doc__r5   r:   r>   rO   rV   Ústaticmethodrd   rq   r{   r~   r…   rŽ   r—   rœ   r«   r±   r´   r¹   r¾   rÃ   rÇ   Ú__static_attributes__Ú__classdictcell__Ú__classcell__)rA   Ú__classdict__s   @@r!   r   r      s  ù‡ € Ø€GØ€Iô
Kð  ×)Ñ)×1Ñ1€IÔôð" —M‘M×)Ñ)€E„Môð —M‘M×)Ñ)€E„M÷ð —M‘M×)Ñ)€E„Môð, —M‘M×)Ñ)€E„Mô"ðH —M‘M×)Ñ)€E„Mð ñó ðò
ò0<ò(<ò 'ò&ò6ò 9ò<òB@ò
>òòFò"÷3ò 3r$   r   c                ó"   € \        V \        4      # )a0  Is `x` of csr_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 csr matrix

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

Examples
--------
>>> from scipy.sparse import csr_array, csr_matrix, coo_matrix, isspmatrix_csr
>>> isspmatrix_csr(csr_matrix([[5]]))
True
>>> isspmatrix_csr(csr_array([[5]]))
False
>>> isspmatrix_csr(coo_matrix([[5]]))
False
)ri   r   rb   s   &r!   Úisspmatrix_csrrÖ   )  s   € ô@ �aœÓ$Ð$r$   c                   ó   € ] tR tRtRtRtR# )r   iM  a²  
Compressed Sparse Row array.

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

    csr_array(S)
        with another sparse array or matrix S (equivalent to S.tocsr())

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

    csr_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]``.

    csr_array((data, indices, indptr), [shape=(M, N)])
        is the standard CSR representation where the column indices for
        row 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
    CSR format data array of the array
indices : ndarray
    CSR format index array of the array
indptr : ndarray
    CSR 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. 'csr'
nnz : int
    Number of values stored in the array
size : int
    Number of values stored in the array
T : csr_array
    The transpose of the array
mT : csr_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 CSR format
  - efficient arithmetic operations CSR + CSR, CSR * CSR, etc.
  - efficient row slicing
  - fast matrix vector products

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

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

Examples
--------

>>> import numpy as np
>>> from scipy.sparse import csr_array
>>> csr_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])
>>> csr_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])
>>> csr_array((data, indices, indptr), shape=(3, 3)).toarray()
array([[1, 0, 2],
       [0, 0, 3],
       [4, 5, 6]])

Duplicate entries are summed together:

>>> row = np.array([0, 1, 2, 0])
>>> col = np.array([0, 1, 1, 0])
>>> data = np.array([1, 2, 4, 8])
>>> csr_array((data, (row, col)), shape=(3, 3)).toarray()
array([[9, 0, 0],
       [0, 2, 0],
       [0, 4, 0]])

As an example of how to construct a CSR array incrementally,
the following snippet builds a term-document array from texts:

>>> docs = [["hello", "world", "hello"], ["goodbye", "cruel", "world"]]
>>> indptr = [0]
>>> indices = []
>>> data = []
>>> vocabulary = {}
>>> for d in docs:
...     for term in d:
...         index = vocabulary.setdefault(term, len(vocabulary))
...         indices.append(index)
...         data.append(1)
...     indptr.append(len(indices))
...
>>> csr_array((data, indices, indptr), dtype=int).toarray()
array([[2, 1, 0, 0],
       [0, 1, 1, 1]])

ra   N©rÉ   rÊ   rË   rÌ   rÏ   rÑ   ra   r$   r!   r   r   M  s   † õ@r$   c                   ó   € ] tR tRtRtRtR# )r   iÑ  ah  
Compressed Sparse Row 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:
    csr_matrix(D)
        where D is a 2-D ndarray

    csr_matrix(S)
        with another sparse array or matrix S (equivalent to S.tocsr())

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

    csr_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]``.

    csr_matrix((data, indices, indptr), [shape=(M, N)])
        is the standard CSR representation where the column indices for
        row 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
    CSR format data array of the matrix
indices : ndarray
    CSR format index array of the matrix
indptr : ndarray
    CSR 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. 'csr'
nnz : int
    Number of values stored in the matrix
size : int
    Number of values stored in the matrix
T : csr_matrix
    The transpose of the matrix
mT : csr_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 CSR format
  - efficient arithmetic operations CSR + CSR, CSR * CSR, etc.
  - efficient row slicing
  - fast matrix vector products

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

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

Examples
--------

>>> import numpy as np
>>> from scipy.sparse import csr_matrix
>>> csr_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])
>>> csr_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])
>>> csr_matrix((data, indices, indptr), shape=(3, 3)).toarray()
array([[1, 0, 2],
       [0, 0, 3],
       [4, 5, 6]])

Duplicate entries are summed together:

>>> row = np.array([0, 1, 2, 0])
>>> col = np.array([0, 1, 1, 0])
>>> data = np.array([1, 2, 4, 8])
>>> csr_matrix((data, (row, col)), shape=(3, 3)).toarray()
array([[9, 0, 0],
       [0, 2, 0],
       [0, 4, 0]])

As an example of how to construct a CSR matrix incrementally,
the following snippet builds a term-document matrix from texts:

>>> docs = [["hello", "world", "hello"], ["goodbye", "cruel", "world"]]
>>> indptr = [0]
>>> indices = []
>>> data = []
>>> vocabulary = {}
>>> for d in docs:
...     for term in d:
...         index = vocabulary.setdefault(term, len(vocabulary))
...         indices.append(index)
...         data.append(1)
...     indptr.append(len(indices))
...
>>> csr_matrix((data, indices, indptr), dtype=int).toarray()
array([[2, 1, 0, 0],
       [0, 1, 1, 1]])

ra   NrØ   ra   r$   r!   r   r   Ñ  s   † õIr$   )r   r   rÖ   )rÏ   Ú__docformat__Ú__all__ÚnumpyrJ   Ú_matrixr   Ú_baser   r   Ú_sparsetoolsr   r   r	   r
   r   Ú_sputilsr   Ú_compressedr   r   rÖ   r   r   ra   r$   r!   Ú<module>râ      sc   ðÙ )à%€â
7€ã å ß #÷Aõ Aå å #ôT3�
ô T3òn %ôHA�	˜7ô AôHJ�˜9ö Jr$   