Ë
    âQ(hàú  ã                   ó>  — d Z dZg d¢ZddlZddlmZ ddlZddlm	Z	 dd	l
mZ dd
lmZmZmZmZmZmZmZ ddlmZmZmZmZ ddlmZmZ ddlmZmZmZm Z m!Z!m"Z"m#Z#m$Z$m%Z%m&Z&m'Z' ddl(Z( G d„ dee«      Z)d„ Z*d„ Z+d„ Z,d„ Z-dd„Z.d„ Z/ G d„ de)e«      Z0 G d„ dee)«      Z1y)z2 A sparse matrix in COOrdinate or 'triplet' formatzrestructuredtext en)Ú	coo_arrayÚ
coo_matrixÚisspmatrix_cooé    N)Úwarné   )Úcopy_if_neededé   )Úspmatrix)Ú	coo_tocsrÚcoo_todenseÚcoo_todense_ndÚ
coo_matvecÚcoo_matvec_ndÚcoo_matmat_denseÚcoo_matmat_dense_nd)ÚissparseÚSparseEfficiencyWarningÚ_spbaseÚsparray)Ú_data_matrixÚ_minmax_mixin)Úupcast_charÚ	to_nativeÚisshapeÚgetdtypeÚgetdataÚdowncast_intp_indexÚget_index_dtypeÚcheck_shapeÚcheck_reshape_kwargsÚisscalarlikeÚisdensec                   ó   — e Zd ZdZ edd«      Zd-ddœd„Zed„ «       Zej                  d„ «       Zed	„ «       Z
e
j                  d
„ «       Z
d„ Zej                  j                  e_        d.d„Zej                  j                  e_        d.d„Zej                  j                  e_        d„ Zd/d„Zej"                  j                  e_        d0d„Zej$                  j                  e_        d1d„Zej&                  j                  e_        d2d„Zd2d„Zd2d„Zd2d„Zej.                  j                  e_        d2d„Zej0                  j                  e_        d2d„Zej2                  j                  e_        d3d„Zej4                  j                  e_        d„ Zd4d„Zd0d„Zd„ Zd„ Z d„ Z!d„ Z"d „ Z#d!„ Z$d"„ Z%d#„ Z&d$„ Z'd%„ Z(d&„ Z)d'„ Z*d5d(„Z+d)„ Z,d*„ Z-d+„ Z.d2d,„Z/y)6Ú	_coo_baseÚcoor	   éA   N©Úmaxprintc                óö  ‡‡‡— t        j                  | ||¬«       ‰st        Št        |t        «      �rst        || j                  ¬«      r¬t        || j                  ¬«      | _        | j                  t        | j                  «      ¬«      Št        |t        ¬«      }t	        ˆfd„t        t        | j                  «      «      D «       «      | _        t!        j"                  g |¬«      | _        d| _        �n	 |\  }}|€/t-        d	„ |D «       «      rt+        d
«      ‚t	        d„ |D «       «      }t        || j                  ¬«      | _        | j                  |t        | j.                  «      d¬«      Št	        ˆˆfd„|D «       «      | _        t1        |‰|¬«      | _        d| _        �nft3        |«      �r$|j4                  | j4                  k(  r†‰r„t	        d„ |j                  D «       «      | _        |j$                  j7                  t        ||«      «      | _        t        |j.                  | j                  ¬«      | _        |j&                  | _        �n»|j9                  «       }
t	        |
j                  «      | _        |
j$                  j7                  t        ||
«      d¬«      | _        t        |
j.                  | j                  ¬«      | _        d| _        �n6t!        j:                  |«      }t        | t<        «      s=t!        j>                  |«      }|j@                  dk7  rt)        d|j@                  › d�«      ‚t        |j.                  | j                  ¬«      | _        |�At        || j                  ¬«      | j                  k7  rd|› d| j                  › �}t+        |«      ‚| j                  t        | j                  «      ¬«      Š|jC                  «       }t	        ˆfd„|D «       «      | _        t1        ||   ‰|¬«      | _        d| _        t        | j                  «      dkD  r!t	        d„ | j                  D «       «      | _        | jE                  «        y # t(        t*        f$ r}	t)        d«      |	‚d }	~	ww xY w)Nr'   ©Úallow_nd©Úmaxval)Údefaultc              3   óL   •K  — | ]  }t        j                  g ‰¬ «      –— Œ y­w©©ÚdtypeN©ÚnpÚarray)Ú.0Ú_Ú	idx_dtypes     €úO/var/www/skyplay_api_hub/venv/lib/python3.12/site-packages/scipy/sparse/_coo.pyú	<genexpr>z%_coo_base.__init__.<locals>.<genexpr>(   s)   øè ø€ ò $GØ)*ô %'§H¡H¨R°y×$AÐ$Añ $Gùó   ƒ!$r1   Tzinvalid input formatc              3   ó8   K  — | ]  }t        |«      d k(  –— Œ y­w)r   N©Úlen©r6   Úidxs     r9   r:   z%_coo_base.__init__.<locals>.<genexpr>3   s   è ø€ Ò;¨Sœ3˜s›8 q�=Ñ;ùs   ‚z4cannot infer dimensions from zero sized index arraysc              3   ór   K  — | ]/  }t        j                  t        j                  |«      «      d z   –— Œ1 y­w©r	   N)ÚoperatorÚindexr4   Úmaxr?   s     r9   r:   z%_coo_base.__init__.<locals>.<genexpr>6   s.   è ø€ ò "5Ø&)ô #+§.¡.´·±¸³Ó"=ÀÕ"Añ "5ùs   ‚57)r-   Úcheck_contentsc              3   óN   •K  — | ]  }t        j                  |‰‰¬ «      –— Œ y­w)©Úcopyr2   Nr3   )r6   r@   rI   r8   s     €€r9   r:   z%_coo_base.__init__.<locals>.<genexpr><   s)   øè ø€ ò $8Ø),ô %'§H¡H¨S°tÀ9×$MÐ$Mñ $8ùs   ƒ"%rH   Fc              3   ó<   K  — | ]  }|j                  «       –— Œ y ­w©N©rI   r?   s     r9   r:   z%_coo_base.__init__.<locals>.<genexpr>C   s   è ø€ Ò'J°s¨¯©¯
Ñ'Jùó   ‚rL   r   z!expected 2D array or matrix, not ÚDzinconsistent shapes: z != c              3   óD   •K  — | ]  }|j                  ‰d ¬«      –— Œ y­w©FrL   N)Úastype)r6   r@   Úindex_dtypes     €r9   r:   z%_coo_base.__init__.<locals>.<genexpr>]   s&   øè ø€ ò $8Ø),ð %(§J¡J¨{À J×$Gñ $8ùó   ƒ c              3   ó^   K  — | ]%  }|j                  t        j                  d ¬«      –— Œ' y­wrP   )rQ   r4   Úint64r?   s     r9   r:   z%_coo_base.__init__.<locals>.<genexpr>c   s!   è ø€ ÒXÀS §
¡
¬2¯8©8¸% 
× @ÑXùs   ‚+-)#r   Ú__init__r   Ú
isinstanceÚtupler   Ú	_allow_ndr   Ú_shapeÚ_get_index_dtyperE   r   ÚfloatÚranger>   Úcoordsr4   r5   ÚdataÚhas_canonical_formatÚ	TypeErrorÚ
ValueErrorÚanyÚshaper   r   ÚformatrQ   ÚtocooÚasarrayr   Ú
atleast_2dÚndimÚnonzeroÚ_check)ÚselfÚarg1rd   r2   rI   r(   Ú
data_dtypeÚobjr^   Úer%   ÚMÚmessager8   rR   s       `        @@r9   rV   z_coo_base.__init__   sˆ  ú€ Ü×Ñ˜d D°8Õ<ÙÜ!ˆDä�dœEÕ"Ü�t d§n¡nÕ5Ü)¨$¸¿¹ÔH�”Ø ×1Ñ1¼¸T¿[¹[Ó9IÐ1ÓJ�	Ü% e´UÔ;�
Ü#ó $GÜ.3´C¸¿¹Ó4DÓ.Eô$Gó G�”äŸH™H R¨zÔ:�”	Ø,0�Ö)ðCØ"&‘K�C˜ð �=ÜÑ;°FÔ;Ô;Ü(ð *>ó ?ð ?ä!ñ "5Ø-3ô"5ó 5�Eä)¨%¸$¿.¹.ÔI�”Ø ×1Ñ1°&Ü9<¸T¿Z¹Z»ØAEð 2ó G�	ô $ô $8Ø06ô$8ó 8�”ä# C¨d¸%Ô@�”	Ø,1�Ö)ä˜�~Ø—;‘; $§+¡+Ò-±$Ü"'Ñ'J¸d¿k¹kÔ'JÓ"J�D”KØ $§	¡	× 0Ñ 0´¸%ÀÓ1FÓ G�D”IÜ"-¨d¯j©jÀ4Ç>Á>Ô"R�D”KØ04×0IÑ0I�DÖ-àŸ*™*›,�CÜ"'¨¯
©
Ó"3�D”KØ #§¡§¡´¸ÀÓ0DÈ5 Ó Q�D”IÜ"-¨c¯i©iÀ$Ç.Á.Ô"Q�D”KØ05�DÖ-ô —J‘J˜tÓ$�Ü! $¬Ô0ÜŸ™ aÓ(�AØ—v‘v ’{Ü'Ð*KÈAÏFÉFÈ8ÐSTÐ(UÓVÐVä)¨!¯'©'¸D¿N¹NÔK�”ØÐ$Ü" 5°4·>±>ÔBÀdÇkÁkÒQØ$9¸%¸ÀÀTÇ[Á[ÀMÐ"R˜Ü(¨Ó1Ð1à"×3Ñ3¼3¸t¿{¹{Ó;KÐ3ÓL�ØŸ™›�Ü#ó $8Ø06ô$8ó 8�”ä# A f¡I°DÀÔF�”	Ø,0�Ô)äˆt�{‰{Ó˜aÒÜÑXÈDÏKÉKÔXÓXˆDŒKà�‰�øôm "¤:Ð.ò CÜ#Ð$:Ó;ÀÐBûðCús   Ã9Q ÑQ8Ñ'Q3Ñ3Q8c                 ó¤   — | j                   dkD  r| j                  d   S t        j                  | j                  «      }|j                  d¬«       |S )Nr	   éþÿÿÿF)Úwrite)ri   r^   r4   Ú
zeros_likeÚcolÚsetflags)rl   Úresults     r9   Úrowz_coo_base.rowg   s@   € à�9‰9�qŠ=Ø—;‘;˜r‘?Ð"Ü—‘˜tŸx™xÓ(ˆØ�‰˜eˆÔ$Øˆó    c                 óä   — | j                   dk  rt        d«      ‚t        j                  || j                  d   j
                  ¬«      }| j                  d d |fz   | j                  dd  z   | _        y )Nr   z8cannot set row attribute of a 1-dimensional sparse arrayrt   r1   éÿÿÿÿ)ri   rb   r4   rg   r^   r2   )rl   Únew_rows     r9   rz   z_coo_base.rowp   s`   € à�9‰9�qŠ=ÜÐWÓXÐXÜ—*‘*˜W¨D¯K©K¸©O×,AÑ,AÔBˆØ—k‘k # 2Ð&¨'¨Ñ3°d·k±kÀ"À#Ð6FÑFˆ�r{   c                 ó    — | j                   d   S ©Nr}   ©r^   )rl   s    r9   rw   z_coo_base.colw   s   € à�{‰{˜2‰Ðr{   c                 ó�   — t        j                  || j                  d   j                  ¬«      }| j                  d d |fz   | _        y )Nr}   r1   )r4   rg   r^   r2   )rl   Únew_cols     r9   rw   z_coo_base.col{   s9   € ä—*‘*˜W¨D¯K©K¸©O×,AÑ,AÔBˆØ—k‘k # 2Ð&¨'¨Ñ3ˆ�r{   c                 ó‚  ‡	— t        || j                  | j                  ¬«      }t        |«      \  }}|| j                  k(  r|r| j	                  «       S | S t        | j                  | j                  |¬«      }t        |«      dk(  r+|dk(  rt        ||d   «      }n.t        ||d   «      d d d…   }nt        j                  |||¬«      }| j                  | j                  t        |«      ¬«      Š	t        ˆ	fd	„|D «       «      }|r| j                  j	                  «       }n| j                  }| j                  ||f|d
¬«      S )Nr*   ©Úorderr   ÚCr	   r   r}   r,   c              3   óL   •K  — | ]  }t        j                  |‰¬ «      –— Œ y­wr0   ©r4   rg   )r6   Úcor8   s     €r9   r:   z$_coo_base.reshape.<locals>.<genexpr>˜   s   øè ø€ ÒP¸rœ2Ÿ:™: b°	×:Ð:ÑPùr;   F©rd   rI   )r   rd   rY   r    rI   Ú_ravel_coordsr^   r>   Údivmodr4   Úunravel_indexr[   rE   rX   r_   Ú	__class__)
rl   ÚargsÚkwargsrd   r†   rI   Úflat_coordsÚ
new_coordsÚnew_datar8   s
            @r9   Úreshapez_coo_base.reshape€   s  ø€ Ü˜D $§*¡*°t·~±~ÔFˆÜ*¨6Ó2‰ˆˆtð �D—J‘JÒÙØ—y‘y“{Ð"à�ô
 $ D§K¡K°·±À5ÔIˆÜˆu‹:˜Š?Ø˜Š|Ü# K°°q±Ó:‘
ä# K°°q±Ó:¹4¸R¸4Ñ@‘
ä×)Ñ)¨+°uÀEÔJˆJà×)Ñ)¨$¯+©+¼cÀ%»jÐ)ÓIˆ	ÜÓPÀZÔPÓPˆ
ñ Ø—y‘y—~‘~Ó'‰Hà—y‘yˆHà�~‰~˜x¨Ð4¸EÈˆ~ÓNÐNr{   c                 ó  ‡— |�|dk(  r˜| j                   dk(  r‰t        | j                  «      Št        ˆfd„| j                  D «       «      rt        d«      ‚| j                  j                   dk7  st        d„ | j                  D «       «      rt        d«      ‚t        ‰«      S |dk  r|| j                   z  }|| j                   k\  rt        d«      ‚t        j                  t        | j                  d|z
     «      | j                  d|z
     ¬«      S )	Nr   r	   c              3   ó:   •K  — | ]  }t        |«      ‰k7  –— Œ y ­wrK   r=   )r6   r@   Únnzs     €r9   r:   z$_coo_base._getnnz.<locals>.<genexpr>¨   s   øè ø€ Ò: s”3�s“8˜s•?Ñ:ùs   ƒz3all index and data arrays must have the same lengthc              3   ó:   K  — | ]  }|j                   d k7  –— Œ y­wrB   )ri   r?   s     r9   r:   z$_coo_base._getnnz.<locals>.<genexpr>¬   s   è ø€ Ò)O¸C¨#¯(©(°a­-Ñ)Oùó   ‚z'coordinates and data arrays must be 1-Dúaxis out of bounds©Ú	minlength)ri   r>   r_   rc   r^   rb   Úintr4   Úbincountr   rd   )rl   Úaxisr˜   s     @r9   Ú_getnnzz_coo_base._getnnz¥   sä   ø€ Øˆ<˜D AšI¨$¯)©)°qª.Ü�d—i‘i“.ˆCÜÓ:¨d¯k©kÔ:Ô:Ü ð "/ó 0ð 0ð �y‰y�~‰~ Ò"¤cÑ)OÀ4Ç;Á;Ô)OÔ&OÜ Ð!JÓKÐKä�s“8ˆOà�!Š8Ø�D—I‘IÑˆDØ�4—9‘9ÒÜÐ1Ó2Ð2ä�{‰{Ô.¨t¯{©{¸1¸t¹8Ñ/DÓEØ%)§Z¡Z°°D±Ñ%9ô;ð 	;r{   c                 ór  — | j                  «        |€t        j                  | j                  «      S |dk  r|| j                  z  }|dk  s|| j                  k\  rt        d«      ‚| j                  dk7  }| j                  d|z
     |   }t        j                  t        |«      | j                  d|z
     ¬«      S )Nr   r›   r	   rœ   )
