Skip to content

Commit 36fd440

Browse files
authored
Add specification for computing the dot product (linalg: vecdot) (#137)
* Add dot product specification * Update specification * Fix output shape * Update description * Update copy * Update copy * Rename to inner_dot * Update dtype requirements * Rename to vecdot
1 parent 9893373 commit 36fd440

File tree

1 file changed

+30
-5
lines changed

1 file changed

+30
-5
lines changed

spec/API_specification/linear_algebra_functions.md

+30-5
Original file line numberDiff line numberDiff line change
@@ -115,11 +115,6 @@ Returns the specified diagonals. If `x` has more than two dimensions, then the a
115115

116116
- 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`.
117117

118-
(function-dot)=
119-
### dot()
120-
121-
TODO
122-
123118
(function-eig)=
124119
### eig()
125120

@@ -400,3 +395,33 @@ Transposes (or permutes the axes (dimensions)) of an array `x`.
400395
- **out**: _<array>_
401396
402397
- an array containing the transpose. The returned array must have the same data type as `x`.
398+
399+
(function-vecdot)=
400+
### vecdot(x1, x2, /, *, axis=None)
401+
402+
Computes the (vector) dot product of two arrays.
403+
404+
#### Parameters
405+
406+
- **x1**: _<array>_
407+
408+
- first input array. Should have a numeric data type.
409+
410+
- **x2**: _<array>_
411+
412+
- second input array. Must be compatible with `x1` (see {ref}`broadcasting`). Should have a numeric data type.
413+
414+
- **axis**: _Optional\[ int ]_
415+
416+
- 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`.
417+
418+
#### Returns
419+
420+
- **out**: _<array;>_
421+
422+
- 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`.
423+
424+
#### Raises
425+
426+
- if provided an invalid `axis`.
427+
- if the size of the axis over which to compute the dot product is not the same for both `x1` and `x2`.

0 commit comments

Comments
 (0)