inner(a, b, /)
Ordinary inner product of vectors for 1-D arrays (without complex conjugation), in higher dimensions a sum product over the last axes.
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 :None:None:`ndim(a) = r > 0`
and :None:None:`ndim(b) = s > 0`
:
np.inner(a, b) = np.tensordot(a, b, axes=(-1,-1))
or explicitly:
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:
np.inner(a,b) = a*b
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])
Inner product of two arrays.
dot
Generalised matrix product, using second last dimension of :None:None:`b`
.
einsum
Einstein summation convention.
tensordot
Sum products over arbitrary axes.
Ordinary inner product for vectors:
This example is valid syntax, but we were not able to check execution>>> a = np.array([1,2,3])
... b = np.array([0,1,0])
... np.inner(a, b) 2
Some multidimensional examples:
This example is valid syntax, but we were not able to check execution>>> a = np.arange(24).reshape((2,3,4))This example is valid syntax, but we were not able to check execution
... b = np.arange(4)
... c = np.inner(a, b)
... c.shape (2, 3)
>>> c array([[ 14, 38, 62], [ 86, 110, 134]])This example is valid syntax, but we were not able to check execution
>>> a = np.arange(2).reshape((1,1,2))This example is valid syntax, but we were not able to check execution
... 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.]])See :
Hover to see nodes names; edges to Self not shown, Caped at 50 nodes.
Using a canvas is more power efficient and can get hundred of nodes ; but does not allow hyperlinks; , arrows or text (beyond on hover)
SVG is more flexible but power hungry; and does not scale well to 50 + nodes.
All aboves nodes referred to, (or are referred from) current nodes; Edges from Self to other have been omitted (or all nodes would be connected to the central node "self" which is not useful). Nodes are colored by the library they belong to, and scaled with the number of references pointing them