3
$\begingroup$

What is the algorithm behind this routine and is there documentation available for it?

$\endgroup$
1
  • 2
    $\begingroup$ Did you check the numpy source code? $\endgroup$
    – qwr
    Commented Feb 10 at 22:08

1 Answer 1

3
$\begingroup$

The source code of this function is here, which is a wrapper for a C++ function here, which is calling some BLAS/LAPACK library functions. Specifically, in order to compute the inverse of a matrix $A$, it calls the "SGESV" routine to solve the equation $AX = I$ for the matrix $X$. (note that SGESV can solve arbitrary systems $AX = B$; $B$ does not have to be the identity matrix)

The SGESV routine first computes an LU-decomposition of $A$: it finds a lower triangular matrix $L$ and upper triangular matrix $U$ such that $L U = A$. Solving a system with a triangular matrix is easy, as we can go row by row; we only need to solve an equation with one unknown variable for each row. So, we can solve $AX=B$ as follows: let $X':=UX$, then we have $LX' = A$ and $UX= X'$. These are both systems with a triangular matrix, and solving them gives $X$.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.