I'm converting some Matlab code in Python. I need to do some matrix manipulation. My matrix (A) is (right now) a 65x3 matrix. However, the number of rows is variable depending on what step I'm at in the program.
In Matlab, the code I'm working on is:
output = inv(A'*A) * A';
output = np.dot(np.linalg.inv(np.dot(np.transpose(A), A)), np.transpose(A))
You can use a the
T attribute (transposes the array). Also, if using Python 3.5, you can use
@ for the dot product (see PEP 465 for details).
output = np.linalg.inv(A.T @ A) @ A.T