§
    µ³ÙgÓN  ã                   óê   — d Z dZg d¢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 dd
lmZ ddlmZmZmZmZmZmZ ddlmZ  G d„ de¦  «        Zd„ Zd„ Z G d„ dee¦  «        Z G d„ dee¦  «        ZdS )zSparse DIAgonal formatzrestructuredtext en)Ú	dia_arrayÚ
dia_matrixÚisspmatrix_diaé    Né   )Úcopy_if_neededé   )Úspmatrix)ÚissparseÚ_formatsÚ_spbaseÚsparray)Ú_data_matrix)ÚisshapeÚupcast_charÚgetdtypeÚget_sum_dtypeÚvalidateaxisÚcheck_shape)Ú
dia_matvecc                   óÆ  — 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„ Zd„ Z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ej        j	        e_	        dd„Zd„ Zej        j	        e_	        dS )Ú	_dia_baseÚdiaNF©Úmaxprintc                óÌ  — t          j        | ||¬¦  «         t          |¦  «        rÂ|j        dk    rI|r|                     ¦   «         }|j        | _        |j        | _        t          |j        ¦  «        | _	        �nÒ|j        | j        k    r|r|                     ¦   «         }n| 
                    ¦   «         }|j        | _        |j        | _        t          |j        ¦  «        | _	        �ndt          |t          ¦  «        �rzt          |¦  «        r‡t          |¦  «        | _	        t          j        dt!          |t"          ¬¦  «        ¦  «        | _        |                      t'          | j        ¦  «        ¬¦  «        }t          j        d|¬¦  «        | _        �n¸	 |\  }}	|€t)          d¦  «        ‚|st*          }t          j        t          j        |d         ||¬	¦  «        ¦  «        | _        t          j        |d
         |                      t'          |¦  «        ¬¦  «        |¬	¦  «        }	t          j        |	¦  «        | _        t          |¦  «        | _	        nø# t2          $ r}
d}t)          |¦  «        |
‚d }
~
ww xY w	 t          j        |¦  «        }n+# t2          $ r}
t)          d| j        › d�¦  «        |
‚d }
~
ww xY wt          | t6          ¦  «        r#|j        dk    rt)          d|j        › d�¦  «        ‚|                      |||¬¦  «         
                    ¦   «         }|j        | _        |j        | _        t          |j        ¦  «        | _	        |�.t!          |¦  «        }| j                             |¦  «        | _        | j        j        d
