我想把我的稀疏scipy.lil iu矩阵再通过向量求出稀疏矩阵。假设我有2个lil\u矩阵变量和2个numpy数组a, b, c, d
,如下所示
In [1]: a
Out[1]:
<4x3 sparse matrix of type '<class 'numpy.float64'>'
with 11 stored elements in LInked List format>
In [2]: b
Out[2]:
<4x1 sparse matrix of type '<class 'numpy.float64'>'
with 4 stored elements in LInked List format>
In [3]: c
Out[3]:
array([[ 0., 1., 2.],
[ 1., 2., 3.],
[ 2., 3., 4.],
[ 3., 4., 5.]])
In [4]: d
Out[4]:
array([[ 1.],
[ 2.],
[ 3.],
[ 4.]])
划分numpy矩阵/向量是完美的
^{pr2}$但是分割lil峎矩阵/向量会引起值错误:形状不一致
^{3}$有什么好方法可以用向量来划分稀疏矩阵吗?在
您可以使用
multiply()
方法,结果仍然是稀疏矩阵,但采用coo
格式:相关问题 更多 >
编程相关推荐