Ë
    çÿæi[\  ã                   óî   — d Z dZg d¢ZddlZddlmZmZ ddlm	Z	 dd	l
mZmZmZmZ dd
lmZ ddlmZ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  G d„ de«      Zd„ Z d„ Z! G d„ dee«      Z" G d„ de	e«      Z#y)zSparse DIAgonal formatzrestructuredtext en)Ú	dia_arrayÚ
dia_matrixÚisspmatrix_diaé    Né   )Ú_prune_arrayÚcopy_if_neededé   )Úspmatrix)ÚissparseÚ_formatsÚ_spbaseÚsparray)Ú_data_matrix)ÚisdenseÚisscalarlikeÚisshapeÚupcast_charÚgetdtypeÚget_sum_dtypeÚvalidateaxisÚcheck_shape)Ú
dia_matmatÚ
dia_matvecÚdia_matvecsÚ	dia_tocsrc                   óh  ‡ — e Zd ZdZdddœd„Zd„ Zd„ Zdd„Zej                  j                  e_	        dd„Z
ej                  j                  e
_	        dd	„Zej                  j                  e_	        dd
„Zˆ fd„Zd„ Zˆ fd„Zd„ Zd„ Zˆ fd„Zdd„Zdd„Zej(                  j                  e_	        dd„Zej*                  j                  e_	        dd„Zej,                  j                  e_	        dd„Zej.                  j                  e_	        dd„Zd„ Zej2                  j                  e_	        ˆ xZS )Ú	_dia_baseÚdiaN©Úmaxprintc                óÊ  — t        j                  | ||¬«       t        |«      rÙ|j                  dk(  rP|r|j	                  «       }|j
                  | _        |j                  | _        t        |j                  «      | _	        �nl|j                  | j                  k(  r|r|j	                  «       }n|j                  «       }|j
                  | _        |j                  | _        t        |j                  «      | _	        �nòt        |t        «      �r5t        |«      r}t        |«      | _	        t        j                  dt!        |t"        ¬«      «      | _        | j%                  t'        | j                  «      ¬«      }t        j                  d|¬«      | _        �nY	 |\  }}	|€t)        d«      ‚|st*        }t        j,                  t        j.                  |d   ||¬	«      «      | _        t        j.                  |d
   | j%                  t'        |«      ¬«      |¬	«      }	t        j0                  |	«      | _        t        |«      | _	        n¬	 t        j4                  |«      }t        | t6        «      r(|j8                  dk7  rt)        d|j8                  › d�«      ‚| j;                  |||¬«      j                  «       }|j
                  | _        |j                  | _        t        |j                  «      | _	        |�-t!        |«      }| j
                  j=                  |d¬«      | _        | j                  j8                  d
k7  rt)        d«      ‚| j
                  j8                  dk7  rt)        d«      ‚| j
                  j                  d   t?        | j                  «      k7  r<t)        d| j
                  j                  d   › dt?        | j                  «      › d�«      ‚t?        t        j@                  | j                  «      «      t?        | j                  «      k7  rt)        d«      ‚y # t2        $ r}
