Ë
    ÏÍ:j¶. ã                   óZ  — 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(m)Z)m*Z* ddl+Z+ G d„ dee«      Z,d„ Z-d„ Z.d„ Z/d„ Z0d„ Z1d„ Z2dd„Z3d„ Z4 G d„ de,e«      Z5 G d„ dee,«      Z6y)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ÚisscalarlikeÚ	isintlikeÚisdense)Ú_validate_indicesÚ_broadcast_arraysc                   ó  — e Zd ZdZ e edd«      «      Zd7ddœd„Zed„ «       Z	e	j                  d	„ «       Z	ed
„ «       Zej                  d„ «       Zdddœd„Zej                  j                  e_        d8d„Zej                  j                  e_        d8d„Zej                   j                  e_        d„ Zd9d„Zej$                  j                  e_        ed„ «       Zej&                  j                  e_        d:d„Zej(                  j                  e_        d;d„Zej*                  j                  e_        d<d„Zd<d„Zd<d„Zd<d„Zej2                  j                  e_        d<d„Zej4                  j                  e_        d<d„Zej6                  j                  e_        d=d„Zej8                  j                  e_        d„ Zd>d„Zd„ Z d „ Z!d!„ Z"d:d"„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/d?d/„Z0d0„ Z1d1„ Z2d2„ Z3d<d3„Z4d4„ Z5d5„ Z6d6„ Z7y)@Ú	_coo_baseÚcoor	   éA   NF©Ú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| _        �nht3        |«      �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     €úf/home/mcse/projects/srt_converter/srt-converter-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ùó   ƒ!$r3   Tzinvalid input formatc              3   ó8   K  — | ]  }t        |«      d k(  –— Œ y­w)r   N©Úlen©r8   Úidxs     r;   r<   z%_coo_base.__init__.<locals>.<genexpr>5   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Úindexr6   ÚmaxrA   s     r;   r<   z%_coo_base.__init__.<locals>.<genexpr>8   s.   è ø€ ò "5Ø&)ô #+§.¡.´·±¸³Ó"=ÀÕ"Añ "5ùs   ‚57)r/   Úcheck_contentsc              3   óN   •K  — | ]  }t        j                  |‰‰¬ «      –— Œ y­w)©Úcopyr4   Nr5   )r8   rB   rK   r:   s     €€r;   r<   z%_coo_base.__init__.<locals>.<genexpr>>   s)   øè ø€ ò $8Ø),ô %'§H¡H¨S°tÀ9×$MÐ$Mñ $8ùs   ƒ"%rJ   Fc              3   ó<   K  — | ]  }|j                  «       –— Œ y ­w©N©rK   rA   s     r;   r<   z%_coo_base.__init__.<locals>.<genexpr>E   s   è ø€ Ò'J°s¨¯©¯
Ñ'Jùó   ‚rN   r   z!expected 2D array or matrix, not ÚDzinconsistent shapes: z != c              3   óD   •K  — | ]  }|j                  ‰d ¬«      –— Œ y­w©FrN   N)Úastype)r8   rB   Úindex_dtypes     €r;   r<   z%_coo_base.__init__.<locals>.<genexpr>_   s&   øè ø€ ò $8Ø),ð %(§J¡J¨{À J×$Gñ $8ùs   ƒ c              3   ó^   K  — | ]%  }|j                  t        j                  d ¬«      –— Œ' y­wrR   )rS   r6   Úint64rA   s     r;   r<   z%_coo_base.__init__.<locals>.<genexpr>e   s!   è ø€ ÒXÀS §
¡
¬2¯8©8¸% 
× @ÑXùs   ‚+-)#r   Ú__init__r   Ú
isinstanceÚtupler   Ú	_allow_ndr   Ú_shapeÚ_get_index_dtyperG   r   ÚfloatÚranger@   Úcoordsr6   r7   ÚdataÚhas_canonical_formatÚ	TypeErrorÚ
ValueErrorÚanyÚshaper   r   ÚformatrS   ÚtocooÚasarrayr   Ú
atleast_2dÚndimÚnonzeroÚ_check)ÚselfÚarg1re   r4   rK   r*   Ú
data_dtypeÚobjr_   Úer'   ÚMÚmessager:   rT   s       `        @@r;   rW   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 ÑQ:Ñ)Q5Ñ5Q:c                 ó¤   — | j                   dkD  r| j                  d   S t        j                  | j                  «      }|j                  d¬«       |S )Nr	   éþÿÿÿF)Úwrite)rj   r_   r6   Ú
zeros_likeÚcolÚsetflags)rm   Úresults     r;   Úrowz_coo_base.rowi   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 arrayru   r3   éÿÿÿÿ)rj   rc   r6   rh   r_   r4   )rm   Únew_rows     r;   r{   z_coo_base.rowr   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_   )rm   s    r;   rx   z_coo_base.coly   s   € à�{‰{˜2‰Ðr|   c                 ó�   — t        j                  || j                  d   j                  ¬«      }| j                  d d |fz   | _        y )Nr~   r3   )r6   rh   r_   r4   )rm   Únew_cols     r;   rx   z_coo_base.col}   s9   € ä—*‘*˜W¨D¯K©K¸©O×,AÑ,AÔBˆØ—k‘k # 2Ð&¨'¨Ñ3ˆ�r|   ÚC)ÚorderrK   c                óf  ‡— t        || j                  | j                  ¬«      }|| 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,   ©r†   r   r…   r	   r   r~   r.   c              3   óL   •K  — | ]  }t        j                  |‰¬ «      –— Œ y­wr2   ©r6   rh   )r8   Úcor:   s     €r;   r<   z$_coo_base.reshape.<locals>.<genexpr>™   s   øè ø€ ÒP¸rœ2Ÿ:™: b°	×:Ð:ÑPùr=   F©re   rK   )r   re   rZ   rK   Ú_ravel_coordsr_   r@   Údivmodr6   Úunravel_indexr\   rG   rY   r`   Ú	__class__)rm   r†   rK   re   Úflat_coordsÚ
new_coordsÚnew_datar:   s          @r;   Úreshapez_coo_base.reshape‚   s  ø€ Ü˜E 4§:¡:¸¿¹ÔGˆð �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rM   r?   )r8   rB   Únnzs     €r;   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rD   )rj   rA   s     r;   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)rj   r@   r`   rd   r_   rc   Úintr6   Úbincountr   re   )rm   Úaxisr—   s     @r;   Ú_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_duplicatesr6   Úcount_nonzeror`   rj   rc   r_   rž   r   re   )rm   rŸ   ÚmaskÚcoords       r;   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r2   rŠ   )r8   rB   r:   s     €r;   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)rj   r@   r_   rc   Ú	enumerater4   Úkindr   Únamer\   rG   re   rY   r   r`   r—   Úmin)rm   r§   rB   r:   s      @r;   rl   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rM   )r[   ©r8   r§   rm   s     €r;   r<   z&_coo_base.transpose.<locals>.<genexpr>ñ   s   øè ø€ Ò<°!˜tŸ{™{¨1�~Ñ<ùó   ƒc              3   ó<   •K  — | ]  }‰j                   |   –— Œ y ­wrM   r‚   r´   s     €r;   r<   z&_coo_base.transpose.<locals>.<genexpr>ò   s   øè ø€ Ò=°1 §¡¨A¥Ñ=ùrµ   rŒ   )r^   rj   rX   r   Úhasattrr@   rc   ÚsetrY   r�   r`   )rm   ÚaxesrK   Úpermuted_shapeÚpermuted_coordss   `    r;   Ú	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                 ó¨   — | j                   x}dk  rt        d|› d�«      ‚|dk(  rd nt        t        |dz
  «      «      dz   }| j	                  |¬«      S )Nr   z0Array must be at least 2-dimensional, but it is z-D)r~   ru   )r¹   )rj   rc   rY   r^   r¼   )rm   Únr¹   s      r;   ÚmTz_coo_base.mTø   sY   € à—‘ˆNˆA˜aÒÜÐOÐPQÈsÐRTÐUÓVÐVØ˜A’v‰t¤5¬¨q°1©u«Ó#6¸Ñ#AˆØ�~‰~ 4ˆ~Ó(Ð(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rM   © )r8   ÚoldÚnews      r;   r<   z#_coo_base.resize.<locals>.<genexpr>  s   è ø€ ÒM©(¨#¨s˜C #�IÑMùs   ‚c              3   ó(   •K  — | ]	  }|‰   –— Œ y ­wrM   rÃ   ©r8   rB   r¤   s     €r;   r<   z#_coo_base.resize.<locals>.<genexpr>"  s   øè ø€ Ò#E°# C¨¥IÑ#Eùó   ƒ)r   rZ   rj   rc   r@   r�   r_   re   ÚmathÚprodr6   r�   r`   r[   r”   rd   ÚzipÚlogical_andÚreduceÚallrY   )