k    rt)          d¦  «        ‚| j        j        dk    rt)          d¦  «        ‚| j        j        d         t?          | j        ¦  «        k    r6t)          d| j        j        d         t?          | j        ¦  «        fz  ¦  «        ‚t?          t          j         | j        ¦  «        ¦  «        t?          | j        ¦  «        k    rt)          d¦  «        ‚d S )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    Úshapezoffsets array must have rank 1zdata array must have rank 2zBnumber of diagonals (%d) does not match the number of offsets (%d)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                úG/granary/edev/quantum/lib/python3.11/site-packages/scipy/sparse/_dia.pyr#   z_dia_base.__init__   s(  € ÝÔ˜d D°8Ð<Ñ<Ô<Ð<å�D‰>Œ>ð 5	/ØŒ{˜eÒ#Ð#Øð 'ØŸ9š9™;œ;�DØ œI�”	Ø#œ|�”Ý)¨$¬*Ñ5Ô5�”‘à”; $¤+Ò-Ð-°$Ð-ØŸ	š	™œ�A�AàŸ
š
™œ�AØœF�”	Ø œy�”Ý)¨!¬'Ñ2Ô2�”‘Ý˜�eÑ$Ô$ñ &	/Ý�t‰}Œ}ð 5õ *¨$Ñ/Ô/�”ÝœH U­H°UÅEÐ,JÑ,JÔ,JÑKÔK�”	Ø ×1Ò1½¸T¼Z¹¼Ð1ÑIÔI�	Ý!œx¨°9Ð=Ñ=Ô=�”‘ð5à$(‘M�D˜'ð
 �}Ý(Ð)DÑEÔEÐEØð .Ý-˜Ý "¤­b¬h°t¸A´wÀeÐRVÐ.WÑ.WÔ.WÑ XÔ X�D”IÝ œh t¨A¤wØ-1×-BÒ-BÍ#ÈeÉ*Ì*Ð-BÑ-UÔ-UØ,0ð2ñ 2ô 2�Gõ $&¤=°Ñ#9Ô#9�D”LÝ"-¨eÑ"4Ô"4�D”K�Køõ !ð 5ð 5ð 5ØK�GÝ$ WÑ-Ô-°1Ð4øøøøð5øøøð MÝ”z $Ñ'Ô'��øÝð Mð Mð MÝ ð "EØ$(¤Kð"Eð "Eð "Eñ Fô FØKLðMøøøøðMøøøõ ˜$¥Ñ(Ô(ð Y¨T¬Y¸!ª^¨^Ý Ð!W¸T¼YÐ!WÐ!WÐ!WÑXÔXÐXØ×#Ò# D°¸UÐ#ÑCÔC×IÒIÑKÔKˆAØœˆDŒIØœ9ˆDŒLÝ% a¤gÑ.Ô.ˆDŒKàÐÝ ‘”ˆHØœ	×(Ò(¨Ñ2Ô2ˆDŒIð Œ<Ô Ò!Ð!ÝÐ=Ñ>Ô>Ð>àŒ9Œ>˜QÒÐÝÐ:Ñ;Ô;Ð;àŒ9Œ?˜1Ô¥ T¤\Ñ!2Ô!2Ò2Ð2Ýð @à”y” qÔ)­3¨t¬|Ñ+<Ô+<Ð=ñ>ñ ?ô ?ð ?õ �rŒy˜œÑ&Ô&Ñ'Ô'­3¨t¬|Ñ+<Ô+<Ò<Ð<ÝÐEÑFÔFÐFð =Ð<s0   ÆI É
I6ÉI1É1I6É:J Ê
J7ÊJ2Ê2J7c                 óÊ   — t           | j                 \  }}t          | t          ¦  «        rdnd}| j        j        d         }d|› d|› d| j        › d| j        › d|› d	| j        › d
�S )Nr2   Úmatrixr   ú<z sparse z of dtype 'z'
	with z stored elements (z diagonals) and shape ú>)r   r$   r)   r   r%   r"   r    Únnz)r;   Ú_ÚfmtÚ
sparse_clsÚds        rB   Ú__repr__z_dia_base.__repr__c   s¦   € Ý˜$œ+Ô&‰ˆˆ3Ý *¨4µÑ 9Ô 9ÐG�W�W¸xˆ
ØŒIŒO˜AÔˆðY�ð Yð Y˜Zð Yð Y°D´Jð Yð YØ”hðYð YØ23ðYð YØKOÌ:ðYð Yð 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"   r+   Úaranger%   r&   )r;   Únum_rowsÚnum_colsÚoffset_indsÚrowÚmasks         rB   Ú
_data_maskz_dia_base._data_maskl   sl   € ð "œZÑˆ�(Ý”i ¤	¤°Ô 2Ñ3Ô3ˆØ˜DœL¨¨¨¨4¨Ô0Ñ0ˆØ�q’ˆØ��x’Ñ ˆØ�˜xÒ'Ñ(ˆØˆrM   c                 óŠ   — |�t          d¦  «        ‚|                      ¦   «         }t          j        | j        |         ¦  «        S )Nz<count_nonzero over an axis is not implemented for DIA format)ÚNotImplementedErrorrU   r+   Úcount_nonzeror%   )r;   ÚaxisrT   s      rB   rX   z_dia_base.count_nonzerow   sE   € ØÐÝ%ØNñô ð ð �ŠÑ Ô ˆÝÔ ¤	¨$¤Ñ0Ô0Ð0rM   c                 óÔ   — |�t          d¦  «        ‚| j        \  }}d}| j        D ]5}|dk    r|t          |||z
  ¦  «        z  }Œ|t          ||z   |¦  «        z  }Œ6t	          |¦  «        S )Nz6_getnnz over an axis is not implemented for DIA formatr   )rW   r"   r&   ÚminÚint)r;   rY   ÚMÚNrG   Úks         rB   Ú_getnnzz_dia_base._getnnz�   s„   € ØÐÝ%ð '7ñ 8ô 8ð 8àŒj‰ˆˆ!ØˆØ”ð 	"ð 	"ˆAØ�1ŠuˆuØ•s˜1˜Q˜q™S‘z”zÑ!��à•s˜1˜Q™3˜q‘z”zÑ!��Ý�3‰xŒxˆrM   c           
      óœ  — t          |¦  «         |�|dk     r|dz  }t          | j        ¦  «        }| j        \  }}d }|dk    r‹|                      ¦   «         }| j        |z                       d¬¦  «        }	|	j        d         |k    r|	}