d}t)        |«      |
‚d }
~
ww xY w# t2        $ r}
t)        d| j                  › d�«      |
‚d }
~
ww xY w)Nr   r   )r   r   )Údefault©Úmaxvalr   ©Údtypezexpected a shape argument)r&   Úcopyr	   z+unrecognized form for dia_array constructorzunrecognized form for z_matrix constructorr   zDIA arrays don't support zD input. Use 2D)r&   ÚshapeF©r'   zoffsets array must have rank 1zdata array must have rank 2znumber of diagonals (z() does not match the number of offsets (Ú)z&offset array contains duplicate values)!r   Ú__init__r   Úformatr'   ÚdataÚoffsetsr   r(   Ú_shapeÚtodiaÚ
isinstanceÚtupler   ÚnpÚzerosr   ÚfloatÚ_get_index_dtypeÚmaxÚ
ValueErrorr   Ú
atleast_2dÚarrayÚ
atleast_1dÚ	ExceptionÚasarrayr   ÚndimÚ_coo_containerÚastypeÚlenÚunique)ÚselfÚarg1r(   r&   r'   r    ÚAÚ	idx_dtyper-   r.   ÚeÚmessageÚnewdtypes                úf/Volumes/fast/ai/experiments/voice-extract-mac/.venv/lib/python3.12/site-packages/scipy/sparse/_dia.pyr+   z_dia_base.__init__   s‚  € Ü×Ñ˜d D°8Õ<ä�DŒ>Ø�{‰{˜eÒ#ÙØŸ9™9›;�DØ ŸI™I�”	Ø#Ÿ|™|�”Ü)¨$¯*©*Ó5�–à—;‘; $§+¡+Ò-±$ØŸ	™	›‘AàŸ
™
›�AØŸF™F�”	Ø Ÿy™y�”Ü)¨!¯'©'Ó2�–Ü˜œeÕ$Ü�tŒ}ô *¨$Ó/�”ÜŸH™H U¬H°UÄEÔ,JÓK�”	Ø ×1Ñ1¼¸T¿Z¹Z»Ð1ÓI�	Ü!Ÿx™x¨°9Ô=�–ð5à$(‘M�D˜'ð
 �}Ü(Ð)DÓEÐEÙÜ-˜Ü "§¡¬b¯h©h°t¸A±wÀeÐRVÔ.WÓ X�D”IÜ Ÿh™h t¨A¡wØ-1×-BÑ-BÌ#ÈeË*Ð-BÓ-UØ,0ô2�Gô $&§=¡=°Ó#9�D”LÜ"-¨eÓ"4�D•KðMÜ—z‘z $Ó'�ô ˜$¤Ô(¨T¯Y©Y¸!ª^Ü Ð#<¸T¿Y¹Y¸KÀÐ!WÓXÐXØ×#Ñ# D°¸UÐ#ÓC×IÑIÓKˆAØŸ™ˆDŒIØŸ9™9ˆDŒLÜ% a§g¡gÓ.ˆDŒKàÐÜ “ˆHØŸ	™	×(Ñ(¨¸Ð(Ó>ˆDŒIð �<‰<×Ñ Ò!ÜÐ=Ó>Ð>à�9‰9�>‰>˜QÒÜÐ:Ó;Ð;à�9‰9�?‰?˜1Ñ¤ T§\¡\Ó!2Ò2ÜØ'¨¯	©	¯©¸Ñ(:Ð';ð <Ü" 4§<¡<Ó0Ð1°ð4óð ô Œr�y‰y˜Ÿ™Ó&Ó'¬3¨t¯|©|Ó+<Ò<ÜÐEÓFÐFð =øôY !ò 5ØK�GÜ$ WÓ-°1Ð4ûð5ûô$ ò MÜ Ð!9Ø$(§K¡K =Ð0Cð"Eó FØKLðMûðMús0   ÆP ÉP: Ð	P7Ð$P2Ð2P7Ð:	Q"ÑQÑQ"c                 óî   — t         | j                     \  }}t        | t        «      rdnd}| j                  j
                  d   }d|› d|› d| j                  › d| j                  › d|› d	| j
                  › d
�S )Nr:   Úmatrixr   Ú<z sparse z of dtype 'z'
	with z stored elements (z diagonals) and shape Ú>)r   r,   r1   r   r-   r(   r&   Únnz)rC   Ú_ÚfmtÚ
sparse_clsÚds        rJ   Ú__repr__z_dia_base.__repr__d   s|   € Ü˜$Ÿ+™+Ñ&‰ˆˆ3Ü *¨4´Ô 9‘W¸xˆ
Ø�I‰I�O‰O˜AÑˆà�ˆu�H˜Z˜L¨°D·J±J°<ð @Ø—h‘h�ZÐ1°!°Ð4JÈ4Ï:É:È,ÐVWðYð	
ó    c                 óÒ   — | j                   \  }}t        j                  | j                  j                   d   «      }|| j                  dd…df   z
  }|dk\  }|||k  z  }|||k  z  }|S )z~Returns a mask of the same shape as self.data, where
        mask[i,j] is True when data[i,j] corresponds to a stored element.r	   Nr   )r(   r3   Úaranger-   r.   )rC   Únum_rowsÚnum_colsÚoffset_indsÚrowÚmasks         rJ   Ú
_data_maskz_dia_base._data_maskm   so   € ð "ŸZ™ZÑˆ�(Ü—i‘i §	¡	§¡°Ñ 2Ó3ˆØ˜DŸL™Lª¨4¨Ñ0Ñ0ˆØ�q‘ˆØ��x‘Ñ ˆØ�˜xÑ'Ñ(ˆØˆrU   c                 ó€   — |�t        d«      ‚| j                  «       }t        j                  | j                  |   «      S )Nz<count_nonzero over an axis is not implemented for DIA format)ÚNotImplementedErrorr]   r3   Úcount_nonzeror-   )rC   Úaxisr\   s      rJ   r`   z_dia_base.count_nonzerox   s?   € ØÐÜ%ØNóð ð �‰Ó ˆÜ×Ñ §	¡	¨$¡Ó0Ð0rU   c           	      ó^  — |�t        d«      ‚| j                  \  }}t        | j                  j                  d   |«      }t	        t        j                  t        j                  || j                  z   |«      t        j                  | j                  d«      z
  d«      j                  «       «      S )Nz6_getnnz over an axis is not implemented for DIA formatr	   r   )
r_   r(   Úminr-   Úintr3   ÚmaximumÚminimumr.   Úsum)rC   ra   ÚMÚNÚLs        rJ   Ú_getnnzz_dia_base._getnnz‚   s�   € ØÐÜ%ð '7ó 8ð 8à�z‰z‰ˆˆ1Ü�—	‘	—‘ Ñ" AÓ&ˆÜ”2—:‘:œbŸj™j¨¨T¯\©\Ñ)9¸1Ó=Ü Ÿj™j¨¯©°qÓ9ñ:àó!ç!$¡£ó(ð 	(rU   c           
      ó:  — t        |«      }t        | j                  «      }| j                  \  }}d }|dk(  r‹| j	                  «       }| j
                  |z  j                  d¬«      }	|	j                  d   |k(  r|	}
