Skip to content
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

RFC: add Hermitian transpose function #555

Open
asmeurer opened this issue Dec 10, 2022 · 2 comments
Open

RFC: add Hermitian transpose function #555

asmeurer opened this issue Dec 10, 2022 · 2 comments
Labels
API extension Adds new functions or objects to the API. Needs Discussion Needs further discussion. RFC Request for comments. Feature requests and proposed changes. topic: Complex Data Types Complex number data types.

Comments

@asmeurer
Copy link
Member

See for instance numpy/numpy#13797. It might be useful to have a special function for a hermitian transpose, which would be equivalent to conjugate(matrix_transpose(x)).

The other suggestion is a .H operator on matrices. A complication here is that libraries that use views would not be able to make .H a view unless they add a special conjugate-complex dtype. See the discussion at numpy/numpy#13797. (the .H attribute is really the bigger thing here, as it least to more readable code, but if it is added it probably makes sense to also add a corresponding function)

@kgryte kgryte added RFC Request for comments. Feature requests and proposed changes. topic: Complex Data Types Complex number data types. labels Dec 10, 2022
@shoyer
Copy link
Contributor

shoyer commented Dec 12, 2022

A complication here is that libraries that use views would not be able to make .H a view unless they add a special conjugate-complex dtype.

It's worth noting that libraries that use JIT compilers (e.g., JAX and PyTorch) will likely be able to optimize these operations even without explicit views.

@rgommers rgommers added the API extension Adds new functions or objects to the API. label Dec 13, 2022
@rgommers
Copy link
Member

PyTorch has a special "complex conjugate bit", which makes torch.Tensor.H an O(1) operation even in eager mode. I believe the conclusion from the NumPy discussion was that something like that is also desired if .H is going to be a thing (implemented as special dtype - the details probably don't matter, just that it's a lot of work and it's not moving forward).

I'd prefer not to touch .H, because we can't really adopt it without giving NumPy (and perhaps other libraries) the choice between (a) doing a lot of work, (b) not being compliant, or (c) letting go of a pretty fundamental design rule that attribute access should be cheap.

It might be useful to have a special function for a hermitian transpose, which would be equivalent to conjugate(matrix_transpose(x)).

This seems easier to do.

@kgryte kgryte added the Needs Discussion Needs further discussion. label Apr 4, 2024
@kgryte kgryte changed the title Hermitian transpose function/attribute RFC: add Hermitian transpose function Apr 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API extension Adds new functions or objects to the API. Needs Discussion Needs further discussion. RFC Request for comments. Feature requests and proposed changes. topic: Complex Data Types Complex number data types.
Projects
None yet
Development

No branches or pull requests

4 participants