dpnp.inner
- dpnp.inner(a, b)[source]
Returns the inner product of two arrays.
For full documentation refer to
numpy.inner
.- Parameters:
a ({dpnp.ndarray, usm_ndarray, scalar}) -- First input array. Both inputs a and b can not be scalars at the same time.
b ({dpnp.ndarray, usm_ndarray, scalar}) -- Second input array. Both inputs a and b can not be scalars at the same time.
- Returns:
out -- If either a or b is a scalar, the shape of the returned arrays matches that of the array between a and b, whichever is an array. If a and b are both 1-D arrays then a 0-d array is returned; otherwise an array with a shape as
out.shape = (*a.shape[:-1], *b.shape[:-1])
is returned.- Return type:
dpnp.ndarray
See also
dpnp.einsum
Einstein summation convention..
dpnp.dot
Generalized matrix product, using second last dimension of b.
dpnp.tensordot
Sum products over arbitrary axes.
Examples
# Ordinary inner product for vectors
>>> import dpnp as np >>> a = np.array([1, 2, 3]) >>> b = np.array([0, 1, 0]) >>> np.inner(a, b) array(2)
# Some multidimensional examples
>>> a = np.arange(24).reshape((2,3,4)) >>> b = np.arange(4) >>> c = np.inner(a, b) >>> c.shape (2, 3) >>> c array([[ 14, 38, 62], [86, 110, 134]])
>>> a = np.arange(2).reshape((1,1,2)) >>> b = np.arange(6).reshape((3,2)) >>> c = np.inner(a, b) >>> c.shape (1, 1, 3) >>> c array([[[1, 3, 5]]])
An example where b is a scalar
>>> np.inner(np.eye(2), 7) array([[7., 0.], [0., 7.]])