n3t        j                  ||	j                  ¬«      }
|	|
d |	j                  d    | j                  |
|¬«      }nÇt        j                  |df|¬«      }t        j                  ||¬«      }t        ||t        | j                  «      | j
                  j                  d   | j                  | j
                  ||«       | j                  |«      }|€|j                  ||¬«      S | j                  |j                  |¬«      «      }|j                  d||¬«      S )	N©r   r   )ra   r%   r	   )r&   Úout© )ra   r&   rn   )r   r   r&   r(   r]   r-   rg   r3   r4   Ú_ascontainerÚonesr   rA   r.   )rC   ra   r&   rn   Ú	res_dtyperX   rY   Úretr\   ÚxÚresÚrow_sumsÚones                rJ   rg   z_dia_base.sumŽ   sf  € Ü˜DÓ!ˆä! $§*¡*Ó-ˆ	Ø!ŸZ™ZÑˆ�(Øˆà�4Š<Ø—?‘?Ó$ˆDØ—‘˜TÑ!×&Ñ&¨AÐ&Ó.ˆAØ�w‰w�q‰z˜XÒ%Ø‘ä—h‘h˜x¨q¯w©wÔ7�Ø#$��K�Q—W‘W˜Q‘ZÐ Ø×#Ñ# C¨yÐ#Ó9‰Cô —x‘x ¨1 °YÔ?ˆHÜ—'‘'˜(¨)Ô4ˆCÜ�x ¬3¨t¯|©|Ó+<Ø—y‘y—‘ qÑ)¨4¯<©<¸¿¹ÀCÈôSð ×(Ñ(¨Ó2ˆHàˆ|Ø—|‘|¨%°S�|Ó9Ð9à×#Ñ# H§L¡L°d LÓ$;Ó<ˆCà�w‰w˜B e°ˆwÓ5Ð5rU   c                 óF  — t        |t        «      s|j                  | «      S t        j                  | j
                  |j
                  «      rG| j                  |r| j                  |j                  z
  «      S | j                  |j                  z   «      S t        j                  | j
                  |j
                  «      }t        j                  || j
                  «      }t        j                  ||j
                  «      }| j                  j                  d   }|j                  j                  d   }||k(  rut        |«      t        | j
                  «      k(  rT| j                  t        |«         }|r||d d …fxx   |j                  z  cc<   �nx||d d …fxx   |j                  z  cc<   �n[||k(  rqt        |«      t        |j
                  «      k(  rP|r|j                  t        |«          }n|j                  t        |«         }||d d …fxx   | j                  z  cc<   nåt        | j                  d   |d   z   | j                  d   «      }	t        j                  t        |«      |	ft        j                  | j                  |j                  «      ¬«      }||d |…fxx   | j                  d d …d |	…f   z  cc<   |r%||d |…fxx   |j                  d d …d |	…f   z  cc<   n$||d |…fxx   |j                  d d …d |	…f   z  cc<   | j!                  ||f| j                  ¬«      S )Nr	   r   éÿÿÿÿr%   ©r(   )r1   r   Ú_add_sparser3   Úarray_equalr.   Ú
_with_datar-   Úunion1dÚsearchsortedr(   rA   Ú_invert_indexrc   r4   Úresult_typeÚ_dia_container)
rC   ÚotherÚsubÚnew_offsetsÚself_idxÚ	other_idxÚself_dÚother_dÚnew_datarS   s
             rJ   r{   z_dia_base._add_sparse°   s›  € ä˜%¤Ô+Ø×$Ñ$ TÓ*Ð*ô �>‰>˜$Ÿ,™,¨¯©Ô6Ø—?‘?¹S 4§9¡9¨u¯z©zÑ#9ó ;ð ;Ø#'§9¡9¨u¯z©zÑ#9ó;ð ;ô —j‘j §¡¨u¯}©}Ó=ˆÜ—?‘? ;°·±Ó=ˆÜ—O‘O K°·±Ó?ˆ	à—‘—‘ Ñ#ˆØ—*‘*×"Ñ" 1Ñ%ˆð �WÒ¤ [Ó!1´S¸¿¹Ó5FÒ!FØ—y‘y¤¨xÓ!8Ñ9ˆHÙØ˜¢A˜Ó&¨%¯*©*Ñ4Õ&à˜¢A˜Ó&¨%¯*©*Ñ4Õ&Ø�wÒ¤3 {Ó#3´s¸5¿=¹=Ó7IÒ#IÙØ!ŸJ™J¤}°YÓ'?Ñ@Ð@‘à Ÿ:™:¤m°IÓ&>Ñ?�Ø�Xšq�[Ó! T§Y¡YÑ.Ô!ô �D—J‘J˜q‘M K°¡OÑ3°T·Z±ZÀ±]ÓCˆAô —x‘xÜ�[Ó! 1Ð%Ü—n‘n T§Y¡Y°·
±
Ó;ôˆHð �X˜w ˜wÐ&Ó'¨4¯9©9²Q¸¸¸°UÑ+;Ñ;Ó'ÙØ˜ H W HÐ,Ó-°·±ºA¸rÀ¸r¸EÑ1BÑBÔ-à˜ H W HÐ,Ó-°·±ºA¸rÀ¸r¸EÑ1BÑBÓ-Ø×"Ñ" H¨kÐ#:À$Ç*Á*Ð"ÓMÐMrU   c                 óh   •— t        |t        «      st        ‰| �  |«      S | j	                  |d¬«      S )NT)r„   )r1   r   ÚsuperÚ_sub_sparser{   )rC   rƒ   Ú	__class__s     €rJ   r�   z_dia_base._sub_sparseß   s3   ø€ ä˜%¤Ô+Ü‘7Ñ& uÓ-Ð-à×Ñ ¨4ÐÓ0Ð0rU   c                 ó>   — | j                  | j                  |z  «      S ©N)r}   r-   )rC   rƒ   s     rJ   Ú_mul_scalarz_dia_base._mul_scalaræ   s   € Ø�‰˜tŸy™y¨5Ñ0Ó1Ð1rU   c                 óP  •— t        |«      r| j                  |«      S t        |«      �r•|j                  dkD  r| j	                  «       |z  S d| j
                  v sd| j
                  v sd|j
                  v rt        ‰| �  |«      S t        j                  |«      }|j
                  \  }}| j
                  \  }}t        | j                  j
                  d   |«      }| j                  d d …d |…f   j                  t        j                  | j                  |«      «      }|dk(  r||dd |…f   z  }n||k7  rt        d«      ‚t        j                  |«      }||kD  r|| j                   d d …d f   z
  |z  }	n|| j                   d d …d f   |z  z
  }	|dk(  rd}n||k7  rt        d«      ‚|||	|f   z  }| j#                  |«      S t%        |t&        «      r|j
                  | j
                  k7  rt        ‰| �  |«      S t        j(                  | j                   |j                   dd¬«      \  }
}}t        | j                  j
                  d   |j                  j
                  d   «      }| j                  |d |…f   |j                  |d |…f   z  }| j+                  ||
f| j
                  ¬«      S )Nr   r   r	   zinconsistent shapesT)Úassume_uniqueÚreturn_indicesrz   )r   r‘   r   r>   Útoarrayr(   rŒ   Úmultiplyr3   r9   rc   r-   r@   r�   r8   rW   r.   r}   r1   r   Úintersect1dr‚   )rC   rƒ   Ú
other_rowsÚ
other_colsÚrowsÚcolsrj   r-   ÚjÚir.   r†   r‡   rŽ   s                €rJ   r–   z_dia_base.multiplyé   sk  ø€ Ü˜ÔØ×#Ñ# EÓ*Ð*ä�5�>Ø�z‰z˜AŠ~Ø—|‘|“~¨Ñ-Ð-ð �D—J‘J‰ ! t§z¡z¡/°Q¸%¿+¹+Ñ5EÜ‘wÑ'¨Ó.Ð.ä—M‘M %Ó(ˆEØ%*§[¡[Ñ"ˆJ˜
ØŸ™‰JˆD�$Ü�D—I‘I—O‘O AÑ&¨Ó-ˆAØ—9‘9šQ   ˜UÑ#×*Ñ*¬2¯>©>¸$¿)¹)ÀUÓ+KÓLˆDØ˜QŠØ˜˜a  ! ˜e™Ñ$‘Ø˜tÒ#Ü Ð!6Ó7Ð7ä—I‘I˜a“L�Ø�t’8Ø˜TŸ\™\ª!¨T¨'Ñ2Ñ2°dÑ:‘Aà˜DŸL™Lª¨D¨Ñ1°DÑ8Ñ8�AØ ’?Ø‘AØ 4Ò'Ü$Ð%:Ó;Ð;Ø˜˜a ˜d™Ñ#�Ø—?‘? 4Ó(Ð(ô ˜%¤Ô+¨u¯{©{¸d¿j¹jÒ/HÜ‘7Ñ# EÓ*Ð*ô
 �N‰N˜4Ÿ<™<¨¯©Ø)-¸dôDñ 	%ˆ�˜9ô �—	‘	—‘ Ñ" E§J¡J×$4Ñ$4°QÑ$7Ó8ˆØ�y‰y˜ 2 A 2˜Ñ&¨¯©°I¸rÀ¸r°MÑ)BÑBˆØ×"Ñ" D¨' ?¸$¿*¹*Ð"ÓEÐErU   c                 ó°  — |}t        j                  | j                  d   t        | j                  j
                  |j                  j
                  «      ¬«      }| j                  j                  d   }| j                  \  }}t        ||t        | j                  «      || j                  | j                  |j                  «       |j                  «       «       |S )Nr   r%   r	   )r3   r4   r(   r   r&   Úcharr-   r   rA   r.   Úravel)rC   rƒ   rt   Úyrj   rh   ri   s          rJ   Ú_matmul_vectorz_dia_base._matmul_vector  s›   € Øˆä�H‰H�T—Z‘Z ‘]¬+°d·j±j·o±oØ78·w±w·|±|ó+Eô Fˆð �I‰I�O‰O˜AÑˆà�j‰j‰ˆˆ!ä�1�Qœ˜DŸL™LÓ)¨1¨d¯l©l¸D¿I¹IØ—7‘7“9˜aŸg™g›iô	)ð ˆrU   c                 óT  — t        j                  | j                  d   |j                  d   ft        j                  | j                  |«      ¬«      }t        g | j                  ¢| j                  j                  ¢| j                  ‘| j                  ‘|j                  d   ‘|‘|‘­Ž  |S )Nr   r	   r%   )r3   r4   r(   r�   r-   r   r.   )rC   rƒ   ru   s      rJ   Ú_matmul_multivectorz_dia_base._matmul_multivector)  s–   € Ü�h‰h˜Ÿ
