我正在尝试将向量(3 乘 1)乘以其转置(1 乘 3)。我得到一个 (3 x 3) 数组,但我无法得到它的倒数。知道为什么吗?
import numpy as np
c=array([1, 8, 50])
np.transpose(c[np.newaxis]) * c
array([[ 1, 8, 50],
[ 8, 64, 400],
[ 50, 400, 2500]])
np.linalg.inv(np.transpose(c[np.newaxis]) * c)
Traceback (most recent call last):
File "<console>", line 1, in <module>
File "C:\Python26\lib\site-packages\numpy\linalg\linalg.py", line 445, in inv
return wrap(solve(a, identity(a.shape[0], dtype=a.dtype)))
File "C:\Python26\lib\site-packages\numpy\linalg\linalg.py", line 328, in solve
raise LinAlgError, 'Singular matrix'
LinAlgError: Singular matrix