Implementation of LU Decomposition #26
Open
+262
−6
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR implements LU decomposition by enhancing
gaussian_elimination
to support step-by-step recording of row operations. These recorded steps can then be replayed on an identity matrix to construct theL
matrix.Four new methods are introduced:gaussian_elimination_ex
: An extended version of Gaussian elimination that includes an option to record the steps performed during row operations. The existinggaussian_elimination
method now serves as a wrapper for this function.lu_decomposition
: Computes the LU decomposition of a matrix. This method returns the lower triangular matrixL
, the upper triangular matrixU
, and a permutation vectorpv
(if row permutations occur during Gaussian elimination).lu_decomposition_in_place
: A more memory-efficient variant oflu_decomposition
. Instead of returningU
, it modifies the original matrix (self
) in place to representU
.permute_rows
: A utility function that applies a permutation vectorpv
to a matrix, enabling consistent handling of row permutations.EDIT: APIs are updated, and explained in a seperate comment.