Skip to content

Change defaults of trace and diagonal to axis1=-2, axis2=-1. #222

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

Closed
wants to merge 1 commit into from
Closed
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
16 changes: 8 additions & 8 deletions spec/extensions/linear_algebra_functions.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ Accordingly, the standardization process affords the opportunity to reduce inter

In general, interfaces should avoid polymorphic return values (e.g., returning an array **or** a namedtuple, dependent on, e.g., an optional keyword argument). Dedicated interfaces for each return value type are preferred, as dedicated interfaces are easier to reason about at both the implementation level and user level. Example interfaces which could be combined into a single overloaded interface, but are not, include:

- `eig`: computing both eigenvalues and eignvectors.
- `eig`: computing both eigenvalues and eigenvectors.
- `eigvals`: computing only eigenvalues.

4. **Implementation agnosticism**: a standardized interface should eschew parameterization (including keyword arguments) biased toward particular implementations.
Expand Down Expand Up @@ -140,7 +140,7 @@ Returns the determinant of a square matrix (or stack of square matrices) `x`.
- 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. The returned array must have the same data type as `x`.

(function-linalg-diagonal)=
### linalg.diagonal(x, /, *, axis1=0, axis2=1, offset=0)
### linalg.diagonal(x, /, *, axis1=-2, axis2=-1, offset=0)

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.

Expand All @@ -152,11 +152,11 @@ Returns the specified diagonals. If `x` has more than two dimensions, then the a

- **axis1**: _int_

- first axis (dimension) with respect to which to take diagonal. Default: `0`.
- first axis (dimension) with respect to which to take diagonal. Default: `-2`.

- **axis2**: _int_

- second axis (dimension) with respect to which to take diagonal. Default: `1`.
- second axis (dimension) with respect to which to take diagonal. Default: `-1`.

- **offset**: _int_

Expand Down Expand Up @@ -598,7 +598,7 @@ Computes the singular values of a matrix (or a stack of matrices) `x`.
- an array with shape `(..., K)` that contains the vector(s) of singular values of length `K`. For each vector, the singular values must be sorted in descending order by magnitude, such that `s[..., 0]` is the largest value, `s[..., 1]` is the second largest value, et cetera. The first `x.ndim-2` dimensions must have the same shape as those of the input `x`. The returned array must have the same floating-point data type as `x`.

(function-linalg-trace)=
### linalg.trace(x, /, *, axis1=0, axis2=1, offset=0)
### linalg.trace(x, /, *, axis1=-2, axis2=-1, offset=0)

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.

Expand All @@ -610,11 +610,11 @@ Returns the sum along the specified diagonals. If `x` has more than two dimensio

- **axis1**: _int_

- first axis (dimension) with respect to which to compute the trace. Default: `0`.
- first axis (dimension) with respect to which to compute the trace. Default: `-2`.

- **axis2**: _int_

- second axis (dimension) with respect to which to compute the trace. Default: `1`.
- second axis (dimension) with respect to which to compute the trace. Default: `-1`.

- **offset**: _int_

Expand Down Expand Up @@ -648,4 +648,4 @@ Alias for {ref}`function-transpose`.
(function-linalg-vecdot)=
### linalg.vecdot(x1, x2, /, *, axis=None)

Alias for {ref}`function-vecdot`.
Alias for {ref}`function-vecdot`.