Úsum_duplicatesr4   Úcount_nonzeror_   ri   rb   r^   rŸ   r   rd   )rl   r    ÚmaskÚcoords       r9   r¤   z_coo_base.count_nonzero»   s¤   € Ø×ÑÔØˆ<Ü×#Ñ# D§I¡IÓ.Ð.à�!Š8Ø�D—I‘IÑˆDØ�!Š8�t˜tŸy™yÒ(ÜÐ1Ó2Ð2Ø�y‰y˜A‰~ˆØ—‘˜A ™HÑ% dÑ+ˆÜ�{‰{Ô.¨uÓ5ÀÇÁÈAÐPTÉHÑAUÔVÐVr{   c           
      óš  ‡— | j                   t        | j                  «      k7  r.t        dt        | j                  «      › d| j                   › �«      ‚t	        | j                  «      D ]G  \  }}|j
                  j                  dk7  sŒ t        d|› d|j
                  j                  › d�d¬«       ŒI | j                  | j                  t        | j                  «      ¬	«      Št        ˆfd
„| j                  D «       «      | _        t        | j                  «      | _        | j                  dkD  rŸt	        | j                  «      D ]†  \  }}|j                  «       | j                  |   k\  r/t        d|› d|j                  «       › d| j                  |   › �«      ‚|j!                  «       dk  sŒit        d|› d|j!                  «       › �«      ‚ yy)z' Checks data structure for consistency z2mismatching number of index arrays for shape; got z, expected Úizindex array z has non-integer dtype (ú)é   ©Ú
stacklevelr,   c              3   óL   •K  — | ]  }t        j                  |‰¬ «      –— Œ y­wr0   r‰   )r6   r@   r8   s     €r9   r:   z#_coo_base._check.<locals>.<genexpr>×   s'   øè ø€ ò 5Ø!$ô ŸJ™J s°)×<Ð<ñ 5ùr;   r   zaxis z index z exceeds matrix dimension znegative axis z index: N)ri   r>   r^   rb   Ú	enumerater2   Úkindr   Únamer[   rE   rd   rX   r   r_   r˜   Úmin)rl   r¨   r@   r8   s      @r9   rk   z_coo_base._checkÊ   s˜  ø€ à�9‰9œ˜DŸK™KÓ(Ò(Üð $Ü$'¨¯©Ó$4Ð#5°[ÀÇÁÀðMó Nð Nô   §¡Ó,ò 	#‰FˆAˆsØ�y‰y�~‰~ Ó$Ü�| A 3Ð&>¸s¿y¹y¿~¹~Ð>NÈaÐPØ !ö#ð	#ð
 ×)Ñ)¨$¯+©+¼cÀ$Ç*Á*»oÐ)ÓNˆ	Üó 5Ø(,¯©ô5ó 5ˆŒä˜dŸi™iÓ(ˆŒ	à�8‰8�aŠ<Ü# D§K¡KÓ0ò N‘��3Ø—7‘7“9 §
¡
¨1¡Ò-Ü$ u¨Q¨C¨w°s·w±w³y°kð B9Ø9=¿¹ÀA¹¸ð&Ió Jð Jà—7‘7“9˜q“=Ü$ ~°a°S¸ÀÇÁÃÀÐ%LÓMÐMñNð r{   c                 óÆ  ‡ — |€t        ‰ j                  «      d d d…   }n{t        ‰ t        «      r[t	        |d«      rt        |«      ‰ j                  k7  rt        d«      ‚t        t        |«      «      ‰ j                  k7  rt        d«      ‚|dk7  rt        d«      ‚t        ˆ fd„|D «       «      }t        ˆ fd„|D «       «      }‰ j                  ‰ j                  |f||¬	«      S )
Nr}   Ú__len__z"axes don't match matrix dimensionszrepeated axis in transpose)r	   r   zoSparse matrices do not support an 'axes' parameter because swapping dimensions is the only logical permutation.c              3   ó<   •K  — | ]  }‰j                   |   –— Œ y ­wrK   )rZ   ©r6   r¨   rl   s     €r9   r:   z&_coo_base.transpose.<locals>.<genexpr>ð   s   øè ø€ Ò<°!˜tŸ{™{¨1�~Ñ<ùó   ƒc              3   ó<   •K  — | ]  }‰j                   |   –— Œ y ­wrK   r�   rµ   s     €r9   r:   z&_coo_base.transpose.<locals>.<genexpr>ñ   s   øè ø€ Ò=°1 §¡¨A¥Ñ=ùr¶   r‹   )r]   ri   rW   r   Úhasattrr>   rb   ÚsetrX   r�   r_   )rl   ÚaxesrI   Úpermuted_shapeÚpermuted_coordss   `    r9   Ú	transposez_coo_base.transposeã   sÏ   ø€ Øˆ<Ü˜Ÿ™Ó#¡D b DÑ)‰DÜ˜œgÔ&Ü˜4 Ô+¬s°4«y¸D¿I¹IÒ/EÜ Ð!EÓFÐFÜ”3�t“9‹~ §¡Ò*Ü Ð!=Ó>Ð>Ø�VŠ^Üð 9ó :ð :ô Ó<°tÔ<Ó<ˆÜÓ=¸Ô=Ó=ˆØ�~‰~˜tŸy™y¨/Ð:Ø$2¸ð ó ?ð 	?r{   c                 ól  ‡	— t        || j                  ¬«      }| j                  dkD  rt        d«      ‚t	        |«      dkD  rt        d«      ‚t	        |«      | j                  kD  rot        | j                  | j                  «      }t        j                  |«      }t        j                  |d | |«      | _        | j                  d | | _        || _        y t	        |«      | j                  k  r…| j                  d t	        |«      dz
   dz   d| j                  t	        |«      z
  z  z   }| j                  |«      }|j                  d t	        |«       | _        |j                  d t	        |«       | _        t        d„ t!        | j                  |«      D «       «      }|r�t        j"                  j%                  t!        | j                  |«      D ��cg c]
  \  }}||k  ‘Œ c}}«      Š	‰	j'                  «       s7t)        ˆ	fd	„| j                  D «       «      | _        | j                  ‰	   | _        || _        y c c}}w )
