flopscope.numpy.vecdot
fnp.vecdot(a, b, **kwargs)[flopscope source][numpy source]
Vector dot product of two arrays.
Adapted from NumPy docs np.vecdot
Vector dot product along last axis.
Let be a vector in x1 and be
a corresponding vector in x2. The dot product is defined as:
where the sum is over the last dimension (unless axis is specified) and
where denotes the complex conjugate if
is complex and the identity otherwise.
Parameters
- x1, x2:array_like
Input arrays, scalars not allowed.
- out:ndarray, optional
A location into which the result is stored. If provided, it must have the broadcasted shape of
x1andx2with the last axis removed. If not provided or None, a freshly-allocated array is used.- **kwargs
For other keyword-only arguments, see the ufunc docs.
Returns
- y:ndarray
The vector dot product of the inputs. This is a scalar only when both x1, x2 are 1-d vectors.
Raises
- :ValueError
If the last dimension of
x1is not the same size as the last dimension ofx2.If a scalar value is passed in.
See also
- we.flops.vdot same but flattens arguments first
- we.flops.matmul Matrix-matrix product.
- we.flops.vecmat Vector-matrix product.
- we.flops.matvec Matrix-vector product.
- we.flops.einsum Einstein summation convention.
Examples
>>> import flopscope.numpy as fnpGet the projected size along a given normal for an array of vectors.
>>> v = flops.array([[0., 5., 0.], [0., 0., 10.], [0., 6., 8.]])
>>> n = flops.array([0., 0.6, 0.8])
>>> flops.vecdot(v, n)
array([ 3., 8., 10.])