™
 1™ u§{¡{°1¡~Ð6ÜŸ^™^¨D¯I©I°uÓ=ô?ˆäð 	0�T—Z‘Zð 	0 $§)¡)§/¡/ð 	0°4·<±<ð 	0ÀÇÁð 	0Ø—K‘K ‘Nð	0Ø$)ð	0Ø+.ó	0àˆ
rU   c                 ól  •— t        |t        «      st        ‰| �  |«      S d| j                  v sd|j                  v r-| j                  | j                  d   |j                  d   f«      S t        g | j                  ¢| j                  j                  ¢| j                  ‘| j                  ‘|j                  d   ‘|j                  j                  ¢|j                  ‘|j                  ‘­Ž \  }}| j                  |j                  t        |«      d«      |f| j                  d   |j                  d   f«      S )Nr   r	   ry   )r1   r   rŒ   Ú_matmul_sparser(   r‚   r   r-   r.   ÚreshaperA   )rC   rƒ   r.   r-   rŽ   s       €rJ   r¦   z_dia_base._matmul_sparse0  s  ø€ ä˜%¤Ô+Ü‘7Ñ)¨%Ó0Ð0ð �—
‘
‰?˜a 5§;¡;Ñ.Ø×&Ñ&¨¯
©
°1©°u·{±{À1±~Ð'FÓGÐGä"ð > D§J¡Jð >°·±·±ð >Ø#'§<¡<ð>Ø15·±ð>à#(§;¡;¨q¡>ð>à49·J±J×4DÑ4Dð>ð $)§=¡=ð>ð 38·*±*ò>‰ˆ�ð ×"Ñ" D§L¡L´°W³¸rÓ$BÀGÐ#LØ$(§J¡J¨q¡M°5·;±;¸q±>Ð#BóDð 	DrU   c                 ó€  — | j                   \  }}|j                  dk(  rt        j                  }nt	        |«      }|dk  rt        ||z   ||«      }d}|}nt        |||z
  |«      }|}||z   }|j                  dk7  r|d | }| j                  j                   \  }	}
|| j                  v ro||
kD  rIt        j                  |	|f| j                  j                  ¬«      }| j                  |d d …d |
…f<   || _        || j                  | j                  |k(  ||…f<   y t        j                  | j                  | j                  j                  j                  |«      «      | _        t        ||
«      }t        j                  |	dz   |f| j                  j                  ¬«      }| j                  |d d…d |
…f<   ||d||…f<   || _        y )Nr   r%   r	   ry   )r(   r>   r3   ÚinfrA   rc   r-   r.   r4   r&   ÚappendÚtyper7   )rC   ÚvaluesÚkrh   ri   Úvalues_nÚnÚ	min_indexÚ	max_indexÚ	data_rowsÚ	data_colsr-   Úms                rJ   Ú_setdiagz_dia_base._setdiag@  s•  € Ø�z‰z‰ˆˆ1à�;‰;˜!Òä—v‘v‰Hä˜6“{ˆHàˆqŠ5Ü�A˜‘E˜1˜hÓ'ˆAØˆIØ‰Iä�A�q˜1‘u˜hÓ'ˆAØˆIØ˜A™ˆIà�;‰;˜!Òà˜B˜Q�ZˆFà#Ÿy™yŸ™Ñˆ	�9Ø�—‘ÑØ˜9Ò$Ü—x‘x ¨IÐ 6¸d¿i¹i¿o¹oÔN�Ø&*§i¡i�’Q˜
˜˜
�]Ñ#Ø �”	Ø@FˆD�I‰I�d—l‘l aÑ'¨°9Ð)<Ð<Ò=äŸ9™9 T§\¡\°4·<±<×3EÑ3E×3JÑ3JÈ1Ó3MÓNˆDŒLÜ�I˜yÓ)ˆAÜ—8‘8˜Y¨™]¨AÐ.°d·i±i·o±oÔFˆDØ$(§I¡IˆD��"��j�y�j�Ñ!Ø,2ˆD��Y˜yÐ(Ð(Ñ)ØˆD�IrU   c                 ó*   — |r| j                  «       S | S r�   r)   )rC   r'   s     rJ   r0   z_dia_base.todiae  s   € ÙØ—9‘9“;ÐàˆKrU   c                 ó¦  — |�|dk7  rt        d«      ‚| j                  \  }}t        | j                  «      }| j                   }t	        j
                  t        |«      t        j                  ¬«      d d …d f   }t	        j
                  |t        j                  ¬«      ||z  d d …d f   z
  }t        d|| j                  j                  d   z
  «      }	t	        j                  | j                  t	        j                  | j                  j                  d   |	f| j                  j                  ¬«      f«      }
