scipy.sparse.lil_diags

scipy.sparse.lil_diags(diags, offsets, (m, n), dtype='d')

Generate a lil_matrix with the given diagonals.

Parameters :

diags : list of list of values e.g. [[1,2,3],[4,5]]

values to be placed on each indicated diagonal.

offsets : list of ints

diagonal offsets. This indicates the diagonal on which the given values should be placed.

(r,c) : tuple of ints

row and column dimensions of the output.

dtype : dtype

output data-type.

Examples

>>> lil_diags([[1,2,3],[4,5],[6]],[0,1,2],(3,3)).todense()
matrix([[ 1.,  4.,  6.],
        [ 0.,  2.,  5.],
        [ 0.,  0.,  3.]])

Previous topic

scipy.sparse.lil_eye

Next topic

scipy.sparse.spdiags

This Page