1、稀疏矩阵的常见存储形式
Block Sparse Row matrix
A sparse matrix in COOrdinate format.
Compressed Sparse Column matrix
Compressed Sparse Row matrix
Sparse matrix with DIAgonal storage
Dictionary Of Keys based sparse matrix.
Row-based linked list sparse matrix
2、不同存储形式的区别
>>> from scipy import sparse
>>> sparse.bsr_matrix([[1,0,0,0,0],[0,1,0,0,1]])
<2x5 sparse matrix of type '<class 'numpy.int32'>'
with 3 stored elements (blocksize = 1x1) in Block Sparse Row format>
>>> sparse.coo_matrix([[1,0,0,0,0],[0,1,0,0,1]])
<2x5 sparse matrix of type '<class 'numpy.int32'>'
with 3 stored elements in COOrdinate format>
>>> sparse.csc_matrix([[1,0,0,0,0],[0,1,0,0,1]])
<2x5 sparse matrix of type '<class 'numpy.int32'>'
with 3 stored elements in Compressed Sparse Column format>
>>> sparse.csr_matrix([[1,0,0,0,0],[0,1,0,0,1]])
<2x5 sparse matrix of type '<class 'numpy.int32'>'
with 3 stored elements in Compressed Sparse Row format>
>>> sparse.dia_matrix([[1,0,0,0,0],[0,1,0,0,1]])
<2x5 sparse matrix of type '<class 'numpy.int32'>'
with 4 stored elements (2 diagonals) in DIAgonal format>
>>> sparse.dok_matrix([[1,0,0,0,0],[0,1,0,0,1]])
<2x5 sparse matrix of type '<class 'numpy.int32'>'
with 3 stored elements in Dictionary Of Keys format>
>>> sparse.lil_matrix([[1,0,0,0,0],[0,1,0,0,1]])
<2x5 sparse matrix of type '<class 'numpy.int32'>'
with 3 stored elements in LInked List format>
3、sparse模块中用于创建稀疏矩阵的函数
Sparse matrix with ones on diagonal
Identity matrix in sparse format
kronecker product of sparse matrices A and B
kronecker sum of sparse matrices A and B
Construct a sparse matrix from diagonals.
Return a sparse matrix from diagonals.
Build a block diagonal sparse matrix from provided matrices.
Return the lower triangular portion of a matrix in sparse format
Return the upper triangular portion of a matrix in sparse format
Build a sparse matrix from sparse sub-blocks
Stack sparse matrices horizontally (column wise)
Stack sparse matrices vertically (row wise)
Generate a sparse matrix of the given shape and density with uniformly distributed values.
Generate a sparse matrix of the given shape and density with randomly distributed values.
4、用法演示(为了不影响排版,直接从我整理的PPT上截图过来了)