rm   re   r‘   Úmax_sizeÚ	tmp_shapeÚtmpÚis_truncatingrB   Úsizer¤   s
            @r;   Ú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_contiguousrc   rj   r   r6   r7   r—   r_   r`   Úravelre   r   r{   rx   ÚappendÚcumprodÚconcatenater”   )	rm   r†   ÚoutÚBÚfortranrr   ÚNÚstridesr_   s	            r;   Ú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 )	aP  Convert this array/matrix to Compressed Sparse Column format.

        Duplicate entries will be summed together.

        Parameters
        ----------
        copy : bool, optional
            Unused. A copy is always made in the 2D case. And CSC is 2D.

        Returns
        -------
        csc array/matrix
            The converted array/matrix in CSC format.

        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 rP   r   r3   r	   )Ú	csc_array©re   )rj   rc   r—   Ú_csc_containerre   r4   Ú_cscræ   Ú_coo_to_compressedÚ_swapra   r¢   )rm   rK   ræ   ÚindptrÚindicesr`   re   Úxs           r;   Útocscz_coo_base.tocscD  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 )
aÏ  Convert this array/matrix to Compressed Sparse Row format.

        Duplicate entries will be summed together.

        Parameters
        ----------
        copy : bool, optional
            With ``copy=False``, the data/indices may be shared between this
            array/matrix and the resultant csr_array/matrix. But only for 1D.
            For 2D, a copy will always be made.

        Returns
        -------
        csr array/matrix
            The converted array/matrix in CSR format.

        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 rP   r   r3   r	   )Ú	csr_arrayrN   rç   )rj   rc   r—   Ú_csr_containerre   r4   Ú_csrrñ   rê   rë   ra   r¢   )	rm   rK   rñ   Úarraysrì   rí   r`   re   rî   s	            r;   Útocsrz_coo_base.tocsrp  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   r3   FrN   )Ú_shape_as_2dr\   r_   rG   r—   rj   rK   r@   r6   r7   r`   re   rS   ÚemptyÚ
empty_liker4   r   )rm   ÚswaprK   rr   râ   r:   rí   r—   rì   r`   ÚmajorÚminors               r;   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 rM   rN   )rm   rK   s     r;   rg   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 rP   T)Úreturn_inverseéd   zConstructing a DIA matrix with z diagonals is inefficientrª   r   )r   r   r3   r	   rç   )rj   rc   r¢   rx   r{   r6   Úuniquer@   r   r   r`   rÓ   Úzerosr4   rG   Ú_dia_containerre   )rm   rK   ÚksÚdiagsÚdiag_idxr`   s         r;   Ú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 rP   r3   r	   r   )rj   rc   r¢   Ú_dok_containerre   r4   r_   rË   Údictr`   Ú_dict)rm   rK   Údokr_   s       r;   Ú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   r3   c              3   ó(   •K  — | ]	  }|‰   –— Œ y ­wrM   rÃ   )r8   rB   Ú	diag_masks     €r;   r<   z%_coo_base.diagonal.<locals>.<genexpr>÷  s   øè ø€ Ò?¨C˜˜Y�Ñ?ùrÈ   )rj   rc   re   r6   rø   r`   r4   r  r°   rG   r{   rx   ra   rY   r_   Ú_sum_duplicates)
rm   ÚkÚrowsÚcolsÚdiagr{   r`   Úindsr9   r  s
            @r;   Ú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   r3   F)rj   rc   re   r@   r{   r4   rx   r°   r6   Ú
logical_orÚarangerø   rÞ   r_   r`   ra   )rm   Úvaluesr  rr   râ   r:   Ú	full_keepÚ	max_indexÚkeepr   r„   r“   s               r;   Ú_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rM   rN   rA   s     r;   r<   z'_coo_base._with_data.<locals>.<genexpr>+  s   è ø€ Ò=¨#˜3Ÿ8™8Ÿ:Ñ=ùrO   ©re   r4   )rY   r_   r�   re   r4   )rm   r`   rK   r_   s       r;   Ú
_with_dataz_coo_base._with_data&  sE   € ñ ÜÑ=°·±Ô=Ó=‰Fà—[‘[ˆFØ�~‰~˜t V˜n°D·J±JÀdÇjÁjˆ~ÓQÐQr|   c                 óf  — t        || j                  | j                  «      \  }}}}t        j                  t        | j                  «      t        j                  ¬«      }g }g }g }	t        t        || j                  «      «      D �]  \  }
\  }}t        |t        «      r	|||k(  z  }Œ#t        |t        «      r²|t        d «      k(  r|j                  |«       ŒS|j                  | j                  |
   «      \  }}}|dk7  rD|dk  r||k  ||kD  z  }n||k\  ||k  z  }t        j                   ||z
  |«      \  }}||dk(  |z  z  }n||k\  ||k  z  }||z
  }||z  }|j                  |«       Œå|j                  |«       |	j                  |«       �Œ	 |dk(  r8| j                  |   j#                  «       j%                  | j&                  d¬«      S |D �cg c]  }||   ‘Œ	 }}| j                  |   }|	�rt)        |	Ž }	|	d   j                  }t        j*                  |	«      j-                  t        |	«      dd«      }t        j*                  |D �cg c]  }||   ‘Œ	 c}«      d d …d d …d f   }||k(  j/                  d¬«      }|j1                  «       \  }}||   }|D �cg c]  }||   ‘Œ	 }}t3        t        j4                  ||¬	«      «      }t        |«      |d   |d   z
  dz   k(  r|d   }|d | |z   ||d  z   }n||z   }|r‘|rt        j6                  |d   «      }n7t        j8                  t        |«      | j                  d   j&                  ¬«      }|j;                  |d   |«       |dd  D ]"  }
|j;                  |
|j=                  «       «       Œ$ t?        ||f|| j&                  ¬
«      S c c}w c c}w c c}w )Nr3   r	   r   rÃ   FrN   r~   ©rŸ   rç   r"  ) r#   re   rf   r6   Úonesr@   r`   Úbool_r­   rË   r_   rX   r�   ÚslicerÜ   rí   rŽ   ÚsumrS   r4   r$   r7   r”   rÎ   rk   Úlistr�   rw   r  ÚinsertrK   r   )rm   ÚkeyrF   Ú	new_shapeÚarr_int_posÚnone_posÚ
index_maskÚslice_coordsÚ
arr_coordsÚarr_indicesr§   rB   r‹   ÚstartÚstopÚstepÚin_rangeÚnew_ixÚmr’   r“   Ú	arr_shapeÚkeyarrÚfoundÚarr_coÚarr_ixÚnew_arr_coordsÚposÚ
coord_likes                                r;   Ú__getitem__z_coo_base.__getitem__0  s–  € Ü2CØ�—‘˜TŸ[™[ó3
Ñ/ˆˆy˜+ xô —W‘WœS §¡›^´2·8±8Ô<ˆ
ØˆØˆ
ØˆÜ%¤c¨%°·±Ó&=Ó>ó 	(‰LˆA‰y��RÜ˜#œsÔ#Ø˜r S™yÑ)‘
Ü˜C¤Ô'Øœ% ›+Ò%Ø ×'Ñ'¨Õ+à(+¯©°D·J±J¸q±MÓ(BÑ%�E˜4 Ø˜q’yØ !š8Ø(*¨e©¸¸T¹	Ñ'B™Hà(*¨e©¸¸T¹	Ñ'B˜HÜ$&§I¡I¨b°5©j¸$Ó$?™	˜ Ø" q¨A¡v°Ñ&9Ñ9™
à$&¨%¡K°B¸±IÑ#>˜Ø!# e¡˜Ø" hÑ.˜
Ø ×'Ñ'¨Õ/à×!Ñ! "Ô%Ø×"Ñ" 3Ö'ð-	(ð0 ˜Š?Ø—9‘9˜ZÑ(×,Ñ,Ó.×5Ñ5°d·j±jÀuÐ5ÓMÐMà/;Ö<¨�b˜“nÐ<ˆ
Ð<Ø—9‘9˜ZÑ(ˆò Ü+¨[Ð9ˆKØ# A™×,Ñ,ˆIô —X‘X˜kÓ*×2Ñ2´3°{Ó3CÀQÈÓKˆFÜŸ™¸JÖ"G°b 2 j£>Ò"GÓHÊÊAÈtÈÑTˆJØ˜zÑ)×.Ñ.°AÐ.Ó6ˆEØ"Ÿ]™]›_‰NˆF�FØ Ñ'ˆHØ/9Ö:¨˜"˜V›*Ð:ˆJÐ:Ü!¤"×"2Ñ"2°6ÀÔ"KÓLˆNô �;Ó ;¨r¡?°[À±^Ñ#CÀaÑ#GÒGà! !‘n�Ø'¨¨Ð-°Ñ>ÀÈCÈDÐAQÑQ‘
ð ,¨jÑ8�
áÙÜŸ]™]¨:°a©=Ó9‘
äŸX™X¤c¨(£m¸4¿;¹;Àq¹>×;OÑ;OÔP�
Ø×Ñ˜h q™k¨:Ô6Ø˜a˜b�\ò 8�Ø×!Ñ! ! Z§_¡_Ó%6Õ7ð8ä˜( JÐ/°yÈÏ
É
ÔSÐSùò] =ùò, #Hùò ;s   ÇN$ÉN)ÊN.c           	      óÞ  — t        || j                  | j                  «      \  }}}}|r4t        |«      }|d d d…   D ]  }|j	                  |«       Œ t        |«      }|r[t        |«      }|D �ci c]  }t        ||   x}	«      rŒ||	“Œ }
}t        |
j                  «       Ž }t        |
|«      D ]
  \  }}	|	||<   Œ t        |«      r*d|j                  v ry t        ||| j                  «      \  }}n@t        j                  || j                  ¬«      }|j                  dk(  ry t!        ||«      \  }}| j#                  |«      \  }}t%        |«      dk(  r!t%        |d   «      dk(  r||c| _        | _        y d }d}|rp|D ]k  }t+        |t,        «      rŒt        |«      rŒ |j                  }t%        |«      |d   |d   z
  dz   k(  r|d   }nd}|||t%        |«      z    }t/        ||«      } n d}i }t1        |«      D ]3  \  }}||k(  r|t%        |«      z  }t+        |t,        «      sŒ*|||<   |dz  }Œ5 d g| j2                  z  }t%        |«      }t1        |«      D ]…  \  }}t        |«      rt        j4                  ||f«      ||<   Œ,t+        |t,        «      r4|j7                  | j                  |   «      \  }}}||||      |z  z   ||<   Œp|j9                  «          ||<   Œ‡ |j;                  «       }t        j<                  |«      }t        j>                  |dd¬«      \  }}t        j@                  |||   g«      | _        t        d„ t        ||d d …|f   «      D «       «      | _        d| _!        y c c}w )	Nr~   r   r3   r	   T)rŸ   Úreturn_indexc              3   óF   K  — | ]  }t        j                  |«      –— Œ y ­wrM   )r6   Úhstack)r8   Úcs     r;   r<   z(_coo_base.__setitem__.<locals>.<genexpr>ñ  s   è ø€ ÒV¨QœBŸI™I aŸLÑVùs   ‚!F)"r#   re   rf   r*  ÚpoprY   r!   r$   r  rË   r   Ú_get_sparse_data_and_coordsr4   r6   rh   rÓ   Ú_get_dense_data_and_coordsÚ