n-t          j        ||	j        ¬¦  «        }
|	|
d |	j        d         …<   |  	                    |
|¬¦  «        }nÇt          j        |df|¬¦  «        }t          j
        ||¬¦  «        }t          ||t          | j        ¦  «        | j        j        d         | j        | j        ||¦  «         |  	                    |¦  «        }|€|                     ||¬¦  «        S |  	                    |                     |¬¦  «        ¦  «        }|�|j        |j        k    rt          d¦  «        ‚|                     d||¬	¦  «        S )
Nr   r   ©rY   r   r   )r    Úoutzdimensions do not match© )rY   r    rc   )r   r   r    r"   rU   r%   Úsumr+   r,   Ú_ascontainerÚonesr   r9   r&   r0   )r;   rY   r    rc   Ú	res_dtyperP   rQ   ÚretrT   ÚxÚresÚrow_sumsÚones                rB   re   z_dia_base.sum�   sÎ  € Ý�TÑÔÐàÐ  q¢ Ø�A‰IˆDå! $¤*Ñ-Ô-ˆ	Ø!œZÑˆ�(Øˆà�1Š9ˆ9Ø—?’?Ñ$Ô$ˆDØ”˜TÑ!×&Ò&¨AÐ&Ñ.Ô.ˆAØŒw�qŒz˜XÒ%Ð%Ø��å”h˜x¨q¬wÐ7Ñ7Ô7�Ø#$��K�Q”W˜Q”Z�KÑ Ø×#Ò# C¨yÐ#Ñ9Ô9ˆCˆCõ ”x ¨1 °YÐ?Ñ?Ô?ˆHÝ”'˜(¨)Ð4Ñ4Ô4ˆCÝ�x ­3¨t¬|Ñ+<Ô+<Ø”y” qÔ)¨4¬<¸¼ÀCÈñSô Sð Sð ×(Ò(¨Ñ2Ô2ˆHàˆ|Ø—|’|¨%°S�|Ñ9Ô9Ð9à×#Ò# H§L¢L°d LÑ$;Ô$;Ñ<Ô<ˆCàˆ?˜sœy¨C¬IÒ5Ð5ÝÐ6Ñ7Ô7Ð7à�wŠw˜B e°ˆwÑ5Ô5Ð5rM   c                 óö  — t          |t          ¦  «        s|                     | ¦  «        S t          j        | j        |j        ¦  «        r"|                      | j        |j        z   ¦  «        S t          j        | j        |j        ¦  «        }t          j	        || j        ¦  «        }t          j	        ||j        ¦  «        }| j        j
        d         }|j        j
        d         }||k    rZt          |¦  «        t          | j        ¦  «        k    r5| j        t          |¦  «                 }||d d …fxx         |j        z  cc<   �n||k    rYt          |¦  «        t          |j        ¦  «        k    r4|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<   ||d |…fxx         |j        d d …d |…f         z  cc<   |                      ||f| j
        ¬¦  «        S )Nr   r   éÿÿÿÿr   ©r"   )r)   r   Ú_add_sparser+   Úarray_equalr&   Ú
_with_datar%   Úunion1dÚsearchsortedr"   r9   Ú_invert_indexr[   r,   Úresult_typeÚ_dia_container)	r;   ÚotherÚnew_offsetsÚself_idxÚ	other_idxÚself_dÚother_dÚnew_datarK   s	            rB   rq   z_dia_base._add_sparse¸   st  € å˜%¥Ñ+Ô+ð 	+Ø×$Ò$ TÑ*Ô*Ð*õ Œ>˜$œ,¨¬Ñ6Ô6ð 	;Ø—?’? 4¤9¨u¬zÑ#9Ñ:Ô:Ð:õ ”j ¤¨u¬}Ñ=Ô=ˆÝ”? ;°´Ñ=Ô=ˆÝ”O K°´Ñ?Ô?ˆ	à”” Ô#ˆØ”*Ô" 1Ô%ˆð �WÒÐ¥ [Ñ!1Ô!1µS¸¼Ñ5FÔ5FÒ!FÐ!FØ”y¥¨xÑ!8Ô!8Ô9ˆHØ�Y   �\Ð"Ð"Ô" e¤jÑ0Ð"Ð"Ñ"Ñ"Ø�wÒÐ¥3 {Ñ#3Ô#3µs¸5¼=Ñ7IÔ7IÒ#IÐ#IØ”z¥-°	Ñ":Ô":Ô;ˆHØ�X˜q˜q˜q�[Ð!Ð!Ô! T¤YÑ.Ð!Ð!Ñ!Ð!õ �D”J˜q”M K°¤OÑ3°T´ZÀ´]ÑCÔCˆAõ ”xÝ�[Ñ!Ô! 1Ð%Ý”n T¤Y°´
Ñ;Ô;ðñ ô ˆHð �X˜w ˜wÐ&Ð'Ð'Ô'¨4¬9°Q°Q°Q¸¸¸°UÔ+;Ñ;Ð'Ð'Ñ'Ø�Y   Ð(Ð)Ð)Ô)¨U¬Z¸¸¸¸2¸A¸2¸Ô->Ñ>Ð)Ð)Ñ)Ø×"Ò" H¨kÐ#:À$Ä*Ð"ÑMÔMÐMrM   c                 ó<   — |                       | j        |z  ¦  «        S ©N)rs   r%   )r;   ry   s     rB   Ú_mul_scalarz_dia_base._mul_scalarÝ   s   € Ø�Š˜tœy¨5Ñ0Ñ1Ô1Ð1rM   c                 ót  — |}t          j        | j        d         t          | j        j        |j        j        ¦  «        ¬¦  «        }| j        j        d         }| j        \  }}t          ||t          | j	        ¦  «        || j	        | j        | 
                    ¦   «         | 
                    ¦   «         ¦  «         |S )Nr   r   r   )r+   r,   r"   r   r    Úcharr%   r   r9   r&   Úravel)r;   ry   rj   ÚyÚLr]   r^   s          rB   Ú_matmul_vectorz_dia_base._matmul_vectorà   s¦   € ØˆåŒH�T”Z ”]­+°d´j´oØ78´w´|ñ+Eô +Eð Fñ Fô Fˆð ŒIŒO˜AÔˆàŒj‰ˆˆ!å�1�Q�˜DœLÑ)Ô)¨1¨d¬l¸D¼IØ—7’7‘9”9˜aŸgšg™iœiñ	)ô 	)ð 	)ð ˆrM   r   c                 ó  — | j         \  }}|j        dk    rt          j        }nt	          |¦  «        }|dk     rt          ||z   ||¦  «        }d}|}nt          |||z
  |¦  «        }|}||z   }|j        dk    r
|d |…         }| j        j         \  }	}
|| j        v rX||
k    r9t          j        |	|f| j        j	        ¬¦  «        }| j        |d d …d |
…f<   || _        || j        | j        |k    ||…f<   d S t          j
        | j        | j        j	                             |¦  «        ¦  «        | _        t          ||
