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

Add H member to array for calculating the Hermitian #8882

Closed
NeilGirdhar opened this issue Apr 1, 2017 · 3 comments
Closed

Add H member to array for calculating the Hermitian #8882

NeilGirdhar opened this issue Apr 1, 2017 · 3 comments

Comments

@NeilGirdhar
Copy link
Contributor

NeilGirdhar commented Apr 1, 2017

numpy.matrix.H exists, but with the addition of the @ operator to Python most people use np.array. It is currently possible to write arr.T.conjugate(), but arr.H would be clear and succinct for people working with complex matrices. Please consider adding an H shortcut.

@njsmith
Copy link
Member

njsmith commented Apr 1, 2017

This has been considered and rejected in the past because .T returns a view, which is cheap and allows updates to the underlying array, but .H would return a copy, which is expensive and does not allow modification of the underlying array. So they're less parallel then you'd think, and in particular we think it's actually a good thing if operations that might involve allocating lots of memory have function-call parentheses on them to remind you that you're performing some non-trivial action.

I did at some point suggest the somewhat wacky idea of adding a "conjugated complex" dtype that stores the value x + yj as the tuple (x, -y). This would make it possible to have a .H property that returns a view. But no-one has followed up on this suggestion. Whether this is due to lack of time or because everyone recoiled in horror, I can't say :-). It could be both...

@NeilGirdhar
Copy link
Contributor Author

NeilGirdhar commented Apr 1, 2017

@njsmith Okay, thanks for taking a look. I swear I did a search for Hermitian here!

I agree with you that if .T returns a view (didn't know that) that .H should either do the same or else not exist.

@NeilGirdhar
Copy link
Contributor Author

NeilGirdhar commented Apr 1, 2017

@njsmith https://github.com/numpy/numpy/search?q=hermitian&type=Issues&utf8=%E2%9C%93 returns nothing, so I guess it was before this project started using Github. Anyway, this bug might prevent other people from making the same suggestion.

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

No branches or pull requests

2 participants