_zero_manyr@   r`   r_   rX   r(  r�   r­   rj   Úbroadcast_torí   rÛ   rK   r7   r  rF  ra   )rm   r,  rî   rF   r-  r.  r/  Újr§   ÚarrÚarr_posr3  Úx_dataÚx_coordsÚold_dataÚ
old_coordsr:  r@  rB   Ú	x_arr_cooÚx_arr_coo_ravelÚx_axÚx_axesr’   Únew_nnzr4  r5  r6  r“   r9   Úinds                                  r;   Ú__setitem__z_coo_base.__setitem__„  sz  € ä2CØ�—‘˜TŸ[™[ó3
Ñ/ˆˆy˜+ xñ Ü˜Y›ˆIØ™d ˜d‘^ò !�Ø—‘˜aÕ ð!ä˜iÓ(ˆIñ Ü˜“KˆEØ'2ÖU !¼)È5ÐQRÉ8ÀOÀCÕ:T�q˜#‘vÐUˆGÐUÜ+¨W¯^©^Ó-=Ð>ˆKÜ˜g {Ó3ò ‘��3Ø��a’ðô �AŒ;Ø�A—G‘G‰|ØÜ:¸1¸iÈÏÉÓTÑˆF‘Hä—
‘
˜1 D§J¡JÔ/ˆAØ�v‰v˜Š{ØÜ9¸!¸YÓGÑˆF�Hð  $Ÿ™¨uÓ5Ñˆ�*äˆx‹=˜AÒ¤# h¨q¡kÓ"2°aÒ"7Ø%-¨zÐ"ˆDŒI�t”{àð ˆ	ØˆÙð ò �Ü! #¤uÕ-´iÀµnØ #§	¡	�Iô
 ˜;Ó'¨K¸©O¸kÈ!¹nÑ,LÈqÑ,PÒQØ)¨!™n™à˜ð !)¨¨S´3°y³>Ñ-AÐ B�Iä&3°I¸yÓ&I�OÙð#ð( ˆØˆÜ Ó&ò 	‰FˆAˆsØ�CŠxØœ˜I›Ñ&�Ü˜#œuÕ%Ø ��q‘	Ø˜‘	‘ð	ð �V˜dŸi™iÑ'ˆ
Ü�f“+ˆÜ Ó&ò 	=‰FˆAˆsÜ˜Œ~Ü!#§¡°°w°jÓ!A�
˜1‘ØÜ˜C¤Ô'Ø$'§K¡K°·
±
¸1±Ó$>Ñ!��t˜TØ!&¨°&¸±)Ñ)<¸tÑ)CÑ!C�
˜1’à #§	¡	£¨OÑ <�
˜1’ð	=ð —;‘;“=ˆô —X‘X˜jÓ)ˆ
Ü—‘˜:¨A¸DÔA‰ˆˆ3ô —I‘I˜x¨°#©Ð7Ó8ˆŒ	ÜÑV´#°jÀ*ÊQÐPSÈVÑBTÓ2UÔVÓVˆŒØ$)ˆÕ!ùò{ Vs   Á.M*ÂM*c                 óž  — t        j                  t        | j                  «      t         j                  ¬«      }g }g }t        t        || j                  «      «      D ]ù  \  }\  }}t        |t        «      r	|||k(  z  }Œ"t        |t        «      r‡|t        d «      k7  ry|j                  | j                  |   «      \  }}	}
|
dk7  rA|
dk  r||k  ||	kD  z  }n||k\  ||	k  z  }t        j                  ||z
  |
«      }||dk(  |z  z  }Œ¨||k\  ||	k  z  }||z  }Œ¹t        |t        «      r|t        d «      k(  rŒØ|j                  |«       |j                  |«       Œû |rºt        j                  |«      j!                  t        |«      dd«      }t        j                  |D �cg c]  }||   ‘Œ	 c}«      d d …d d …d f   }||k(  j#                  d¬«      }|j%                  «       \  }}t        j&                  |«      }d||j%                  «       d   |   <   ||z  }| j                  D �cg c]  }||    ‘Œ
 }}| j                  |    }||fS c c}w c c}w )Nr3   r	   r   r~   r%  T)r6   r&  r@   r`   r'  r­   rË   r_   rX   r�   r(  rí   re   ÚmodrÜ   r7   r”   rÎ   rk   rw   )rm   rF   r0  r2  r3  r§   rB   r‹   r4  r5  r6  r7  r9  r;  r<  Úarr_coor9   Úarr_index_maskÚpruned_coordsÚpruned_datas                       r;   rK  z_coo_base._zero_manyô  s5  € ô —7‘7œ3˜tŸy™y›>´·±Ô:ˆ
Øˆ
ØˆÜ%¤c¨%°·±Ó&=Ó>ò 	(‰LˆA‰y��RÜ˜#œsÔ#Ø˜r S™yÑ)‘
Ü˜C¤Ô'¨C´5¸³;Ò,>Ø$'§K¡K°·
±
¸1±Ó$>Ñ!��t˜TØ˜1’9Ø˜a’xØ$&¨%¡K°B¸±IÑ#>™à$&¨%¡K°B¸±IÑ#>˜ÜŸ™˜r E™z¨4Ó0�AØ 1¨¡6¨XÑ"5Ñ5‘Jà " e¡°°T±	Ñ:�HØ (Ñ*‘JÜ˜C¤Ô'¨C´5¸³;Ò,>àà×!Ñ! "Ô%Ø×"Ñ" 3Õ'ð)	(ñ. Ü—X‘X˜kÓ*×2Ñ2´3°{Ó3CÀQÈÓKˆFÜŸ™¸JÖ"G°b 2 j£>Ò"GÓHÊÊAÈtÈÑTˆJØ˜zÑ)×.Ñ.°AÐ.Ó6ˆEØŸ™›‰JˆG�QÜŸ]™]¨:Ó6ˆNØ?CˆN˜:×-Ñ-Ó/°Ñ2°7Ñ;Ñ<Ø˜.Ñ(ˆJð 48·;±;Ö?¨R˜˜Z˜K›Ð?ˆÐ?Ø—i‘i  Ñ,ˆØ˜MÐ)Ð)ùò #Hùò @s   ÆIÈ"I
c                 ó–   — | j                   ry| j                  | j                  | j                  «      }|\  | _        | _        d| _         y)zfEliminate duplicate entries by adding them together.

        This is an *in place* operation
        NT)ra   r  r_   r`   )rm   Úsummeds     r;   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rM   rÃ   )r8   rB   r†   s     €r;   r<   z,_coo_base._sum_duplicates.<locals>.<genexpr>2  s   øè ø€ Ò4 c�s˜5•zÑ4ùrÈ   r	   Tc              3   ó(   •K  — | ]	  }|‰   –— Œ y ­wrM   rÃ   )r8   rB   Úunique_masks     €r;   r<   z,_coo_base._sum_duplicates.<locals>.<genexpr>8  s   øè ø€ Ò:¨C�s˜;Õ'Ñ:ùrÈ   r3   )r@   r6   ÚlexsortrY   r  rÍ   rÜ   rk   ÚaddÚreduceatr   r4   )rm   r_   r`   rB   Úunique_indsr†   rf  s        @@r;   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rM   rÃ   rÇ   s     €r;   r<   z,_coo_base.eliminate_zeros.<locals>.<genexpr>D  s   øè ø€ Ò=¨#˜C �IÑ=ùrÈ   N)r`   rY   r_   )rm   r¤   s    @r;   Ú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)r4   rK   r	   r   rÖ   r   r~   FrN   )re   rc   r   r4   Úcharr6   r7   r�   rØ   rÙ   rj   r   r—   r_   r`   rÛ   r÷   r   r{   rx   rÜ   rÝ   rÞ   Ú