|
||f   }
| j                  |
|f||f|¬«      S )N)r	   r   zvSparse arrays/matrices do not support an 'axes' parameter because swapping dimensions is the only logical permutation.r%   r   r	   )r(   r'   )r8   r(   r7   r.   r3   rW   rA   Úintcr-   Úhstackr4   r&   r‚   )rC   Úaxesr'   rX   rY   Úmax_dimr.   ÚrÚcÚ
pad_amountr-   s              rJ   Ú	transposez_dia_base.transposem  s3  € ØÐ ¨¢Üð Ló Mð Mð "ŸZ™ZÑˆ�(Ü�d—j‘j“/ˆð —<‘<�-ˆô �I‰I”c˜'“l¬"¯'©'Ô2²1°d°7Ñ;ˆÜ�I‰I�h¤b§g¡gÔ.°'¸GÑ2CÂQÈÀWÑ1MÑMˆÜ˜˜G D§I¡I§O¡O°AÑ$6Ñ6Ó7ˆ
Ü�y‰y˜$Ÿ)™)¤R§X¡X¨t¯y©y¯©¸qÑ/AÀ:Ð.NØ48·I±I·O±Oô&Eð Fó Gˆà�A�q�D‰zˆØ×"Ñ" D¨' ?Ø�hð; Ø&*ð #ó ,ð 	,rU   c                 ó  — | j                   \  }}|| k  s||k\  r+t        j                  d| j                  j                  ¬«      S t        j
                  | j                  |k(  «      \  }t        d|«      }t        ||z   |«      }||z
  }|j                  dk(  r+t        j                  || j                  j                  ¬«      S | j                  |d   ||…f   }|t        |«      z
  }	|	dkD  rt        j                  |d|	fd¬«      }|S )Nr   r%   Úconstant)Úmode)r(   r3   Úemptyr-   r&   Únonzeror.   r7   rc   Úsizer4   rA   Úpad)
rC   r­   rš   r›   ÚidxÚ	first_colÚlast_colÚresult_sizeÚresultÚpaddings
             rJ   Údiagonalz_dia_base.diagonal…  så   € Ø—Z‘Z‰
ˆˆdØ��Š:˜˜dšÜ—8‘8˜A T§Y¡Y§_¡_Ô5Ð5Ü�z‰z˜$Ÿ,™,¨!Ñ+Ó,‰ˆÜ˜˜1“Iˆ	Ü�t˜a‘x Ó&ˆØ Ñ*ˆØ�8‰8�qŠ=Ü—8‘8˜K¨t¯y©y¯©Ô?Ð?Ø—‘˜3˜q™6 9¨XÐ#5Ð5Ñ6ˆØ¤ F£Ñ+ˆØ�QŠ;Ü—V‘V˜F Q¨ L°zÔBˆFØˆrU   c                 óÖ  — d| j                   v st        | j                  «      dk(  r'| j                  | j                   | j                  ¬«      S | j                   \  }}| j
                  }| j                  t        |||«      ¬«      }t        j                  | j                  «      j                  |d¬«      }t        j                  || j                  ¬«      }t        j                  ||¬«      }t        j                  d|z   |¬«      }	t        ||g| j                  j                   ¢| j                  j                  |d¬«      ‘| j                  ‘|‘|‘|‘|	‘­Ž }
| j                  t        |
||«      ¬«      }t        |d |
 «      }t        |d |
 j                  |d¬«      «      }|	j                  |d¬«      }	| j                  |||	f| j                   | j                  ¬«      }d|_        |S )	Nr   r%   r#   Fr)   r	   )r(   r&   T)r(   rA   r.   Ú_csr_containerr&   rO   r6   r7   r3   Úargsortr@   rÃ   r   r-   r   Úhas_canonical_format)rC   r'   Ún_rowsÚn_colsÚmax_nnzrF   ÚorderÚcsr_dataÚindicesÚindptrrO   rn   s               rJ   Útocsrz_dia_base.tocsr—  sÇ  € Ø�—
