numpy.linalg.vecdot#
- linalg.vecdot(x1, x2, /, *, axis=-1)[源代码]#
计算向量点积.
与
numpy.vecdot相比,此函数仅限于与 Array API 兼容的参数.设 \(\mathbf{a}\) 是
x1中的一个向量, \(\mathbf{b}\) 是x2中对应的向量. 点积定义为:\[\mathbf{a} \cdot \mathbf{b} = \sum_{i=0}^{n-1} \overline{a_i}b_i\]over the dimension specified by
axisand where \(\overline{a_i}\) denotes the complex conjugate if \(a_i\) is complex and the identity otherwise.- 参数:
- x1array_like
第一个输入数组.
- x2array_like
第二个输入数组.
- 轴int, optional
计算点积的轴.默认值:
-1.
- 返回:
- outputndarray
输入的向量点积.
参见
示例
获取向量数组沿给定法线的投影大小.
>>> v = np.array([[0., 5., 0.], [0., 0., 10.], [0., 6., 8.]]) >>> n = np.array([0., 0.6, 0.8]) >>> np.linalg.vecdot(v, n) array([ 3., 8., 10.])