link lu
August 14, 1996; Ralph E. Griswold
This file is in the public domain.
lu_decomp(M, I) performs LU decomposition on the square matrix M using the vector I. Both M and I are modified in the process. The value returned is +1 or -1 depending on whether the number of row interchanges is even or odd. lu_decomp() is used in combination with lu_back_sub() to solve linear equations or invert matrices. lu_decomp() fails if the matrix is singular. lu_back_sub(M, I, B) solves the set of linear equations M x X = B. M is the matrix as modified by lu_decomp(). I is the index vector produced by lu_decomp(). B is the right-hand side vector and return with the solution vector. M and I are not modified by lu_back_sub() and can be used in successive calls of lu_back_sub() with different Bs. ____________________________________________________________ Acknowledgement: These procedures are based on algorithms given in "Numerical Recipes; The Art of Scientific Computing"; William H. Press, Brian P. Flannery, Saul A. Teukolsky. and William T. Vetterling; Cambridge University Press, 1986.