我正在做一个非常简单的任务,就是采用矩阵' m1203.raw.mat'的SVD,这是一个非常稀疏的矩阵,只包含少数几个值,即
awk '{for(i=1;i<=NF;++i){print $i}}' m1203.raw.mat | sort | uniq -c
返回
227510 0.0
979 -1.0
1070 1.0
22 -2.0
27 2.0
1 -3.0
2 -4.0
3 4.0
1 -7.0
1 7.0
但矩阵的大小几乎是MB(否则我会附上它)
无论如何,这个简单的任务
import numpy
a = numpy.loadtxt('m1203.raw.mat')
s = [float(i) for i in range(-7,8)]
for r in a :
for c in r :
assert(c in s)
numpy.linalg.svd(a)
给出
Traceback (most recent call last):
File "trial.py", line 4, in <module>
numpy.linalg.svd(a)
File "/usr/lib/python2.7/dist-packages/numpy/linalg/linalg.py", line 1327, in svd
u, s, vt = gufunc(a, signature=signature, extobj=extobj)
File "/usr/lib/python2.7/dist-packages/numpy/linalg/linalg.py", line 99, in _raise_linalgerror_svd_nonconvergence
raise LinAlgError("SVD did not converge")
numpy.linalg.linalg.LinAlgError: SVD did not converge
任何想法?