On this page
numpy.linalg.tensorsolve
linalg.tensorsolve(a, b, axes=None)[source]- 
    
Solve the tensor equation
a x = bfor x.It is assumed that all indices of
xare summed over in the product, together with the rightmost indices ofa, as is done in, for example,tensordot(a, x, axes=b.ndim).- Parameters
 - 
      
aarray_like- 
        
Coefficient tensor, of shape
b.shape + Q.Q, a tuple, equals the shape of that sub-tensor ofaconsisting of the appropriate number of its rightmost indices, and must be such thatprod(Q) == prod(b.shape)(in which senseais said to be ‘square’). barray_like- 
        
Right-hand tensor, which can be of any shape.
 axestuple of ints, optional- 
        
Axes in
ato reorder to the right, before inversion. If None (default), no reordering is done. 
 - Returns
 - 
      
xndarray, shape Q
 - Raises
 - 
      
- LinAlgError
 - 
        
If
ais singular or not ‘square’ (in the above sense). 
 
See also
numpy.tensordot, tensorinv,numpy.einsum
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 
© 2005–2021 NumPy Developers
Licensed under the 3-clause BSD License.
 https://numpy.org/doc/1.20/reference/generated/numpy.linalg.tensorsolve.html