
    -ij]                         S r Sr/ SQrSSKrSSKJr  SSKJr  SS	K	J
r
JrJrJr  SS
KJr  SSKJrJrJrJrJrJrJrJr  SSKJrJrJr   " S S\5      rS rS r " S S\\5      r  " S S\\5      r!g)zSparse DIAgonal formatzrestructuredtext en)	dia_array
dia_matrixisspmatrix_dia    N   )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_matvecsc                     ^  \ rS rSrSrSSS.S jjrS rS rSS jr\	R                  R                  \l
        SS	 jr\	R                  R                  \l
        SS
 jr\	R                  R                  \l
        SS jrU 4S jrS rU 4S jrS rS rU 4S jrSS jrSS jr\	R*                  R                  \l
        S S jr\	R,                  R                  \l
        SS jr\	R.                  R                  \l
        SS jr\	R0                  R                  \l
        SS jr\	R2                  R                  \l
        S!S jrS r\	R6                  R                  \l
        SrU =r$ )"	_dia_base   diaNmaxprintc                   [         R                  " XUS9  [        U5      (       a  UR                  S:X  aU  U(       a  UR	                  5       nUR
                  U l        UR                  U l        [        UR                  5      U l	        GOwUR                  U R                  :X  a  U(       a  UR	                  5       nOUR                  5       nUR
                  U l        UR                  U l        [        UR                  5      U l	        GO[        U[        5      (       Ga2  [        U5      (       av  [        U5      U l	        [        R                  " S[!        U["        S95      U l        U R%                  ['        U R                  5      S9n[        R                  " SUS9U l        GO[ Uu  pUc  [)        S5      eU(       d  [*        n[        R,                  " [        R.                  " US   X4S	95      U l        [        R.                  " US
   U R%                  ['        U5      S9US	9n	[        R0                  " U	5      U l        [        U5      U l	        O [        R4                  " U5      n[        U [6        5      (       a)  UR8                  S:w  a  [)        SUR8                   S35      eU R;                  XUS9R                  5       nUR
                  U l        UR                  U l        [        UR                  5      U l	        Ub+  [!        U5      nU R
                  R=                  U5      U l        U R                  R8                  S
:w  a  [)        S5      eU R
                  R8                  S:w  a  [)        S5      eU R
                  R                  S   [?        U R                  5      :w  a<  [)        SU R
                  R                  S    S[?        U R                  5       S35      e[?        [        R@                  " U R                  5      5      [?        U R                  5      :w  a  [)        S5      eg ! [2         a  n
Sn[)        U5      U
eS n
A
ff = f! [2         a  n
[)        SU R                   S35      U
eS n
A
ff = f)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 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                D/var/www/html/venv/lib/python3.13/site-packages/scipy/sparse/_dia.pyr)   _dia_base.__init__   s~   d8<D>>{{e#99;D II	#||)$**5;;$++-$		A

AFF	 yy)!''2e$$t}} *$/HHUHUE,JK	 11TZZ1I	!xx9=5$(MD
 }()DEE- "bhhtAwe.W XDI hhtAw-1-B-B#e*-B-U,02G $&==#9DL"-e"4DKMzz$' $((TYY!^ #<TYYK!WXX##DU#CIIKADI99DL%agg.DKH		((2DI <<!=>>99>>Q:;;99??1T\\!22'		(:'; <"4<<014  ryy&'3t||+<<EFF =Y ! 5KG$W-145$  M !9$(KK=0C"E FKLMMs0   (P2 Q 2
Q<Q

Q
Q;Q66Q;c                     [         U R                     u  p[        U [        5      (       a  SOSnU R                  R
                  S   nSU SU SU R                   SU R                   SU S	U R
                   S
3$ )Nr8   matrixr   <z sparse z of dtype 'z'
	with z stored elements (z diagonals) and shape >)r   r*   r/   r   r+   r'   r%   nnz)rA   _fmt
sparse_clsds        rH   __repr___dia_base.__repr__d   s}    $++& *4 9 9Wx
IIOOAuHZLDJJ< @hhZ1!4J4::,VWY	
    c                     U R                   u  p[        R                  " U R                  R                   S   5      nX0R                  SS2S4   -
  nUS:  nXTU:  -  nXSU:  -  nU$ )zvReturns 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'   r1   aranger+   r,   )rA   num_rowsnum_colsoffset_indsrowmasks         rH   
_data_mask_dia_base._data_maskm   sg     "ZZii		 23LL400qx x'(rU   c                     Ub  [        S5      eU R                  5       n[        R                  " U R                  U   5      $ )Nz<count_nonzero over an axis is not implemented for DIA format)NotImplementedErrorr]   r1   count_nonzeror+   )rA   axisr\   s      rH   ra   _dia_base.count_nonzerox   s?    %N   		$00rU   c                     Ub  [        S5      eU R                  u  p#SnU R                   H-  nUS:  a  U[        X#U-
  5      -  nM  U[        X%-   U5      -  nM/     [	        U5      $ )Nz6_getnnz over an axis is not implemented for DIA formatr   )r`   r'   r,   minint)rA   rb   MNrN   ks         rH   _getnnz_dia_base._getnnz   sn    % '7 8 8jjA1us1qSz!s13qz!	 
 3xrU   c           
         [        U5      n[        U R                  5      nU R                  u  pVS nUS:X  a  U R	                  5       nU R
                  U-  R                  SS9n	U	R                  S   U:X  a  U	n
O/[        R                  " XiR                  S9n
XS U	R                  S   & U R                  XS9nO[        R                  " US4US9n[        R                  " XdS9n[        XV[        U R                  5      U R
                  R                  S   U R                  U R
                  X5        U R                  U5      nUc  UR                  X#S9$ U R                  UR                  US95      nUR                  SX#S9$ )	Nr   r   rb   r$   r   )r%   out )rb   r%   ro   )r   r   r%   r'   r]   r+   sumr1   r2   _ascontaineronesr   r?   r,   )rA   rb   r%   ro   	res_dtyperX   rY   retr\   xresrow_sumsones                rH   rq   _dia_base.sum   sT   D!!$**-	!ZZ4<??$DT!&&A&.AwwqzX%hhxww7#$KQWWQZ ##C#9C xx1Y?H''(4Cx3t||+<yyq)4<<CS ((2H|||%|99##HLLdL$;<CwwBew55rU   c                 t   [        U[        5      (       d  UR                  U 5      $ [        R                  " U R
                  UR
                  5      (       aL  U R                  U(       a  U R                  UR                  -
  5      $ U R                  UR                  -   5      $ [        R                  " U R
                  UR
                  5      n[        R                  " X0R
                  5      n[        R                  " X1R
                  5      nU R                  R                  S   nUR                  R                  S   nXg:X  ay  [        U5      [        U R
                  5      :X  aW  U R                  [        U5         nU(       a  XS S 24==   UR                  -  ss'   GO}XS S 24==   UR                  -  ss'   GOaXg:X  av  [        U5      [        UR
                  5      :X  aT  U(       a  UR                  [        U5         * nOUR                  [        U5         nXS S 24==   U R                  -  ss'   O[        U R                  S   US   -   U R                  S   5      n	[        R                  " [        U5      U	4[        R                  " U R                  UR                  5      S9nXS U24==   U R                  S S 2S U	24   -  ss'   U(       a$  XS U24==   UR                  S S 2S U	24   -  ss'   O#XS U24==   UR                  S S 2S U	24   -  ss'   U R!                  X4U R                  S9$ )Nr   r   r$   r'   )r/   r   _add_sparser1   array_equalr,   
_with_datar+   union1dsearchsortedr'   r?   _invert_indexre   r2   result_type_dia_container)
rA   othersubnew_offsetsself_idx	other_idxself_dother_dnew_datarR   s
             rH   r~   _dia_base._add_sparse   s   %++$$T** >>$,,66??S499uzz#9 ; ;#'99uzz#9; ; jju}}=??;=OOK?	#**""1% [!1S5F!Fyyx!89HA&%**4&A&%**4&3{#3s5==7I#I!JJ}Y'?@@ ::mI&>?q[!TYY.! DJJqMKO3TZZ]CA xx[!1%nnTYY

;H ww&'499QU+;;'HWH,-ArrE1BB-HWH,-ArrE1BB-""H#:$**"MMrU   c                 l   > [        U[        5      (       d  [        TU ]  U5      $ U R	                  USS9$ )NT)r   )r/   r   super_sub_sparser~   )rA   r   	__class__s     rH   r   _dia_base._sub_sparse   s6    %++7&u--400rU   c                 >    U R                  U R                  U-  5      $ N)r   r+   )rA   r   s     rH   _mul_scalar_dia_base._mul_scalar   s    tyy5011rU   c                 l  > [        U5      (       a  U R                  U5      $ [        U5      (       Ga  UR                  S:  a  U R	                  5       U-  $ SU R
                  ;   d   SU R
                  ;   d  SUR
                  ;   a  [        TU ]  U5      $ [        R                  " U5      nUR
                  u  p#U R
                  u  pE[        U R                  R
                  S   U5      nU R                  S S 2S U24   R                  [        R                  " U R                  U5      5      nUS:X  a  XqSS U24   -  nO}X$:w  a  [        S5      e[        R                  " U5      nXd:  a  XR                   S S 2S 4   -
  U-  n	OXR                   S S 2S 4   U-  -
  n	US:X  a  SnOX5:w  a  [        S5      eXqX4   -  nU R#                  U5      $ [%        U[&        5      (       a  UR
                  U R
                  :w  a  [        TU ]  U5      $ [        R(                  " U R                   UR                   SSS9u  pn[        U R                  R
                  S   UR                  R
                  S   5      nU R                  US U24   UR                  US U24   -  nU R+                  Xz4U R
                  S9$ )Nr   r   r   zinconsistent shapesT)assume_uniquereturn_indicesr}   )r   r   r   r<   toarrayr'   r   multiplyr1   r7   re   r+   r>   r   r6   rW   r,   r   r/   r   intersect1dr   )rA   r   
other_rows
other_colsrowscolsLr+   jir,   r   r   r   s                rH   r   _dia_base.multiply   s[   ##E**5>>zzA~||~-- DJJ!tzz/Q%++5Ew'..MM%(E%*[["JJDDIIOOA&-A99QU#**2>>$))U+KLDQa!e$# !677IIaL8\\!T'22d:ALLD1D88A?A'$%:;;ad#??4(( %++u{{djj/H7#E**
 NN4<<)-dD 	%9 		"EJJ$4$4Q$78yy2A2&IrrM)BB""D?$**"EErU   c                    Un[         R                  " U R                  S   [        U R                  R
                  UR                  R
                  5      S9nU R                  R                  S   nU R                  u  pV[        XV[        U R                  5      X@R                  U R                  UR                  5       UR                  5       5        U$ )Nr   r$   r   )r1   r2   r'   r   r%   charr+   r   r?   r,   ravel)rA   r   rv   yr   rg   rh   s          rH   _matmul_vector_dia_base._matmul_vector  s    HHTZZ]+djjoo78ww||+E F IIOOAjj1DLL)1llDII779aggi	) rU   c                 R   [         R                  " U R                  S   UR                  S   4[         R                  " U R                  U5      S9n[        / U R                  QU R                  R                  QU R                  PU R                  PUR                  S   PUPUP76   U$ )Nr   r   r$   )r1   r2   r'   r   r+   r   r,   )rA   r   rw   s      rH   _matmul_multivector_dia_base._matmul_multivector,  s    hh

1u{{1~6^^DIIu=? 	0TZZ 	0$))// 	04<< 	0 	0KKN	0$)	0+.	0
rU   c                 |  > [        U[        5      (       d  [        TU ]  U5      $ SU R                  ;   d  SUR                  ;   a-  U R                  U R                  S   UR                  S   45      $ [        / U R                  QU R                  R                  QU R                  PU R                  PUR                  S   PUR                  R                  QUR                  PUR                  P76 u  p#U R                  UR                  [        U5      S5      U4U R                  S   UR                  S   45      $ )Nr   r   r|   )r/   r   r   _matmul_sparser'   r   r   r+   r,   reshaper?   )rA   r   r,   r+   r   s       rH   r   _dia_base._matmul_sparse3  s   %++7)%00 

?a5;;.&&

1u{{1~'FGG" >DJJ > >#'<<>15>#(;;q>>49JJ4D4D> $)==> 38**> ""DLLWr$BG#L$(JJqM5;;q>#BD 	DrU   c                 f   U R                   u  p4UR                  S:X  a  [        R                  nO[	        U5      nUS:  a  [        X2-   XE5      nSnUnO[        X4U-
  U5      nUnX&-   nUR                  S:w  a  US U nU R                  R                   u  pX R                  ;   ai  X:  aE  [        R                  " X4U R                  R                  S9nU R                  US S 2S U
24'   Xl        XR                  U R                  U:H  Xx24'   g [        R                  " U R                  U R                  R                  R                  U5      5      U l        [        X5      n[        R                  " U	S-   U4U R                  R                  S9nU R                  US S2S U
24'   XSXx24'   Xl        g )Nr   r$   r   r|   )r'   r<   r1   infr?   re   r+   r,   r2   r%   appendtyper5   )rA   valuesri   rg   rh   values_nn	min_index	max_index	data_rows	data_colsr+   ms                rH   _setdiag_dia_base._setdiagC  su   zz;;!vvH6{Hq5AE1'AIIA1uh'AII;;!BQZF#yy	$xx 6diiooN&*iiQ

]# 	@FIIdlla')<<=99T\\4<<3E3E3J3J13MNDLI)A88Y]A.diiooFD$(IID"jyj!,2Y(()IrU   c                 4    U(       a  U R                  5       $ U $ r   r&   )rA   r&   s     rH   r.   _dia_base.todiah  s    99;KrU   c                    Ub  US:w  a  [        S5      eU R                  u  p4[        U R                  5      nU R                  * n[        R
                  " [        U5      [        R                  S9S S 2S 4   n[        R
                  " U[        R                  S9Xe-  S S 2S 4   -
  n[        SXPR                  R                  S   -
  5      n	[        R                  " U R                  [        R                  " U R                  R                  S   U	4U R                  R                  S945      n
XU4   n
U R                  X4XC4US9$ )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&   )r6   r'   r5   r,   r1   rW   r?   intcr+   hstackr2   r%   r   )rA   axesr&   rX   rY   max_dimr,   rc
pad_amountr+   s              rH   	transpose_dia_base.transposep  s'    L M M "ZZdjj/ <<- IIc'l"''21d7;IIhbgg.'2CQW1MMGIIOOA$667
yy$))RXXtyyq/A:.N48IIOO&E F GqDz""D?; &* # , 	,rU   c                    U R                   u  p#X* ::  d  X:  a)  [        R                  " SU R                  R                  S9$ [        R
                  " U R                  U:H  5      u  n[        SU5      n[        X!-   U5      nXe-
  nUR                  S:X  a(  [        R                  " XpR                  R                  S9$ U R                  US   XV24   nU[        U5      -
  n	U	S:  a  [        R                  " USU	4SS9nU$ )Nr   r$   constant)mode)r'   r1   emptyr+   r%   nonzeror,   r5   re   sizer2   r?   pad)
rA   ri   r   r   idx	first_collast_colresult_sizeresultpaddings
             rH   diagonal_dia_base.diagonal  s    ZZ
:88ATYY__55zz$,,!+,1I	tx&*88q=88Kyy??3q69#556F+Q;VVFQLzBFrU   c                    U R                   S:X  a$  U R                  U R                  U R                  S9$ U R                  u  p#U R                  R                  u  pE[
        R                  " U5      nX`R                  S S 2S 4   -
  nUS:  nXU:  -  nXU:  -  nXR                  S:g  -  nU R                  [        U R                  5      S9n	[
        R                  " US-   U	S9n
[
        R                  " UR                  SS9S U 5      U
SUS-   & XS:  a	  X   XS-   S & UR                  UR                     R                  U	SS9nU R                  R                  UR                     nU R                  XU
4U R                  U R                  S9$ )	Nr   r$   r"   r   rn   Fr   )r'   r%   )rN   _csc_containerr'   r%   r+   r1   rW   r,   r4   r5   r2   cumsumrq   Tr>   )rA   r&   rX   rY   num_offsets
offset_lenrZ   r[   r\   rD   indptrindicesr+   s                rH   tocsc_dia_base.tocsc  sp   88q=&&tzz&DD!ZZ"&))//ii
+LL400qx x'(a ))TZZ)A	(Q,i8!#4888+;IX+F!GqA $*$6Fa<=!%%-&&yu&=yy{{466"""D6#:$**)- # 5 	5rU   c                 N   U R                   u  p#U R                  R                   u  pE[        R                  " U5      nX`R                  S S 2S 4   -
  nUS:  nXU:  -  nXU:  -  nXR                  S:g  -  nXx   n[        R
                  " Xd5      UR                  5          n	U R                  U R                  4[        U R                   5      S9n
UR                  U
SS9nU	R                  U
SS9n	U R                  U   nU R                  XU	44U R                   U R                  SS9$ )Nr   )arraysr#   Fr   )r'   r%   r&   )r'   r+   r1   rW   r,   tiler   r4   r5   r>   r=   r%   )rA   r&   rX   rY   r   r   rZ   r[   r\   colrD   r+   s               rH   tocoo_dia_base.tocoo  s    !ZZ"&))//ii
+LL400qx x'(a iggk/

=))LL?3tzz? * 
	 jjj/jjj/yy "":djj

 # 
 	
rU   c                     U(       a3  U R                  XR                  R                  5       4U R                  S9$ U R                  XR                  4U R                  S9$ )zReturns a matrix with the same sparsity structure as self,
but with different data.  By default the structure arrays are copied.
r}   )r   r,   r&   r'   )rA   r+   r&   s      rH   r   _dia_base._with_data  sb     &&||((*+4:: '   &&||$DJJ '  rU   c                    [        U5      nUu  p#U R                  S S 2S U24   U l        X R                  S   :  a  [        R                  " U R
                  U R                  S   -   U R                  R                  S   :  5      (       a`  U R
                  S S 2S 4   U R                  S   -   [        R                  " U R                  R                  S   5      :*  nSU R                  U'   Xl        g )Nr   r   )r   r+   r'   r1   anyr,   rW   r-   )rA   r'   rg   rh   r\   s        rH   resize_dia_base.resize  s    E"IIa!e$	

1t||djjm3diiooa6HHIILLD)DJJqM9IIdiiooa012DDIIdOrU   )r-   r+   r,   )NNFr   )NNN)Frm   )NF)T)__name__
__module____qualname____firstlineno___formatr)   rS   r]   ra   r   __doc__rj   rq   r~   r   r   r   r   r   r   r   r.   r   r   r   r   r   r   __static_attributes____classcell__)r   s   @rH   r   r      s:   GKGT KGZ
	1 $1199M oo--GO6@ ++%%CK-N^12/FbD #J MM))EM,,  ))11I  ''//H50 MM))EM
0 MM))EM ^^++FNNrU   r   c                 t    [         R                  " U 5      n[         R                  " [        U 5      5      X'   U$ )z)Helper function to invert an index array.)r1   
zeros_likerW   r?   )r   invs     rH   r   r     s)    
--
CyyS"CHJrU   c                 "    [        U [        5      $ )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   )rv   s    rH   r   r     s    . a$$rU   c                       \ rS rSrSrSrg)r   i  aH  
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.]])
rp   Nr   r   r   r   r   r   rp   rU   rH   r   r         HrU   r   c                       \ rS rSrSrSrg)r   i\  a[  
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.]])
rp   Nr   rp   rU   rH   r   r   \  r  rU   r   )"r   __docformat____all__numpyr1   
_lib._utilr   _matrixr	   _baser
   r   r   r   _datar   _sputilsr   r   r   r   r   r   r   r   _sparsetoolsr   r   r   r   r   r   r   r   rp   rU   rH   <module>r     su    %
7  '  7 7    > =W, W,t%6I	7 IXI9 IrU   