I am a second year open university BS mathematics student taking a course on numerical methods. I thought it would be good idea to implement some of these algorithms in C++ - to learn how numerical algorithms are implemented from first principles programatically, as opposed to doing it by hand. I also want to refresh my C++ knowledge and become a proficient programmer. Of course, I am aware that there are sophisticated numerical libraries to solve algebraic problems, but I have decided to defer that for a while.

I have a copy of Numerical recipes using C++ and I implemented the algorithm for Gaussian elimination using full pivoting (page 42). I cannot claim, that I have completely grasped the entire program; the use of few vectors $ipiv$, $idxr[n]$, $idxc[n]$ is unintuitive to me. I am not able to relate it, to the way full pivoting is done by hand.

I will not post the source code (nrgauss.cpp) here, since it's licensed. If anyone has worked through this book and has any tips and suggestion, that would be very insightful. If there's any other book, which lists C++ routines, that helps as well.

Thanks so much in advance,


  • $\begingroup$ apps.nrbook.com/empanel/index.html?pg=48# $\endgroup$ – Shogun May 11 at 21:02
  • $\begingroup$ @Shogun, the content does not open. $\endgroup$ – Quasar May 11 at 21:21
  • 1
    $\begingroup$ if you look on wikipedia at the LU decomp (en.wikipedia.org/wiki/LU_decomposition) in the references you see (Press, WH; Teukolsky, SA; Vetterling, WT; Flannery, BP (2007), "Section 2.3", Numerical Recipes: The Art of Scientific Computing (3rd ed.), New York: Cambridge University Press, ISBN 978-0-521-88068-8.) $\endgroup$ – Shogun May 11 at 21:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.