Sparse matrix with ones on diagonal
Returns a sparse (m x n) matrix where the k-th diagonal is all ones and everything else is zeros.
Parameters : | n : integer
m : integer, optional
k : integer, optional
dtype : :
format : string
|
---|
Examples
>>> from scipy import sparse
>>> sparse.eye(3).todense()
matrix([[ 1., 0., 0.],
[ 0., 1., 0.],
[ 0., 0., 1.]])
>>> sparse.eye(3, dtype=np.int8)
<3x3 sparse matrix of type '<type 'numpy.int8'>'
with 3 stored elements (1 diagonals) in DIAgonal format>