_container)	rm   Úotherr4   rz   rá   rr   râ   rã   r_   s	            r;   Ú
_add_densez_coo_base._add_denseJ  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©   ro  rp  r¨   r	   r%  rç   )rj   rõ   Ú_add_sparsere   rc   r�   r6   rÞ   r`   rY   r_   ©rm   rs  r“   r’   rÖ   s        r;   rw  z_coo_base._add_sparseb  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 rv  )rj   rõ   Ú_sub_sparsere   rc   r�   r6   rÞ   r`   rY   r_   r   rx  s        r;   rz  z_coo_base._sub_sparsen  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~   r3   r	   r   z$coo_matvec not implemented for ndim=)rj   r6   r  rÉ   rÊ   re   r   r4   rq  r7   rÜ   rÝ   rÞ   r_   r   r—   r@   r`   r”   rx   r{   rw   ÚNotImplementedErrorr   rX   r   )	rm   rs  rz   re   rã   r_   Úresult_shaperx   r{   s	            r;   Ú_matmul_vectorz_coo_base._matmul_vectorz  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)Nru   r~   r	   )r    Ú_mul_scalarrj   ÚAttributeErrorr6   rh   rY   r^   r¼   Ú_matmul_dispatchÚNotImplemented)rm   rs  Úo_ndimÚpermÚtrÚs_ndimÚrets          r;   Ú_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,)ru   z&Batch dimensions are not broadcastablez	 (n,..,k=z,..,m)->(n,..,m)r   )r    Úmultiplyr   r"   r6   Ú
asanyarrayrj   r4   Úobject_rƒ  re   r�  r   r‚  r�   Úndarrayr~  rÛ   r”   rc   Úbroadcast_shapesÚ_matmul_multivectorr€  r÷   Ú_matmul_sparserY   )rm   rs  Úother_arâ   Ú
err_prefixrz   ÚmsgÚbatch_shape_AÚbatch_shape_BÚ
self_is_1dÚother_is_1ds              r;   r‚  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 øôM "ò  Ø“ð ûô2 &ò SÜ(Ð)QÓRÐRðSûôN &ò 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   ru   r~   r3   r…   r   )Útype)r   r4   rq  rj   r”   re   r�  rY   r6   r�  Ú_broadcast_torL  r  r   r—   r@   r7   rÞ   r_   r`   rÛ   rx   r{   rw   r   Úviewrš  )
rm   rs  Úresult_dtyperz   Úbroadcast_shapeÚ
self_shapeÚother_shaper}  rx   r{   s
             r;   r�  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                   t        |«      r| |z  S | j                  d   |j                  dd d   k7  r&t        d| j                  › d|j                  › d	�«      ‚| j
                  d
k  r|j
                  d
k  r| |z  S t        |«      r| j                  |«      S | j                  |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 or sparse array
            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~   ru   Nzshapes rp  z are not aligned for n-D dotr©   )r   r"   r    r6   rŒ  rj   r4   r�  rb   rš  re   r�  rc   Ú
