- out : ndarray
If a and b are both
scalars or both 1-D arrays then a scalar is returned; otherwise
an array is returned.
out.shape = (*a.shape[:-1], *b.shape[:-1])
Raises:
- ValueError
If both a and b are nonscalar and their last dimensions have
different sizes.
Notes
Masked values are replaced by 0.
For vectors (1-D arrays) it computes the ordinary inner-product:
np.inner(a, b) = sum(a[:]*b[:])
More generally, if ndim(a) = r > 0 and ndim(b) = s > 0:
np.inner(a, b) = np.tensordot(a, b, axes=(-1,-1))
np.inner(a, b)[i0,...,ir-2,j0,...,js-2]
= sum(a[i0,...,ir-2,:]*b[j0,...,js-2,:])
In addition a or b may be scalars, in which case:
Examples
b
)
c
.
shape
(2, 3)
c
array([[ 14, 38, 62],
[ 86, 110, 134]])
=
np
.
inner
(
a
,
b
)
c
.
shape
(1, 1, 3)
c
array([[[1, 3, 5]]])