¦  «        }t          j        |	dz   |f| j        j	        ¬¦  «        }| j        |d d…d |
…f<   ||d||…f<   || _        d S )Nr   r   r   ro   )r"   r6   r+   Úinfr9   r[   r%   r&   r,   r    ÚappendÚtyper/   )r;   Úvaluesr_   r]   r^   Úvalues_nÚnÚ	min_indexÚ	max_indexÚ	data_rowsÚ	data_colsr%   Úms                rB   Ú_setdiagz_dia_base._setdiagï   s©  € ØŒz‰ˆˆ1àŒ;˜!ÒÐå”vˆHˆHå˜6‘{”{ˆHàˆqŠ5ˆ5Ý�A˜‘E˜1˜hÑ'Ô'ˆAØˆIØˆIˆIå�A�q˜1‘u˜hÑ'Ô'ˆAØˆIØ˜A™ˆIàŒ;˜!ÒÐà˜B˜Q˜B”ZˆFà#œyœÑˆ	�9Ø�”ÐÐØ˜9Ò$Ð$Ý”x ¨IÐ 6¸d¼i¼oÐNÑNÔN�Ø&*¤i��Q�Q�Q˜
˜˜
�]Ñ#Ø �”	Ø@FˆDŒI�d”l aÒ'¨°9Ð)<Ð<Ñ=Ð=Ð=åœ9 T¤\°4´<Ô3E×3JÒ3JÈ1Ñ3MÔ3MÑNÔNˆDŒLÝ�I˜yÑ)Ô)ˆAÝ”8˜Y¨™]¨AÐ.°d´i´oÐFÑFÔFˆDØ$(¤IˆD��"��j�y�j�Ñ!Ø,2ˆD��Y˜yÐ(Ð(Ñ)ØˆDŒIˆIˆIrM   c                 ó2   — |r|                       ¦   «         S | S r�   ©r!   )r;   r!   s     rB   r(   z_dia_base.todia  s   € Øð 	Ø—9’9‘;”;ÐàˆKrM   c                 ór  — |�|dk    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         }
|                      |
|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!   )r0   r"   r/   r&   r+   rO   r9   Úintcr%   Úhstackr,   r    rx   )r;   Úaxesr!   rP   rQ   Úmax_dimr&   ÚrÚcÚ
pad_amountr%   s              rB   Ú	transposez_dia_base.transpose  sM  € ØÐ ¨¢ Ýð Lñ Mô Mð Mð "œZÑˆ�(Ý�d”j‘/”/ˆð ”<�-ˆõ ŒI•c˜'‘l”l­"¬'Ð2Ñ2Ô2°1°1°1°d°7Ô;ˆÝŒI�h¥b¤gÐ.Ñ.Ô.°'¸GÑ2CÀQÀQÀQÈÀWÔ1MÑMˆÝ˜˜G D¤I¤O°AÔ$6Ñ6Ñ7Ô7ˆ
ÝŒy˜$œ)¥R¤X¨t¬y¬¸qÔ/AÀ:Ð.NØ48´I´Oð&Eñ &Eô &Eð Fñ Gô Gˆà�A�q�DŒzˆØ×"Ò" D¨' ?Ø�hð; Ø&*ð #ñ ,ô ,ð 	,rM   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k    rt          j        |d|	fd¬¦  «        }|S )Nr   r   Úconstant)Úmode)r"   r+   Úemptyr%   r    Únonzeror&   r/   r[   Úsizer,   r9   Úpad)
r;   r_   ÚrowsÚcolsÚidxÚ	first_colÚlast_colÚresult_sizeÚresultÚpaddings
             rB   Údiagonalz_dia_base.diagonal4  sñ   € Ø”Z‰
ˆˆdØ��Š:ˆ:˜˜dš˜Ý”8˜A T¤Y¤_Ð5Ñ5Ô5Ð5ÝŒz˜$œ,¨!Ò+Ñ,Ô,‰ˆÝ˜˜1‘I”Iˆ	Ý�t˜a‘x Ñ&Ô&ˆØ Ñ*ˆØŒ8�qŠ=ˆ=Ý”8˜K¨t¬y¬Ð?Ñ?Ô?Ð?Ø”˜3˜qœ6 9¨XÐ#5Ð5Ô6ˆØ¥ F¡¤Ñ+ˆØ�QŠ;ˆ;Ý”V˜F Q¨ L°zÐBÑBÔBˆFØˆrM   c                 ó  — | j         dk    r!|                      | j        | j        ¬¦  «        S | j        \  }}| j        j        \  }}t          j        |¦  «        }|| j        d d …d f         z
  }|dk    }|||k     z  }|||k     z  }|| j        dk    z  }|                      t          | j        ¦  «        ¬¦  «        }	t          j
        |dz   |	¬¦  «        }
