1、稀疏矩阵的常见存储形式bsr_matrix(arg1[, shape, dtype, copy, blocksize])
Block Sparse Row matrixcoo_matrix(arg1[, shape, dtype, copy])
A sparse matrix in COOrdinate format.csc_matrix(arg1[, shape, dtype, copy])
Compressed Sparse Column matrixcsr_matrix(arg1[, shape, dtype, copy])
Compressed Sparse Row matrixdia_matrix(arg1[, shape, dtype, copy])
Sparse matrix with DIAgonal storagedok_matrix(arg1[, shape, dtype, copy])
Dictionary Of Keys based sparse matrix.lil_matrix(arg1[, shape, dtype, copy])
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 ''
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 ''
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 ''
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 ''
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 ''
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 ''
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 ''
with 3 stored elements in LInked List format>
3、sparse模块中用于创建稀疏矩阵的函数eye(m[, n, k, dtype, format])
Sparse matrix with ones on diagonalidentity(n[, dtype, format])
Identity matrix in sparse formatkron(A, B[, format])
kronecker product of sparse matrices A and Bkronsum(A, B[, format])
kronecker sum of sparse matrices A and Bdiags(diagonals[, offsets, shape, format, dtype])
Construct a sparse matrix from diagonals.spdiags(data, diags, m, n[, format])
Return a sparse matrix from diagonals.block_diag(mats[, format, dtype])
Build a block diagonal sparse matrix from provided matrices.tril(A[, k, format])
Return the lower triangular portion of a matrix in sparse formattriu(A[, k, format])
Return the upper triangular portion of a matrix in sparse formatbmat(blocks[, format, dtype])
Build a sparse matrix from sparse sub-blockshstack(blocks[, format, dtype])
Stack sparse matrices horizontally (column wise)vstack(blocks[, format, dtype])
Stack sparse matrices vertically (row wise)rand(m, n[, density, format, dtype, ...])
Generate a sparse matrix of the given shape and density with uniformly distributed values.random(m, n[, density, format, dtype, ...])
Generate a sparse matrix of the given shape and density with randomly distributed values.
4、用法演示(为了不影响排版,直接从我整理的PPT上截图过来了)
长按二维码向我转账
受苹果公司新规定影响,微信 iOS 版的赞赏功能被关闭,可通过二维码转账支持公众号。
阅读
好看
已推荐到看一看
你的朋友可以在“发现”-“看一看”看到你认为好看的文章。
已取消,“好看”想法已同步删除
已推荐到看一看
和朋友分享想法
最多200字,当前共字
发送
已发送
朋友将在看一看看到
确定
分享你的想法...
取消
分享想法到看一看
确定
最多200字,当前共字
发送中
网络异常,请稍后重试
微信扫一扫
关注该公众号
联系我们
欢迎来到TinyMind®。
关于TinyMind的内容或商务合作、网站建议,举报不良信息等均可联系我们。TinyMind商标已注册,本站为TinyMind唯一官网,任何盗用TinyMind品牌名建立的网站均为盗版,公司保留追究侵权的权利。
TinyMind客服邮箱:support@tinymind.net.cn
©TinyMind.net.cn,腾英旗下专业AI技术社区 沪ICP备17018069号-3
友情链接
腾英公司旗下