_dense_dotÚ_sparse_dotrg   )rm   rs  Úo_arrays      r;   Údotz_coo_base.dot4  s+  € ôl ˜”¤7¨5¤>´\À%Ô5Hä—m‘m EÓ*ˆGà�|‰|˜qÒ  W§]¡]´b·j±jÒ%@ÜÐ"DÄTÈ%Ã[ÀMÐQRÐ SÓTÐTð Ø—’ô
 ˜ÔØ˜%‘<Ðð �:‰:�b‰>˜UŸ[™[¨¨Ð-¨aÑ0Ò0Ü˜w t§z¡z l°%¸¿¹°}Ø;ð<ó =ð =ð �9‰9�qŠ=˜UŸZ™Z¨!š^Ø˜%‘<ÐÜ�5Œ>Ø—?‘? 5Ó)Ð)Ø×Ñ §¡£Ó.Ð.øô! "ò  Ø’ð ús   Á<D> Ä>EÅEc                 ó   — t        | | j                  dz
  g«      \  }}t        |t        d|j                  dz
  «      g«      \  }}||j                  z  }|j	                  «       }||z   }g }|r||fn|f}	t        |j                  |	«      D ]*  \  }
}|j                  t        j                  |
|«      «       Œ, t        |j                  |f|¬«      S )Nr	   r   r   rç   )Ú_convert_to_2drj   rG   ÚTrg   rË   r_   Úextendr6   r�   r   r`   )rm   rs  Úself_2dÚs_new_shapeÚother_2dÚo_new_shaperÊ   Úcombined_shaper_   Ú
new_shapesrG  Úss               r;   r¤  z_coo_base._sparse_dot„  sÍ   € ô  .¨d°T·Y±YÀ±]°OÓDÑˆ�Ü .¨u´s¸1¸e¿j¹jÈ1¹nÓ7MÐ6NÓ OÑˆ�+à˜Ÿ™Ñ#ˆØ�z‰z‹|ˆð % {Ñ2ˆð ˆÙ3>�k ;Ñ/À[ÀNˆ
Ü˜Ÿ™ ZÓ0ò 	2‰DˆAˆqØ�M‰Mœ"×*Ñ*¨1¨aÓ0Õ1ð	2ô ˜$Ÿ)™) VÐ,°NÔCÐCr|   c                 ó"  — | j                   }|dk  r|dk(  rdn| j                  d   f}| }nt        | | j                   dz
  g«      \  }}|j                   }|dk  r|dk(  rdn|j                  d   f}|}n‚|j                  d d |j                  dd  z   }|dz
  gt        |dz
  «      ¢|dz
  ‘­}t	        j
                  ||«      }	|	j                  |j                  d   t        j                  |«      f«      }||z  }
||z   }|
j                  |«      S )Nr   r	   rÃ   r   r~   ru   )	rj   re   r¨  r^   r6   r¼   r”   rÉ   rÊ   )rm   rs  r‡  r¬  r«  r„  r®  r­  Úreorder_dimsÚo_reorgrÊ   r¯  s               r;   r£  z_coo_base._dense_dot™  s  € ð —‘ˆØ�QŠ;Ø &¨!¢™"°$·*±*¸Q±-Ð1AˆKØ‰Gä#1°$¸¿¹ÀQ¹¸Ó#HÑ ˆG�[à—‘ˆØ�QŠ;Ø &¨!¢™"°%·+±+¸b±/Ð1CˆKØ‰HàŸ+™+ c rÐ*¨U¯[©[¸¸Ð-=Ñ=ˆKØ" Q™JÐG¬¨v¸©zÓ):ÐG¸FÀQ¹JÑGˆLÜ—l‘l 5¨,Ó7ˆGØ—‘¨¯©°B©¼¿¹À;Ó9OÐ'PÓQˆHà˜Ñ!ˆð % {Ñ2ˆØ�|‰|˜NÓ+Ð+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
        ----------
        other : array_like
            Tensor 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: 'r¢  c              3   ób   •K  — | ]&  \  }}‰j                   |   ‰j                   |   k7  –— Œ( y ­wrM   rç   )r8   ÚaxÚbxrs  rm   s      €€r;   r<   z&_coo_base.tensordot.<locals>.<genexpr>  s2   øè ø€ ò 9Ù�2�rð �z‰z˜"‰~ §¡¨R¡Õ0ñ 9ùs   ƒ,/z*sizes of the corresponding axes must match)r"   r   r6   rŒ  rj   r4   r�  rb   rš  re   r�  Ú_process_axesrd   rË   rc   Ú_dense_tensordotÚ_sparse_tensordot)rm   rs  r¹   Úother_arrayÚ	axes_selfÚ
axes_others   ``    r;   Ú	tensordotz_coo_base.tensordot´  sô   ù€ ôp �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        | |«      \  }}t        ||«      \  }}||j                  z  }t        |«      s|S |j                  «       }||z   }	g }
|r||fn|f}t	        |j
                  |«      D ]-  \  }}|sŒ	|
j                  t        j                  ||«      «       Œ/ t        |j                  |
f|	¬«      S )Nrç   )r¨  r©  r   rg   rË   r_   rª  r6   r�   r   r`   )rm   rs  Ús_axesÚo_axesr«  r¬  r­  r®  rÊ   r¯  r_   r°  rG  r±  s                 r;   r»  z_coo_base._sparse_tensordot#  sÂ   € ô  .¨d°FÓ;Ñˆ�Ü .¨u°fÓ =Ñˆ�+ð ˜Ÿ™Ñ#ˆä˜Œ~ØˆKØ�z‰z‹|ˆð % {Ñ2ˆð ˆÙ3>�k ;Ñ/À[ÀNˆ
Ü˜Ÿ™ ZÓ0ò 	6‰DˆAˆqÚØ—‘œb×.Ñ.¨q°!Ó4Õ5ð	6ô
 ˜$Ÿ)™) VÐ,°NÔCÐCr|   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sŒ|‘Œ }
}|D �cg c]  }|j                  |   ‘Œ }}|
D �cg c]  }|j                  |   ‘Œ }}| j                  ||z   «      }t	        j                  ||
d d |z   |
dd  z   «      }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@   re   r^   r¼   r6   rÉ   rÊ   r”   r¦  )rm   rs  rÁ  rÂ  r‡  r„  r§   Ú
s_non_axesÚs_axes_shapeÚs_non_axes_shapeÚ
o_non_axesÚo_axes_shapeÚo_non_axes_shapeÚleftÚrightÚreshape_leftÚreshape_rights                    r;   rº  z_coo_base._dense_tensordot=  s†  € Ü�T—Z‘Z“ˆÜ�U—[‘[Ó!ˆä!& v£ÖB˜A°!¸6²/’aÐBˆ
ÐBØ/5Ö6¨!˜Ÿ
™
 1›Ð6ˆÐ6Ø3=Ö>¨a˜DŸJ™J q›MÐ>ÐÐ>ä!& v£ÖB˜A°!¸6²/’aÐBˆ
ÐBØ06Ö7¨1˜Ÿ™ A›Ð7ˆÐ7Ø4>Ö?¨q˜EŸK™K¨›NÐ?ÐÐ?à�~‰~˜j¨6Ñ1Ó2ˆÜ—‘˜U J¨s° O°fÑ$<¸zÈ"È#¸Ñ$NÓOˆàCÐ)ÐC¬4¯9©9°\Ó+BÑCˆð1Ð*¨3¨BÐ/ð 1´·±¸<Ó1Hð 1Ø*¨2¨3Ð/ñ1ˆð �|‰|˜LÓ)×-Ñ-¨e¯m©m¸MÓ.JÓKÐKùò CùÚ6ùÚ>ùâBùÚ7ùÚ?s/   ¸	E6ÁE6ÁE;Á(F Â	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©   Nru   r~   rç   )rj   r   r‘  re   r6   r�  rY   r›  Ú_block_diagrg   Ú_extract_block_diag)rm   rs  rŸ  r   rž  Úself_new_shapeÚother_new_shapeÚself_broadcastedÚother_broadcastedÚself_block_diagÚother_block_diagÚprod_block_diags               r;   r‘  z_coo_base._matmul_sparseR  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rD   rÃ   )r8   Úor¾   s      r;   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   r3   ru   )re   rK   r@   rc   rY   rd   rË   r”   r   r_   rG   r`   r6   ÚtileÚrepeatr  r—   r^   r   )rm   r-  rK   Ú	old_shapere   r:   r_   r“   r’   Ú
cum_repeatÚrepeat_countÚnew_dimr§   r—   s                 r;   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|   c                 óž   — t        | |«      \  }}t        j                  |j                  d   df|¬«      }||z  j	                  |«      |d<   |S )Nr	   r3   .)r¨  r6   r&  re   r”   )rm   rŸ   Ú	res_dtyperß   ÚA2dr-  r&  s          r;   Ú_sum_ndz_coo_base._sum_nd³  sL   € ä'¨¨dÓ3‰ˆˆYÜ�w‰w˜Ÿ	™	 !™ aÐ(°	Ô:ˆà˜$‘J×'Ñ'¨	Ó2ˆˆC‰Øˆ
r|   c                 ó¼   — t        | |«      \  }}|j                  d||«      }t        j                  |j                  d   |«      }t        |j                  |f|«      S )Nr	   r   )r¨  Ú_min_or_max_axisr6   r�   r_   r   r`   )rm   rŸ   Ú
min_or_maxÚexplicitrã  r-  ÚresÚunraveled_coordss           r;   Ú_min_or_max_axis_ndz_coo_base._min_or_max_axis_nd»  sX   € Ü'¨¨dÓ3‰ˆˆYØ×"Ñ" 1 j°(Ó;ˆÜ×+Ñ+¨C¯J©J°q©M¸9ÓEÐä˜#Ÿ(™(Ð$4Ð5°yÓAÐAr|   c                 ój   — t        | |«      \  }}|j                  d|||«      }|j                  |«      S )Nr	   )r¨  Ú_argminmax_axisr”   )rm   rŸ   Ú	argminmaxÚcomparerè  rã  r-  Úres_flats           r;   Ú_argminmax_axis_ndz_coo_base._argminmax_axis_ndÂ  s9   € Ü'¨¨dÓ3‰ˆˆYØ×&Ñ& q¨)°W¸hÓGˆØ×Ñ 	Ó*Ð*r|   )NNFrM   )NF)ÚreturnN)NN)F)r   )T)r   )8Ú__name__Ú
__module__Ú__qualname__Ú_formatrY   r^   rZ   rW   Úpropertyr{   Úsetterrx   r”   r   Ú__doc__r    r£   rl   r¼   r¿   rÔ   rä   rï   rõ   rê   rg   r  r  r  r   r  r#  rB  rZ  rK  r¢   r  rm  rt  rw  rz  r~  r‰  r‚  r�  r¦  r¤  r£  r¿  r»  rº  r‘  r›  rä  rë  rñ  rÃ   r|   r;   r&   r&      sZ  „ Ø€GÙ‘e˜A˜r“lÓ#€IðGÈTô GðR ñó ðð 	‡Z�ZñGó ðGð ñó ðð 	‡Z�Zñ4ó ð4ð %(¨eô  OðD —o‘o×-Ñ-€G„Oó;ð( —o‘o×-Ñ-€G„OóWð $×1Ñ1×9Ñ9€MÔòNó2?ð$  ×)Ñ)×1Ñ1€IÔàñ)ó ð)ð —‘×#Ñ#€B„Jó$ðL —^‘^×+Ñ+€F„Nó%ð2 —o‘o×-Ñ-€G„Oó*óX,ó\1ó6ð —M‘M×)Ñ)€E„MóDð, —M‘M×)Ñ)€E„Móð —M‘M×)Ñ)€E„Móð( $×,Ñ,×4Ñ4€HÔò$*óNRòRTòhn*ò`)*óV	)òò&>ò3ò0
ò
òòB'ò2[òz!-òFN/ò`Dò*,ó6mHò^Dò4Lò*(
óT5<ònòBó+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=2Nru   r~   r	   r   rç   )
rj   rc   rÉ   rÊ   re   r”   r_   r   r`   rY   )rm   Ú
num_blocksÚn_colÚn_rowÚres_arrr’   r-  s          r;   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 )Nru   r~   r3   r©   rç   )r`   r{   rx   r6   rø   r@   r—   r�   r^   r   rY   )rm   re   rý  rü  r`   r{   rx   r’   Útemp_block_idxr§   rÓ   s              r;   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                 ó®  — | j                  «       } | j                  «        t        | j                  «      }| j                  j                  |d¬«      }| j                  }||k(  r||fS t        |«      t        |«      z
  }|dkD  r<dg|z  t        |«      z   }t        j                  |d   «      }t        |g|z  |z   «      }|dk  rAt        | «      D ]2  }|d   dk(  r|dd  }|dd  }Œ|d   dk(  r|d d }|d d }Œ)t        d«      ‚ d}	t        t        ||«      «      D ]�  \  }
\  }}||k(  rŒ|dk7  rt        d«      ‚t        |d   «      }t        j                  t        j                   |«      |«      ||
<   t        |«      D ]$  \  }}||
k(  rŒt        j"                  ||«      ||<   Œ& |	|z  }	Œ‘ t        j"                  |j%                  «       |	«      }||fS )NFrN   r   r	   r~   zshape mismatch in assignment)rg   r¢   r*  r_   r`   rS   re   r@   r6   Ú	zeroslikerY   r^   rc   r­   rË   rÜ  r  rÛ  rÛ   )rî   r-  r4   rQ  rP  Úx_shapeÚlen_diffÚcoord_zerosr9   Ú
tot_expandr§   ÚnnÚnxÚx_nnzrM  r‹   s                   r;   rI  rI  ú  sô  € Ø	�‰‹	€AØ×ÑÔä�A—H‘H‹~€HØ�V‰V�]‰]˜5 uˆ]Ó-€FØ�g‰g€Gà�GÒØ�xÐÐô �9‹~¤ G£Ñ,€HØ�!‚|à�#˜‘.¤4¨£=Ñ0ˆÜ—l‘l 8¨A¡;Ó/ˆÜ˜+˜¨Ñ1°HÑ<Ó=ˆð �!‚|Ü˜�yÓ!ò 	AˆAØ�q‰z˜QŠØ! ! "˜+�Ø# A B˜<‘Ø˜‘ Ò!Ø! # 2˜,�Ø# C R˜=‘ä Ð!?Ó@Ð@ð	Að €JÜ ¤ Y°Ó!8Ó9ò ‰ˆ‰8ˆB�Ø�Š8ØØ�Š7ÜÐ;Ó<Ð<Ü�H˜Q‘KÓ ˆÜ—i‘i¤§	¡	¨"£¨uÓ5ˆ�‰Ü˜xÓ(ò 	*‰EˆAˆrØ�AŠvØÜŸ'™' " b›/ˆH�QŠKð	*ð 	�bÑ‰
ðô �W‰W�V—\‘\“^ ZÓ0€FØ�8ÐÐr|   c                 ó$  — | j                   |k7  r$t        j                  | j                  «       |«      } |dk(  r@t	        t        j
                  dg«      gt        |«      z  «      }| j                  «       }||fS | j                  «       }| |   }||fS )NrÃ   r   )	re   r6   rL  ÚsqueezerY   r7   r@   rÛ   rk   )rî   r-  rQ  rP  s       r;   rJ  rJ  +  sƒ   € Ø‡w�w�)ÒÜ�O‰O˜AŸI™I›K¨Ó3ˆà�B‚Üœ"Ÿ(™( A 3›-˜¬3¨y«>Ñ9Ó:ˆØ—‘“ˆð �8ÐÐð —9‘9“;ˆØ�8‘ˆØ�8ÐÐr|   c                 óh  ‡ ‡— t        |t        «      rL|dk  s|t        ‰ ‰«      kD  rt        d«      ‚t	        t        ‰ |z
  ‰ «      «      }t	        t        |«      «      }n•t        |t        t        z  «      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rM   rÃ   )r8   r·  Úndim_as     €r;   r<   z _process_axes.<locals>.<genexpr>D  ó#   øè ø€ Ò=°ˆr�V‰|Ò+˜r V G™|Ó+Ñ=ùó   ƒc              3   ó8   •K  — | ]  }|‰k\  xs |‰ k  –— Œ y ­wrM   rÃ   )r8   r¸  Úndim_bs     €r;   r<   z _process_axes.<locals>.<genexpr>E  r  r  z/axes indices are out of bounds for input arraysz3axes must be an integer or a tuple/list of integersr   )
