dpnp.linalg.tensorsolve

dpnp.linalg.tensorsolve(a, b, axes=None)[source]

Solve the tensor equation a x = b for x.

For full documentation refer to numpy.linalg.tensorsolve.

Parameters:
  • a ({dpnp.ndarray, usm_ndarray}) -- Coefficient tensor, of shape b.shape + Q. Q, a tuple, equals the shape of that sub-tensor of a consisting of the appropriate number of its rightmost indices, and must be such that prod(Q) == prod(b.shape) (in which sense a is said to be 'square').

  • b ({dpnp.ndarray, usm_ndarray}) -- Right-hand tensor, which can be of any shape.

  • axes ({None, tuple of ints}, optional) -- Axes in a to reorder to the right, before inversion. If None , no reordering is done. Default: None.

Returns:

out -- The tensor with shape Q such that b.shape + Q == a.shape.

Return type:

dpnp.ndarray

See also

dpnp.linalg.tensordot

Compute tensor dot product along specified axes.

dpnp.linalg.tensorinv

Compute the 'inverse' of an N-dimensional array.

dpnp.einsum

Evaluates the Einstein summation convention on the operands.

Examples

>>> import dpnp as np
>>> 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)
array([ True])