LUFactorized Implemented?

Open
#314 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
25/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
rust
Domain
data

Research direction

Start with the LUFactorized::factorize_into and solve_inplace implementations shown in the issue, then trace the A::lu and A::solve entry points. Confirm whether the matrix passed to A::lu is mutated into factors and whether the stored ipiv is used; done when the behavior is explained or corrected with a regression test.

Written by the indexing model from the issue text.

Description

I was having a look at the code behind LUFactorized and it appears that there is no LU factorization done at all. For example, the factorize_into source is

fn factorize_into(mut self) -> Result<LUFactorized<S>> {
    let ipiv = A::lu(self.layout()?, self.as_allocated_mut()?)?;
    Ok(LUFactorized { a: self, ipiv })
}

where self here is the original matrix. While it is fine to be storing the original matrix A (perhaps the LU decomposition is lazily evaluated), the solve_inplace code indicates that this is actually not the case at all. Instead it just uses the standard solve function without actually doing any LU decomposition at any point.

fn solve_inplace<'a, Sb>(
    &self,
    rhs: &'a mut ArrayBase<Sb, Ix1>,
) -> Result<&'a mut ArrayBase<Sb, Ix1>>
where
    Sb: DataMut<Elem = A>,
{
    assert_eq!(
        rhs.len(),
        self.a.len_of(Axis(1)),
        "The length of `rhs` must be compatible with the shape of the factored matrix.",
    );
    A::solve(
        self.a.square_layout()?,
        Transpose::No,
        self.a.as_allocated()?,
        &self.ipiv,
        rhs.as_slice_mut().unwrap(),
    )?;
    Ok(rhs)
}

Am I missing something? Or is this a temporary implementation until an LU factorization can be properly implemented?

Dominant language
Rust
Stars
452
Forks
95
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from rust-ndarray/ndarray-linalg

All issues in rust-ndarray/ndarray-linalg

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.