Nr*   r   zonly 1-D or 2-D input acceptedz!shape argument must be 1-D or 2-Dr	   )r}   ©r	   c              3   ó,   K  — | ]  \  }}||kD  –— Œ y ­wrK   © )r6   ÚoldÚnews      r9   r:   z#_coo_base.resize.<locals>.<genexpr>  s   è ø€ ÒM©(¨#¨s˜C #�IÑMùs   ‚c              3   ó(   •K  — | ]	  }|‰   –— Œ y ­wrK   rÁ   ©r6   r@   r¥   s     €r9   r:   z#_coo_base.resize.<locals>.<genexpr>  s   øè ø€ Ò#E°# C¨¥IÑ#Eùó   ƒ)r   rY   ri   rb   r>   rŒ   r^   rd   ÚmathÚprodr4   rŽ   r_   rZ   r•   rc   ÚzipÚlogical_andÚreduceÚallrX   )
rl   rd   r’   Úmax_sizeÚ	tmp_shapeÚtmpÚis_truncatingr@   Úsizer¥   s
            @r9   Úresizez_coo_base.resize÷   sË  ø€ Ü˜E¨D¯N©NÔ;ˆØ�9‰9�qŠ=ÜÐ=Ó>Ð>Üˆu‹:˜Š>ÜÐ@ÓAÐAäˆu‹:˜Ÿ	™	Ò!Ü'¨¯©°T·Z±ZÓ@ˆKÜ—y‘y Ó'ˆHÜ×*Ñ*¨;°y¸Ð+AÀ5ÓIˆDŒKØŸ	™	 ) 8Ð,ˆDŒIØˆDŒKØô ˆu‹:˜Ÿ	™	Ò!à—‘˜OœS ›Z¨!™^Ð,Øñà˜$Ÿ)™)¤c¨%£jÑ0Ñ1ñ2ð ð
 —,‘,˜yÓ)ˆCØŸ*™* [¤c¨%£jÐ1ˆDŒKØŸ)™) K¤S¨£ZÐ0ˆDŒKô ÑM´c¸$¿*¹*ÀeÓ6LÔMÓMˆÙÜ—>‘>×(Ñ(Ü,/°·±¸UÓ,C÷*Ù(˜s D��d“
ó*ó ˆDð —8‘8”:Ü#Ó#E¸¿¹Ô#EÓE�”Ø ŸI™I d™O�”	àˆ�ùó*s   Ç
H0
c                 ó@  — | j                  ||«      }t        |j                  j                  «      }|s!|j                  j                  st        d«      ‚| j                  dk(  rat        t        j                  dg«      | j                  | j                  | j                  d   | j                  |j                  d«      |«       �n@| j                  dk(  rY| j                  \  }}t        ||| j                  | j                   | j"                  | j                  |j                  d«      |«       nØ|r7t        j$                  dt        j&                  | j                  d d «      «      }nBt        j$                  t        j&                  | j                  dd  d d d…   «      d d d…   d«      }t        j(                  | j                  «      }t        || j                  | j                  || j                  |j                  d«      |«       |j+                  | j                  «      S )Nz&Output array must be C or F contiguousr	   r   ÚAr   r}   )Ú_process_toarray_argsrž   ÚflagsÚf_contiguousÚc_contiguousrb   ri   r   r4   r5   r˜   r^   r_   Úravelrd   r   rz   rw   ÚappendÚcumprodÚconcatenater•   )	rl   r†   ÚoutÚBÚfortranrq   ÚNÚstridesr^   s	            r9   Útoarrayz_coo_base.toarray  s‡  € Ø×&Ñ& u¨cÓ2ˆÜ�a—g‘g×*Ñ*Ó+ˆÙ˜qŸw™w×3Ò3ÜÐEÓFÐFð �9‰9˜Š>Üœ2Ÿ8™8 Q C›=¨$¯(©(°D·I±IØŸ;™; q™>¨4¯9©9°a·g±g¸c³lÀGöMà�Y‰Y˜!Š^Ø—:‘:‰DˆAˆqÜ˜˜1˜dŸh™h¨¯©°$·(±(¸D¿I¹IØŸ™ › gõ/ñ ÜŸ)™) A¤r§z¡z°$·*±*¸S¸b°/Ó'BÓC‘äŸ)™)¤B§J¡J¨t¯z©z¸!¸"¨~¹dÀ¸dÑ/CÓ$DÁTÀrÀTÑ$JÈAÓN�Ü—^‘^ D§K¡KÓ0ˆFÜ˜7 D§H¡H¨d¯i©iØ! 4§9¡9¨a¯g©g°c«l¸GôEð �y‰y˜Ÿ™Ó$Ð$r{   c                 ór  — | j                   dk7  rt        d| j                   › d�«      ‚| j                  dk(  r'| j                  | j                  | j
                  ¬«      S ddlm} | j                  |j                  «      \  }}}}| j                  |||f|¬«      }| j                  s|j                  «        |S )	aQ  Convert this array/matrix to Compressed Sparse Column format

        Duplicate entries will be summed together.

        Examples
        --------
        >>> from numpy import array
        >>> from scipy.sparse import coo_array
        >>> row  = array([0, 0, 1, 3, 1, 0, 0])
        >>> col  = array([0, 2, 1, 3, 1, 0, 0])
        >>> data = array([1, 1, 1, 1, 1, 1, 1])
        >>> A = coo_array((data, (row, col)), shape=(4, 4)).tocsc()
        >>> A.toarray()
        array([[3, 0, 1, 0],
               [0, 2, 0, 0],
               [0, 0, 0, 0],
               [0, 0, 0, 1]])

        r   z+Cannot convert. CSC format must be 2D. Got rN   r   r1   r	   )Ú	csc_array©rd   )ri   rb   r˜   Ú_csc_containerrd   r2   Ú_cscrä   Ú_coo_to_compressedÚ_swapr`   r£   )rl   rI   rä   ÚindptrÚindicesr_   rd   Úxs           r9   Útocscz_coo_base.tocsc:  s¨   € ð( �9‰9˜Š>ÜÐJÈ4Ï9É9È+ÐUVÐWÓXÐXØ�8‰8�qŠ=Ø×&Ñ& t§z¡z¸¿¹Ð&ÓDÐDå'Ø+/×+BÑ+BÀ9Ç?Á?Ó+SÑ(ˆF�G˜T 5à×#Ñ# T¨7°FÐ$;À5Ð#ÓIˆAØ×,Ò,Ø× Ñ Ô"ØˆHr{   c                 óŽ  — | j                   dkD  rt        d| j                   › d�«      ‚| j                  dk(  r'| j                  | j                  | j
                  ¬«      S ddlm} | j                  |j                  |¬«      }|\  }}}}| j                  |||f| j                  ¬	«      }| j                  s|j                  «        |S )
aN  Convert this array/matrix to Compressed Sparse Row format

        Duplicate entries will be summed together.

        Examples
        --------
        >>> from numpy import array
        >>> from scipy.sparse import coo_array
        >>> row  = array([0, 0, 1, 3, 1, 0, 0])
        >>> col  = array([0, 2, 1, 3, 1, 0, 0])
        >>> data = array([1, 1, 1, 1, 1, 1, 1])
        >>> A = coo_array((data, (row, col)), shape=(4, 4)).tocsr()
        >>> A.toarray()
        array([[3, 0, 1, 0],
               [0, 2, 0, 0],
               [0, 0, 0, 0],
               [0, 0, 0, 1]])

        r   z*Cannot convert. CSR must be 1D or 2D. Got rN   r   r1   r	   )Ú	csr_arrayrL   rå   )ri   rb   r˜   Ú_csr_containerrd   r2   Ú_csrrï   rè   ré   r`   r£   )	rl   rI   rï   Úarraysrê   rë   r_   rd   rì   s	            r9   Útocsrz_coo_base.tocsr[  s¶   € ð( �9‰9�qŠ=ÜÐIÈ$Ï)É)ÈÐTUÐVÓWÐWØ�8‰8�qŠ=Ø×&Ñ& t§z¡z¸¿¹Ð&ÓDÐDå'Ø×,Ñ,¨Y¯_©_À4Ð,ÓHˆFØ+1Ñ(ˆF�G˜T 5à×#Ñ# T¨7°FÐ$;À4Ç:Á:Ð#ÓNˆAØ×,Ò,Ø× Ñ Ô"ØˆHr{   c                 ó^  —  || j                   «      \  }}| j                  | j                  t        | j                  |«      ¬«      }| j
                  dk(  rŠ|r| j                  d   j                  «       n| j                  d   }t        |«      }t        j                  d|g|¬«      }|r| j                  j                  «       n| j                  }	|||	| j                  fS  || j                  «      \  }
}t        |
«      }|
j                  |d¬«      }
|j                  |d¬«      }t        j                  |dz   |¬«      }t        j                  ||¬«      }t        j                  | j                  | j                  ¬«      }	t!        ||||
|| j                  |||	«	       |||	| j                  fS )z?convert (shape, coords, data) to (indptr, indices, data, shape)r,   r	   r   r1   FrL   )Ú_shape_as_2dr[   r^   rE   r˜   ri   rI   r>   r4   r5   r_   rd   rQ   ÚemptyÚ
empty_liker2   r   )rl   ÚswaprI   rq   rà   r8   rë   r˜   rê   r_   ÚmajorÚminors               r9   rè   z_coo_base._coo_to_compressed}  s]  € á�D×%Ñ%Ó&‰ˆˆ1ð ×)Ñ)¨$¯+©+¼cÀ$Ç(Á(ÈAÓ>NÐ)ÓOˆ	à�9‰9˜Š>Ù/3�d—k‘k !‘n×)Ñ)Ô+¸¿¹ÀQ¹ˆGÜ�g“,ˆCÜ—X‘X˜q #˜h¨iÔ8ˆFÙ'+�4—9‘9—>‘>Ô#°·±ˆDØ˜7 D¨$¯*©*Ð4Ð4ñ ˜DŸK™KÓ(‰ˆˆuÜ�%‹jˆØ—‘˜Y¨U�Ó3ˆØ—‘˜Y¨U�Ó3ˆä—‘˜!˜a™% yÔ1ˆÜ—-‘- ¨YÔ7ˆÜ�}‰}˜TŸY™Y¨d¯j©jÔ9ˆä�!�Q˜˜U E¨4¯9©9°f¸gÀtÔLØ�w  d§j¡jÐ0Ð0r{   c                 ó*   — |r| j                  «       S | S rK   rL   )rl   rI   s     r9   rf   z_coo_base.tocoo˜  s   € ÙØ—9‘9“;ÐàˆKr{   c                 óª  — | j                   dk7  rt        d| j                   › d�«      ‚| j                  «        | j                  | j                  z
  }t        j                  |d¬«      \  }}t        |«      dkD  rt        dt        |«      › d�t        d¬	«       | j                  j                  d
k(  r"t        j                  d| j                  ¬«      }nbt        j                  t        |«      | j                  j                  «       dz   f| j                  ¬«      }| j                  ||| j                  f<   | j                  ||f| j                   ¬«      S )Nr   z+Cannot convert. DIA format must be 2D. Got rN   T)Úreturn_inverseéd   zConstructing a DIA matrix with z diagonals is inefficientr«   r   )r   r   r1   r	   rå   )ri   rb   r£   rw   rz   r4   Úuniquer>   r   r   r_   rÑ   Úzerosr2   rE   Ú_dia_containerrd   )rl   rI   ÚksÚdiagsÚdiag_idxr_   s         r9   Útodiaz_coo_base.todia   s  € Ø�9‰9˜Š>ÜÐJÈ4Ï9É9È+ÐUVÐWÓXÐXØ×ÑÔØ�X‰X˜Ÿ™Ñ ˆÜŸ)™) B°tÔ<‰ˆˆxäˆu‹:˜ÒäÐ2´3°u³:°,ð ?"ð "ä(°Qõ8ð
 �9‰9�>‰>˜QÒÜ—8‘8˜F¨$¯*©*Ô5‰Dä—8‘8œS ›Z¨¯©¯©«¸Ñ)9Ð:À$Ç*Á*ÔMˆDØ'+§y¡yˆD�˜4Ÿ8™8Ð#Ñ$à×"Ñ" D¨% =¸¿
¹
Ð"ÓCÐCr{   c                 ón  — | j                   dkD  rt        d| j                   › d�«      ‚| j                  «        | j                  | j                  | j
                  ¬«      }| j                   dk(  r| j                  d   }nt        | j                  Ž }t        t        || j                  «      «      |_
        |S )Nr   z*Cannot convert. DOK must be 1D or 2D. Got rN   r1   r	   r   )ri   rb   r£   Ú_dok_containerrd   r2   r^   rÉ   Údictr_   Ú_dict)rl   rI   Údokr^   s       r9   Útodokz_coo_base.todok¸  s’   € Ø�9‰9�qŠ=ÜÐIÈ$Ï)É)ÈÐTUÐVÓWÐWØ×ÑÔØ×!Ñ! $§*¡*°D·J±JÐ!Ó?ˆà�9‰9˜Š>Ø—[‘[ ‘^‰Fä˜$Ÿ+™+Ð&ˆFäœ˜V T§Y¡YÓ/Ó0ˆŒ	Øˆ
r{   c           
      óˆ  ‡	— | j                   dk7  rt        d«      ‚| j                  \  }}|| k  s||k\  r+t        j                  d| j
                  j                  ¬«      S t        j                  t        |t        |d«      z   |t        |d«      z
  «      | j                  ¬«      }| j                  |z   | j                  k(  Š	| j                  r| j                  ‰	   }| j
                  ‰	   }nCt        ˆ	fd„| j                  D «       «      }| j                  || j
                  ‰	   «      \  \  }}}|||t        |d«      z   <   |S )Nr   z diagonal requires two dimensionsr   r1   c              3   ó(   •K  — | ]	  }|‰   –— Œ y ­wrK   rÁ   )r6   r@   Ú	diag_masks     €r9   r:   z%_coo_base.diagonal.<locals>.<genexpr>Ö  s   øè ø€ Ò?¨C˜˜Y�Ñ?ùrÆ   )ri   rb   rd   r4   rö   r_   r2   r   r±   rE   rz   rw   r`   rX   r^   Ú_sum_duplicates)
rl   ÚkÚrowsÚcolsÚdiagrz   r_   Úindsr7   r  s
            @r9   Údiagonalz_coo_base.diagonalÈ  s  ø€ Ø�9‰9˜Š>ÜÐ?Ó@Ð@Ø—Z‘Z‰
ˆˆdØ��Š:˜˜dšÜ—8‘8˜A T§Y¡Y§_¡_Ô5Ð5Ü�x‰xœ˜D¤3 q¨!£9Ñ,¨d´S¸¸A³YÑ.>Ó?Ø"Ÿj™jô*ˆà—X‘X ‘\ d§h¡hÑ.ˆ	à×$Ò$Ø—(‘(˜9Ñ%ˆCØ—9‘9˜YÑ'‰DäÓ?°4·;±;Ô?Ó?ˆDØ!×1Ñ1°$¸¿	¹	À)Ñ8LÓM‰N‰HˆS�!�dØ $ˆˆS”3�q˜!“9‰_Ñàˆr{   c                 óx  — | j                   dk7  rt        d«      ‚| j                  \  }}|j                   rt        |«      sy | j                  j
                  }| j                  | j                  z
  |k7  }|dk  rˆt        ||z   |«      }|j                   rt        |t        |«      «      }t        j                  || j                  |k\  «      }t        j                  | | |z   |¬«      }	t        j                  ||¬«      }
n…t        |||z
  «      }|j                   rt        |t        |«      «      }t        j                  || j                  |k\  «      }t        j                  ||¬«      }	t        j                  |||z   |¬«      }
|j                   r|d | }n&t        j                  || j
                  ¬«      }||d d  t        j                  | j                  |   |	f«      t        j                  | j                  |   |
f«      f| _        t        j                  | j                  |   |f«      | _        d| _        y )Nr   z*setting a diagonal requires two dimensionsr   r1   F)ri   rb   rd   r>   rz   r2   rw   r±   r4   Ú
logical_orÚarangerö   rÜ   r^   r_   r`   )rl   Úvaluesr  rq   rà   r8   Ú	full_keepÚ	max_indexÚkeepr~   rƒ   r”   s               r9   Ú_setdiagz_coo_base._setdiagÞ  sÆ  € Ø�9‰9˜Š>ÜÐIÓJÐJØ�z‰z‰ˆˆ1Ø�;Š;œs 6œ{ØØ—H‘H—N‘Nˆ	ð —H‘H˜tŸx™xÑ'¨1Ñ,ˆ	ØˆqŠ5Ü˜A˜a™C ›ˆIØ�{Š{Ü 	¬3¨v«;Ó7�	Ü—=‘= ¨D¯H©H¸	Ñ,AÓBˆDÜ—i‘i   Q B¨¡N¸)ÔDˆGÜ—i‘i 	°Ô;‰Gä˜A˜q ™s›ˆIØ�{Š{Ü 	¬3¨v«;Ó7�	Ü—=‘= ¨D¯H©H¸	Ñ,AÓBˆDÜ—i‘i 	°Ô;ˆGÜ—i‘i  1 y¡=¸	ÔBˆGð �;Š;Ø˜j˜yÐ)‰Hä—x‘x 	°·±Ô<ˆHØ ˆH‘QˆKô —~‘~ t§x¡x°¡~°wÐ&?Ó@Ü—~‘~ t§x¡x°¡~°wÐ&?Ó@ðBˆŒä—N‘N D§I¡I¨d¡O°XÐ#>Ó?ˆŒ	Ø$)ˆÕ!r{   c                 ó¬   — |rt        d„ | j                  D «       «      }n| j                  }| j                  ||f| j                  |j                  ¬«      S )zŒReturns a matrix with the same sparsity structure as self,
        but with different data. By default the index arrays are copied.
        c              3   ó<   K  — | ]  }|j                  «       –— Œ y ­wrK   rL   r?   s     r9   r:   z'_coo_base._with_data.<locals>.<genexpr>
  s   è ø€ Ò=¨#˜3Ÿ8™8Ÿ:Ñ=ùrM   )rd   r2   )rX   r^   r�   rd   r2   )rl   r_   rI   r^   s       r9   Ú
