Repository navigation
RFC: Handle Hermitian(::Sparse) \ SparseArray - #322
Conversation
|
Whatever we decide on, this should be backported to v1.9 I guess. |
Codecov Report
📣 This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more @@ Coverage Diff @@
## main JuliaLang/julia#322 +/- ##
==========================================
- Coverage 93.68% 93.66% -0.02%
==========================================
Files 12 12
Lines 7454 7455 +1
==========================================
Hits 6983 6983
- Misses 471 472 +1
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
|
Since this was not working on earlier versions, I think it's more natural to make this throw for now, as a quickfix. The general case about what to do with sparse rhs should be discussed first, and then probably requires modifications in more places than this. |
|
Sparse RHS can be optimized, but usually I believe you need to be able to leverage that in your solver as discussed in the Sparse Matrices in Matlab paper. @DrTimothyAldenDavis @Wimmerer IIRC SuiteSparse doesn't support sparse RHS in solvers. I just wanted to confirm or be corrected. |
| # We could do this as lu(A') = lu(A)' with UMFPACK, but the user could want to do one over the other | ||
| lu(A::Union{Adjoint{T, S}, Transpose{T, S}}; check::Bool = true) where {T<:UMFVTypes, S<:AbstractSparseMatrixCSC{T}} = | ||
| lu(copy(A); check) | ||
| lu(A::AdjOrTrans{T,S}; check::Bool = true) where {T<:UMFVTypes, S<:AbstractSparseMatrixCSC{T}} = |
There was a problem hiding this comment.
I see there has been some nice clean ups!
|
I do exploit the sparse right-hand-side internally in several places (it forms the key kernel for cs_lu and KLU for example, and is called n times to do the entire LU factorization, solving x = L\b where x, L, and b are all saprse). I also exploit it inside CHOLMOD in the update/downdate. However, it's hard to exploit in general for solving x=A\b because if b is sparse and A forms a single strongly-connected component (the typical case) then x is dense. So it's hard to exploit. x can be sparse for x=A\b if A is permutable into block triangular form (via cs_dmperm for example). I use the BTF form in KLU+BTF but I can't recall if I also allow b to be sparse when doing x=A\b. |
|
@DrTimothyAldenDavis I don't see any support for it in the KLU interface, but I may experiment with doing it with the Julia port. |
|
OK .. then I guess I don't have one. I think I may have one for UMFPACK but I convert it to full first ... I can't recall exactly ... too much code over too many years. |
|
Making this throw (now) is only a continuation of the same earlier behavior. We can still always make it work if we want by either calling specific code paths, or densifying the rhs. |
|
The backport to To backport manually, run these commands in your terminal: # Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add .worktrees/backport-1.9 1.9
# Navigate to the new working tree
cd .worktrees/backport-1.9
# Create a new branch
git switch --create backport-322-to-1.9
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick --mainline 1 0d2d30afb156b48d329ed212309b56a31c4a84a4
# Push it to GitHub
git push --set-upstream origin backport-322-to-1.9
# Go back to the original working tree
cd ../..
# Delete the working tree
git worktree remove .worktrees/backport-1.9Then, create a pull request where the |
While playing with JuliaLang/LinearAlgebra.jl#977 a little more I noticed one peculiarity.
On v1.8
On v1.9:
While this works, the problem is that this runs by
_generic_lufact!due to the relaxations in JuliaLang/julia#47107. We have two options: (i) throw and suggest to densify the rhs, or (ii) densify silently. I think (ii) is not too bad, because if a user expects the solve to be successful, then a dense version of the result will be typically more memory efficient than a sparse version thereof due to intrinsic density.