I need to implement a matrix inversion of a very big matrix that currently is exceeding the memory limits of my machine (unfortunately I have little memory running on 32-bit machines). I would like to use a few PCs together to get the result. I am using Linux and I have access to several machines with MPI.

Can you suggest a good C++ library that implements that function? If that's not available, any good article or algorithm on the topic is appreciated as well.

At the moment, I am reading these:

  • 5
    $\begingroup$ Most of us work very hard to avoid inverting large matrices. Perhaps if you explained your requirements in more detail some smart person could recommend an approach which would obviate inversion. $\endgroup$ Sep 18, 2013 at 9:12
  • $\begingroup$ hi I am trying to use Levemberg Marquardt/Feed Forward neural network. I need to invert a matrix to solve a set of equations for calculating the wights increments during learning. $\Delta x=[J^\top(x)J(x)+\mu I]^{-1}J^\top(x)R$. THe number of neurons is very high (I am trying 10000). $\endgroup$ Sep 18, 2013 at 11:03
  • $\begingroup$ p.s. I am sorry but I don't know how to edit a formula here. I hope you can help me also to improve my quality of posting. $\endgroup$ Sep 18, 2013 at 11:05
  • $\begingroup$ @AbruzzoForteeGentile: StackExchange sites use MathJax to render mathematical formula, so if you write out your formula using LaTeX notation, the output will look like a LaTeX-typeset formula. $\endgroup$ Sep 18, 2013 at 19:01
  • $\begingroup$ @Geoff Great stuff! Thanks for your quick feedback. $\endgroup$ Sep 19, 2013 at 8:25

1 Answer 1


Like HighPerformanceMark already pointed out, one does not need to invert a matrix explicitly to solve linear systems. In the Levenberg-Marquardt algorithm, the matrix is positive definite and symmetric and, consequently, you can use the Conjugate Gradient method to solve the linear system. This avoids the need to compute the exact inverse of a matrix and is generally faster and less memory intensive. It should not be a problem at all to solve linear systems with a few 100,000 unknowns with this even on small PCs (depending on how dense/sparse your matrix is).

  • $\begingroup$ Hi Wolfgang. Thank for your response; anyway the neurons I am going to face will be higher soon and (as far as I remember) is calculated as the square of the neurons I use. Do you mind to recommend in any case a library for that? I just want to be prepared to the worst case. $\endgroup$ Sep 18, 2013 at 12:13
  • $\begingroup$ P.S. Off course I'll look at the Conjugate Gradient so I thank you for that. $\endgroup$ Sep 18, 2013 at 12:23
  • 1
    $\begingroup$ I think you should read a book on numerical methods to understand how CG works, at least to get the big picture. I would suggest using PETSc to solve your linear system. PETSc also works in parallel. $\endgroup$ Sep 18, 2013 at 12:38

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.