Use generic_trimatdiv!() in ldiv!() for QRSparse#697
Use generic_trimatdiv!() in ldiv!() for QRSparse#697JamesWrigley wants to merge 1 commit intoJuliaSparse:mainfrom
Conversation
This avoids having to go through UpperTriangular, which requires making a square matrix out of our rectangular F.R matrix. Taking a view of F.R would hit a slow fallback for ldiv!(), and making a new square matrix would cause allocations.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #697 +/- ##
==========================================
- Coverage 84.35% 84.33% -0.02%
==========================================
Files 13 13
Lines 9347 9348 +1
==========================================
- Hits 7885 7884 -1
- Misses 1462 1464 +2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Would a widened method signature somewhere help (also other cases)? |
|
Hmm I'm not sure, do you mean adding something like |
|
It was just a wild guess, like could we modify the call path by changing a method signature to allow the previously used method to be used (again)? In case you know, which |
|
Ah I see what you mean 🤔 So according to Cthulhu these are the signatures for the copy and view respectively: generic_trimatdiv!(C::Vector{Float64},
uplo_char(A::UpperTriangular{Float64, SparseMatrixCSC{Float64, Int64}})::Core.Const('U'),
isunit_char(A::UpperTriangular{Float64, SparseMatrixCSC{Float64, Int64}})::Core.Const('N'),
_wrapperop(parent(A))::Core.Const(identity),
_unwrap_at(parent(A))::SparseMatrixCSC{Float64, Int64},
B::Vector{Float64})
generic_trimatdiv!(C::Vector{Float64},
uplo_char(A::UpperTriangular{Float64, SubArray{Float64, 2, SparseMatrixCSC{Float64, Int64}, Tuple{Base.OneTo{Int64}, Base.OneTo{Int64}}, false}})::Core.Const('U'),
isunit_char(A::UpperTriangular{Float64, SubArray{Float64, 2, SparseMatrixCSC{Float64, Int64}, Tuple{Base.OneTo{Int64}, Base.OneTo{Int64}}, false}})::Core.Const('N'),
_wrapperop(parent(A))::Core.Const(identity),
_unwrap_at(parent(A))::SubArray{Float64, 2, SparseMatrixCSC{Float64, Int64}, Tuple{Base.OneTo{Int64}, Base.OneTo{Int64}}, false},
B::Vector{Float64})
I think the issue is that this subarray type has a Whereas |
|
I think that could be another PR. Being able to assume that the whole column is included in the view may be important, given how we store row numbers by column. So, for the time being this should be okay. |
dkarrasch
left a comment
There was a problem hiding this comment.
LGTM, and I assume this is well covered by tests.
This avoids having to go through UpperTriangular, which requires making a square matrix out of our rectangular F.R matrix. Taking a view of F.R would hit a slow fallback for ldiv!(), and making a new square matrix would cause allocations.
Fixes #696. Written with help from Claude 🤖
Benchmark script adapted from BaseBenchmarks: