2

There is a hermitian conjugate function for numpy.matrix object, which is numpy.matrix.H. However numpy.matrix is not recommended and such a method does not seem to exist for numpy.ndarray. Currently I'm using numpy.ndarray.T.conj() which works, but is there a shorter method for hermitian conjugate ?

Mateo Vial
  • 658
  • 4
  • 13
  • 1
    Your subject line is misleading. You DO know how to perform this operation, and compactly. What you are seeking is a shortcut, one that adds little, if any computational value. Look at the docs/code for `.H`. All it does is `self.transpose().conjugate()` or just `self.transpose()`. – hpaulj Mar 08 '22 at 16:39
  • It is not misleading. I did not ask how to do it, but whether it existed for the specific `numpy.ndarray` class, because I expected it to exist but could not find it. It turns out that `numpy.ndarray.H` does **not** exist, and that's a satisfying answer for my question. You seem to be the only one to have been misled here – Mateo Vial Mar 08 '22 at 21:19
  • In any case the lists of attributes/methods for `np.matrix`, https://numpy.org/doc/stable/reference/generated/numpy.matrix.html#numpy.matrix, and for and `ndarray`, https://numpy.org/doc/stable/reference/arrays.ndarray.html#array-attributes are accurrate, without any any hidden or forgotten ones. – hpaulj Mar 09 '22 at 00:45
  • Possibly `.H` was added to `np.matrix` because MATLAB has a `x'` and `x.'` for Hermitian and transpose. This subclass was written years ago to make `numpy` more appealing to wayward MATLAB users. – hpaulj Mar 09 '22 at 01:10

0 Answers0