_with_dataz_coo_base._with_data  sE   € ñ ÜÑ=°·±Ô=Ó=‰Fà—[‘[ˆFØ�~‰~˜t V˜n°D·J±JÀdÇjÁjˆ~ÓQÐQr{   c                 ó–   — | j                   ry| j                  | j                  | j                  «      }|\  | _        | _        d| _         y)zeEliminate duplicate entries by adding them together

        This is an *in place* operation
        NT)r`   r  r^   r_   )rl   Úsummeds     r9   r£   z_coo_base.sum_duplicates  s@   € ð
 ×$Ò$ØØ×%Ñ% d§k¡k°4·9±9Ó=ˆØ!'ÑˆŒ�T”YØ$(ˆÕ!r{   c           	      óü  ‡‡— t        |«      dk(  r||fS t        j                  |d d d…   «      Št        ˆfd„|D «       «      }|‰   }t        j                  j                  |D �cg c]  }|dd  |d d k7  ‘Œ c}«      Št        j                  d‰«      Št        ˆfd„|D «       «      }t        j                  ‰«      \  }t        j                  j                  |t        |«      | j                  ¬«      }||fS c c}w )Nr   r}   c              3   ó(   •K  — | ]	  }|‰   –— Œ y ­wrK   rÁ   )r6   r@   r†   s     €r9   r:   z,_coo_base._sum_duplicates.<locals>.<genexpr>"  s   øè ø€ Ò4 c�s˜5•zÑ4ùrÆ   r	   Tc              3   ó(   •K  — | ]	  }|‰   –— Œ y ­wrK   rÁ   )r6   r@   Úunique_masks     €r9   r:   z,_coo_base._sum_duplicates.<locals>.<genexpr>(  s   øè ø€ Ò:¨C�s˜;Õ'Ñ:ùrÆ   r1   )r>   r4   ÚlexsortrX   r  rË   rÚ   rj   ÚaddÚreduceatr   r2   )rl   r^   r_   r@   Úunique_indsr†   r&  s        @@r9   r  z_coo_base._sum_duplicates  sä   ù€ äˆt‹9˜Š>Ø˜4�<Ðô —
‘
˜6¡$ B $™<Ó(ˆÜÓ4¨VÔ4Ó4ˆØ�E‰{ˆÜ—m‘m×*Ñ*Ø+1ö,
Ø$'ˆC��ˆG�s˜3˜B�xÓò,
ó ˆô —i‘i  kÓ2ˆÜÓ:°6Ô:Ó:ˆÜ—z‘z +Ó.‰ˆÜ�v‰v�‰˜tÔ%8¸Ó%EÈTÏZÉZˆÓXˆØ�tˆ|Ðùò,
s   Á&C9c                 ó’   ‡— | j                   dk7  Š| j                   ‰   | _         t        ˆfd„| j                  D «       «      | _        y)z[Remove zero entries from the array/matrix

        This is an *in place* operation
        r   c              3   ó(   •K  — | ]	  }|‰   –— Œ y ­wrK   rÁ   rÅ   s     €r9   r:   z,_coo_base.eliminate_zeros.<locals>.<genexpr>4  s   øè ø€ Ò=¨#˜C �IÑ=ùrÆ   N)r_   rX   r^   )rl   r¥   s    @r9   Úeliminate_zerosz_coo_base.eliminate_zeros-  s7   ø€ ð
 �y‰y˜A‰~ˆØ—I‘I˜d‘OˆŒ	ÜÓ=°·±Ô=Ó=ˆ�r{   c                 óÜ  — |j                   | j                   k7  r&t        d| j                   › d|j                   › d�«      ‚t        | j                  j                  |j                  j                  «      }t        j                  ||d¬«      }t        |j                  j                  «      }| j                  dk(  rat        t        j                  dg«      | j                  | j                  | j                  d   | j                  |j                  d«      |«       �n@| j                  d	k(  rY| j                   \  }}t#        ||| j                  | j$                  | j&                  | j                  |j                  d«      |«       nØ|r7t        j(                  dt        j*                  | j                   d d
 «      «      }nBt        j(                  t        j*                  | j                   dd  d d d
…   «      d d d
…   d«      }t        j,                  | j                  «      }t        || j                  | j                  || j                  |j                  d«      |«       | j/                  |d¬«      S )NúIncompatible shapes (ú and r©   T)r2   rI   r	   r   rÔ   r   r}   FrL   )rd   rb   r   r2   Úcharr4   r5   rž   rÖ   r×   ri   r   r˜   r^   r_   rÙ   rõ   r   rz   rw   rÚ   rÛ   rÜ   Ú
_container)	rl   Úotherr2   ry   rß   rq   rà   rá   r^   s	            r9   Ú
_add_densez_coo_base._add_dense:  s¿  € Ø�;‰;˜$Ÿ*™*Ò$ÜÐ4°T·Z±Z°LÀÀeÇkÁkÀ]ÐRSÐTÓUÐUÜ˜DŸJ™JŸO™O¨U¯[©[×-=Ñ-=Ó>ˆÜ—‘˜% u°4Ô8ˆÜ�f—l‘l×/Ñ/Ó0ˆØ�9‰9˜Š>Üœ2Ÿ8™8 Q C›=¨$¯(©(°D·I±IØŸ;™; q™>¨4¯9©9°f·l±lÀ3Ó6GÈöRà�Y‰Y˜!Š^Ø×$Ñ$‰DˆAˆqÜ˜˜1˜dŸh™h¨¯©°$·(±(¸D¿I¹IØŸ™ SÓ)¨7õ4ñ ÜŸ)™) A¤r§z¡z°$·*±*¸S¸b°/Ó'BÓC‘äŸ)™)¤B§J¡J¨t¯z©z¸!¸"¨~¹dÀ¸dÑ/CÓ$DÁTÀrÀTÑ$JÈAÓN�Ü—^‘^ D§K¡KÓ0ˆFÜ˜7 D§H¡H¨d¯i©iØ! 4§9¡9¨f¯l©l¸3Ó.?ÀôJà�‰˜v¨EˆÓ2Ð2r{   c                 ó  — | j                   dk  r| j                  «       j                  |«      S |j                  | j                  k7  r&t	        d| j                  › d|j                  › d�«      ‚| j                  |«      }t        j                  | j                  |j                  f«      }t        t        j                  | j                  |j                  fd¬«      «      }| j                  ||f| j                  ¬«      }|S ©Nrª   r/  r0  r©   r	   )r    rå   )ri   ró   Ú_add_sparserd   rb   r�   r4   rÜ   r_   rX   r^   ©rl   r3  r”   r“   rÔ   s        r9   r7  z_coo_base._add_sparseR  sÃ   € Ø�9‰9�qŠ=Ø—:‘:“<×+Ñ+¨EÓ2Ð2à�;‰;˜$Ÿ*™*Ò$ÜÐ4°T·Z±Z°LÀÀeÇkÁkÀ]ÐRSÐTÓUÐUØ—‘˜uÓ%ˆÜ—>‘> 4§9¡9¨e¯j©jÐ"9Ó:ˆÜœ2Ÿ>™>¨4¯;©;¸¿¹Ð*EÈAÔNÓOˆ
Ø�N‰N˜H jÐ1¸¿¹ˆNÓDˆØˆr{   c                 óø  — | j                   dk  r| j                  «       j                  |«      S |j                  | j                  k7  r&t	        d| j                  › d|j                  › d�«      ‚| j                  |«      }t        j                  | j                  |j                   f«      }t        t        j                  | j                  |j                  fd¬«      «      }t        ||f| j                  ¬«      }|S r6  )ri   ró   Ú_sub_sparserd   rb   r�   r4   rÜ   r_   rX   r^   r   r8  s        r9   r:  z_coo_base._sub_sparse_  s¿   € Ø�9‰9�qŠ=Ø—:‘:“<×+Ñ+¨EÓ2Ð2à�;‰;˜$Ÿ*™*Ò$ÜÐ4°T·Z±Z°LÀÀeÇkÁkÀ]ÐRSÐTÓUÐUØ—‘˜uÓ%ˆÜ—>‘> 4§9¡9¨u¯z©z¨kÐ":Ó;ˆÜœ2Ÿ>™>¨4¯;©;¸¿¹Ð*EÈAÔNÓOˆ
Ü�x Ð,°D·J±JÔ?ˆØˆr{   c           	      óÐ  — | j                   dkD  �r:t        j                  t        j                  | j
                  d d «      t        | j                  j                  |j                  j                  «      ¬«      }t        j                  | j
                  «      }t        j                  t        j                  |d d d d d…   «      d d d…   dd  d«      }t        j                  | j                  «      }t        | j                  t!        | j
                  «      ||| j"                  ||«       |j%                  | j
                  d d «      }|S | j                   dkD  r| j
                  d   nd}t        j                  |t        | j                  j                  |j                  j                  «      ¬«      }| j                   dk(  r| j&                  }| j(                  }nL| j                   dk(  r%| j                  d   }t        j*                  |«      }nt-        d| j                   › �«      ‚t/        | j                  ||| j"                  ||«       t1        | t2        «      r
|dk(  r|d   S |S )Nr   r}   r1   r	   r   z$coo_matvec not implemented for ndim=)ri   r4   r   rÇ   rÈ   rd   r   r2   r1  r5   rÚ   rÛ   rÜ   r^   r   r˜   r>   r_   r•   rw   rz   rv   ÚNotImplementedErrorr   rW   r   )	rl   r3  ry   rd   rá   r^   Úresult_shaperw   rz   s	            r9   Ú_matmul_vectorz_coo_base._matmul_vectorl  sÓ  € Ø�9‰9�q‹=Ü—X‘XœdŸi™i¨¯
©
°3°B¨Ó8Ü$/°·
±
·±ÀÇÁ×AQÑAQÓ$RôTˆFä—H‘H˜TŸZ™ZÓ(ˆEÜ—i‘i¤§
¡
¨5°°"¨:±d¸°dÑ+;Ó <¹T¸r¸TÑ BÀ1À2Ð FÈÓJˆGÜ—^‘^ D§K¡KÓ0ˆFÜ˜$Ÿ(™(¤C¨¯
©
£O°W¸fÀdÇiÁiØ ô)ð —^‘^ D§J¡J¨s° OÓ4ˆFØˆMð )-¯	©	°Aª�t—z‘z !’}¸1ˆÜ—‘˜,Ü +¨D¯J©J¯O©O¸U¿[¹[×=MÑ=MÓ NôPˆà�9‰9˜Š>Ø—(‘(ˆCØ—(‘(‰CØ�Y‰Y˜!Š^Ø—+‘+˜a‘.ˆCÜ—-‘- Ó$‰Cä%Ø6°t·y±y°kÐBóDð Dô 	�4—8‘8˜S # t§y¡y°%¸Ô@ä�dœGÔ$¨¸Ò):Ø˜!‘9ÐØˆr{   c                 ó  — t        |«      r| j                  |«      S 	 |j                  }t        t        |«      d d «      t        t        |«      dd  d d d…   «      z   }|j                  |«      }| j                  }t        t        |«      d d «      t        t        |«      dd  d d d…   «      z   }| j                  |«      j                  |«      }|t        u rt        S |dk(  s|dk(  rt        |j                  «      }nIt        t        |j                  «      d d «      t        t        |j                  «      dd  d d d…   «      z   }|j                  |«      S # t        $ r% t	        j
                  |«      }|j                  }Y �Œ\w xY w)Nrt   r}   r	   )r!   Ú_mul_scalarri   ÚAttributeErrorr4   rg   rX   r]   r½   Ú_matmul_dispatchÚNotImplemented)rl   r3  Úo_ndimÚpermÚtrÚs_ndimÚrets          r9   Ú_rmatmul_dispatchz_coo_base._rmatmul_dispatchŽ  s^  € Ü˜ÔØ×#Ñ# EÓ*Ð*ð$ØŸ™�ô œ˜v› s¨Ð+Ó,¬u´U¸6³]À2À3Ð5GÉÈ"ÈÑ5MÓ/NÑNˆDØ—‘ Ó&ˆBà—Y‘YˆFÜœ˜v› s¨Ð+Ó,¬u´U¸6³]À2À3Ð5GÉÈ"ÈÑ5MÓ/NÑNˆDØ—.‘. Ó&×7Ñ7¸Ó;ˆCØ”nÑ$Ü%Ð%à˜Š{˜f¨škÜ˜SŸX™X“‘äœU 3§8¡8›_¨S¨bÐ1Ó2´U¼5ÀÇÁ»?È2È3Ð;OÑPTÐRTÐPTÑ;UÓ5VÑV�Ø—=‘= Ó&Ð&øô! "ò $ÜŸ
™
 5Ó)�ØŸ™“ð$ús   žE Å*FÆFc                 ó¦  — t        |«      r| j                  |«      S t        |«      s_t        |«      sTt	        j
                  |«      }|j                  dk(  r#|j                  t        j                  k(  rt        S 	 |j                   | j                  dk  r%|j                  dk  rt        j                  | |«      S | j                  d   }d}|j                  t        j                  u �r"|j                  |fk(  r| j!                  |«      S |j                  |dfk(  r@| j!                  |j#                  «       «      } |j$                  g | j                  d d ¢d‘­Ž S |j                  dk(  r#|› d|› d|j                  d   › d�}t'        |«      ‚|j                  d	   |k(  rK| j                  d d	 }|j                  d d	 }||k7  r	 t	        j(                  ||«       | j+                  |«      S t'        |› d|› d|j                  d	   › d�«      ‚t        |«      r| j-                  |«      S t        |«      �r]| j                  dk(  }	|j                  dk(  }
|	r| j%                  | j.                  «      } |
r |j%                  |j                  d   df«      }||j                  d	   k7  r!t'        |› d|› d|j                  d	   › d�«      ‚| j                  dkD  s|j                  dkD  r:| j                  d d	 }|j                  d d	 }||k7  r	 t	        j(                  ||«       | j1                  |«      }|	r@|j%                  t3        |j                  d d	 «      t3        |j                  dd  «      z   «      }|
r|j%                  |j                  d d «      }|S y # t        $ r |}Y �Œw xY w# t&        $ r t'        d
«      ‚w xY w# t&        $ r t'        d
«      ‚w xY w)Nr   rª   r}   z)matmul: dimension mismatch with signaturer	   z (n,k=z),(k=z,)->(n,)rt   z&Batch dimensions are not broadcastablez	 (n,..,k=z,..,m)->(n,..,m)r   )r!   Úmultiplyr   r"   r4   Ú
asanyarrayri   r2   Úobject_rC  rd   rA  r   rB  r�   Úndarrayr>  rÙ   r•   rb   Úbroadcast_shapesÚ_matmul_multivectorr@  rõ   Ú_matmul_sparserX   )rl   r3  Úother_arà   Ú
err_prefixry   ÚmsgÚbatch_shape_AÚbatch_shape_BÚ
self_is_1dÚother_is_1ds              r9   rB  z_coo_base._matmul_dispatch¨  s¬  € Ü˜ÔØ—=‘= Ó'Ð'ä˜”¤7¨5¤>ä—m‘m EÓ*ˆGà�|‰|˜qÒ  W§]¡]´b·j±jÒ%@ô &Ð%ð Ø—’ð �9‰9�qŠ=˜UŸZ™Z¨!š^Ü×+Ñ+¨D°%Ó8Ð8à�J‰J�r‰NˆØ@ˆ
Ø�?‰?œbŸj™jÒ(Ø�{‰{˜q˜dÒ"Ø×*Ñ*¨5Ó1Ð1Ø�{‰{˜q !˜fÒ$Ø×,Ñ,¨U¯[©[«]Ó;�Ø%�v—~‘~Ð: t§z¡z°#°2 Ð:¸Ò:Ð:Ø�z‰z˜QŠØ#˜ F¨1¨#¨U°5·;±;¸q±>Ð2BÀ(ÐK�Ü  “oÐ%Ø�{‰{˜2‰ !Ò#à $§
¡
¨3¨B �Ø %§¡¨C¨RÐ 0�Ø  MÒ1ðSä×+Ñ+¨M¸=ÔIð ×/Ñ/°Ó6Ð6ä Ø!�l )¨A¨3¨e°E·K±KÀ±OÐ3DÐDTÐUóð ô
 ˜Ôà×#Ñ# EÓ*Ð*ä�E�?ØŸ™ a™ˆJØŸ*™*¨™/ˆKñ Ø—|‘| D×$5Ñ$5Ó6�áØŸ™ u§{¡{°1¡~°qÐ&9Ó:�ð �E—K‘K ‘OÒ#Ü Ø!�l )¨A¨3¨e°E·K±KÀ±OÐ3DÐDTÐUóð ð �y‰y˜1Š} §
¡
¨Q¢Ø $§
¡
¨3¨B �Ø %§¡¨C¨RÐ 0�Ø  MÒ1ðSä×+Ñ+¨M¸=ÔIð ×(Ñ(¨Ó/ˆFñ àŸ™¬¨f¯l©l¸3¸BÐ.?Ó(@Ü(-¨f¯l©l¸2¸3Ð.?Ó(@ñ)Aó B�áØŸ™¨¯©°S°bÐ(9Ó:�ØˆMðM øôO "ò  Ø“ð ûô2 &ò SÜ(Ð)QÓRÐRðSûôP &ò SÜ(Ð)QÓRÐRðSús*   Á;N ÇN# ÌN; ÎN ÎN Î#N8Î;Oc                 ó8  — t        | j                  j                  |j                  j                  «      }| j                  dk\  s|j                  dk\  �rÌ| j                  dk(  rn| j	                  d| j
                  d   «      j                  |«      }|j	                  t        |j
                  d d «      t        |j
                  dd  «      z   «      S t        j                  | j
                  d d |j
                  d d «      }|| j
                  dd  z   }||j
                  dd  z   }| j                  |«      } t        j                  ||«      }|| j
                  dd z   |j
                  dd  z   }t        j                  ||¬«      }t        | j                  t        | j
                  «      |j
                  d   t        j                   |«      t        j                   |«      t        j"                  | j$                  «      | j&                  |j)                  d«      |«	       |S | j                  dk(  r7| j
                  d   |j
                  d   f}| j*                  }| j,                  }	nC| j                  dk(  r4|j
                  d   f}| j$                  d   }t        j.                  |«      }	t        j                  |¬«      }t1        | j                  |j
                  d   	| j&                  |j)                  d«      |«       |j3                  t5        |«      ¬	«      S )
Nrª   r	   r   rt   r}   r1   r‡   r   )Útype)r   r2   r1  ri   r•   rd   rP  rX   r4   rO  Ú_broadcast_toÚbroadcast_tor   r   r˜   r>   r5   rÜ   r^   r_   rÙ   rw   rz   rv   r   ÚviewrZ  )
rl   r3  Úresult_dtypery   Úbroadcast_shapeÚ
self_shapeÚother_shaper=  rw   rz   s
             r9   rP  z_coo_base._matmul_multivector  sf  € Ü" 4§:¡:§?¡?°E·K±K×4DÑ4DÓEˆØ�9‰9˜Š>˜UŸZ™Z¨1›_à�y‰y˜AŠ~ØŸ™ a¨¯©°A©Ó7×KÑKÈEÓR�Ø—~‘~¤e¨E¯K©K¸¸Ð,<Ó&=ÄÀeÇkÁkÐRTÐRUÐFVÓ@WÑ&WÓXÐXä ×1Ñ1°$·*±*¸S¸b°/À5Ç;Á;ÈsÐPRÐCSÓTˆOØ(¨4¯:©:°b°c¨?Ñ:ˆJØ)¨E¯K©K¸¸Ð,<Ñ<ˆKà×%Ñ% jÓ1ˆDÜ—O‘O E¨;Ó7ˆEØ*¨T¯Z©Z¸¸2Ð->Ñ>ÀÇÁÈRÈSÐAQÑQˆLÜ—X‘X˜l°,Ô?ˆFÜ §¡¬#¨d¯j©j«/¸5¿;¹;Àr¹?Ü "§¡¨Ó 5´r·x±xÀÓ7MÜ "§¡¨t¯{©{Ó ;Ø $§	¡	¨5¯;©;°sÓ+;¸VôEð ˆMà�9‰9˜Š>Ø ŸJ™J q™M¨5¯;©;°q©>Ð:ˆLØ—(‘(ˆCØ—(‘(‰CØ�Y‰Y˜!Š^Ø!ŸK™K¨™NÐ,ˆLØ—+‘+˜a‘.ˆCÜ—-‘- Ó$ˆCÜ—‘˜,¨lÔ;ˆÜ˜Ÿ™ 5§;¡;¨r¡?°C¸ØŸ™ E§K¡K°Ó$4°fô	>à�{‰{¤ U£ˆ{Ó,Ð,r{   c                 ó(  — t        |«      s|t        |«      sqt        |«      sft        j                  |«      }|j
                  dk(  r5|j                  t        j                  k(  rt        dt        |«      › d�«      ‚	 |j                   | j
                  dk  r:t        j                  |«      s|j
                  dk  rt        j                  | |«      S t        j                  |«      r| |z  S t        |«      r| j                  |«      S |j                   dk7  rt        d«      ‚| j
                  dk(  rY|j
                  dk(  rJ| j                  d   |j                  d   k7  r&t#        d| j                  › d	|j                  › d
�«      ‚| |z  S | j
                  dk(  rY|j
                  dk(  rJ| j                  d   |j                  d   k7  r&t#        d| j                  › d	|j                  › d�«      ‚| |z  S | j%                  |«      S # t        $ r |}Y �Œˆw xY w)a°  Return the dot product of two arrays.

        Strictly speaking a dot product involves two vectors.
        But in the sense that an array with ndim >= 1 is a collection
        of vectors, the function computes the collection of dot products
        between each vector in the first array with each vector in the
        second array. The axis upon which the sum of products is performed
        is the last axis of the first array and the second to last axis of
        the second array. If the second array is 1-D, the last axis is used.

        Thus, if both arrays are 1-D, the inner product is returned.
        If both are 2-D, we have matrix multiplication. If `other` is 1-D,
        the sum product is taken along the last axis of each array. If
        `other` is N-D for N>=2, the sum product is over the last axis of
        the first array and the second-to-last axis of the second array.

        Parameters
        ----------
        other : array_like (dense or sparse)
            Second array

        Returns
        -------
        output : array (sparse or dense)
            The dot product of this array with `other`.
            It will be dense/sparse if `other` is dense/sparse.

        Examples
        --------

        >>> import numpy as np
        >>> from scipy.sparse import coo_array
        >>> A = coo_array([[1, 2, 0], [0, 0, 3], [4, 0, 5]])
        >>> v = np.array([1, 0, -1])
        >>> A.dot(v)
        array([ 1, -3, -1], dtype=int64)

        For 2-D arrays it is the matrix product:

        >>> A = coo_array([[1, 0], [0, 1]])
        >>> B = coo_array([[4, 1], [2, 2]])
        >>> A.dot(B).toarray()
        array([[4, 1],
               [2, 2]])

        For 3-D arrays the shape extends unused axes by other unused axes.

        >>> A = coo_array(np.arange(3*4*5*6)).reshape((3,4,5,6))
        >>> B = coo_array(np.arange(3*4*5*6)).reshape((5,4,6,3))
        >>> A.dot(B).shape
        (3, 4, 5, 5, 4, 3)
        r   z"dot argument not supported type: 'ú'rª   r%   z input must be a COO matrix/arrayr	   úshapes r0  z" are not aligned for inner productr   z are not aligned for matmul)r   r"   r!   r4   rL  ri   r2   rM  ra   rZ  rd   rA  Úisscalarr   ÚdotÚ
_dense_dotre   rb   Ú_sparse_dot)rl   r3  Úo_arrays      r9   rf  z_coo_base.dot+  sË  € ôj ˜”¤7¨5¤>´\À%Ô5Hä—m‘m EÓ*ˆGà�|‰|˜qÒ  W§]¡]´b·j±jÒ%@ÜÐ"DÄTÈ%Ã[ÀMÐQRÐ SÓTÐTð Ø—’ð �9‰9�qŠ=œbŸk™k¨%Ô0°E·J±J¸q²LÜ—;‘;˜t UÓ+Ð+ä�;‰;�uÔØ˜%‘<ÐÜ�5Œ>Ø—?‘? 5Ó)Ð)Ø�\‰\˜UÒ"ÜÐ>Ó?Ð?Ø�Y‰Y˜!Š^ §
¡
¨a¢à�z‰z˜!‰} §¡¨A¡Ò.Ü  7¨4¯:©:¨,°e¸E¿K¹K¸=Ø!Eð"Fó Gð Gà˜%‘<ÐØ�Y‰Y˜!Š^ §
¡
¨a¢à�z‰z˜!‰} §¡¨A¡Ò.Ü  7¨4¯:©:¨,°e¸E¿K¹K¸=Ø!>ð"?ó @ð @à˜%‘<Ðà×#Ñ# EÓ*Ð*øô3 "ò  Ø“ð ús   Á<H ÈHÈHc                 óà  — | j                   dk(  }|j                   dk(  }|r| j                  | j                  «      } |r |j                  |j                  d   df«      }| j                  d   |j                  d   k7  r&t	        d| j                  › d|j                  › d�«      ‚t        | j                  | j                  | j                   dz
  g«      }t        |j                  |j                  |j                   dz
  g«      }| j                  d d }|j                  d d |j                  dd  z   }t        j                  |«      | j                  d   f}|j                  d   t        j                  |«      f}	|| j                  d   f}
|j                  d   |f}t        | j                  |
f|«      }t        |j                  |f|	«      }||z  j                  «       }||z   }||f}g }t        |j                  |«      D ]*  \  }}|j                  t        j                  ||«      «       Œ, t        |j                  |f|«      }|r|j                  |dd  «      }|r|j                  |d d «      }|S )	Nr	   r   r}   rt   rd  r0  ú are not aligned for n-D dotr   )ri   r•   rõ   rd   rb   Ú_ravel_non_reduced_axesr^   rÇ   rÈ   r   r_   rf   rÉ   Úextendr4   rŽ   )rl   r3  rW  rX  Úself_raveled_coordsÚother_raveled_coordsÚself_nonreduced_shapeÚother_nonreduced_shapeÚravel_coords_shape_selfÚravel_coords_shape_otherÚself_2d_coordsÚother_2d_coordsÚself_2dÚother_2drÈ   Úcombined_shapeÚshapesÚprod_coordsÚcÚsÚprod_arrs                        r9   rh  z_coo_base._sparse_dot„  sc  € Ø—Y‘Y !‘^ˆ
Ø—j‘j A‘oˆñ Ø—<‘< × 1Ñ 1Ó2ˆDÙØ—M‘M 5§;¡;¨q¡>°1Ð"5Ó6ˆEà�:‰:�b‰>˜UŸ[™[¨™_Ò,Ü  7¨4¯:©:¨,°e¸E¿K¹K¸=Ø!?ð"@ó Að Aô
 6°d·k±kØ6:·j±jÀ4Ç9Á9ÈQÁ;À-óQÐä6°u·|±|Ø7<·{±{ÀUÇZÁZÐPQÁ\ÀNó TÐð !%§
¡
¨3¨B ÐØ!&§¡¨S¨bÐ!1°E·K±KÀÀÐ4DÑ!DÐô $(§9¡9Ð-BÓ#CÀTÇZÁZÐPRÁ^Ð"TÐØ$)§K¡K°¡O´T·Y±YÐ?UÓ5VÐ#WÐ à-¨t¯{©{¸2©Ð?ˆØ Ÿ<™<¨Ñ+Ð-AÐBˆä˜TŸY™Y¨Ð7Ð9PÓQˆÜ˜eŸj™j¨/Ð:Ð<TÓUˆà˜(Ñ"×)Ñ)Ó+ˆð /Ð1GÑGˆð (Ð)?Ð@ˆØˆÜ˜Ÿ™ VÓ,ò 	7‰DˆAˆqØ×Ñœr×/Ñ/°°1Ó5Õ6ð	7ô ˜dŸi™i¨Ð5°~ÓFˆñ Ø×'Ñ'¨°q°rÐ(:Ó;ˆHÙØ×'Ñ'¨°s¸Ð(;Ó<ˆHàˆr{   c                 ó.  — | j                   dk(  }|j                   dk(  }|r| j                  | j                  «      } |r |j                  |j                  d   df«      }| j                  d   |j                  d   k7  r&t	        d| j                  › d|j                  › d�«      ‚| j                  d d dt        |j                  «      dz
  z  z   | j                  dd  z   }dt        | j                  «      dz
  z  |j                  z   }| j                  d d |j                  d d z   |j                  dd  z   }| j                  |«      |j                  |«      z  }|j                  |«      }|r|j                  |dd  «      }|r|j                  |d d «      }|S )	Nr	   r   r}   rt   rd  r0  rk  r¿   )ri   r•   rõ   rd   rb   r>   )	rl   r3  rW  rX  Únew_shape_selfÚnew_shape_otherr=  ry   r}  s	            r9   rg  z_coo_base._dense_dot½  sˆ  € Ø—Y‘Y !‘^ˆ
Ø—j‘j A‘oˆñ Ø—<‘< × 1Ñ 1Ó2ˆDÙØ—M‘M 5§;¡;¨q¡>°1Ð"5Ó6ˆEà�:‰:�b‰>˜UŸ[™[¨™_Ò,Ü  7¨4¯:©:¨,°e¸E¿K¹K¸=Ø!?ð"@ó Að Að �J‰J�s˜ˆO˜d¤c¨%¯+©+Ó&6¸Ñ&:Ñ;Ñ;¸d¿j¹jÈÈ¸oÑMð 	ð ¤# d§j¡j£/°AÑ"5Ñ6¸¿¹ÑDˆà—z‘z # 2�¨¯©°S°bÐ)9Ñ9¸E¿K¹KÈÈÐ<LÑLˆØ—‘˜nÓ-°·±¸oÓ0NÑNˆØ—>‘> ,Ó/ˆñ Ø×'Ñ'¨°Q°RÐ(8Ó9ˆHÙØ×'Ñ'¨°S°bÐ(9Ó:ˆHàˆr{   c                 ó  ‡ ‡— t        ‰«      sqt        ‰«      sft        j                  ‰«      }|j                  dk(  r5|j
                  t        j                  k(  rt        dt        ‰«      › d�«      ‚	 ‰j                   t        ‰ j                  ‰j                  |«      \  }}t        ˆˆ fd„t        ||«      D «       «      rt        d«      ‚t        ‰«      r‰ j                  ‰||«      S ‰ j!                  ‰||«      S # t        $ r |ŠY ŒŒw xY w)aŒ  Return the tensordot product with another array along the given axes.

        The tensordot differs from dot and matmul in that any axis can be
        chosen for each of the first and second array and the sum of the
        products is computed just like for matrix multiplication, only not
        just for the rows of the first times the columns of the second. It
        takes the dot product of the collection of vectors along the specified
        axes.  Here we can even take the sum of the products along two or even
        more axes if desired. So, tensordot is a dot product computation
        applied to arrays of any dimension >= 1. It is like matmul but over
        arbitrary axes for each matrix.

        Given two tensors, `a` and `b`, and the desired axes specified as a
        2-tuple/list/array containing two sequences of axis numbers,
        ``(a_axes, b_axes)``, sum the products of `a`'s and `b`'s elements
        (components) over the axes specified by ``a_axes`` and ``b_axes``.
        The `axes` input can be a single non-negative integer, ``N``;
        if it is, then the last ``N`` dimensions of `a` and the first
        ``N`` dimensions of `b` are summed over.

        Parameters
        ----------
        a, b : array_like
            Tensors to "dot".

        axes : int or (2,) array_like
            * integer_like
              If an int N, sum over the last N axes of `a` and the first N axes
              of `b` in order. The sizes of the corresponding axes must match.
            * (2,) array_like
              A 2-tuple of sequences of axes to be summed over, the first applying
              to `a`, the second to `b`. The sequences must be the same length.
              The shape of the corresponding axes must match between `a` and `b`.

        Returns
        -------
        output : coo_array
            The tensor dot product of this array with `other`.
            It will be dense/sparse if `other` is dense/sparse.

        See Also
        --------
        dot

        Examples
        --------
        >>> import numpy as np
        >>> import scipy.sparse
        >>> A = scipy.sparse.coo_array([[[2, 3], [0, 0]], [[0, 1], [0, 5]]])
        >>> A.shape
        (2, 2, 2)

        Integer axes N are shorthand for (range(-N, 0), range(0, N)):

        >>> A.tensordot(A, axes=1).toarray()
        array([[[[ 4,  9],
                 [ 0, 15]],
        <BLANKLINE>
                [[ 0,  0],
                 [ 0,  0]]],
        <BLANKLINE>
        <BLANKLINE>
               [[[ 0,  1],
                 [ 0,  5]],
        <BLANKLINE>
                [[ 0,  5],
                 [ 0, 25]]]])
        >>> A.tensordot(A, axes=2).toarray()
        array([[ 4,  6],
               [ 0, 25]])
        >>> A.tensordot(A, axes=3)
        array(39)

        Using tuple for axes:

        >>> a = scipy.sparse.coo_array(np.arange(60).reshape(3,4,5))
        >>> b = np.arange(24).reshape(4,3,2)
        >>> c = a.tensordot(b, axes=([1,0],[0,1]))
        >>> c.shape
        (5, 2)
        >>> c
        array([[4400, 4730],
               [4532, 4874],
               [4664, 5018],
               [4796, 5162],
               [4928, 5306]])

        r   z#tensordot arg not supported type: 'rc  c              3   ób   •K  — | ]&  \  }}‰j                   |   ‰j                   |   k7  –— Œ( y ­wrK   rå   )r6   ÚaxÚbxr3  rl   s      €€r9   r:   z&_coo_base.tensordot.<locals>.<genexpr>C  s2   øè ø€ ò 9Ù�2�rð �z‰z˜"‰~ §¡¨R¡Õ0ñ 9ùs   ƒ,/z*sizes of the corresponding axes must match)r"   r   r4   rL  ri   r2   rM  ra   rZ  rd   rA  Ú_process_axesrc   rÉ   rb   Ú_dense_tensordotÚ_sparse_tensordot)rl   r3  rº   Úother_arrayÚ	axes_selfÚ
axes_others   ``    r9   Ú	tensordotz_coo_base.tensordotÜ  sô   ù€ ôr �uŒ~¤h¨u¤oäŸ-™-¨Ó.ˆKà×Ñ 1Ò$¨×):Ñ):¼b¿j¹jÒ)HÜÐ"EÄdÈ5ÃkÀ]ÐRSÐ TÓUÐUð$Ø—’ô !.¨d¯i©i¸¿¹ÀTÓ JÑˆ	�:ô ô 9Ü  ¨JÓ7ô9ô 9äÐIÓJÐJä�5Œ>Ø×(Ñ(¨°	¸:ÓFÐFà×)Ñ)¨%°¸JÓGÐGøô "ò $Ø#’ð$ús   Á3C> Ã>DÄDc                 ót  ‡ ‡‡‡— t        ‰ j                  «      }t        ‰j                  «      }t        ‰ j                  ‰ j                  ‰«      }t	        j
                  ‰D �cg c]  }‰ j                  |   ‘Œ c}‰D �cg c]  }‰ j                  |   ‘Œ c}«      }t        ‰j                  ‰j                  ‰«      }	t	        j
                  ‰D �
cg c]  }
‰j                  |
   ‘Œ c}
‰D �
cg c]  }
‰j                  |
   ‘Œ c}
«      }t        ˆˆ fd„t        |«      D «       «      }t        ˆˆfd„t        |«      D «       «      }t        j                  |«      t        j                  ‰D �cg c]  }‰ j                  |   ‘Œ c}«      f}t        j                  ‰D �cg c]  }‰j                  |   ‘Œ c}«      t        j                  |«      f}||f}||	f}t        ‰ j                  |f|«      }t        ‰j                  |f|«      }||z  j                  «       }||z   }g }t        |j                  ||f«      D ]-  \  }}|sŒ	|j                  t	        j                  ||«      «       Œ/ |g k(  rt!        |j                  «      S t        |j                  |f|¬«      S c c}w c c}w c c}
w c c}
w c c}w c c}w )Nc              3   óD   •K  — | ]  }|‰vr‰j                   |   –— Œ y ­wrK   rå   )r6   rƒ  r‰  rl   s     €€r9   r:   z._coo_base._sparse_tensordot.<locals>.<genexpr>]  s(   øè ø€ ò &6¸Ø!#¨9Ñ!4ð '+§j¡j°¥nñ &6ùrS   c              3   óD   •K  — | ]  }|‰vr‰j                   |   –— Œ y ­wrK   rå   )r6   rƒ  rŠ  r3  s     €€r9   r:   z._coo_base._sparse_tensordot.<locals>.<genexpr>_  s(   øè ø€ ò '8¸2Ø"$¨JÑ"6ð (-§{¡{°2¥ñ '8ùrS   rå   )r>   rd   rl  r^   r4   Úravel_multi_indexrX   r]   rÇ   rÈ   r   r_   rf   rÉ   rm  rŽ   Úsum)rl   r3  r‰  rŠ  Ú	ndim_selfÚ
ndim_otherÚself_non_red_coordsrƒ  Úself_reduced_coordsÚother_non_red_coordsÚaÚother_reduced_coordsrp  rq  rr  rs  rt  ru  rv  rw  rÈ   rx  r^   r{  r|  s   ````                     r9   r‡  z_coo_base._sparse_tensordotM  sl  û€ Ü˜Ÿ
™
“Oˆ	Ü˜Ÿ™Ó%ˆ
ô 6°d·k±kÀ4Ç:Á:Ø6?óAÐä ×2Ñ2Ø'0Ö1 ˆT�[‰[˜‹_Ò1ÈYÖ3WÀr°D·J±J¸r³NÒ3WóYÐä6°u·|±|ÀUÇ[Á[Ø7Aó CÐä!×3Ñ3Ø&0Ö1 ˆU�\‰\˜!‹_Ò1ÈJÖ3WÀq°E·K±KÀ³NÒ3Wó 
Ðô !&ô &6¼uÀYÓ?Oô &6ó !6Ðä!&ô '8ÄÀzÓARô '8ó "8Ðô $(§9¡9Ð-BÓ#CÜ $§	¡	ÀIÖ*N¸b¨4¯:©:°b«>Ò*NÓ Oð#QÐä$(§I¡IÈÖ.TÀ2¨u¯{©{¸2«Ò.TÓ$UÜ$(§I¡IÐ.DÓ$Eð$GÐ ð .Ð/BÐCˆØ/Ð1EÐFˆä˜TŸY™Y¨Ð7Ð9PÓQˆÜ˜eŸj™j¨/Ð:Ð<TÓUˆð ˜(Ñ"×)Ñ)Ó+ˆð /Ð1GÑGˆð ˆÜ˜Ÿ™Ð&;Ð=SÐ%TÓUò 	6‰DˆAˆqÚØ—‘œb×.Ñ.¨q°!Ó4Õ5ð	6ð �RŠ<Ü�t—y‘y“>Ð!ô ˜$Ÿ)™) VÐ,°NÔCÐCùòQ 2ùÒ3Wùò 2ùÒ3Wùò +OùÚ.Ts$   Á#JÁ?J!
ÃJ&Ã,J+
Å,J0
ÆJ5c                 ó.  — t        | j                  «      }t        |j                  «      }t        |«      D �cg c]	  }||vsŒ|‘Œ }}|D �cg c]  }| j                  |   ‘Œ }	}|D �cg c]  }| j                  |   ‘Œ }
}t        |«      D �cg c]  }||vr|‘Œ
 }}|D �cg c]  }|j                  |   ‘Œ }}|D �cg c]  }|j                  |   ‘Œ }}||z   }|d d |z   |dd  z   }| j                  |«      } t	        j                  ||«      }g |
¢t        j                  |	«      ‘­}g |d d ¢t        j                  |«      ‘|dd  ¢­}| j                  |«      j                  |j                  |«      «      S c c}w c c}w c c}w c c}w c c}w c c}w r€   )	r>   rd   r]   r½   r4   rÇ   rÈ   r•   rf  )rl   r3  r‰  rŠ  r‘  r’  rƒ  Únon_reduced_axes_selfr|  Úreduced_shape_selfÚnon_reduced_shape_selfÚnon_reduced_axes_otherÚreduced_shape_otherÚnon_reduced_shape_otherÚpermute_selfÚpermute_otherÚreshape_selfÚreshape_others                     r9   r†  z_coo_base._dense_tensordot�  s®  € Ü˜Ÿ
™
“Oˆ	Ü˜Ÿ™Ó%ˆ
ä.3°IÓ.>Ö V¨À"ÈIÒBU¢Ð VÐÐ VØ5>Ö?°˜dŸj™j¨›mÐ?ÐÐ?Ø9NÖ!O°A $§*¡*¨Q£-Ð!OÐÐ!Oä/4°ZÓ/@ö ";¨Ø%'¨zÑ%9ò #%ð ";Ðð ";à7AÖB°!˜uŸ{™{¨1›~ÐBÐÐBØ;QÖ"R°a 5§;¡;¨q£>Ð"RÐÐ"Rà,¨yÑ8ˆà" 3 BÐ'¨*Ñ4Ð7MÈbÈcÐ7RÑRð 	ð �~‰~˜lÓ+ˆÜ—‘˜U MÓ2ˆàOÐ/ÐO´·±Ð;MÓ1NÑOˆð7Ð1°#°2Ð6ð 7¼¿	¹	ÐBUÓ8Vð 7Ø0°°Ð5ñ7ˆð �|‰|˜LÓ)×-Ñ-¨e¯m©m¸MÓ.JÓKÐKùò) !WùÚ?ùÚ!Oùò";ùâBùÚ"Rs)   ¸	E9ÁE9ÁE>Á(FÂFÂ FÂ<Fc                 ó  — | j                   dk  r%|j                   dk  rt        j                  | |«      S | j                  }|j                  }t	        j
                  |dd |dd «      }t        |«      |dd z   }t        |«      |dd z   }| j                  |«      }|j                  |«      }t        |«      }	t        |«      }
|	|
z  j                  «       }t        |g |¢| j                  d   ‘|j                  d   ‘­¬«      S )añ  
        Perform sparse-sparse matrix multiplication for two n-D COO arrays.
        The method converts input n-D arrays to 2-D block array format,
        uses csr_matmat to multiply them, and then converts the
        result back to n-D COO array.

        Parameters:
        self (COO): The first n-D sparse array in COO format.
        other (COO): The second n-D sparse array in COO format.

        Returns:
        prod (COO): The resulting n-D sparse array after multiplication.
        rª   Nrt   r}   rå   )ri   r   rQ  rd   r4   rO  rX   r[  Ú_block_diagrf   Ú_extract_block_diag)rl   r3  r`  ra  r_  Úself_new_shapeÚother_new_shapeÚself_broadcastedÚother_broadcastedÚself_block_diagÚother_block_diagÚprod_block_diags               r9   rQ  z_coo_base._matmul_sparseœ  s  € ð �9‰9�qŠ=˜UŸZ™Z¨!š^Ü×)Ñ)¨$°Ó6Ð6ð —Z‘Zˆ
Ø—k‘kˆô ×-Ñ-¨j¸¸"¨o¸{È3ÈBÐ?OÓPˆÜ˜Ó/°*¸R¸S°/ÑAˆÜ Ó0°;¸r¸sÐ3CÑCˆà×-Ñ-¨nÓ=ÐØ!×/Ñ/°Ó@Ðô &Ð&6Ó7ˆÜ&Ð'8Ó9Ðð +Ð-=Ñ=×DÑDÓFˆô #ØØE�OÐE T§Z¡Z°¡^ÐE°U·[±[À±_ÑEô
ð 	
r{   c                 ób  — | j                   |k(  r|r| j                  «       S | S | j                   }t        |«      t        |«      k  rt        d«      ‚dt        |«      t        |«      z
  z  t	        |«      z   }t        d„ t        ||«      D «       «      rt        d|› d�«      ‚| j                  |«      } t        | j                  t        |«      ¬«      }| j                  }| j                  }|dd  }d}	|d   |d   k7  rY|d   }
|	|
z  }	t        j                  ||
«      }t        j                  t        j                  d	|
|¬
«      | j                   «      }|f}t#        dt        |«      dz    d«      D ]¯  }||   ||   k7  rƒ||   }
|	|
z  }	t        |«      }t        j                  ||
«      }t	        t        j                  ||dz   d  |
«      «      }t        j                  t        j                  d	|
|¬
«      |«      }|f|z   }Œ‘t        j                  ||   |	«      }|f|z   }Œ± t%        ||f|«      S )NzDNew shape must have at least as many dimensions as the current shaper¿   c              3   ó:   K  — | ]  \  }}|d k7  xr ||k7  –— Œ y­wrB   rÁ   )r6   ÚoÚns      r9   r:   z*_coo_base._broadcast_to.<locals>.<genexpr>Ö  s$   è ø€ ÒE¡t q¨!��Q‘Ò!˜1 ™6Ó!ÑEùrš   zcurrent shape z- cannot be broadcast to new shape {new_shape}r,   r}   r	   r   r1   rt   )rd   rI   r>   rb   rX   rc   rÉ   r•   r   r^   rE   r_   r4   ÚtileÚrepeatr  r˜   r]   r   )rl   Ú	new_shaperI   Ú	old_shaperd   r8   r^   r”   r“   Ú
cum_repeatÚrepeat_countÚnew_dimr¨   r˜   s                 r9   r[  z_coo_base._broadcast_toÇ  s,  € Ø�:‰:˜Ò"Ù"&�4—9‘9“;Ð0¨DÐ0à—J‘Jˆ	ô ˆy‹>œC 	›NÒ*Üð 5ó 6ð 6ð œ˜I›¬¨Y«Ñ7Ñ8¼5ÀÓ;KÑKˆô ÑE¬s°5¸)Ó/DÔEÔEÜ˜~¨i¨[ð 9Bð Bó Cð Cð �|‰|˜EÓ"ˆä# D§K¡K¼¸I»ÔGˆ	Ø—‘ˆØ—9‘9ˆØ˜B˜C�[ˆ
Øˆ
à�‰9˜	 "™Ò%Ø$ R™=ˆLØ˜,Ñ&ˆJÜ—w‘w˜x¨Ó6ˆHÜ—i‘i¤§	¡	¨!¨\ÀÔ KÈTÏXÉXÓVˆGØ!˜ˆJä�rœS ›Z¨™\˜?¨BÓ/ò 	5ˆAØ�Q‰x˜9 Q™<Ò'Ø(¨™|�Ø˜lÑ*�
Ü˜(“m�ô Ÿ7™7 8¨\Ó:�Ü"¤2§7¡7¨:°a¸±c°dÐ+;¸\Ó#JÓK�
ô Ÿ)™)¤B§I¡I¨a°ÀYÔ$OÐQTÓU�Ø%˜Z¨*Ñ4‘
ô Ÿ'™' &¨¡)¨ZÓ8�Ø%˜Z¨*Ñ4‘
ð!	5ô$ ˜( JÐ/°Ó;Ð;r{   )NNFrK   )NF)ÚreturnN)NN)F)r   )T)r   )0Ú__name__Ú
__module__Ú__qualname__Ú_formatr]   rY   rV   Úpropertyrz   Úsetterrw   r•   r   Ú__doc__r¡   r¤   rk   r½   rÒ   râ   rí   ró   rè   rf   r  r  r  r   r  r   r£   r  r-  r4  r7  r:  r>  rI  rB  rP  rf  rh  rg  r‹  r‡  r†  rQ  r[  rÁ   r{   r9   r$   r$      s  „ Ø€GÙ�a˜“€IðGÈTô GðR ñó ðð 	‡Z�ZñGó ðGð ñó ðð 	‡Z�Zñ4ó ð4ò!OðF —o‘o×-Ñ-€G„Oó;ð( —o‘o×-Ñ-€G„OóWð $×1Ñ1×9Ñ9€MÔòNó2?ð$  ×)Ñ)×1Ñ1€IÔó$ðL —^‘^×+Ñ+€F„Nó%ð2 —o‘o×-Ñ-€G„OóóB óD1ó6ð —M‘M×)Ñ)€E„MóDð, —M‘M×)Ñ)€E„Móð —M‘M×)Ñ)€E„Móð( $×,Ñ,×4Ñ4€HÔò$*óNRó	)òò&>ò3ò0
ò
òòD'ò4\ò~!-òHV+òr7òró>nHòb1DòhLò6(
ôV5<r{   r$   c                 óò  — | j                   dk  rt        d«      ‚t        j                  | j                  dd «      }| j                  d   }| j                  d   }| j                  |||f«      }|j                  d   |j                  d   |j                  d   z  z   |j                  d   |j                  d   |j                  d   z  z   f}||z  ||z  f}t        | j                  t        |«      f|¬«      S )	zð
    Converts an N-D COO array into a 2-D COO array in block diagonal form.

    Parameters:
    self (coo_array): An N-Dimensional COO sparse array.

    Returns:
    coo_array: A 2-Dimensional COO sparse array in block diagonal form.
    r   zarray must have atleast dim=2Nrt   r}   r	   r   rå   )
