Open
Conversation
## Summary Add a specialized `isdiag` method for `AbstractSparseMatrixCSC` that traverses the CSC structure directly in O(nnz) time, compared to the generic fallback which is O(n²) for an n×n matrix. **Changes:** - Import `isdiag` from LinearAlgebra - Add `isdiag(A::AbstractSparseMatrixCSC)` that checks diagonal property by traversing the sparse structure - Add comprehensive tests for `isdiag` on sparse matrices ## Motivation This addresses performance issues in packages like OrdinaryDiffEq.jl where `isdiag` checks on large sparse mass matrices caused severe initialization delays. For large DAE systems (e.g., 259k variables), this reduces initialization time from ~60 seconds to <1ms. Reference: SciML/OrdinaryDiffEq.jl#3011 ## Benchmarks ``` n=1000: generic=0.00ms, efficient=0.00ms n=10000: generic=0.04ms, efficient=0.00ms, speedup=12626x n=50000: generic=0.19ms, efficient=0.00ms, speedup=47511x n=100000: generic=0.39ms, efficient=0.00ms, speedup=96737x ``` The efficient implementation runs in essentially constant time since it only needs to check the stored elements. ## Test plan - Added `isdiag` tests in `test/sparsematrix_ops.jl`: - Diagonal matrices (sparse diagonal, empty matrix) - Non-diagonal matrices (tridiagonal, bidiagonal, full) - Non-square matrices - Consistency with dense `isdiag` - Explicit zeros on off-diagonal (should still be diagonal) 🤖 Generated with [Claude Code](https://claude.ai/code) --------- Co-authored-by: ChrisRackauckas-Claude <noreply@anthropic.com> Co-authored-by: Chris Rackauckas <accounts@chrisrackauckas.com>
Create a unified initialization function for all SuiteSparse libraries (both in the stdlib and elsewhere like KLU). This remains lazily initialized. Should address #671. I wonder whether this should be truly `public` but KLU, AMD, and ParU, SPEX will rely on this to function correctly so probably should be. Also bumps wrapper generation. @gbaraldi not sure how to test this with your PR but tests on MinFEM.jl seem to pass locally for me.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## release-1.13 #701 +/- ##
================================================
+ Coverage 84.14% 84.34% +0.19%
================================================
Files 12 13 +1
Lines 9330 9339 +9
================================================
+ Hits 7851 7877 +26
+ Misses 1479 1462 -17 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
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.
indtypeforSparseMatrixCSCColumnSubset#700HermOrSymsparse matrix times dense matrix #692mul!forHermOrSymsparse matrices #689