Using alternative LAPACK driver in numpy's svd method?

一世执手 提交于 2019-12-06 03:20:33

What worked for me was to only compute the "economy size" SVD of that matrix X:

U,S,V = np.linalg.svd(X, full_matrices=False)

I'm a little late, but maybe this will help someone else...

I had a similar problem in julia.

I found this approach from the R help list, which should work for any environment using the lapack library:

Basically, if svd(M) fails, try svd(M'), and swap the resulting U,V appropriately.

Here's how I'm doing it in julia:

try
  U,S,V = svd( E_restricted )
  failed = false
catch
  failed = true
end
if failed
  # try it with matrix transposed
  try
    V,S,U = svd( E_restricted' )
    failed = false
  catch
    failed = true
  end
end
if failed
  error("ERROR: svd(E) and svd(E') failed!")
end
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!