‘
‰?œc $§,¡,Ó/°1Ò4Ø×&Ñ& t§z¡z¸¿¹Ð&ÓDÐDàŸ™‰ˆ�Ø—(‘(ˆð
 ×)Ñ)´°W¸fÀfÓ1MÐ)ÓNˆ	Ü—
‘
˜4Ÿ<™<Ó(×/Ñ/°	ÀÐ/ÓFˆÜ—8‘8˜G¨4¯:©:Ô6ˆÜ—(‘(˜7¨)Ô4ˆÜ—‘˜!˜f™*¨IÔ6ˆä˜ ð :¨¯©¯©ð :ØŸ™×+Ñ+¨I¸EÐ+ÓBð:ØDHÇIÁIð:àð:à'ð:à)0ð:à28ò:ˆð ×)Ñ)´°S¸&À&Ó1IÐ)ÓJˆ	Ü ¨¨# Ó/ˆÜ˜w t¨˜}×3Ñ3°IÀEÐ3ÓJÓKˆØ—‘˜y¨u�Ó5ˆØ×!Ñ! 8¨W°fÐ"=Ø(,¯
©
¸$¿*¹*ð "ó Fˆà#'ˆÔ Øˆ
rU   c                 óÆ   — |r7| j                  || j                  j                  «       f| j                  ¬«      S | j                  || j                  f| j                  ¬«      S )z‘Returns a matrix with the same sparsity structure as self,
        but with different data.  By default the structure arrays are copied.
        rz   )r‚   r.   r'   r(   )rC   r-   r'   s      rJ   r}   z_dia_base._with_data·  sf   € ñ Ø×&Ñ&Ø�t—|‘|×(Ñ(Ó*Ð+°4·:±:ð 'ó ð ð ×&Ñ&Ø�t—|‘|Ð$¨D¯J©Jð 'ó ð rU   c                 óÚ  — t        |«      }|\  }}| j                  d d …d |…f   | _        || j                  d   kD  r¨t        j                  | j
                  | j                  d   z   | j                  j                  d   k  «      r_| j
                  d d …d f   | j                  d   z   t        j                  | j                  j                  d   «      k  }d| j                  |<   || _        y )Nr   r	   )r   r-   r(   r3   Úanyr.   rW   r/   )rC   r(   rh   ri   r\   s        rJ   Úresizez_dia_base.resizeÄ  s½   € Ü˜EÓ"ˆØ‰ˆˆ1à—I‘Iša  ! ˜eÑ$ˆŒ	à�—
‘
˜1‘ÒÜ—‘�t—|‘| d§j¡j°¡mÑ3°d·i±i·o±oÀaÑ6HÑHÔIà—L‘L¢ D Ñ)¨D¯J©J°q©MÑ9Ü—I‘I˜dŸi™iŸo™o¨aÑ0Ó1ñ2ˆDàˆD�I‰I�d‰Oàˆ�rU   )NNFr�   )NNN)Frm   )NF)T)Ú__name__Ú
__module__Ú__qualname__Ú_formatr+   rT   r]   r`   r   Ú__doc__rk   rg   r{   r�   r‘   r–   r¢   r¤   r¦   rµ   r0   r¿   rÍ   rÙ   r}   rÝ   Ú__classcell__)rŽ   s   @rJ   r   r      s"  ø„ Ø€GðKGÈTô KGòZ
ò	ó1ð $×1Ñ1×9Ñ9€MÔó(ð —o‘o×-Ñ-€G„Oó6ð@ —+‘+×%Ñ%€C„Kó-Nô^1ò2ô/FòbòôDó #óJð —M‘M×)Ñ)€E„Mó,ð,  ×)Ñ)×1Ñ1€IÔóð  ×'Ñ'×/Ñ/€HÔóð: —M‘M×)Ñ)€E„Móòð —^‘^×+Ñ+€F‡N€NrU   r   c                 ór   — t        j                  | «      }t        j                  t        | «      «      || <   |S )z)Helper function to invert an index array.)r3   Ú
zeros_likerW   rA   )rÇ   Úinvs     rJ   r€   r€   Ö  s+   € ä
�-‰-˜Ó
€CÜ�y‰yœ˜S›Ó"€Cˆ�HØ€JrU   c                 ó"   — t        | t        «      S )aÒ  Is `x` of dia_matrix type?

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

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

    Examples
    --------
    >>> from scipy.sparse import dia_array, dia_matrix, coo_matrix, isspmatrix_dia
    >>> isspmatrix_dia(dia_matrix([[5]]))
    True
    >>> isspmatrix_dia(dia_array([[5]]))
    False
    >>> isspmatrix_dia(coo_matrix([[5]]))
    False
    )r1   r   )rt   s    rJ   r   r   Ý  s   € ô. �aœÓ$Ð$rU   c                   ó   — e Zd ZdZy)r   a<  
    Sparse array with DIAgonal storage.

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

        dia_array(S)
            with another sparse array or matrix S (equivalent to S.todia())

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

        dia_array((data, offsets), shape=(M, N))
            where the ``data[k,:]`` stores the diagonal entries for
            diagonal ``offsets[k]`` (See example below)

    Attributes
    ----------
    dtype : dtype
        Data type of the array
    shape : 2-tuple
        Shape of the array
    ndim : int
        Number of dimensions (this is always 2)
    nnz
    size
    data
        DIA format data array of the array
    offsets
        DIA format offset array of the array
    T

    Notes
    -----

    Sparse arrays can be used in arithmetic operations: they support
    addition, subtraction, multiplication, division, and matrix power.
    Sparse arrays with DIAgonal storage do not support slicing.

    Examples
    --------

    >>> import numpy as np
    >>> from scipy.sparse import dia_array
    >>> dia_array((3, 4), dtype=np.int8).toarray()
    array([[0, 0, 0, 0],
           [0, 0, 0, 0],
           [0, 0, 0, 0]], dtype=int8)

    >>> data = np.array([[1, 2, 3, 4]]).repeat(3, axis=0)
    >>> offsets = np.array([0, -1, 2])
    >>> dia_array((data, offsets), shape=(4, 4)).toarray()
    array([[1, 0, 3, 0],
           [1, 2, 0, 4],
           [0, 2, 3, 0],
           [0, 0, 3, 4]])

    >>> from scipy.sparse import dia_array
    >>> n = 10
    >>> ex = np.ones(n)
    >>> data = np.array([ex, 2 * ex, ex])
    >>> offsets = np.array([-1, 0, 1])
    >>> dia_array((data, offsets), shape=(n, n)).toarray()
    array([[2., 1., 0., ..., 0., 0., 0.],
           [1., 2., 1., ..., 0., 0., 0.],
           [0., 1., 2., ..., 0., 0., 0.],
           ...,
           [0., 0., 0., ..., 2., 1., 0.],
           [0., 0., 0., ..., 1., 2., 1.],
           [0., 0., 0., ..., 0., 1., 2.]])
    N©rÞ   rß   rà   râ   ro   rU   rJ   r   r   ø  ó   „ òHrU   r   c                   ó   — e Zd ZdZy)r   aO  
    Sparse matrix with DIAgonal storage.

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

        dia_matrix(S)
            with another sparse array or matrix S (equivalent to S.todia())

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

        dia_matrix((data, offsets), shape=(M, N))
            where the ``data[k,:]`` stores the diagonal entries for
            diagonal ``offsets[k]`` (See example below)

    Attributes
    ----------
    dtype : dtype
        Data type of the matrix
    shape : 2-tuple
        Shape of the matrix
    ndim : int
        Number of dimensions (this is always 2)
    nnz
    size
    data
        DIA format data array of the matrix
    offsets
        DIA format offset array of the matrix
    T

    Notes
    -----

    Sparse matrices can be used in arithmetic operations: they support
    addition, subtraction, multiplication, division, and matrix power.
    Sparse matrices with DIAgonal storage do not support slicing.

    Examples
    --------

    >>> import numpy as np
    >>> from scipy.sparse import dia_matrix
    >>> dia_matrix((3, 4), dtype=np.int8).toarray()
    array([[0, 0, 0, 0],
           [0, 0, 0, 0],
           [0, 0, 0, 0]], dtype=int8)

    >>> data = np.array([[1, 2, 3, 4]]).repeat(3, axis=0)
    >>> offsets = np.array([0, -1, 2])
    >>> dia_matrix((data, offsets), shape=(4, 4)).toarray()
    array([[1, 0, 3, 0],
           [1, 2, 0, 4],
           [0, 2, 3, 0],
           [0, 0, 3, 4]])

    >>> from scipy.sparse import dia_matrix
    >>> n = 10
    >>> ex = np.ones(n)
    >>> data = np.array([ex, 2 * ex, ex])
    >>> offsets = np.array([-1, 0, 1])
    >>> dia_matrix((data, offsets), shape=(n, n)).toarray()
    array([[2., 1., 0., ..., 0., 0., 0.],
           [1., 2., 1., ..., 0., 0., 0.],
           [0., 1., 2., ..., 0., 0., 0.],
           ...,
           [0., 0., 0., ..., 2., 1., 0.],
           [0., 0., 0., ..., 1., 2., 1.],
           [0., 0., 0., ..., 0., 1., 2.]])
    Nré   ro   rU   rJ   r   r   D  rê   rU   r   )$râ   Ú__docformat__Ú__all__Únumpyr3   Ú
_lib._utilr   r   Ú_matrixr
   Ú_baser   r   r   r   Ú_datar   Ú_sputilsr   r   r   r   r   r   r   r   Ú_sparsetoolsr   r   r   r   r   r€   r   r   r   ro   rU   rJ   Ú<module>rõ      sv   ðÙ à%€â
7€ã ç 5Ý ß 7Ó 7Ý ÷÷ ó ÷ IÓ Hô,�ô ,òDò%ô6I�	˜7ô IôXI�˜9õ IrU   