Hi there,


Sorry if this has already been asked before. I tried googling for it, but perhaps I could not find the right words to search for. My question is: Which is the fastest way to compute A\*inv(B) [edit] where A and B are matrices?



Efficient computation of AB^-1 for matrices
What are the sizes of $\mathbf{A}$ and $\mathbf{B}$? This information is important.


Let me assume you mean you want the efficient *numerical* computation of the matrix $ \mathbf{A} \mathbf{B}^{-1}$.


The general strategy would be to do this: Let $\mathbf{J} = \mathbf{A} \mathbf{B}^{-1}$; therefore $\mathbf{J}\mathbf{B} = \mathbf{A}$. You must then rewrite this into $\mathbf{P}\mathbf{x} = \mathbf{Q}$ form (this depends on the dimensions of your matrices). 


For instance, for $\mathbf{A} \in \mathbb{R}^{m \times n}$, $\mathbf{B} \in \mathbb{R}^{n \times n}$ and $\mathbf{J} \in \mathbb{R}^{m \times n}$, you can write a system of equations:


$J\_{i,\*} \cdot B\_{\*,j} = A\_{i,j}$


(Notation: for a matrix $\mathbf{X}$, we define $X\_{i,\*}$ as the $i$-th row vector and $X\_{\*,j}$ as the $j$-th column vector, and $X\_{i,j}$ as the element in the $i$-th row and $j$-th column).


From here, you can use a fast linear solver to solve the resulting linear equation system -- you will get a solution for the elements of $\mathbf{J}$. 


By solving a linear system of equations and not taking the inverse directly, you're not only cutting down on the no. of operations required, you can exploit also properties like sparsity, inertia, etc. and have capabilities like pre-conditioning at your disposal.


