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

Implement hermitian conjugate utilities #19232

Closed
wants to merge 1 commit into from

Conversation

gautierronan
Copy link

x.T.conj() -> x.H
x.mT.conj() -> x.mH

Similar to pytorch behavior, very useful for dealing with complex arrays.

Copy link

google-cla bot commented Jan 7, 2024

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@jakevdp
Copy link
Collaborator

jakevdp commented Jan 7, 2024

Hi - typically for array attributes and properties we've followed NumPy and/or the Python array API standard in order to minimize the cognitive overhead for people switching between standard Python array syntax. NumPy does not have .H and .mH, and this idea has been proposed and rejected on several occasions (see e.g. numpy/numpy#8882 and links within). In the Array API standard, the idea is being considered (data-apis/array-api#555), but is not yet part of the standard, though it appears to be on the draft roadmap for a future revision: data-apis/array-api#643.

That's not to say that we shouldn't add this, but it means there is a higher bar before we consider adding such syntax. Some of the concerns in the above discussions don't really apply to JAX, particularly in JIT-compiled mode where the hermitian transpose operation can be optimized away. If the array API standard adds this, we should ensure that JAX's definition is compliant, otherwise we might be facing a rather painful deprecation process for adjusting the syntax in the near future.

With all that in mind, I think we should hold off on this for now – what do you think?

@gautierronan
Copy link
Author

Thanks for your detailed answer. My point of view on the matter is that this feature is:

  1. very simple to add and maintain,
  2. very practical for users who work on complex arrays regularly (I personally use x.conj().T tens of times every day),
  3. already implemented in pytorch (although they are much less compliant with the numpy API of course).

That being said, your arguments are also very sound. I'll let you guys decide, but I'm very much in favor of the feature :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants