Repository navigation
Efficient sparse of RectDiagonal and OffDiagonal - #459
Open
dlfivefifty wants to merge 2 commits into
Open
dlfivefifty wants to merge 2 commits into
dlfivefifty wants to merge 2 commits into
Conversation
`SparseMatrixCSC` / `sparse` of a `RectDiagonal`, `OffDiagonal` or `Diagonal` of a fill now builds the CSC arrays directly from the band, instead of going through the generic fallback that visits every entry. As for `Diagonal`, zeros in the band are not stored. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #459 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 11 11
Lines 1316 1362 +46
=========================================
+ Hits 1316 1362 +46 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
It was previously only covered through the old sparse conversion of RectDiagonal fills. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
sparse(A)/SparseMatrixCSC(A)forAaRectDiagonal(with any band, not only fills), anOffDiagonal, or aDiagonalof a fill now buildscolptr/rowval/nzvaldirectly from the band. It runs in O(n + length(band)) instead of using SparseArrays' genericAbstractMatrixfallback, which visits all m×n entries.RectOrDiagonalFillmethod, which built the matrix fromgetindex_value(v)*Iand so only covered constant bands. It now uses one method forUnion{Diagonal{<:Any,<:AbstractFillVector}, RectDiagonal, OffDiagonal}, built on the_band/_bandindex/_bandlengthhelpers fromsrc/offdiagonal.jl.SparseMatrixCSC(::Diagonal)in SparseArrays, zeros in the band are not stored (usesSparseArrays._isnotzero). The old method also dropped them for aZerosband, so this keeps the existing behaviour.SparseMatrixCSC{Tv}(A)keeps usingeltype(axes(A,1))as the index type, as before.RectDiagonalwhosediagis longer thanmin(m, n)(e.g.RectDiagonal([1,2,3], 3, 1)) only stores the visible entries.Tests run
testsparsediagon a range ofRectDiagonal/OffDiagonals: super- and sub-diagonals, rectangular, empty bands, bands containing zeros,Fill/Zerosbands, and slices ofEye. They also check that the CSC structure is identical tosparse(Matrix(A)). The full test suite passes on Julia 1.10 and 1.13.🤖 Generated with Claude Code