Skip to content

Use similar promotion rules in trace() as sum() and prod() #493

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
asmeurer opened this issue Oct 6, 2022 · 2 comments · Fixed by #502
Closed

Use similar promotion rules in trace() as sum() and prod() #493

asmeurer opened this issue Oct 6, 2022 · 2 comments · Fixed by #502
Labels
topic: Linear Algebra Linear algebra. topic: Type Promotion Type promotion.
Milestone

Comments

@asmeurer
Copy link
Member

asmeurer commented Oct 6, 2022

sum() and prod() use special promotion rules (see #202 and https://data-apis.org/array-api/latest/API_specification/generated/signatures.statistical_functions.sum.html#signatures.statistical_functions.sum). trace() is effectively a sum over the diagonal, so it should use the same rules. np.trace() currently already acts the same as np.sum() in this regard.

Presumably this also means we should add a dtype argument to trace()

@asmeurer
Copy link
Member Author

asmeurer commented Oct 6, 2022

Also np.trace() does have a dtype argument https://numpy.org/doc/stable/reference/generated/numpy.trace.html.

@rgommers rgommers added this to the v2022 milestone Oct 7, 2022
@rgommers
Copy link
Member

rgommers commented Oct 7, 2022

Agreed with trace needing the special casting rule and also with it needing a dtype keyword, thanks @asmeurer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: Linear Algebra Linear algebra. topic: Type Promotion Type promotion.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants