Return a sparse matrix from diagonals.
Parameters : | data : array_like
diags : diagonals to set
m, n : int
format : format of the result (e.g. “csr”)
|
---|
See also
Examples
>>> data = array([[1,2,3,4],[1,2,3,4],[1,2,3,4]])
>>> diags = array([0,-1,2])
>>> spdiags(data, diags, 4, 4).todense()
matrix([[1, 0, 3, 0],
[1, 2, 0, 4],
[0, 2, 3, 0],
[0, 0, 3, 4]])