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

Implement Sparse Left-Looking LU factorization #1289

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

JulianKnodt
Copy link
Contributor

@JulianKnodt JulianKnodt commented Aug 23, 2023

This allows a sparse matrix to be used for efficient solving with a dense LU decomposition.

It generally follows lectures from Tim Davis
https://www.youtube.com/watch?v=wiL_jIuENkk&ab_channel=TimDavis
(Lectures 1-3), and implements a basic left looking sparse LU factorization.
I primarily focus on CSC matrices, since they are what is focused on in the lecture, identical to what is done in Matlab.

I believe for most use cases this should be efficient and correct, and thus it serves as a useful to building even more customized solvers down the line.

Summary of changes:

  1. Sparsity Pattern Builder: Allowing for building up sparsity patterns, rather than constructing them all in one go. This seemed to be a drawback of the previous design, and I've added a builder to construct Sparsity Patterns. This was necessary when computing the sparsity of the decomposed LU matrix.

  2. Sparse lower triangular solving. For most users, the result will probably want LUx = b, with b a dense vector. While constructing the LU matrix though, it calls a sparse Ly = s, with s sparse. This allows for building up a sparse LU pattern iteratively. The LU matrix is packed into a single sparse matrix, with the diagonal belonging to U, and L has implicit 1s along the diagonal.

  3. Dense lower/upper triangular solving. This is what the end user will interact with. I've added it to take slices, but I should probably convert it to DMatrices. Slices feel more natural to me though, since it decouples the requirement of the input being a matrix, as it's just solving a vector anyway.

r? @sebcrozet @Andlon

Not sure if y'all have time to review.

Motivation:

Currently I'm trying to reimplement a paper that uses libigl within Rust, but there's a significant amount of library functionality that is missing. Specifically, quadratic programming doesn't exist, so this is a step to making it available.

Closes #1197

@JulianKnodt JulianKnodt marked this pull request as draft September 11, 2023 04:14
@JulianKnodt JulianKnodt force-pushed the sparse_lu branch 4 times, most recently from fe9bef1 to 0db2532 Compare September 11, 2023 09:11
@JulianKnodt JulianKnodt changed the title Add solve_upper_triangular to CsrMatrix [WIP] Implement Sparse Left-Looking LU factorization Sep 11, 2023
@JulianKnodt JulianKnodt marked this pull request as ready for review September 25, 2023 01:25
@JulianKnodt JulianKnodt changed the title [WIP] Implement Sparse Left-Looking LU factorization Implement Sparse Left-Looking LU factorization Sep 25, 2023
@JulianKnodt JulianKnodt marked this pull request as draft October 4, 2023 06:29
@JulianKnodt JulianKnodt marked this pull request as ready for review October 4, 2023 08:57
@JulianKnodt JulianKnodt force-pushed the sparse_lu branch 2 times, most recently from 2c4c5e3 to f39ba10 Compare November 27, 2023 07:08
Add `solve_upper_triangular` to `CsrMatrix`

This allows a sparse matrix to be used for efficient solving with a dense LU decomposition.

Add CscBuilder

For partial construction of Csc matrices

Start working on actual LU factorization

Complete basic version of sparse LU factorization

Reformat to compile in old version

Add LU tests

Add upper triangular solve

Complete tests of Sparse LU factorization
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.

[feature request] ETA sparse solvers?
1 participant