基本上,我只是想做一个简单的矩阵乘法,具体来说,提取它的每一列并通过将它除以它的长度来标准化它。
#csc sparse matrix
self.__WeightMatrix__ = self.__WeightMatrix__.tocsc()
#iterate through columns
for Col in xrange(self.__WeightMatrix__.shape[1]):
Column = self.__WeightMatrix__[:,Col].data
List = [x**2 for x in Column]
#get the column length
Len = math.sqrt(sum(List))
#here I assumed dot(number,Column) would do a basic scalar product
dot((1/Len),Column)
#now what? how do I update the original column of the matrix, everything that have been returned are copies, which drove me nuts and missed pointers so much
我搜索了 scipy 稀疏矩阵文档,没有得到任何有用的信息。我希望一个函数返回一个指向矩阵的指针/引用,以便我可以直接修改它的值。谢谢