I have a python program which relies on an Extended Kalman Filter (that I didn't write). It takes full advantage of numpy, but it is still bottlenecking at three key matrix inversions.
They are of the form (all square):
$R := RBC^{-1}$ (3x3 rotation matrix update)
$K := PH^{t}(HP(H^t+S))^{-1}$ (15x15 Kalman progression)
$R := BC^{-1}R$ (another rotation update)
The first two reduce to essentially $X = AB^{-1}$, the last to $X = B (C^{-1}R) = BY$
I know that if I can get any of these into the form $AX = B$ equivalent to $X = A^{-1}B$, I can use linalg.solve, which is much faster than inversion.
My matrix-fu is pretty rusty. Is there any way to trasform the above $AB^{-1}$ expression so that the inverted term is on the left hand side? Transpose and multiplication are all pretty cheap, solve is 2-4 times as fast as inv. I know there are neat matrix tricks out there, but their usage is beyond my knowledge.
If transposition is cheap, $$ AB^{-1}=[(AB^{-1})^t]^t=[(B^t)^{-1}A^t]^t $$ and you have $(B^t)^{-1}A^t$ with the inversion on the left. Alternatively, you can just do $$ AB^{-1}=A(B^{-1}I). $$