I am new to python so by gentle with me , I try to convert code from Matlab to numpy python , I am working with matrix .
I have some basic question (that I didn't found the answers in Google):
What is the equivalent for the ' tag for example : H' , H= H*H'
What is the equivalent for the / (mrdivide) tag for example : H= H/A
Thanks, MAK
-
FYI: docs.scipy.org/doc/numpy-dev/user/numpy-for-matlab-users.htmlWarren Weckesser– Warren Weckesser2017年08月06日 22:02:23 +00:00Commented Aug 6, 2017 at 22:02
1 Answer 1
'(transpose) means the conjugate transpose of a matrix. For real matrices, it is given bynp.transpose(arr)or the shorthandarr.T. For complex matrices, you need to use more complicatedarr.conj().T./(mrdivide) solves the equationx A = b->x = b / Ausing least squares (np.linalg.lstsq). This is equivalent to(x A)^T = b^T -> A^T x^T = b^T, which can be done usingnp.linalg.lstsq(A.T, b.T).T.