t          j        |                     d¬¦  «        d |…         ¦  «        |
d|dz   …<   ||k     r|
|         |
|dz   d …<   |j        |j                                      |	d¬¦  «        }| j        j        |j                 }|                      |||
f| j        | j        ¬¦  «        S )	Nr   r   r   r   rb   Fr—   )r"   r    )rG   Ú_csc_containerr"   r    r%   r+   rO   r&   r.   r/   r,   Úcumsumre   ÚTr8   )r;   r!   rP   rQ   Únum_offsetsÚ
offset_lenrR   rS   rT   r>   ÚindptrÚindicesr%   s                rB   Útocscz_dia_base.tocscF  sŒ  € ØŒ8�qŠ=ˆ=Ø×&Ò& t¤z¸¼Ð&ÑDÔDÐDà!œZÑˆ�(Ø"&¤)¤/Ñˆ�ZÝ”i 
Ñ+Ô+ˆà˜DœL¨¨¨¨4¨Ô0Ñ0ˆØ�q’ˆØ��x’Ñ ˆØ�˜xÒ'Ñ(ˆØ�”˜a’Ñ ˆà×)Ò)µ°T´Z±´Ð)ÑAÔAˆ	Ý”˜( Q™,¨iÐ8Ñ8Ô8ˆÝ!#¤¨4¯8ª8¸¨8Ñ+;Ô+;¸I¸X¸IÔ+FÑ!GÔ!Gˆˆq�˜A‘ˆ~ÑØ˜Ò Ð Ø$*¨:Ô$6ˆF�:˜a‘<�=�=Ñ!Ø”%˜œ”-×&Ò& y°uÐ&Ñ=Ô=ˆØŒyŒ{˜4œ6Ô"ˆØ×"Ò" D¨'°6Ð#:À$Ä*Ø)-¬ð #ñ 5ô 5ð 	5rM   c                 ó\  — | j         \  }}| j        j         \  }}t          j        |¦  «        }|| j        d d …d f         z
  }|dk    }|||k     z  }|||k     z  }|| j        dk    z  }||         }t          j        ||¦  «        |                     ¦   «                  }	|                      | j        ft          | j         ¦  «        ¬¦  «        }
