+
    ,ij]                         R t Rt. ROt^ RIt^RIHt ^RIHt ^RI	H
t
HtHtHt ^RIHt ^R	IHtHtHtHtHtHtHtHt ^R
IHtHtHt  ! R R]4      tR tR t ! R R]]4      t  ! R R]]4      t!R# )zSparse DIAgonal formatzrestructuredtext en	dia_array
dia_matrixN)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                     a a ] tR t^t oRtRRR/R lltR tR tRR lt]	P                  P                  ]n
        RR lt]	P                  P                  ]n
        RR	 lt]	P                  P                  ]n
        RR
 ltV 3R ltR tV 3R ltR tR tV 3R ltRR ltRR lt]	P*                  P                  ]n
        RR lt]	P,                  P                  ]n
        RR lt]	P.                  P                  ]n
        RR lt]	P0                  P                  ]n
        RR lt]	P2                  P                  ]n
        R R ltR t]	P6                  P                  ]n
        RtVtV ;t# )!	_dia_basediaNmaxprintc               r	   \         P                  ! WVR 7       \        V4      '       d   VP                  R8X  dW   V'       d   VP	                  4       pVP
                  V n        VP                  V n        \        VP                  4      V n	        EMVP                  V P                  8X  d   V'       d   VP	                  4       pMVP                  4       pVP
                  V n        VP                  V n        \        VP                  4      V n	        EM\        V\        4      '       EdP   \        V4      '       d   \        V4      V n	        \        P                  ! R\!        V\"        R7      4      V n        V P%                  \'        V P                  4      R7      p\        P                  ! ^ VR7      V n        EMs Vw  rVf   \)        R4      hV'       g   \*        p\        P,                  ! \        P.                  ! V^ ,          W4R7      4      V n        \        P.                  ! V^,          V P%                  \'        V4      R7      VR7      p	\        P0                  ! V	4      V n        \        V4      V n	        M \        P4                  ! V4      p\        T \6        4      '       d+   TP8                  ^8w  d   \)        RTP8                   R24      hT P;                  YTR7      P                  4       pTP
                  T n        TP                  T n        \        TP                  4      T n	        Ve,   \!        V4      pV P
                  P=                  V4      V n        V P                  P8                  ^8w  d   \)        R4      hV P
                  P8                  ^8w  d   \)        R4      hV P
                  P                  ^ ,          \?        V P                  4      8w  dA   \)        RV P
                  P                  ^ ,           R\?        V P                  4       R24      h\?        \        P@                  ! V P                  4      4      \?        V P                  4      8w  d   \)        R4      hR#   \2         d   p
Rp\)        T4      T
hRp
?
ii ; i  \2         d    p
\)        R	T P                   R
24      T
hRp
?
ii ; i))r   r   )defaultmaxvaldtypeNzexpected a shape argument)r   copyz+unrecognized form for dia_array constructorzunrecognized form for z_matrix constructorz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#   )!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   &&&&&$       3/usr/lib/python3/dist-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   ;Q+ :R +R	6RR	R6R11R6c                   \         V P                  ,          w  r\        V \        4      '       d   R MRpV P                  P
                  ^ ,          pRV RV RV P                   RV P                   RV RV P
                   R2# )	r3   matrix<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   &    rC   __repr___dia_base.__repr__d   s}    $++& *4 9 9Wx
IIOOAuHZLDJJ< @hhZ1!4J4::,VWY	
    c                    V P                   w  r\        P                  ! V P                  P                   ^,          4      pW0P                  R,          ,
          pV^ 8  pWTV8  ,          pWSV8  ,          pV# )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.NNNN)r!   r,   aranger&   r'   )r<   num_rowsnum_colsoffset_indsrowmasks   &     rC   
_data_mask_dia_base._data_maskm   sc     "ZZii		 23LL00qx x'(rP   c                    Ve   \        R4      hV P                  4       p\        P                  ! V P                  V,          4      # )Nz<count_nonzero over an axis is not implemented for DIA format)NotImplementedErrorrZ   r,   count_nonzeror&   )r<   axisrY   s   && rC   r^   _dia_base.count_nonzerox   s?    %N   		$00rP   c                    Ve   \        R4      hV P                  w  r#^ pV P                   F>  pV^ 8  d   V\        W#V,
          4      ,          pK%  V\        W%,           V4      ,          pK@  	  \	        V4      # )Nz6_getnnz over an axis is not implemented for DIA format)r]   r!   r'   minint)r<   r_   MNrI   ks   &&    rC   _getnnz_dia_base._getnnz   sn    % '7 8 8jjA1us1qSz!s13qz!	 
 3xrP   c           
     Z   \        V4      p\        V P                  4      pV P                  w  rVR pVR8X  d   V P	                  4       pV P
                  V,          P                  ^ R7      p	V	P                  ^ ,          V8X  d   T	p
M6\        P                  ! WiP                  R7      p
WR V	P                  ^ ,          % V P                  WR7      pM\        P                  ! V^3VR7      p\        P                  ! WdR7      p\        WV\        V P                  4      V P
                  P                  ^,          V P                  V P
                  W4       V P                  V4      pVf   VP                  W#R7      # V P                  VP                  VR7      4      pVP                  RW#R7      # )Nr_   r   )r   out)r_   r   rk   r#    )r   r   r   r!   rZ   r&   sumr,   r-   _ascontaineronesr   r:   r'   )r<   r_   r   rk   	res_dtyperU   rV   retrY   xresrow_sumsones   &&&&         rC   rn   _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5rP   c                N   \        V\        4      '       g   VP                  V 4      # \        P                  ! V P
                  VP
                  4      '       dV   T P                  V'       d"   V P                  VP                  ,
          4      # V P                  VP                  ,           4      # \        P                  ! V P
                  VP
                  4      p\        P                  ! W0P
                  4      p\        P                  ! W1P
                  4      pV P                  P                  ^,          pVP                  P                  ^,          pWg8X  d   \        V4      \        V P
                  4      8X  di   V P                  \        V4      ,          pV'       d#   WR3;;,          VP                  ,          uu&   EMWR3;;,          VP                  ,          uu&   EMWg8X  d   \        V4      \        VP
                  4      8X  de   V'       d   VP                  \        V4      ,          ) pMVP                  \        V4      ,          pWR3;;,          V P                  ,          uu&   EM\        V P                  ^ ,          VR,          ,           V P                  ^,          4      p	\        P                  ! \        V4      V	3\        P                  ! V P                  VP                  4      R7      pWRV13;;,          V P                  RRV	13,          ,          uu&   V'       d/   WRV13;;,          VP                  RRV	13,          ,          uu&   M-WRV13;;,          VP                  RRV	13,          ,          uu&   V P!                  W3V P                  R7      # )   rS   r   Nr!   )r*   r   _add_sparser,   array_equalr'   
_with_datar&   union1dsearchsortedr!   r:   _invert_indexrb   r-   result_type_dia_container)
r<   othersubnew_offsetsself_idx	other_idxself_dother_dnew_datarM   s
   &&&       rC   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MrP   c                t   < \        V\        4      '       g   \        SV `  V4      # V P	                  VR R7      # )T)r   )r*   r   super_sub_sparser|   )r<   r   	__class__s   &&rC   r   _dia_base._sub_sparse   s6    %++7&u--400rP   c                F    V P                  V P                  V,          4      # N)r~   r&   )r<   r   s   &&rC   _mul_scalar_dia_base._mul_scalar   s    tyy5011rP   c                  < \        V4      '       d   V P                  V4      # \        V4      '       Ed   VP                  ^8  d   V P	                  4       V,          # ^ V P
                  9   g#   ^V P
                  9   g   ^ VP
                  9   d   \        SV `  V4      # \        P                  ! V4      pVP
                  w  r#V P
                  w  rE\        V P                  P
                  ^,          V4      pV P                  RRV13,          P                  \        P                  ! V P                  V4      4      pV^8X  d   Wq^ RV13,          ,          pMW$8w  d   \        R4      h\        P                  ! V4      pWd8  d"   WP                   R,          ,
          V,          p	M WP                   R,          V,          ,
          p	V^8X  d   ^ pMW58w  d   \        R4      hWqW3,          ,          pV P#                  V4      # \%        V\&        4      '       d   VP
                  V P
                  8w  d   \        SV `  V4      # \        P(                  ! V P                   VP                   RRR7      w  rp\        V P                  P
                  ^,          VP                  P
                  ^,          4      pV P                  VRV13,          VP                  VRV13,          ,          pV P+                  Wz3V P
                  R7      # )   rS   Nzinconsistent shapesT)assume_uniquereturn_indicesrz   rR   )r   r   r   r7   toarrayr!   r   multiplyr,   r2   rb   r&   r9   r   r1   rT   r'   r~   r*   r   intersect1dr   )r<   r   
other_rows
other_colsrowscolsLr&   jir'   r   r   r   s   &&           rC   r   _dia_base.multiply   sS   ##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\\'22d:ALL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ErP   c                   Tp\         P                  ! V P                  ^ ,          \        V P                  P
                  VP                  P
                  4      R7      pV P                  P                  ^,          pV P                  w  rV\        WV\        V P                  4      W@P                  V P                  VP                  4       VP                  4       4       V# r#   r   )r,   r-   r!   r   r   charr&   r   r:   r'   ravel)r<   r   rs   yr   rd   re   s   &&     rC   _matmul_vector_dia_base._matmul_vector  s    HHTZZ]+djjoo78ww||+E F IIOOAjj1DLL)1llDII779aggi	) rP   c                r   \         P                  ! V P                  ^ ,          VP                  ^,          3\         P                  ! V P                  V4      R7      p\        . V P                  OV P                  P                  OV P                  NV P                  NVP                  ^,          NVNVN5!   V# r   )r,   r-   r!   r   r&   r   r'   )r<   r   rt   s   && rC   _matmul_multivector_dia_base._matmul_multivector,  s    hh

1u{{1~6^^DIIu=? 	0TZZ 	0$))// 	04<< 	0 	0KKN	0$)	0+.	0
rP   c                  < \        V\        4      '       g   \        SV `  V4      # ^ V P                  9   g   ^ VP                  9   d6   V P                  V P                  ^ ,          VP                  ^,          34      # \        . V P                  OV P                  P                  OV P                  NV P                  NVP                  ^,          NVP                  P                  OVP                  NVP                  N5!  w  r#V P                  VP                  \        V4      R4      V3V P                  ^ ,          VP                  ^,          34      # )r#   r{   )r*   r   r   _matmul_sparser!   r   r   r&   r'   reshaper:   )r<   r   r'   r&   r   s   &&  rC   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rP   c                   V P                   w  r4VP                  ^ 8X  d   \        P                  pM\	        V4      pV^ 8  d   \        W2,           WE4      p^ pTpM\        W4V,
          V4      pTpW&,           pVP                  ^ 8w  d   VRV pV P                  P                   w  rW P                  9   dm   W8  dG   \        P                  ! W3V P                  P                  R7      pV P                  VRRV
13&   Wn        WP                  V P                  V8H  Wx13&   R# \        P                  ! V P                  V P                  P                  P                  V4      4      V n        \        W4      p\        P                  ! V	^,           V3V P                  P                  R7      pV P                  VRR1RV
13&   WRWx13&   Wn        R# )r#   Nr   rS   r{   )r!   r7   r,   infr:   rb   r&   r'   r-   r   appendtyper0   )r<   valuesrf   rd   re   values_nn	min_index	max_index	data_rows	data_colsr&   ms   &&&          rC   _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(()IrP   c                6    V'       d   V P                  4       # V # r   r    )r<   r    s   &&rC   r)   _dia_base.todiah  s    99;KrP   c                   Ve   VR8w  d   \        R4      hV P                  w  r4\        V P                  4      pV P                  ) p\        P
                  ! \        V4      \        P                  R7      R,          p\        P
                  ! V\        P                  R7      We,          R,          ,
          p\        ^ WPP                  P                  ^,          ,
          4      p	\        P                  ! V P                  \        P                  ! V P                  P                  ^ ,          V	3V P                  P                  R7      34      p
WV3,          p
V P                  W3WC3VR7      # )NzvSparse arrays/matrices do not support an 'axes' parameter because swapping dimensions is the only logical permutation.r   )r!   r    )ry   r#   rR   )r1   r!   r0   r'   r,   rT   r:   intcr&   hstackr-   r   r   )r<   axesr    rU   rV   max_dimr'   rc
pad_amountr&   s   &&&        rC   	transpose_dia_base.transposep  s    L M M "ZZdjj/ <<- IIc'l"''27;IIhbgg.'2CW1MMGIIOOA$667
yy$))RXXtyyq/A:.N48IIOO&E F GqDz""D?; &* # , 	,rP   c                D   V P                   w  r#W) 8:  g   W8  d-   \        P                  ! ^ V P                  P                  R7      # \        P
                  ! V P                  V8H  4      w  p\        ^ V4      p\        W!,           V4      pWe,
          pVP                  ^ 8X  d,   \        P                  ! WpP                  P                  R7      # V P                  V^ ,          WV13,          pV\        V4      ,
          p	V	^ 8  d   \        P                  ! V^ V	3RR7      pV# )r#   r   constant)mode)r!   r,   emptyr&   r   nonzeror'   r0   rb   sizer-   r:   pad)
r<   rf   r   r   idx	first_collast_colresult_sizeresultpaddings
   &&        rC   diagonal_dia_base.diagonal  s    ZZ