ri   rb   rÇ   rÈ   rd   r•   r^   r   r_   rX   )rl   Ú
num_blocksÚn_colÚn_rowÚres_arrr“   r³  s          r9   r¤  r¤  ÿ  sê   € ð ‡y�y�‚{ÜÐ8Ó9Ð9Ü—‘˜4Ÿ:™: c r˜?Ó+€JØ�J‰J�r‰N€EØ�J‰J�r‰N€EØ�l‰l˜J¨¨uÐ5Ó6€Gà�‰�qÑ˜GŸN™N¨1Ñ-°·±¸aÑ0@Ñ@Ñ@Ø�‰�qÑ˜GŸN™N¨1Ñ-°·±¸aÑ0@Ñ@Ñ@ð€Jð
 ˜eÑ# Z°%Ñ%7Ð8€IÜ�d—i‘i¤ zÓ!2Ð3¸9ÔEÐEr{   c                 óx  — |d   |d   }}| j                   }| j                  | j                  }}t        j                  t        |«      | j                  ft        ¬«      }||z  |d<   ||z  |d<   ||z  }t        t        |«      dz
  dd«      D ]  }	||	   }
||
z  ||	<   ||
z  }Œ t        |t        |«      f|¬«      S )Nrt   r}   r1   rª   rå   )r_   rz   rw   r4   rö   r>   r˜   rž   r]   r   rX   )rl   rd   rÃ  rÂ  r_   rz   rw   r“   Útemp_block_idxr¨   rÑ   s              r9   r¥  r¥    sÏ   € Ø˜‘9˜e B™iˆ5€Eð �9‰9€DØ�x‰x˜Ÿ™ˆ€Cô —‘œ3˜u›: t§x¡xÐ0¼Ô<€Jð ˜5‘[€Jˆr�NØ˜5‘[€Jˆr�Nð ˜E‘\€NÜ”3�u“: ‘> 2 rÓ*ò 0ˆØ�Q‰xˆØ&¨Ñ-ˆ
�1‰Ø'¨4Ñ/‰ð0ô �dœE *Ó-Ð.°eÔ<Ð<r{   c                 óf  ‡ ‡— t        |t        «      rL|dk  s|t        ‰ ‰«      kD  rt        d«      ‚t	        t        ‰ |z
  ‰ «      «      }t	        t        |«      «      }n”t        |t        t        f«      rst        |«      dk7  rt        d«      ‚|\  }}t        |«      t        |«      k7  rt        d«      ‚t        ˆ fd„|D «       «      st        ˆfd„|D «       «      rt        d«      ‚t        d	«      ‚|D �cg c]  }|d
