Solve the tensor equation a x = b for x.
It is assumed that all indices of x are summed over in the product, together with the rightmost indices of a, as is done in, for example, tensordot(a, x, axes=len(b.shape)).
Parameters : | a : array_like
b : array_like
axes : tuple of ints, optional
|
---|---|
Returns : | x : ndarray, shape Q |
Raises : | LinAlgError :
|
See also
tensordot, tensorinv
Examples
>>> 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