rX   r�   r°   rc   r*  r^   rY   r@   rd   rb   )r  r  r¹   Úaxes_aÚaxes_brŸ   s   ``    r;   r¹  r¹  8  s&  ù€ Ü�$œÔØ�!Š8�tœc &¨&Ó1Ò1ÜÐMÓNÐNÜ”e˜F T™M¨6Ó2Ó3ˆÜ”e˜D“kÓ"‰Ü	�Dœ%¤$™,Ô	'Üˆ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   Ã8D*ÄD/c                 ó  ‡ ‡— t        ˆ fd„‰D «       «      }t        ˆ fd„‰D «       «      }t        ||«      }t        ‰ j                  «      }t        ˆfd„t	        |«      D «       «      }|rct        ˆ fd„|D «       «      }t        ˆ fd„|D «       «      }t        ||«      }	|	|f}
t        j                  |«      t        j                  |«      f}n|f}
t        j                  |«      f}d}t        ‰ j                  |
f|¬«      }||fS )Nc              3   ó<   •K  — | ]  }‰j                   |   –— Œ y ­wrM   r‚   ©r8   r§   r'   s     €r;   r<   z!_convert_to_2d.<locals>.<genexpr>P  s   øè ø€ Ò4¨!˜Ÿ
™
 1�Ñ4ùrµ   c              3   ó<   •K  — | ]  }‰j                   |   –— Œ y ­wrM   rç   r  s     €r;   r<   z!_convert_to_2d.<locals>.<genexpr>Q  s   øè ø€ Ò2¨�s—y‘y •|Ñ2ùrµ   c              3   ó,   •K  — | ]  }|‰vsŒ|–— Œ y ­wrM   rÃ   )r8   r§   rŸ   s     €r;   r<   z!_convert_to_2d.<locals>.<genexpr>U  s   øè ø€ Ò=˜1¨q¸ª}”QÑ=ùs   ƒ	�c              3   ó<   •K  — | ]  }‰j                   |   –— Œ y ­wrM   r‚   r  s     €r;   r<   z!_convert_to_2d.<locals>.<genexpr>W  s   øè ø€ Ò@°! §
