From bc73de339174a62aee9cdfe4280d5729bed6f1cf Mon Sep 17 00:00:00 2001 From: Athan Reines Date: Mon, 24 Aug 2020 00:55:18 -0700 Subject: [PATCH 01/20] Add cross signature --- .../linear_algebra_functions.md | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 spec/API_specification/linear_algebra_functions.md diff --git a/spec/API_specification/linear_algebra_functions.md b/spec/API_specification/linear_algebra_functions.md new file mode 100644 index 000000000..8bc9c7ff4 --- /dev/null +++ b/spec/API_specification/linear_algebra_functions.md @@ -0,0 +1,38 @@ +# Linear Algebra Functions + +> Array API specification for linear algebra functions. + +A conforming implementation of the array API standard must provide and support the following functions adhering to the following conventions. + +- Positional parameters must be [positional-only](https://www.python.org/dev/peps/pep-0570/) parameters. Positional-only parameters have no externally-usable name. When a function accepting positional-only parameters is called, positional arguments are mapped to these parameters based solely on their order. +- Optional parameters must be [keyword-only](https://www.python.org/dev/peps/pep-3102/) arguments. +- Broadcasting semantics must follow the semantics defined in :ref:`broadcasting`. +- Unless stated otherwise, functions must support the data types defined in :ref:`data-types`. +- Unless stated otherwise, functions must adhere to the type promotion rules defined in :ref:`type-promotion`. +- Unless stated otherwise, floating-point operations must adhere to IEEE 754-2019. + + + +### # cross(a, b, /, *, axis=-1) + +Returns the cross product of 3-element vectors. If `a` and `b` are multi-dimensional arrays (i.e., both have a rank greater than `1`), then the cross-product of each pair of corresponding 3-element vectors is independently computed. + +#### Parameters + +- **a**: _<array>_ + + - first input array. + +- **b**: _<array>_ + + - second input array. Must have the same shape as `a`. + +- **axis**: _int_ + + - the axis of `a` and `b` containing the vectors for which to compute the cross product. If set to `-1`, the function computes the cross product for vectors defined by the last axis. Default: `-1`. + +#### Returns + +- **out**: _<array>_ + + - an array containing the cross products. \ No newline at end of file From 7d9be38d23755c8d7349e7f382584a52de95b44e Mon Sep 17 00:00:00 2001 From: Athan Reines Date: Mon, 24 Aug 2020 01:06:49 -0700 Subject: [PATCH 02/20] Add det specification --- .../linear_algebra_functions.md | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/spec/API_specification/linear_algebra_functions.md b/spec/API_specification/linear_algebra_functions.md index 8bc9c7ff4..a9429ebd1 100644 --- a/spec/API_specification/linear_algebra_functions.md +++ b/spec/API_specification/linear_algebra_functions.md @@ -35,4 +35,20 @@ Returns the cross product of 3-element vectors. If `a` and `b` are multi-dimensi - **out**: _<array>_ - - an array containing the cross products. \ No newline at end of file + - an array containing the cross products. + +### # det(a, /) + +Returns the determinant of a square matrix (or stack of square matrices) `a`. + +#### Parameters + +- **a**: _<array>_ + + - input array having shape `(..., M, M)` and whose innermost two dimensions form square matrices. + +#### Returns + +- **out**: _<array>_ + + - if `a` is a two-dimensional array, a zero-dimensional array containing the determinant; otherwise, a non-zero dimensional array containing the determinant for each square matrix. From 88090b4d6db5298aa19bc773ddd33fd224cb0f05 Mon Sep 17 00:00:00 2001 From: Athan Reines Date: Mon, 24 Aug 2020 01:30:54 -0700 Subject: [PATCH 03/20] Add diagonal specification --- .../linear_algebra_functions.md | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/spec/API_specification/linear_algebra_functions.md b/spec/API_specification/linear_algebra_functions.md index a9429ebd1..76cc90f13 100644 --- a/spec/API_specification/linear_algebra_functions.md +++ b/spec/API_specification/linear_algebra_functions.md @@ -52,3 +52,37 @@ Returns the determinant of a square matrix (or stack of square matrices) `a`. - **out**: _<array>_ - if `a` is a two-dimensional array, a zero-dimensional array containing the determinant; otherwise, a non-zero dimensional array containing the determinant for each square matrix. + +### # diagonal(a, /, *, offset=0, axis1=0, axis2=1) + +Returns the specified diagonals. If `a` has more than two dimensions, then the axes specified by `axis1` and `axis2` are used to determine the two-dimensional sub-arrays from which to return diagonals. + +#### Parameters + +- **a**: _<array>_ + + - input array. Must have at least `2` dimensions. + +- **offset**: _int_ + + - offset specifying the off-diagonal relative to the main diagonal. + + - `offset = 0`: the main diagonal. + - `offset > 0`: off-diagonal above the main diagonal. + - `offset < 0`: off-diagonal below the main diagonal. + + Default: `0`. + +- **axis1**: _int_ + + - first axis with respect to which to take diagonal. Default: `0`. + +- **axis2**: _int_ + + - second axis with respect to which to take diagonal. Default: `1`. + +#### Returns + +- **out**: _<array>_ + + - if `a` 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 type as `a`. From 02f80be4e53bbcdc4da023246028abcdb7130c4b Mon Sep 17 00:00:00 2001 From: Athan Reines Date: Mon, 24 Aug 2020 01:35:44 -0700 Subject: [PATCH 04/20] Add inv specification --- .../linear_algebra_functions.md | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/spec/API_specification/linear_algebra_functions.md b/spec/API_specification/linear_algebra_functions.md index 76cc90f13..1969c4056 100644 --- a/spec/API_specification/linear_algebra_functions.md +++ b/spec/API_specification/linear_algebra_functions.md @@ -85,4 +85,20 @@ Returns the specified diagonals. If `a` has more than two dimensions, then the a - **out**: _<array>_ - - if `a` 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 type as `a`. + - if `a` 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. Must have the same type as `a`. + +### # inv(a, /) + +Computes the multiplicative inverse of a square matrix (or stack of square matrices) `a`. + +#### Parameters + +- **a**: _<array>_ + + - input array having shape `(..., M, M)` and whose innermost two dimensions form square matrices. + +#### Returns + +- **out**: _<array>_ + + - an array containing the multiplicative inverses. Must have the same type and shape as `a`. From 41697d90ee9226220fe824276c06d0caa414af63 Mon Sep 17 00:00:00 2001 From: Athan Reines Date: Mon, 24 Aug 2020 10:51:23 -0700 Subject: [PATCH 05/20] Add norm specification --- .../linear_algebra_functions.md | 82 ++++++++++++++++--- spec/purpose_and_scope.md | 4 + 2 files changed, 74 insertions(+), 12 deletions(-) diff --git a/spec/API_specification/linear_algebra_functions.md b/spec/API_specification/linear_algebra_functions.md index 1969c4056..178cb7896 100644 --- a/spec/API_specification/linear_algebra_functions.md +++ b/spec/API_specification/linear_algebra_functions.md @@ -29,7 +29,7 @@ Returns the cross product of 3-element vectors. If `a` and `b` are multi-dimensi - **axis**: _int_ - - the axis of `a` and `b` containing the vectors for which to compute the cross product. If set to `-1`, the function computes the cross product for vectors defined by the last axis. Default: `-1`. + - the axis (dimension) of `a` and `b` containing the vectors for which to compute the cross product. If set to `-1`, the function computes the cross product for vectors defined by the last axis (dimension). Default: `-1`. #### Returns @@ -53,9 +53,9 @@ Returns the determinant of a square matrix (or stack of square matrices) `a`. - if `a` is a two-dimensional array, a zero-dimensional array containing the determinant; otherwise, a non-zero dimensional array containing the determinant for each square matrix. -### # diagonal(a, /, *, offset=0, axis1=0, axis2=1) +### # diagonal(a, /, *, axis1=0, axis2=1, offset=0) -Returns the specified diagonals. If `a` has more than two dimensions, then the axes specified by `axis1` and `axis2` are used to determine the two-dimensional sub-arrays from which to return diagonals. +Returns the specified diagonals. If `a` has more than two dimensions, then the axes (dimensions) specified by `axis1` and `axis2` are used to determine the two-dimensional sub-arrays from which to return diagonals. #### Parameters @@ -63,6 +63,14 @@ Returns the specified diagonals. If `a` has more than two dimensions, then the a - input array. Must have at least `2` dimensions. +- **axis1**: _int_ + + - first axis (dimension) with respect to which to take diagonal. Default: `0`. + +- **axis2**: _int_ + + - second axis (dimension) with respect to which to take diagonal. Default: `1`. + - **offset**: _int_ - offset specifying the off-diagonal relative to the main diagonal. @@ -73,32 +81,82 @@ Returns the specified diagonals. If `a` has more than two dimensions, then the a Default: `0`. -- **axis1**: _int_ +#### Returns + +- **out**: _<array>_ - - first axis with respect to which to take diagonal. Default: `0`. + - if `a` 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. Must have the same data type as `a`. -- **axis2**: _int_ +### # inv(a, /) - - second axis with respect to which to take diagonal. Default: `1`. +Computes the multiplicative inverse of a square matrix (or stack of square matrices) `a`. + +#### Parameters + +- **a**: _<array>_ + + - input array having shape `(..., M, M)` and whose innermost two dimensions form square matrices. #### Returns - **out**: _<array>_ - - if `a` 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. Must have the same type as `a`. + - an array containing the multiplicative inverses. Must have the same data type and shape as `a`. -### # inv(a, /) +### # norm(a, /, *, axis=None, keepdims=False, ord=None) -Computes the multiplicative inverse of a square matrix (or stack of square matrices) `a`. +Computes the matrix or vector norm of `a`. #### Parameters - **a**: _<array>_ - - input array having shape `(..., M, M)` and whose innermost two dimensions form square matrices. + - input array. If `axis` is `None`, `a` must be either one- or two-dimensional. + +- **axis**: _Optional\[ Union\[ int, Tuple\[ int, int ] ] ]_ + + - If an integer, `axis` specifies the axis (dimension) along which to compute vector norms. If a 2-tuple, `axis` specifies the axes (dimensions) defining two-dimensional matrices for which to compute matrix norms. If `None`, + + - if `a` is one-dimensional, the function computes the vector norm. + - if `a` is two-dimensional, the function computes the matrix norm. + - if `a` has more than two dimensions, the function computes the vector norm for vectors defined by the last axis (dimension). Equivalent to specifying `axis=-1`. + + Negative indices must be supported. Default: `None`. + +- **keepdims**: _bool_ + + - If `True`, the axes (dimensions) specified by `axis` must be included in the result as singleton dimensions, and, accordingly, the result must be compatible with the input array (see :ref:`broadcasting`). Otherwise, if `False`, the axes (dimensions) specified by `axis` must not be included in the result. Default: `False`. + +- **ord**: _Optional\[ int, float, inf, 'fro', 'nuc' ]_ + + - order of the norm. The following norms must be supported: + + | ord | matrix | vector | + | ----------- | ------------------------------- | ------------------- | + | None | 'fro' | L2-norm (Euclidean) | + | 'fro' | 'fro' | - | + | 'nuc' | 'nuc' | - | + | 1 | max(sum(abs(x), axis=0)) | L1-norm | + | 2 | largest singular value | L2-norm (Euclidean) | + | inf | max(sum(abs(x), axis=1)) | infinity norm | + | (int,float) | - | p-norm (for p >= 1) | + + where `fro` corresponds to the **Frobenius norm**, `nuc` corresponds to the **nuclear norm**, and `-` indicates that the norm is **not** supported. For matrices, + + - if `ord=1`, the norm corresponds to the induced matrix norm where `p=1` (i.e., the maximum absolute value column sum). + - if `ord=2`, the norm corresponds to the induced matrix norm where `p=inf` (i.e., the maximum absolute value row sum). + - if `ord=inf`, the norm corresponds to the induced matrix norm where `p=2` (i.e., the largest singular value). + + If `None`, + + - if matrix (or matrices), the function computes the Frobenius norm. + - if vector (or vectors), the function computes the L2-norm (Euclidean norm). + + Default: `None`. #### Returns - **out**: _<array>_ - - an array containing the multiplicative inverses. Must have the same type and shape as `a`. + - an array containing the norms. Must have the same data type as `a`. If `axis` is a scalar value (`int` or `float`), the output array has a rank which is one less than the rank of `a`. If `axis` is a 2-tuple, the output array has a rank which is two less than the rank of `a`. + diff --git a/spec/purpose_and_scope.md b/spec/purpose_and_scope.md index 9481d72d1..58f7d1237 100644 --- a/spec/purpose_and_scope.md +++ b/spec/purpose_and_scope.md @@ -50,6 +50,10 @@ For the purposes of this specification, the following terms and definitions appl a (usually fixed-size) multidimensional container of items of the same type and size. +### axis + +an array dimension. + ### broadcast automatic (implicit) expansion of array dimensions to be of equal sizes without copying array data for the purpose of making arrays with different shapes have compatible shapes for element-wise operations. From 20164af9a4d8aef55e575dd834fd1a2990c8fc84 Mon Sep 17 00:00:00 2001 From: Athan Reines Date: Mon, 24 Aug 2020 11:04:52 -0700 Subject: [PATCH 06/20] Add outer product specification --- .../linear_algebra_functions.md | 19 +++++++++++++++++++ spec/purpose_and_scope.md | 8 ++++++++ 2 files changed, 27 insertions(+) diff --git a/spec/API_specification/linear_algebra_functions.md b/spec/API_specification/linear_algebra_functions.md index 178cb7896..0bf1f752b 100644 --- a/spec/API_specification/linear_algebra_functions.md +++ b/spec/API_specification/linear_algebra_functions.md @@ -160,3 +160,22 @@ Computes the matrix or vector norm of `a`. - an array containing the norms. Must have the same data type as `a`. If `axis` is a scalar value (`int` or `float`), the output array has a rank which is one less than the rank of `a`. If `axis` is a 2-tuple, the output array has a rank which is two less than the rank of `a`. +### # outer(a, b, /) + +Computes the outer product of two vectors `a` and `b`. + +#### Parameters + +- **a**: _<array>_ + + - first one-dimensional input array of size `N`. + +- **b**: _<array>_ + + - second one-dimensional input array of size `M`. + +#### Returns + +- **out**: _<array>_ + + - a two-dimensional array containing the outer product and whose shape is `NxM`. \ No newline at end of file diff --git a/spec/purpose_and_scope.md b/spec/purpose_and_scope.md index 58f7d1237..7e00a4e27 100644 --- a/spec/purpose_and_scope.md +++ b/spec/purpose_and_scope.md @@ -66,6 +66,10 @@ two arrays whose dimensions are compatible (i.e., where the size of each dimensi an operation performed element-by-element, in which individual array elements are considered in isolation and independently of other elements within the same array. +### matrix + +a two-dimensional array. + ### rank number of array dimensions (not to be confused with the number of linearly independent columns of a matrix). @@ -78,6 +82,10 @@ a tuple of `N` non-negative integers that specify the sizes of each dimension an a dimension whose size is one. +### vector + +a one-dimensional array. + * * * ## Normative References From f0465713f0479b2141827aee115276e1facf7077 Mon Sep 17 00:00:00 2001 From: Athan Reines Date: Mon, 24 Aug 2020 11:17:58 -0700 Subject: [PATCH 07/20] Add outer specification --- .../linear_algebra_functions.md | 42 ++++++++++++++++++- 1 file changed, 40 insertions(+), 2 deletions(-) diff --git a/spec/API_specification/linear_algebra_functions.md b/spec/API_specification/linear_algebra_functions.md index 0bf1f752b..f8c61baec 100644 --- a/spec/API_specification/linear_algebra_functions.md +++ b/spec/API_specification/linear_algebra_functions.md @@ -79,7 +79,7 @@ Returns the specified diagonals. If `a` has more than two dimensions, then the a - `offset > 0`: off-diagonal above the main diagonal. - `offset < 0`: off-diagonal below the main diagonal. - Default: `0`. + Default: `0`. #### Returns @@ -178,4 +178,42 @@ Computes the outer product of two vectors `a` and `b`. - **out**: _<array>_ - - a two-dimensional array containing the outer product and whose shape is `NxM`. \ No newline at end of file + - a two-dimensional array containing the outer product and whose shape is `NxM`. + +### # trace(a, /, *, axis1=0, axis2=1, offset=0) + +Returns the sum along the specified diagonals. If `a` has more than two dimensions, then the axes (dimensions) specified by `axis1` and `axis2` are used to determine the two-dimensional sub-arrays for which to compute the sum along the specified diagonals. + +#### Parameters + +- **a**: _<array>_ + + - input array. Must have at least `2` dimensions. + +- **axis1**: _int_ + + - first axis (dimension) with respect to which to compute the trace. Default: `0`. + +- **axis2**: _int_ + + - second axis (dimension) with respect to which to compute the trace. Default: `1`. + +- **offset**: _int_ + + - offset specifying the off-diagonal relative to the main diagonal. + + - `offset = 0`: the main diagonal. + - `offset > 0`: off-diagonal above the main diagonal. + - `offset < 0`: off-diagonal below the main diagonal. + + Default: `0`. + +#### Returns + +- **out**: _<array>_ + + - if `a` is a two-dimensional array, a zero-dimensional array containing the trace; otherwise, a multi-dimensional array containing the traces. For a multi-dimensional output array, if `a` has rank `k` and shape `(I, J, K, ..., L, M, N)` and `axis1=-2` and `axis1=-1`, then the output array has rank `k-2` and shape `(I, J, K, ..., L)` where + + ```text + out[i, j, k, ..., l] = trace(a[i, j, k, ..., l, :, :]) + ``` From e0b1e18bd9f1e382d08da315a8ecd352b59c99e3 Mon Sep 17 00:00:00 2001 From: Athan Reines Date: Mon, 24 Aug 2020 11:28:06 -0700 Subject: [PATCH 08/20] Add trace specification --- spec/API_specification/linear_algebra_functions.md | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/spec/API_specification/linear_algebra_functions.md b/spec/API_specification/linear_algebra_functions.md index f8c61baec..7b64b9885 100644 --- a/spec/API_specification/linear_algebra_functions.md +++ b/spec/API_specification/linear_algebra_functions.md @@ -182,7 +182,7 @@ Computes the outer product of two vectors `a` and `b`. ### # trace(a, /, *, axis1=0, axis2=1, offset=0) -Returns the sum along the specified diagonals. If `a` has more than two dimensions, then the axes (dimensions) specified by `axis1` and `axis2` are used to determine the two-dimensional sub-arrays for which to compute the sum along the specified diagonals. +Returns the sum along the specified diagonals. If `a` has more than two dimensions, then the axes (dimensions) specified by `axis1` and `axis2` are used to determine the two-dimensional sub-arrays for which to compute the trace. #### Parameters @@ -212,8 +212,11 @@ Returns the sum along the specified diagonals. If `a` has more than two dimensio - **out**: _<array>_ - - if `a` is a two-dimensional array, a zero-dimensional array containing the trace; otherwise, a multi-dimensional array containing the traces. For a multi-dimensional output array, if `a` has rank `k` and shape `(I, J, K, ..., L, M, N)` and `axis1=-2` and `axis1=-1`, then the output array has rank `k-2` and shape `(I, J, K, ..., L)` where + - if `a` is a two-dimensional array, a zero-dimensional array containing the trace; otherwise, a multi-dimensional array containing the traces. + + The shape of a multi-dimensional output array is determined by removing `axis1` and `axis2` and storing the traces in the last array dimension. For example, if `a` has rank `k` and shape `(I, J, K, ..., L, M, N)` and `axis1=-2` and `axis1=-1`, then a multi-dimensional output array has rank `k-2` and shape `(I, J, K, ..., L)` where ```text out[i, j, k, ..., l] = trace(a[i, j, k, ..., l, :, :]) ``` + From 95194aae31daa1d3f98c716cd29edc9b461f4005 Mon Sep 17 00:00:00 2001 From: Athan Reines Date: Mon, 24 Aug 2020 11:38:46 -0700 Subject: [PATCH 09/20] Add transpose --- .../linear_algebra_functions.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/spec/API_specification/linear_algebra_functions.md b/spec/API_specification/linear_algebra_functions.md index 7b64b9885..e8cc210e1 100644 --- a/spec/API_specification/linear_algebra_functions.md +++ b/spec/API_specification/linear_algebra_functions.md @@ -220,3 +220,22 @@ Returns the sum along the specified diagonals. If `a` has more than two dimensio out[i, j, k, ..., l] = trace(a[i, j, k, ..., l, :, :]) ``` +### # transpose(a, /, *, axes=None) + +Transposes (or permutes the axes (dimensions)) of an array `a`. + +#### Parameters + +- **a**: _<array>_ + + - input array. + +- **axes**: _Optional\[ Tuple\[ int, ... ] ]_ + + - tuple containing a permutation of `(0, 1, ..., N-1)` where `N` is the number of axes (dimensions) of `a`. If `None`, the axes (dimensions) are permuted in reverse order (i.e., equivalent to setting `axes=(N-1, ..., 1, 0)`). Default: `None`. + +#### Returns + +- **out**: _<array>_ + + - an array containing the transpose. Must have the same data type as `a`. \ No newline at end of file From 5095031472d84cd4eb738fb5d175ab9646fd9d99 Mon Sep 17 00:00:00 2001 From: Athan Reines Date: Mon, 24 Aug 2020 11:44:31 -0700 Subject: [PATCH 10/20] Update index --- spec/API_specification/index.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/spec/API_specification/index.rst b/spec/API_specification/index.rst index c256627b6..0c6cefaaf 100644 --- a/spec/API_specification/index.rst +++ b/spec/API_specification/index.rst @@ -13,3 +13,4 @@ API specification broadcasting out_keyword elementwise_functions + linear_algebra_functions \ No newline at end of file From 6a7fde8bb533ee16dad90417d4b9bb443220e65b Mon Sep 17 00:00:00 2001 From: Athan Reines Date: Mon, 24 Aug 2020 16:04:28 -0700 Subject: [PATCH 11/20] Fix type annotation --- spec/API_specification/linear_algebra_functions.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/API_specification/linear_algebra_functions.md b/spec/API_specification/linear_algebra_functions.md index e8cc210e1..32613ea9d 100644 --- a/spec/API_specification/linear_algebra_functions.md +++ b/spec/API_specification/linear_algebra_functions.md @@ -127,7 +127,7 @@ Computes the matrix or vector norm of `a`. - If `True`, the axes (dimensions) specified by `axis` must be included in the result as singleton dimensions, and, accordingly, the result must be compatible with the input array (see :ref:`broadcasting`). Otherwise, if `False`, the axes (dimensions) specified by `axis` must not be included in the result. Default: `False`. -- **ord**: _Optional\[ int, float, inf, 'fro', 'nuc' ]_ +- **ord**: _Optional\[ int, float, Literal\[ inf, 'fro', 'nuc' ] ]_ - order of the norm. The following norms must be supported: From 83593dcec06b2084276e93852ec0fcc40eac2d4d Mon Sep 17 00:00:00 2001 From: Athan Reines Date: Mon, 24 Aug 2020 16:45:53 -0700 Subject: [PATCH 12/20] Update norm behavior for multi-dimensional arrays --- spec/API_specification/linear_algebra_functions.md | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/spec/API_specification/linear_algebra_functions.md b/spec/API_specification/linear_algebra_functions.md index 32613ea9d..cbb84a647 100644 --- a/spec/API_specification/linear_algebra_functions.md +++ b/spec/API_specification/linear_algebra_functions.md @@ -111,17 +111,21 @@ Computes the matrix or vector norm of `a`. - **a**: _<array>_ - - input array. If `axis` is `None`, `a` must be either one- or two-dimensional. + - input array. - **axis**: _Optional\[ Union\[ int, Tuple\[ int, int ] ] ]_ - - If an integer, `axis` specifies the axis (dimension) along which to compute vector norms. If a 2-tuple, `axis` specifies the axes (dimensions) defining two-dimensional matrices for which to compute matrix norms. If `None`, + - If an integer, `axis` specifies the axis (dimension) along which to compute vector norms. + + If a 2-tuple, `axis` specifies the axes (dimensions) defining two-dimensional matrices for which to compute matrix norms. + + If `None`, - if `a` is one-dimensional, the function computes the vector norm. - if `a` is two-dimensional, the function computes the matrix norm. - - if `a` has more than two dimensions, the function computes the vector norm for vectors defined by the last axis (dimension). Equivalent to specifying `axis=-1`. + - if `a` has more than two dimensions, the function computes the vector norm over all array values (i.e., equivalent to computing the vector norm of a flattened array). - Negative indices must be supported. Default: `None`. + Negative indices must be supported. Default: `None`. - **keepdims**: _bool_ @@ -158,7 +162,7 @@ Computes the matrix or vector norm of `a`. - **out**: _<array>_ - - an array containing the norms. Must have the same data type as `a`. If `axis` is a scalar value (`int` or `float`), the output array has a rank which is one less than the rank of `a`. If `axis` is a 2-tuple, the output array has a rank which is two less than the rank of `a`. + - an array containing the norms. Must have the same data type as `a`. If `axis` is `None`, the output array is a zero-dimensional array containing a vector norm. If `axis` is a scalar value (`int` or `float`), the output array has a rank which is one less than the rank of `a`. If `axis` is a 2-tuple, the output array has a rank which is two less than the rank of `a`. ### # outer(a, b, /) From 16fc53c9d5f4a7c71553ba2fe811f9963d065624 Mon Sep 17 00:00:00 2001 From: Athan Reines Date: Mon, 24 Aug 2020 17:00:21 -0700 Subject: [PATCH 13/20] Support all of NumPy's norms Further support for supporting all of NumPy's norms comes from pending updates to Torch (see https://github.com/pytorch/pytorch/pull/42749). --- .../linear_algebra_functions.md | 24 +++++++++++-------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/spec/API_specification/linear_algebra_functions.md b/spec/API_specification/linear_algebra_functions.md index cbb84a647..2efbe49bc 100644 --- a/spec/API_specification/linear_algebra_functions.md +++ b/spec/API_specification/linear_algebra_functions.md @@ -131,19 +131,23 @@ Computes the matrix or vector norm of `a`. - If `True`, the axes (dimensions) specified by `axis` must be included in the result as singleton dimensions, and, accordingly, the result must be compatible with the input array (see :ref:`broadcasting`). Otherwise, if `False`, the axes (dimensions) specified by `axis` must not be included in the result. Default: `False`. -- **ord**: _Optional\[ int, float, Literal\[ inf, 'fro', 'nuc' ] ]_ +- **ord**: _Optional\[ int, float, Literal\[ -inf, inf, 'fro', 'nuc' ] ]_ - order of the norm. The following norms must be supported: - | ord | matrix | vector | - | ----------- | ------------------------------- | ------------------- | - | None | 'fro' | L2-norm (Euclidean) | - | 'fro' | 'fro' | - | - | 'nuc' | 'nuc' | - | - | 1 | max(sum(abs(x), axis=0)) | L1-norm | - | 2 | largest singular value | L2-norm (Euclidean) | - | inf | max(sum(abs(x), axis=1)) | infinity norm | - | (int,float) | - | p-norm (for p >= 1) | + | ord | matrix | vector | + | ------------ | ------------------------------- | -------------------------- | + | None | 'fro' | L2-norm (Euclidean) | + | 'fro' | 'fro' | - | + | 'nuc' | 'nuc' | - | + | 1 | max(sum(abs(x), axis=0)) | L1-norm | + | -1 | min(sum(abs(x), axis=0)) | sum(1./abs(x))**(-1) | + | 2 | largest singular value | L2-norm (Euclidean) | + | -2 | smallest singular value | 1./sqrt(sum(1./abs(x)**2)) | + | inf | max(sum(abs(x), axis=1)) | infinity norm | + | -inf | min(sum(abs(x), axis=1)) | min(abs(x)) | + | (+int,+float) | - | p-norm (for p >= 1) | + | (-int,-float) | - | sum(abs(x)**ord)**(1./ord) | where `fro` corresponds to the **Frobenius norm**, `nuc` corresponds to the **nuclear norm**, and `-` indicates that the norm is **not** supported. For matrices, From 4745713283411cc22cb5808c87d719da4e99372d Mon Sep 17 00:00:00 2001 From: Athan Reines Date: Mon, 24 Aug 2020 17:01:56 -0700 Subject: [PATCH 14/20] Switch order --- spec/API_specification/linear_algebra_functions.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/API_specification/linear_algebra_functions.md b/spec/API_specification/linear_algebra_functions.md index 2efbe49bc..44a03e905 100644 --- a/spec/API_specification/linear_algebra_functions.md +++ b/spec/API_specification/linear_algebra_functions.md @@ -131,7 +131,7 @@ Computes the matrix or vector norm of `a`. - If `True`, the axes (dimensions) specified by `axis` must be included in the result as singleton dimensions, and, accordingly, the result must be compatible with the input array (see :ref:`broadcasting`). Otherwise, if `False`, the axes (dimensions) specified by `axis` must not be included in the result. Default: `False`. -- **ord**: _Optional\[ int, float, Literal\[ -inf, inf, 'fro', 'nuc' ] ]_ +- **ord**: _Optional\[ int, float, Literal\[ inf, -inf, 'fro', 'nuc' ] ]_ - order of the norm. The following norms must be supported: From 46f0bfc1bf1ca91852fdd204d74d4bdf6b6c7d9e Mon Sep 17 00:00:00 2001 From: Athan Reines Date: Mon, 24 Aug 2020 17:13:08 -0700 Subject: [PATCH 15/20] Split into separate tables --- .../linear_algebra_functions.md | 47 ++++++++++++------- 1 file changed, 30 insertions(+), 17 deletions(-) diff --git a/spec/API_specification/linear_algebra_functions.md b/spec/API_specification/linear_algebra_functions.md index 44a03e905..db080c57b 100644 --- a/spec/API_specification/linear_algebra_functions.md +++ b/spec/API_specification/linear_algebra_functions.md @@ -133,23 +133,36 @@ Computes the matrix or vector norm of `a`. - **ord**: _Optional\[ int, float, Literal\[ inf, -inf, 'fro', 'nuc' ] ]_ - - order of the norm. The following norms must be supported: - - | ord | matrix | vector | - | ------------ | ------------------------------- | -------------------------- | - | None | 'fro' | L2-norm (Euclidean) | - | 'fro' | 'fro' | - | - | 'nuc' | 'nuc' | - | - | 1 | max(sum(abs(x), axis=0)) | L1-norm | - | -1 | min(sum(abs(x), axis=0)) | sum(1./abs(x))**(-1) | - | 2 | largest singular value | L2-norm (Euclidean) | - | -2 | smallest singular value | 1./sqrt(sum(1./abs(x)**2)) | - | inf | max(sum(abs(x), axis=1)) | infinity norm | - | -inf | min(sum(abs(x), axis=1)) | min(abs(x)) | - | (+int,+float) | - | p-norm (for p >= 1) | - | (-int,-float) | - | sum(abs(x)**ord)**(1./ord) | - - where `fro` corresponds to the **Frobenius norm**, `nuc` corresponds to the **nuclear norm**, and `-` indicates that the norm is **not** supported. For matrices, + - order of the norm. The following mathematical norms must be supported: + + | ord | matrix | vector | + | ---------------- | ------------------------------- | -------------------------- | + | 'fro' | 'fro' | - | + | 'nuc' | 'nuc' | - | + | 1 | max(sum(abs(x), axis=0)) | L1-norm (Manhattan) | + | 2 | largest singular value | L2-norm (Euclidean) | + | inf | max(sum(abs(x), axis=1)) | infinity norm | + | (int,float >= 1) | - | p-norm | + + The following non-mathematical "norms" must be supported: + + | ord | matrix | vector | + | ---------------- | ------------------------------- | -------------------------- | + | 0 | - | sum(a != 0) | + | -1 | min(sum(abs(x), axis=0)) | sum(1./abs(a))**(-1) | + | -2 | smallest singular value | 1./sqrt(sum(1./abs(a)**2)) | + | -inf | min(sum(abs(x), axis=1)) | min(abs(a)) | + | (int,float < 1) | - | sum(abs(a)**ord)**(1./ord) | + + When `ord` is `None`, the following norms must be the default norms: + + | ord | matrix | vector | + | ---------------- | ------------------------------- | -------------------------- | + | None | 'fro' | L2-norm (Euclidean) | + + where `fro` corresponds to the **Frobenius norm**, `nuc` corresponds to the **nuclear norm**, and `-` indicates that the norm is **not** supported. + + For matrices, - if `ord=1`, the norm corresponds to the induced matrix norm where `p=1` (i.e., the maximum absolute value column sum). - if `ord=2`, the norm corresponds to the induced matrix norm where `p=inf` (i.e., the maximum absolute value row sum). From 8f65e94158de1d1db8e3e149037bced67d877382 Mon Sep 17 00:00:00 2001 From: Athan Reines Date: Mon, 24 Aug 2020 17:13:59 -0700 Subject: [PATCH 16/20] Escape markup --- spec/API_specification/linear_algebra_functions.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/API_specification/linear_algebra_functions.md b/spec/API_specification/linear_algebra_functions.md index db080c57b..586b3fd5a 100644 --- a/spec/API_specification/linear_algebra_functions.md +++ b/spec/API_specification/linear_algebra_functions.md @@ -152,7 +152,7 @@ Computes the matrix or vector norm of `a`. | -1 | min(sum(abs(x), axis=0)) | sum(1./abs(a))**(-1) | | -2 | smallest singular value | 1./sqrt(sum(1./abs(a)**2)) | | -inf | min(sum(abs(x), axis=1)) | min(abs(a)) | - | (int,float < 1) | - | sum(abs(a)**ord)**(1./ord) | + | (int,float < 1) | - | sum(abs(a)\*\*ord)\*\*(1./ord) | When `ord` is `None`, the following norms must be the default norms: From 2ab06d503174cd46995e3e768b099bb8a630d22d Mon Sep 17 00:00:00 2001 From: Athan Reines Date: Mon, 24 Aug 2020 17:15:09 -0700 Subject: [PATCH 17/20] Escape markup --- spec/API_specification/linear_algebra_functions.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/spec/API_specification/linear_algebra_functions.md b/spec/API_specification/linear_algebra_functions.md index 586b3fd5a..d8d754722 100644 --- a/spec/API_specification/linear_algebra_functions.md +++ b/spec/API_specification/linear_algebra_functions.md @@ -146,12 +146,12 @@ Computes the matrix or vector norm of `a`. The following non-mathematical "norms" must be supported: - | ord | matrix | vector | - | ---------------- | ------------------------------- | -------------------------- | - | 0 | - | sum(a != 0) | - | -1 | min(sum(abs(x), axis=0)) | sum(1./abs(a))**(-1) | - | -2 | smallest singular value | 1./sqrt(sum(1./abs(a)**2)) | - | -inf | min(sum(abs(x), axis=1)) | min(abs(a)) | + | ord | matrix | vector | + | ---------------- | ------------------------------- | ------------------------------ | + | 0 | - | sum(a != 0) | + | -1 | min(sum(abs(x), axis=0)) | 1./sum(1./abs(a)) | + | -2 | smallest singular value | 1./sqrt(sum(1./abs(a)\*\*2)) | + | -inf | min(sum(abs(x), axis=1)) | min(abs(a)) | | (int,float < 1) | - | sum(abs(a)\*\*ord)\*\*(1./ord) | When `ord` is `None`, the following norms must be the default norms: From fdc07e1c81e68d197d937165c8c787bc4dc37a66 Mon Sep 17 00:00:00 2001 From: Athan Reines Date: Mon, 24 Aug 2020 20:10:09 -0700 Subject: [PATCH 18/20] Add matrix_transpose interface Interface inspired by TensorFlow (see https://www.tensorflow.org/api_docs/python/tf/linalg/matrix_transpose) and Torch (see https://pytorch.org/docs/stable/generated/torch.transpose.html). Allows transposing a stack of matrices. --- .../linear_algebra_functions.md | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/spec/API_specification/linear_algebra_functions.md b/spec/API_specification/linear_algebra_functions.md index d8d754722..f445af909 100644 --- a/spec/API_specification/linear_algebra_functions.md +++ b/spec/API_specification/linear_algebra_functions.md @@ -103,6 +103,30 @@ Computes the multiplicative inverse of a square matrix (or stack of square matri - an array containing the multiplicative inverses. Must have the same data type and shape as `a`. +### # matrix_transpose(a, /, *, axis1=0, axis2=1) + +Transposes the axes (dimensions) specified by `axis1` and `axis2`. If `a` has more than two dimensions, then the axes (dimensions) specified by `axis1` and `axis2` are used to determine the two-dimensional sub-arrays to be transposed. + +#### Parameters + +- **a**: _<array>_ + + - input array. Must have at least `2` dimensions. + +- **axis1**: _int_ + + - first axis (dimension). Default: `0`. + +- **axis2**: _int_ + + - second axis (dimension). Default: `1`. + +#### Returns + +- **out**: _<array>_ + + - an array containing the matrix transpose(s). + ### # norm(a, /, *, axis=None, keepdims=False, ord=None) Computes the matrix or vector norm of `a`. From cd076e5e62d9527f0463016d28e325541b7485d9 Mon Sep 17 00:00:00 2001 From: Athan Reines Date: Tue, 25 Aug 2020 15:07:50 -0700 Subject: [PATCH 19/20] Rename parameters --- .../linear_algebra_functions.md | 82 +++++++++---------- 1 file changed, 41 insertions(+), 41 deletions(-) diff --git a/spec/API_specification/linear_algebra_functions.md b/spec/API_specification/linear_algebra_functions.md index f445af909..7dc70bc87 100644 --- a/spec/API_specification/linear_algebra_functions.md +++ b/spec/API_specification/linear_algebra_functions.md @@ -13,23 +13,23 @@ A conforming implementation of the array API standard must provide and support t -### # cross(a, b, /, *, axis=-1) +### # cross(x1, x2, /, *, axis=-1) -Returns the cross product of 3-element vectors. If `a` and `b` are multi-dimensional arrays (i.e., both have a rank greater than `1`), then the cross-product of each pair of corresponding 3-element vectors is independently computed. +Returns the cross product of 3-element vectors. If `x1` and `x2` are multi-dimensional arrays (i.e., both have a rank greater than `1`), then the cross-product of each pair of corresponding 3-element vectors is independently computed. #### Parameters -- **a**: _<array>_ +- **x1**: _<array>_ - first input array. -- **b**: _<array>_ +- **x2**: _<array>_ - - second input array. Must have the same shape as `a`. + - second input array. Must have the same shape as `x1`. - **axis**: _int_ - - the axis (dimension) of `a` and `b` containing the vectors for which to compute the cross product. If set to `-1`, the function computes the cross product for vectors defined by the last axis (dimension). Default: `-1`. + - the axis (dimension) of `x1` and `x2` containing the vectors for which to compute the cross product. If set to `-1`, the function computes the cross product for vectors defined by the last axis (dimension). Default: `-1`. #### Returns @@ -37,9 +37,9 @@ Returns the cross product of 3-element vectors. If `a` and `b` are multi-dimensi - an array containing the cross products. -### # det(a, /) +### # det(x, /) -Returns the determinant of a square matrix (or stack of square matrices) `a`. +Returns the determinant of a square matrix (or stack of square matrices) `x`. #### Parameters @@ -51,15 +51,15 @@ Returns the determinant of a square matrix (or stack of square matrices) `a`. - **out**: _<array>_ - - if `a` is a two-dimensional array, a zero-dimensional array containing the determinant; otherwise, a non-zero dimensional array containing the determinant for each square matrix. + - if `x` is a two-dimensional array, a zero-dimensional array containing the determinant; otherwise, a non-zero dimensional array containing the determinant for each square matrix. -### # diagonal(a, /, *, axis1=0, axis2=1, offset=0) +### # diagonal(x, /, *, axis1=0, axis2=1, offset=0) -Returns the specified diagonals. If `a` has more than two dimensions, then the axes (dimensions) specified by `axis1` and `axis2` are used to determine the two-dimensional sub-arrays from which to return diagonals. +Returns the specified diagonals. If `x` has more than two dimensions, then the axes (dimensions) specified by `axis1` and `axis2` are used to determine the two-dimensional sub-arrays from which to return diagonals. #### Parameters -- **a**: _<array>_ +- **x**: _<array>_ - input array. Must have at least `2` dimensions. @@ -85,15 +85,15 @@ Returns the specified diagonals. If `a` has more than two dimensions, then the a - **out**: _<array>_ - - if `a` 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. Must have the same data type as `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. Must have the same data type as `x`. -### # inv(a, /) +### # inv(x, /) -Computes the multiplicative inverse of a square matrix (or stack of square matrices) `a`. +Computes the multiplicative inverse of a square matrix (or stack of square matrices) `x`. #### Parameters -- **a**: _<array>_ +- **x**: _<array>_ - input array having shape `(..., M, M)` and whose innermost two dimensions form square matrices. @@ -101,15 +101,15 @@ Computes the multiplicative inverse of a square matrix (or stack of square matri - **out**: _<array>_ - - an array containing the multiplicative inverses. Must have the same data type and shape as `a`. + - an array containing the multiplicative inverses. Must have the same data type and shape as `x`. -### # matrix_transpose(a, /, *, axis1=0, axis2=1) +### # matrix_transpose(x, /, *, axis1=0, axis2=1) -Transposes the axes (dimensions) specified by `axis1` and `axis2`. If `a` has more than two dimensions, then the axes (dimensions) specified by `axis1` and `axis2` are used to determine the two-dimensional sub-arrays to be transposed. +Transposes the axes (dimensions) specified by `axis1` and `axis2`. If `x` has more than two dimensions, then the axes (dimensions) specified by `axis1` and `axis2` are used to determine the two-dimensional sub-arrays to be transposed. #### Parameters -- **a**: _<array>_ +- **x**: _<array>_ - input array. Must have at least `2` dimensions. @@ -127,13 +127,13 @@ Transposes the axes (dimensions) specified by `axis1` and `axis2`. If `a` has mo - an array containing the matrix transpose(s). -### # norm(a, /, *, axis=None, keepdims=False, ord=None) +### # norm(x, /, *, axis=None, keepdims=False, ord=None) -Computes the matrix or vector norm of `a`. +Computes the matrix or vector norm of `x`. #### Parameters -- **a**: _<array>_ +- **x**: _<array>_ - input array. @@ -145,9 +145,9 @@ Computes the matrix or vector norm of `a`. If `None`, - - if `a` is one-dimensional, the function computes the vector norm. - - if `a` is two-dimensional, the function computes the matrix norm. - - if `a` has more than two dimensions, the function computes the vector norm over all array values (i.e., equivalent to computing the vector norm of a flattened array). + - if `x` is one-dimensional, the function computes the vector norm. + - if `x` is two-dimensional, the function computes the matrix norm. + - if `x` has more than two dimensions, the function computes the vector norm over all array values (i.e., equivalent to computing the vector norm of a flattened array). Negative indices must be supported. Default: `None`. @@ -203,19 +203,19 @@ Computes the matrix or vector norm of `a`. - **out**: _<array>_ - - an array containing the norms. Must have the same data type as `a`. If `axis` is `None`, the output array is a zero-dimensional array containing a vector norm. If `axis` is a scalar value (`int` or `float`), the output array has a rank which is one less than the rank of `a`. If `axis` is a 2-tuple, the output array has a rank which is two less than the rank of `a`. + - an array containing the norms. Must have the same data type as `x`. If `axis` is `None`, the output array is a zero-dimensional array containing a vector norm. If `axis` is a scalar value (`int` or `float`), the output array has a rank which is one less than the rank of `x`. If `axis` is a 2-tuple, the output array has a rank which is two less than the rank of `x`. -### # outer(a, b, /) +### # outer(x1, x2, /) -Computes the outer product of two vectors `a` and `b`. +Computes the outer product of two vectors `x1` and `x2`. #### Parameters -- **a**: _<array>_ +- **x1**: _<array>_ - first one-dimensional input array of size `N`. -- **b**: _<array>_ +- **x2**: _<array>_ - second one-dimensional input array of size `M`. @@ -225,13 +225,13 @@ Computes the outer product of two vectors `a` and `b`. - a two-dimensional array containing the outer product and whose shape is `NxM`. -### # trace(a, /, *, axis1=0, axis2=1, offset=0) +### # trace(x, /, *, axis1=0, axis2=1, offset=0) -Returns the sum along the specified diagonals. If `a` has more than two dimensions, then the axes (dimensions) specified by `axis1` and `axis2` are used to determine the two-dimensional sub-arrays for which to compute the trace. +Returns the sum along the specified diagonals. If `x` has more than two dimensions, then the axes (dimensions) specified by `axis1` and `axis2` are used to determine the two-dimensional sub-arrays for which to compute the trace. #### Parameters -- **a**: _<array>_ +- **x**: _<array>_ - input array. Must have at least `2` dimensions. @@ -257,30 +257,30 @@ Returns the sum along the specified diagonals. If `a` has more than two dimensio - **out**: _<array>_ - - if `a` is a two-dimensional array, a zero-dimensional array containing the trace; otherwise, a multi-dimensional array containing the traces. + - if `x` is a two-dimensional array, a zero-dimensional array containing the trace; otherwise, a multi-dimensional array containing the traces. - The shape of a multi-dimensional output array is determined by removing `axis1` and `axis2` and storing the traces in the last array dimension. For example, if `a` has rank `k` and shape `(I, J, K, ..., L, M, N)` and `axis1=-2` and `axis1=-1`, then a multi-dimensional output array has rank `k-2` and shape `(I, J, K, ..., L)` where + The shape of a multi-dimensional output array is determined by removing `axis1` and `axis2` and storing the traces in the last array dimension. For example, if `x` has rank `k` and shape `(I, J, K, ..., L, M, N)` and `axis1=-2` and `axis1=-1`, then a multi-dimensional output array has rank `k-2` and shape `(I, J, K, ..., L)` where ```text out[i, j, k, ..., l] = trace(a[i, j, k, ..., l, :, :]) ``` -### # transpose(a, /, *, axes=None) +### # transpose(x, /, *, axes=None) -Transposes (or permutes the axes (dimensions)) of an array `a`. +Transposes (or permutes the axes (dimensions)) of an array `x`. #### Parameters -- **a**: _<array>_ +- **x**: _<array>_ - input array. - **axes**: _Optional\[ Tuple\[ int, ... ] ]_ - - tuple containing a permutation of `(0, 1, ..., N-1)` where `N` is the number of axes (dimensions) of `a`. If `None`, the axes (dimensions) are permuted in reverse order (i.e., equivalent to setting `axes=(N-1, ..., 1, 0)`). Default: `None`. + - tuple containing a permutation of `(0, 1, ..., N-1)` where `N` is the number of axes (dimensions) of `x`. If `None`, the axes (dimensions) are permuted in reverse order (i.e., equivalent to setting `axes=(N-1, ..., 1, 0)`). Default: `None`. #### Returns - **out**: _<array>_ - - an array containing the transpose. Must have the same data type as `a`. \ No newline at end of file + - an array containing the transpose. Must have the same data type as `x`. \ No newline at end of file From 4015620d4f9d6300214a0a46b455d62f09d0dd5a Mon Sep 17 00:00:00 2001 From: Athan Reines Date: Mon, 31 Aug 2020 01:06:16 -0700 Subject: [PATCH 20/20] Remove matrix_transpose signature --- .../linear_algebra_functions.md | 24 ------------------- 1 file changed, 24 deletions(-) diff --git a/spec/API_specification/linear_algebra_functions.md b/spec/API_specification/linear_algebra_functions.md index 7dc70bc87..c428c104e 100644 --- a/spec/API_specification/linear_algebra_functions.md +++ b/spec/API_specification/linear_algebra_functions.md @@ -103,30 +103,6 @@ Computes the multiplicative inverse of a square matrix (or stack of square matri - an array containing the multiplicative inverses. Must have the same data type and shape as `x`. -### # matrix_transpose(x, /, *, axis1=0, axis2=1) - -Transposes the axes (dimensions) specified by `axis1` and `axis2`. If `x` has more than two dimensions, then the axes (dimensions) specified by `axis1` and `axis2` are used to determine the two-dimensional sub-arrays to be transposed. - -#### Parameters - -- **x**: _<array>_ - - - input array. Must have at least `2` dimensions. - -- **axis1**: _int_ - - - first axis (dimension). Default: `0`. - -- **axis2**: _int_ - - - second axis (dimension). Default: `1`. - -#### Returns - -- **out**: _<array>_ - - - an array containing the matrix transpose(s). - ### # norm(x, /, *, axis=None, keepdims=False, ord=None) Computes the matrix or vector norm of `x`.