# Efficient computation of $BX=A$ when LU factorization of $A$ is given

First, $AX=B$ is solved, so I have the LU factorization of $A$ computed already.

Now I need to solve $BX=A$. Is there any way to reuse this information (LAPACK gesv was used to compute LU of $A$)?

• I assume you solve for $X$? And what are the dimensions of $A$, $B$ and $X$? – fibonatic May 5 '17 at 9:56
• @fibonatic right, matrix is square, dimension can be several thousands. – lorniper May 5 '17 at 10:56

Your question amounts to asking which is the optimal solution strategy for computing $X,Y$ such that \left\{ \begin{aligned} AX &= B\\ BY &= A \end{aligned} \right. where $A, B$ are generic square dense matrices. Apart from the observation that if $A$ and $B$ are non singular, then $Y=X^{-1}$, I do not see any particular reason for which the knowledge of $X$ should help in the computation of $Y$. But I'd love to be contradicted on this.