¡
¨1¥Ñ@ùrµ   c              3   ó<   •K  — | ]  }‰j                   |   –— Œ y ­wrM   rç   r  s     €r;   r<   z!_convert_to_2d.<locals>.<genexpr>X  s   øè ø€ Ò>°˜sŸy™y¨�|Ñ>ùrµ   rÃ   rç   )	rY   r�   r@   r_   r^   rÉ   rÊ   r   r`   )r'   rŸ   Úaxis_coordsÚ
axis_shapeÚ
axis_ravelrj   Únon_axisÚnon_axis_coordsÚnon_axis_shapeÚnon_axis_ravelÚ	coords_2dÚshape_2dÚnew_coos   ``           r;   r¨  r¨  O  sâ   ù€ ÜÓ4¨tÔ4Ó4€KÜÓ2¨TÔ2Ó2€JÜ˜{¨JÓ7€Jäˆs�z‰z‹?€DÜÓ=¤ d£Ô=Ó=€HÙÜÓ@°xÔ@Ó@ˆÜÓ>°XÔ>Ó>ˆÜ& ¸ÓGˆØ# ZÐ0ˆ	Ü—I‘I˜nÓ-¬t¯y©y¸Ó/DÐE‰à�Mˆ	Ü—I‘I˜jÓ)Ð+ˆØˆä˜Ÿ™ 9Ð-°XÔ>€GØ�NÐ"Ð"r|   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.   r3   ÚFz'order' must be 'C' or 'F'rˆ   )r@   rG   r   r6   r‹  rc   Úravel_multi_index)	r_   re   r†   ÚnrowsÚncolsr{   rx   r/   r:   s	            r;   r�   r�   e  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?

    .. 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 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
    )rX   r   )rî   s    r;   r   r   z  s   € ô@ �aœÓ$Ð$r|   c                   ó   — e Zd ZdZy)r   a7  
    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
    ----------
    data : ndarray
        COO format data array of the sparse array
    coords : tuple of ndarray
        COO format tuple of index arrays
    has_canonical_format : bool
        Whether the matrix has sorted coordinates and no duplicates
    dtype : dtype
        Data type of the array
    shape : tuple of integers
        Shape of the array
    ndim : int
        Number of dimensions of the array
    format : str
        Three letter code for the format of the array storage, e.g. 'coo'
    nnz : int
        Number of values stored in the array
    size : int
        Number of values stored in the array
    T : coo_array
        The transpose of the array
    mT : coo_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 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|   r;   r   r   ž  s   „ òqr|   r   c                   ó"   — e Zd ZdZd„ Zd„ Zd„ Zy)r   a÷  
    A sparse matrix in COOrdinate format.

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

    .. 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:
        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
    ----------
    data : ndarray
        COO format data array of the sparse matrix
    coords : tuple of ndarray
        COO format tuple of index matrix
    has_canonical_format : bool
        Whether the matrix has sorted coordinates and no duplicates
    dtype : dtype
        Data type of the matrix
    shape : tuple of integers
        Shape of the matrix
    ndim : int
        Number of dimensions of the matrix
    format : str
        Three letter code for the format of the matrix storage, e.g. 'coo'
    nnz : int
        Number of values stored in the matrix
    size : int
        Number of values stored in the matrix
    T : coo_matrix
        The transpose of the matrix
    mT : coo_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 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_   r{   rx   )rH  Ú__dict__Úupdate)rm   Ústates     r;   Ú__setstate__zcoo_matrix.__setstate__‘  s>   € Ø˜5Ñ ð  %Ÿy™y¨Ó/°·±¸5Ó1AÐBˆE�(‰OØ�‰×Ñ˜UÕ#r|   c                 ó   — t        d«      ‚)Nz('coo_matrix' object is not subscriptable©rb   )rm   r,  s     r;   rB  zcoo_matrix.__getitem__˜  s   € ÜÐBÓCÐCr|   c                 ó   — t        d«      ‚)Nz4'coo_matrix' object does not support item assignmentr4  )rm   r,  rî   s      r;   rZ  zcoo_matrix.__setitem__›  s   € ÜÐNÓOÐOr|   N)ró  rô  rõ  rù  r2  rB  rZ  rÃ   r|   r;   r   r     s   „ ñ{òz$òDóPr|   r   )r…   )7rù  Ú__docformat__Ú__all__rÉ   Úwarningsr   Únumpyr6   Ú
_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"   Ú_indexr#   r$   rE   r&   rÏ  rÐ  rI  rJ  r¹  r¨  r�   r   r   r   rÃ   r|   r;   ú<module>rA     s·   ðÙ 8à%€â
7€ã Ý ã å 'Ý ÷0÷ 0ñ 0÷ GÓ Fß .÷+÷ +÷ +ñ +÷ 9ã ôi+�˜mô i+òX-Fò2=ò2.òb
òò.#ó,<ò* %ôHr�	˜7ô rôjIP�˜9õ IPr|   