nlcpy.inner

nlcpy.inner(a, b)[ソース]

Computes an inner product of two arrays.

Ordinary inner product of vectors for 1-D arrays (without complex conjugation).

Parameters
a, barray_like

If a and b are nonscalar, their shape must match.

Returns
outndarray

out.shape = a.shape[:-1] + b.shape[:-1]

参考

dot

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.

Examples

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.]])