使用python中的modred模块计算特征向量和特征值时出错

时间:2018-03-03 01:44:34

标签: python eigenvalue eigenvector

我正在尝试使用python中的modred模块计算正交分解。

当代码执行以下行时:

> myPOD = mr.PODHandles(inner_product,max_vecs_per_node=20) eigvals,
> eigvecs = myPOD.compute_decomp(vec_handles)

我收到以下错误。我不理解这个错误,因为我对python很新。

追踪(最近一次呼叫最后一次):

File "podd.py", line 147, in <module>
    eigvals, eigvecs = myPOD.compute_decomp(vec_handles)  
File "/home/sindhuja/.local/lib/python2.7/site-packages/modred/pod.py", line 326, in compute_decomp
    self.compute_eigendecomp(atol=atol, rtol=rtol)  
File "/home/sindhuja/.local/lib/python2.7/site-packages/modred/pod.py", line 301, in compute_eigendecomp
    is_positive_definite=True)   
File "/home/sindhuja/.local/lib/python2.7/site-packages/modred/parallel.py", line 216, in call_and_bcast
    outputs = func(*args, **kwargs)   
File "/home/sindhuja/.local/lib/python2.7/site-packages/modred/util.py", line 250, in eigh
    eigvals, eigvecs = np.linalg.eigh(np.mat(mat))  
File "/home/sindhuja/.local/lib/python2.7/site-packages/numpy/linalg/linalg.py", line 1291, in eigh
    w, vt = gufunc(a, signature=signature, extobj=extobj) 
TypeError: No loop matching the specified signature and casting was found for ufunc eigh_lo

如何处理此错误?

1 个答案:

答案 0 :(得分:0)

试试这个:

eigvals, eigvecs = myPOD_compute_decomp(vec_handles)

这个函数返回两个参数,但你只给一个。