:88ATYY__55zz$,,!+,1I	tx&*88q=88Kyy??3q69#556F+Q;VVFQLzBFrP   c                   V P                   ^ 8X  d(   V P                  V P                  V P                  R7      # V P                  w  r#V P                  P                  w  rE\
        P                  ! V4      pW`P                  R,          ,
          pV^ 8  pWV8  ,          pWV8  ,          pWP                  ^ 8g  ,          pV P                  \        V P                  4      R7      p	\
        P                  ! V^,           V	R7      p
\
        P                  ! VP                  ^ R7      RV 4      V
^V^,           % WS8  d   W,          W^,           R% VP                  VP                  ,          P                  V	RR7      pV P                  P                  VP                  ,          pV P                  WV
3V P                  V P                  R7      # )	r#   r   Nr   rj   Fr   )r!   r   rR   )rI   _csc_containerr!   r   r&   r,   rT   r'   r/   r0   r-   cumsumrn   Tr9   )r<   r    rU   rV   num_offsets
offset_lenrW   rX   rY   r?   indptrindicesr&   s   &&           rC   tocsc_dia_base.tocsc  sl   88q=&&tzz&DD!ZZ"&))//ii
+LL00qx x'(a ))TZZ)A	(Q,i8!#4888+;IX+F!GqA $*$6Fa<=!%%-&&yu&=yy{{466"""D6#:$**)- # 5 	5rP   c                   V P                   w  r#V P                  P                   w  rE\        P                  ! V4      pW`P                  R,          ,
          pV^ 8  pWV8  ,          pWV8  ,          pWP                  ^ 8g  ,          pWx,          p\        P
                  ! Wd4      VP                  4       ,          p	V P                  V P                  3\        V P                   4      R7      p
VP                  V
RR7      pV	P                  V
RR7      p	V P                  V,          pV P                  WV	33V P                   V P                  RR7      # )rS   )arraysr   Fr   )r!   r   r    rR   )r!   r&   r,   rT   r'   tiler   r/   r0   r9   r8   r   )r<   r    rU   rV   r   r   rW   rX   rY   colr?   r&   s   &&          rC   tocoo_dia_base.tocoo  s   !ZZ"&))//ii
+LL00qx x'(a iggk/

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

 # 
 	
rP   c                    V'       d7   V P                  WP                  P                  4       3V P                  R7      # V P                  WP                  3V P                  R7      # )zReturns 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!   )r<   r&   r    s   &&&rC   r~   _dia_base._with_data  sb     &&||((*+4:: '   &&||$DJJ '  rP   c                &   \        V4      pVw  r#V P                  R RV13,          V n        W P                  ^ ,          8  d   \        P                  ! V P
                  V P                  ^ ,          ,           V P                  P                  ^,          8  4      '       dm   V P
                  R,          V P                  ^ ,          ,           \        P                  ! V P                  P                  ^,          4      8*  p^ V P                  V&   Wn        R# )rS   NrR   )r   r&   r!   r,   anyr'   rT   r(   )r<   r!   rd   re   rY   s   &*   rC   resize_dia_base.resize  s    E"IIa!e$	

1t||djjm3diiooa6HHIILL)DJJqM9IIdiiooa012DDIIdOrP   )r(   r&   r'   )NNFr   )NNN)Frl   )NF)T)__name__
__module____qualname____firstlineno___formatr$   rN   rZ   r^   r   __doc__rg   rn   r|   r   r   r   r   r   r   r   r)   r   r   r   r   r~   r   __static_attributes____classdictcell____classcell__)r   __classdict__s   @@rC   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 ^^++FNNrP   r   c                t    \         P                  ! V 4      p\         P                  ! \        V 4      4      W&   V# )z)Helper function to invert an index array.)r,   
zeros_likerT   r:   )r   invs   & rC   r   r     s)    
--
CyyS"CHJrP   c                "    \        V \        4      # )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   )rs   s   &rC   isspmatrix_diar    s    . a$$rP   c                       ] tR tRtRtRtR# )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.]])
rm   Nr   r   r   r   r   r   rm   rP   rC   r   r         HrP   c                       ] tR tRtRtRtR# )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.]])
rm   Nr  rm   rP   rC   r   r   \  r  rP   )r   r   r  )"r   __docformat____all__numpyr,   
_lib._utilr   _matrixr   _baser   r   r   r	   _datar
   _sputilsr   r   r   r   r   r   r   r   _sparsetoolsr   r   r   r   r   r  r   r   rm   rP   rC   <module>r     su    %
7  '  7 7    > =W, W,t%6I	7 IXI9 IrP   