Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implementation of LU Decomposition #26

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

rabbull
Copy link

@rabbull rabbull commented Nov 29, 2024

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 the L 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 existing gaussian_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 matrix L, the upper triangular matrix U, and a permutation vector pv (if row permutations occur during Gaussian elimination).
  • lu_decomposition_in_place: A more memory-efficient variant of lu_decomposition. Instead of returning U, it modifies the original matrix (self) in place to represent U.
  • permute_rows: A utility function that applies a permutation vector pv to a matrix, enabling consistent handling of row permutations.

EDIT: APIs are updated, and explained in a seperate comment.

@CLAassistant
Copy link

CLAassistant commented Nov 29, 2024

CLA assistant check
All committers have signed the CLA.

@rabbull rabbull marked this pull request as draft December 13, 2024 09:30
@rabbull rabbull marked this pull request as ready for review January 28, 2025 00:01
@rabbull rabbull changed the title [WIP] Implementation of LU Decomposition Implementation of LU Decomposition Jan 28, 2025
@rabbull
Copy link
Author

rabbull commented Jan 28, 2025

APIs are updated after rework, the new interfaces provided are:

  • permute_rows: A utility function that applies a permutation vector pv to a matrix, enabling consistent handling of row permutations.
  • partial_row_reduce_impl: An extended version of row reduce that includes an option to record the steps performed during row operations. The existing partial_row_reduce method now serves as a wrapper for this function.
  • lu_decompose: Computes the LU decomposition of a matrix. This method returns a permutation vector pv, the lower triangular matrix L, and the upper triangular matrix U.

Example usage can be refered to the tests added.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants