- nlcpy.inner(a, b)
Computes an inner product of two arrays.
Ordinary inner product of vectors for 1-D arrays (without complex conjugation).
- a, barray_like
If a and b are nonscalar, their shape must match.
out.shape = a.shape[:-1] + b.shape[:-1]
Computes a dot product of two arrays.
For vectors (1-D arrays) it computes the ordinary inner-product:
import nlcpy as vp vp.inner(a, b) # equivalent to sum(a[:]*b[:])
if a or b is scalar, in which case:
vp.inner(a, b) # equivalent to a*b
If a or b is not 1-D array : NotImplementedError occurs.
Ordinary inner product for vectors:
>>> import nlcpy as vp >>> a = vp.array([1,2,3]) >>> b = vp.array([0,1,0]) >>> vp.inner(a, b) array(2)
An example where b is a scalar:
>>> vp.inner(vp.eye(2), 7) array([[7., 0.], [0., 7.]])