k  r|‰ z   n|‘Œ }}|D �cg c]  }|d
k  r|‰z   n|‘Œ }}||fS c c}w c c}w )Nr	   z.axes integer is out of bounds for input arraysr   z%axes must be a tuple/list of length 2z,axes lists/tuples must be of the same lengthc              3   ó8   •K  — | ]  }|‰k\  xs |‰ k  –— Œ y ­wrK   rÁ   )r6   rƒ  Úndim_as     €r9   r:   z _process_axes.<locals>.<genexpr>=  ó#   øè ø€ Ò=°ˆr�V‰|Ò+˜r V G™|Ó+Ñ=ùó   ƒc              3   ó8   •K  — | ]  }|‰k\  xs |‰ k  –— Œ y ­wrK   rÁ   )r6   r„  Úndim_bs     €r9   r:   z _process_axes.<locals>.<genexpr>>  rÊ  rË  z/axes indices are out of bounds for input arraysz3axes must be an integer or a tuple/list of integersr   )
rW   rž   r±   rb   Úlistr]   rX   r>   rc   ra   )rÉ  rÍ  rº   Úaxes_aÚaxes_br    s   ``    r9   r…  r…  1  s&  ù€ Ü�$œÔØ�!Š8�tœc &¨&Ó1Ò1ÜÐMÓNÐNÜ”e˜F T™M¨6Ó2Ó3ˆÜ”e˜D“kÓ"‰Ü	�Dœ5¤$˜-Ô	(Üˆt‹9˜Š>ÜÐDÓEÐEØ‰ˆ�Üˆv‹;œ#˜f›+Ò%ÜÐKÓLÐLÜÓ=°fÔ=Ô=ÜÓ=°fÔ=Ô=ÜÐNÓOÐOäÐMÓNÐNà>DÖE°d˜t ašxˆd�VŠm¨TÑ1ÐE€FÐEØ>DÖE°d˜t ašxˆd�VŠm¨TÑ1ÐE€FÐEØ�6ˆ>Ðùò FùÚEs   Ã7D)ÄD.c                 ó  ‡ — t        |«      }t        |«      D �cg c]	  }||vsŒ|‘Œ }}|st        j                  ‰ d   «      S |D �cg c]  }||   ‘Œ	 }}t	        ˆ fd„|D «       «      }t        j
                  ||«      S c c}w c c}w )Nr   c              3   ó(   •K  — | ]	  }‰|   –— Œ y ­wrK   rÁ   )r6   r@   r^   s     €r9   r:   z*_ravel_non_reduced_axes.<locals>.<genexpr>T  s   øè ø€ ÒG¨s˜v c�{ÑGùrÆ   )r>   r]   r4   rv   rX   r�  )r^   rd   rº   ri   rƒ  Únon_reduced_axesÚnon_reduced_shapeÚnon_reduced_coordss   `       r9   rl  rl  H  s�   ø€ Üˆu‹:€DÜ%*¨4£[ÖC˜r°B¸d²NšÐCÐÐCáä�}‰}˜V A™YÓ'Ð'ð .>Ö> r˜˜r›Ð>ÐÐ>ô ÓGÐ6FÔGÓGÐô ×ÑÐ 2Ð4EÓFÐFùò Dùò ?s   š	B ¤B ÁBc                 óÖ  — t        | «      dk(  r| d   S t        | «      dk(  r±|\  }}| \  }}|dk(  rI|t        d|dz
  «      z  t        d|dz
  «      z   }t        |¬«      }t        j                  |||¬«      |z   S |dk(  rI|t        d|dz
  «      z  t        d|dz
  «      z   }t        |¬«      }t        j                  |||¬«      |z   S t        d«      ‚t        j                  | ||¬	«      S )
z;Like np.ravel_multi_index, but avoids some overflow issues.r	   r   r   r‡   r,   r1   ÚFz'order' must be 'C' or 'F'r…   )r>   rE   r   r4   rK  rb   r�  )	r^   rd   r†   ÚnrowsÚncolsrz   rw   r-   r8   s	            r9   rŒ   rŒ   Z  só   € ä
ˆ6ƒ{�aÒØ�a‰yÐä
ˆ6ƒ{�aÒØ‰ˆˆuØ‰ˆˆSØ�CŠ<Øœc ! U¨Q¡YÓ/Ñ/´#°a¸À¹Ó2CÑCˆFÜ'¨vÔ6ˆIÜ—;‘;˜u c°Ô;¸cÑAÐAØ�cŠ\Øœc ! U¨Q¡YÓ/Ñ/´#°a¸À¹Ó2CÑCˆFÜ'¨vÔ6ˆIÜ—;‘;˜u c°Ô;¸cÑAÐAäÐ9Ó:Ð:Ü×Ñ ¨°UÔ;Ð;r{   c                 ó"   — t        | t        «      S )aÒ  Is `x` of coo_matrix type?

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

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

    Examples
    --------
    >>> from scipy.sparse import coo_array, coo_matrix, csr_matrix, isspmatrix_coo
    >>> isspmatrix_coo(coo_matrix([[5]]))
    True
    >>> isspmatrix_coo(coo_array([[5]]))
    False
    >>> isspmatrix_coo(csr_matrix([[5]]))
    False
    )rW   r   )rì   s    r9   r   r   o  s   € ô. �aœÓ$Ð$r{   c                   ó   — e Zd ZdZy)r   a  
    A sparse array in COOrdinate format.

    Also known as the 'ijv' or 'triplet' format.

    This can be instantiated in several ways:
        coo_array(D)
            where D is an ndarray

        coo_array(S)
            with another sparse array or matrix S (equivalent to S.tocoo())

        coo_array(shape, [dtype])
            to construct an empty sparse array with shape `shape`
            dtype is optional, defaulting to dtype='d'.

        coo_array((data, coords), [shape])
            to construct from existing data and index arrays:
                1. data[:]       the entries of the sparse array, in any order
                2. coords[i][:]  the axis-i coordinates of the data entries

            Where ``A[coords] = data``, and coords is a tuple of index arrays.
            When shape is not specified, it is inferred from the index arrays.

    Attributes
    ----------
    dtype : dtype
        Data type of the sparse array
    shape : tuple of integers
        Shape of the sparse array
    ndim : int
        Number of dimensions of the sparse array
    nnz
    size
    data
        COO format data array of the sparse array
    coords
        COO format tuple of index arrays
    has_canonical_format : bool
        Whether the matrix has sorted coordinates and no duplicates
    format
    T

    Notes
    -----

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

    Advantages of the COO format
        - facilitates fast conversion among sparse formats
        - permits duplicate entries (see example)
        - very fast conversion to and from CSR/CSC formats

    Disadvantages of the COO format
        - does not directly support:
            + arithmetic operations
            + slicing

    Intended Usage
        - COO is a fast format for constructing sparse arrays
        - Once a COO array has been constructed, convert to CSR or
          CSC format for fast arithmetic and matrix vector operations
        - By default when converting to CSR or CSC format, duplicate (i,j)
          entries will be summed together.  This facilitates efficient
          construction of finite element matrices and the like. (see example)

    Canonical format
        - Entries and coordinates sorted by row, then column.
        - There are no duplicate entries (i.e. duplicate (i,j) locations)
        - Data arrays MAY have explicit zeros.

    Examples
    --------

    >>> # Constructing an empty sparse array
    >>> import numpy as np
    >>> from scipy.sparse import coo_array
    >>> coo_array((3, 4), dtype=np.int8).toarray()
    array([[0, 0, 0, 0],
           [0, 0, 0, 0],
           [0, 0, 0, 0]], dtype=int8)

    >>> # Constructing a sparse array using ijv format
    >>> row  = np.array([0, 3, 1, 0])
    >>> col  = np.array([0, 3, 1, 2])
    >>> data = np.array([4, 5, 7, 9])
    >>> coo_array((data, (row, col)), shape=(4, 4)).toarray()
    array([[4, 0, 9, 0],
           [0, 7, 0, 0],
           [0, 0, 0, 0],
           [0, 0, 0, 5]])

    >>> # Constructing a sparse array with duplicate coordinates
    >>> row  = np.array([0, 0, 1, 3, 1, 0, 0])
    >>> col  = np.array([0, 2, 1, 3, 1, 0, 0])
    >>> data = np.array([1, 1, 1, 1, 1, 1, 1])
    >>> coo = coo_array((data, (row, col)), shape=(4, 4))
    >>> # Duplicate coordinates are maintained until implicitly or explicitly summed
    >>> np.max(coo.data)
    1
    >>> coo.toarray()
    array([[3, 0, 1, 0],
           [0, 2, 0, 0],
           [0, 0, 0, 0],
           [0, 0, 0, 1]])

    N)r¹  rº  r»  r¿  rÁ   r{   r9   r   r   Š  s   „ òkr{   r   c                   ó   — e Zd ZdZd„ Zy)r   a.  
    A sparse matrix in COOrdinate format.

    Also known as the 'ijv' or 'triplet' format.

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

        coo_matrix(S)
            with another sparse array or matrix S (equivalent to S.tocoo())

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

        coo_matrix((data, (i, j)), [shape=(M, N)])
            to construct from three arrays:
                1. data[:]   the entries of the matrix, in any order
                2. i[:]      the row indices of the matrix entries
                3. j[:]      the column indices of the matrix entries

            Where ``A[i[k], j[k]] = data[k]``.  When shape is not
            specified, it is inferred from the index arrays

    Attributes
    ----------
    dtype : dtype
        Data type of the matrix
    shape : 2-tuple
        Shape of the matrix
    ndim : int
        Number of dimensions (this is always 2)
    nnz
    size
    data
        COO format data array of the matrix
    row
        COO format row index array of the matrix
    col
        COO format column index array of the matrix
    has_canonical_format : bool
        Whether the matrix has sorted indices and no duplicates
    format
    T

    Notes
    -----

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

    Advantages of the COO format
        - facilitates fast conversion among sparse formats
        - permits duplicate entries (see example)
        - very fast conversion to and from CSR/CSC formats

    Disadvantages of the COO format
        - does not directly support:
            + arithmetic operations
            + slicing

    Intended Usage
        - COO is a fast format for constructing sparse matrices
        - Once a COO matrix has been constructed, convert to CSR or
          CSC format for fast arithmetic and matrix vector operations
        - By default when converting to CSR or CSC format, duplicate (i,j)
          entries will be summed together.  This facilitates efficient
          construction of finite element matrices and the like. (see example)

    Canonical format
        - Entries and coordinates sorted by row, then column.
        - There are no duplicate entries (i.e. duplicate (i,j) locations)
        - Data arrays MAY have explicit zeros.

    Examples
    --------

    >>> # Constructing an empty matrix
    >>> import numpy as np
    >>> from scipy.sparse import coo_matrix
    >>> coo_matrix((3, 4), dtype=np.int8).toarray()
    array([[0, 0, 0, 0],
           [0, 0, 0, 0],
           [0, 0, 0, 0]], dtype=int8)

    >>> # Constructing a matrix using ijv format
    >>> row  = np.array([0, 3, 1, 0])
    >>> col  = np.array([0, 3, 1, 2])
    >>> data = np.array([4, 5, 7, 9])
    >>> coo_matrix((data, (row, col)), shape=(4, 4)).toarray()
    array([[4, 0, 9, 0],
           [0, 7, 0, 0],
           [0, 0, 0, 0],
           [0, 0, 0, 5]])

    >>> # Constructing a matrix with duplicate coordinates
    >>> row  = np.array([0, 0, 1, 3, 1, 0, 0])
    >>> col  = np.array([0, 2, 1, 3, 1, 0, 0])
    >>> data = np.array([1, 1, 1, 1, 1, 1, 1])
    >>> coo = coo_matrix((data, (row, col)), shape=(4, 4))
    >>> # Duplicate coordinates are maintained until implicitly or explicitly summed
    >>> np.max(coo.data)
    1
    >>> coo.toarray()
    array([[3, 0, 1, 0],
           [0, 2, 0, 0],
           [0, 0, 0, 0],
           [0, 0, 0, 1]])

    c                 óŒ   — d|vr%|j                  d«      |j                  d«      f|d<   | j                  j                  |«       y )Nr^   rz   rw   )ÚpopÚ__dict__Úupdate)rl   Ústates     r9   Ú__setstate__zcoo_matrix.__setstate__j  s>   € Ø˜5Ñ ð  %Ÿy™y¨Ó/°·±¸5Ó1AÐBˆE�(‰OØ�‰×Ñ˜UÕ#r{   N)r¹  rº  r»  r¿  râ  rÁ   r{   r9   r   r   ù  s   „ ñnó`$r{   r   )r‡   )2r¿  Ú__docformat__Ú__all__rÇ   Úwarningsr   Únumpyr4   Ú
_lib._utilr   Ú_matrixr
   Ú_sparsetoolsr   r   r   r   r   r   r   Ú_baser   r   r   r   Ú_datar   r   Ú_sputilsr   r   r   r   r   r   r   r   r    r!   r"   rC   r$   r¤  r¥  r…  rl  rŒ   r   r   r   rÁ   r{   r9   ú<module>rí     s«   ðÙ 8à%€â
7€ã Ý ã å 'Ý ÷0÷ 0ñ 0÷ GÓ Fß .÷Q÷ Q÷ Qñ Qó ôb<�˜mô b<òJ'Fò2=ò2ò.Gó$<ò*%ô6l�	˜7ô lô^v$�˜9õ v$r{   