Function LU_decomp (o2scl_linalg)¶
-
template<class mat_t>
int o2scl_linalg::LU_decomp(const size_t N, mat_t &A, o2scl::permutation &p, int &signum)¶ Compute the LU decomposition of the matrix
A
.On output the diagonal and upper triangular part of the input matrix A contain the matrix U. The lower triangular part of the input matrix (excluding the diagonal) contains L. The diagonal elements of L are unity, and are not stored.
The permutation matrix P is encoded in the permutation p. The j-th column of the matrix P is given by the k-th column of the identity matrix, where k = p_j the j-th element of the permutation vector. The sign of the permutation is given by signum. It has the value (-1)^n, where n is the number of interchanges in the permutation.
The algorithm used in the decomposition is Gaussian Elimination with partial pivoting (Golub & Van Loan, Matrix Computations, Algorithm 3.4.1).
- Idea for Future:
The “swap rows j and i_pivot” section could probably be made more efficient using a “matrix_row”-like object as done in GSL. (7/16/09 - I’ve tried this, and it doesn’t seem to improve the speed significantly.)