Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How does numpy.linalg.inv calculate the inverse of an orthogonal matrix?

I'm implementing a LinearTransformation class, which inherits from numpy.matrix and uses numpy.matrix.I to calculate the inverse of the transformation matrix.

Does anyone know whether numpy checks for orthogonality of the matrix before trying to calculate the inverse? I ask because most of my matrices (but not all) will be orthogonal and I wondered whether to implement some quick orthogonality check before trying to invert.

like image 751
Kyle_S-C Avatar asked May 15 '13 15:05

Kyle_S-C


1 Answers

It does not!

numpy.linalg.inv(A) actually calls numpy.linalg.solve(A,I), where I is the identity, and solve uses lapack's LU factorization.

That is, eventually, it does Gaussian elimination where orthogonality isn't detected by default.

And I don't think there is a shot into the dark to check something like A * A.T = I as matrix times matrix is costly.

like image 127
Jan Avatar answered Sep 20 '22 03:09

Jan