vecdot — Python array API standard 2024.12 documentation (original) (raw)

vecdot(x1: array, x2: array, /, *, axis: int = -1) → array

Computes the (vector) dot product of two arrays.

Let \(\mathbf{a}\) be a vector in x1 and \(\mathbf{b}\) be a corresponding vector in x2. The dot product is defined as

\[\mathbf{a} \cdot \mathbf{b} = \sum_{i=0}^{n-1} \overline{a_i}b_i\]

over the dimension specified by axis and where \(n\) is the dimension size and \(\overline{a_i}\) denotes the complex conjugate if \(a_i\) is complex and the identity if \(a_i\) is real-valued.

Parameters:

Returns:

out (array) – if x1 and x2 are both one-dimensional arrays, a zero-dimensional containing the dot product; otherwise, a non-zero-dimensional array containing the dot products and having rank N-1, where N is the rank (number of dimensions) of the shape determined according to Broadcasting along the non-contracted axes. The returned array must have a data type determined by Type Promotion Rules.

Notes

Raises

Changed in version 2022.12: Added complex data type support.

Changed in version 2023.12: Restricted axis to only negative integers.