Skip to content

Add specification for computing the dot product (linalg: vecdot) #137

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
May 12, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 30 additions & 5 deletions spec/API_specification/linear_algebra_functions.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,6 @@ Returns the specified diagonals. If `x` has more than two dimensions, then the a

- if `x` is a two-dimensional array, a one-dimensional array containing the diagonal; otherwise, a multi-dimensional array containing the diagonals and whose shape is determined by removing `axis1` and `axis2` and appending a dimension equal to the size of the resulting diagonals. The returned array must have the same data type as `x`.

(function-dot)=
### dot()

TODO

(function-eig)=
### eig()

Expand Down Expand Up @@ -342,3 +337,33 @@ Transposes (or permutes the axes (dimensions)) of an array `x`.
- **out**: _<array>_

- an array containing the transpose. The returned array must have the same data type as `x`.

(function-vecdot)=
### vecdot(x1, x2, /, *, axis=None)

Computes the (vector) dot product of two arrays.

#### Parameters

- **x1**: _<array>_

- first input array. Should have a numeric data type.

- **x2**: _<array>_

- second input array. Must be compatible with `x1` (see {ref}`broadcasting`). Should have a numeric data type.

- **axis**: _Optional\[ int ]_

- axis over which to compute the dot product. Must be an integer on the interval `[-N, N)`, where `N` is the rank (number of dimensions) of the shape determined according to {ref}`broadcasting`. If specified as a negative integer, the function must determine the axis along which to compute the dot product by counting backward from the last dimension (where `-1` refers to the last dimension). If `None`, the function must compute the dot product over the last axis. Default: `None`.

#### 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 {ref}`broadcasting`. The returned array must have a data type determined by {ref}`type-promotion`.

#### Raises

- if provided an invalid `axis`.
- if the size of the axis over which to compute the dot product is not the same for both `x1` and `x2`.