原文:https://docs.scipy.org/doc/numpy/reference/generated/numpy.linalg.tensorsolve.html
校对:(虚位以待)
numpy.linalg.
tensorsolve
(a, b, axes=None)[source]为x解出张量方程a x = b
假设x的所有索引与a的最右边索引一起在产物中求和,如在例如 tensordot(a, x, axes = len(b.shape))
。
参数: | a:array_like
b:array_like
axes:ints的元组,可选
|
---|---|
返回: | x:ndarray,shape Q |
上升: | LinAlgError
|
也可以看看
tensordot
,tensorinv
,einsum
例子
>>> a = np.eye(2*3*4)
>>> a.shape = (2*3, 4, 2, 3, 4)
>>> b = np.random.randn(2*3, 4)
>>> x = np.linalg.tensorsolve(a, b)
>>> x.shape
(2, 3, 4)
>>> np.allclose(np.tensordot(a, x, axes=3), b)
True