| 	                    |
d¬¦  «        }|	 	                    |
d¬¦  «        }	| j        |         }|  
                    |||	ff| j         | j        d¬¦  «        S )Nr   )Úarraysr   Fr—   )r"   r    r!   )r"   r%   r+   rO   r&   Útiler…   r.   r/   r8   r7   r    )r;   r!   rP   rQ   rµ   r¶   rR   rS   rT   Úcolr>   r%   s               rB   Útocooz_dia_base.tocoo`  s8  € Ø!œZÑˆ�(Ø"&¤)¤/Ñˆ�ZÝ”i 
Ñ+Ô+ˆà˜DœL¨¨¨¨4¨Ô0Ñ0ˆØ�q’ˆØ��x’Ñ ˆØ�˜xÒ'Ñ(ˆØ�”˜a’Ñ ˆØ�$ŒiˆÝŒg�k ;Ñ/Ô/°·
²
±´Ô=ˆØ×)Ò)Ø”L�?­3¨t¬z©?¬?ð *ñ 
ô 
ˆ	ð �jŠj˜¨ˆjÑ/Ô/ˆØ�jŠj˜¨ˆjÑ/Ô/ˆØŒy˜Œˆð ×"Ò"Ø�C˜�:Ð d¤j¸¼
Èð #ñ 
ô 
ð 	
rM   Tc                 ó¶   — |r5|                       || j                             ¦   «         f| j        ¬¦  «        S |                       || 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.
        rp   )rx   r&   r!   r"   )r;   r%   r!   s      rB   rs   z_dia_base._with_data{  sp   € ð ð 	Ø×&Ò&Ø�t”|×(Ò(Ñ*Ô*Ð+°4´:ð 'ñ ô ð ð ×&Ò&Ø�t”|Ð$¨D¬Jð 'ñ ô ð rM   c                 ó¢  — t          |¦  «        }|\  }}| j        d d …d |…f         | _        || j        d         k    rŠt          j        | j        | j        d         z   | j        j        d         k     ¦  «        rO| j        d d …d f         | j        d         z   t          j        | j        j        d         ¦  «        k    }d| j        |<   || _        d S )Nr   r   )r   r%   r"   r+   Úanyr&   rO   r'   )r;   r"   r]   r^   rT   s        rB   Úresizez_dia_base.resizeˆ  sÂ   € Ý˜EÑ"Ô"ˆØ‰ˆˆ1à”I˜a˜a˜a  ! ˜eÔ$ˆŒ	à�”
˜1”ÒÐÝ”�t”| d¤j°¤mÑ3°d´i´oÀaÔ6HÒHÑIÔIð ð ”L    D Ô)¨D¬J°q¬MÑ9Ý”I˜dœiœo¨aÔ0Ñ1Ô1ò2ˆDàˆDŒI�d‰OàˆŒˆˆrM   )NNFr�   )NNN)r   )F)NF)T)Ú__name__Ú
__module__Ú__qualname__Ú_formatr#   rL   rU   rX   r   Ú__doc__r`   re   rq   r‚   rˆ   r•   r(   r    r°   r¹   r¾   rs   rÂ   rd   rM   rB   r   r      sì  € € € € € Ø€GðKGÈTð KGð KGð KGð KGð KGðZ
ð 
ð 
ð	ð 	ð 	ð1ð 1ð 1ð 1ð $Ô1Ô9€MÔðð ð ð ð ”oÔ-€G„Oð$6ð $6ð $6ð $6ðL ”+Ô%€C„Kð#Nð #Nð #NðJ2ð 2ð 2ðð ð ð#ð #ð #ð #ðJð ð ð ð ”MÔ)€E„Mð,ð ,ð ,ð ,ð,  Ô)Ô1€IÔðð ð ð ð  Ô'Ô/€HÔð5ð 5ð 5ð 5ð0 ”MÔ)€E„Mð
ð 
ð 
ð 
ð0 ”MÔ)€E„Mðð ð ð ðð ð ð ”^Ô+€F„N€N€NrM   r   c                 óv   — t          j        | ¦  «        }t          j        t          | ¦  «        ¦  «        || <   |S )z)Helper function to invert an index array.)r+   Ú
zeros_likerO   r9   )rª   Úinvs     rB   rv   rv   š  s/   € å
Œ-˜Ñ
Ô
€CÝŒy�˜S™œÑ"Ô"€Cˆ�HØ€JrM   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
    )r)   r   )rj   s    rB   r   r   ¡  s   € õ. �a�Ñ$Ô$Ð$rM   c                   ó   — e Zd ZdZdS )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Ç   rd   rM   rB   r   r   ¼  ó"   € € € € € ðHð Hð Hð HrM   r   c                   ó   — e Zd ZdZdS )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Í   rd   rM   rB   r   r     rÎ   rM   r   )rÇ   Ú__docformat__Ú__all__Únumpyr+   Ú
_lib._utilr   Ú_matrixr	   Ú_baser
   r   r   r   Ú_datar   Ú_sputilsr   r   r   r   r   r   Ú_sparsetoolsr   r   rv   r   r   r   rd   rM   rB   ú<module>rÙ      s«  ðØ Ð à%€à
7Ð
7Ð
7€à Ð Ð Ð à 'Ð 'Ð 'Ð 'Ð 'Ð 'Ø Ð Ð Ð Ð Ð Ø 7Ð 7Ð 7Ð 7Ð 7Ð 7Ð 7Ð 7Ð 7Ð 7Ð 7Ð 7Ø Ð Ð Ð Ð Ð ðð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð %Ð $Ð $Ð $Ð $Ð $ðD,ð D,ð D,ð D,ð D,�ñ D,ô D,ð D,ðNð ð ð%ð %ð %ð6Ið Ið Ið Ið I�	˜7ñ Iô Ið IðXIð Ið Ið Ið I�˜9ñ Iô Ið Ið Ið IrM   