-
numpy.ma.inner(a, b)
[source] -
Inner product of two arrays.
Ordinary inner product of vectors for 1-D arrays (without complex conjugation), in higher dimensions a sum product over the last axes.
Parameters: a, b : array_like
If
a
andb
are nonscalar, their last dimensions must match.Returns: out : ndarray
out.shape = a.shape[:-1] + b.shape[:-1]
Raises: ValueError
If the last dimension of
a
andb
has different size.See also
-
tensordot
- Sum products over arbitrary axes.
-
dot
- Generalised matrix product, using second last dimension of
b
. -
einsum
- Einstein summation convention.
Notes
Masked values are replaced by 0.
Examples
Ordinary inner product for vectors:
1234>>> a
=
np.array([
1
,
2
,
3
])
>>> b
=
np.array([
0
,
1
,
0
])
>>> np.inner(a, b)
2
A multidimensional example:
12345>>> a
=
np.arange(
24
).reshape((
2
,
3
,
4
))
>>> b
=
np.arange(
4
)
>>> np.inner(a, b)
array([[
14
,
38
,
62
],
[
86
,
110
,
134
]])
An example where
b
is a scalar:123>>> np.inner(np.eye(
2
),
7
)
array([[
7.
,
0.
],
[
0.
,
7.
]])
-
numpy.ma.inner()

2025-01-10 15:47:30
Please login to continue.