From 22b37fdd293ddb0cb7ba4149b011085b090c2920 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Legat?= Date: Mon, 19 Jan 2026 14:43:00 +0100 Subject: [PATCH 1/8] Accept AbstractSparseMatrixCSC for decompression --- src/SparseMatrixColorings.jl | 1 + src/decompression.jl | 2 +- src/matrices.jl | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/SparseMatrixColorings.jl b/src/SparseMatrixColorings.jl index 481c8584..b14d5950 100644 --- a/src/SparseMatrixColorings.jl +++ b/src/SparseMatrixColorings.jl @@ -31,6 +31,7 @@ using PrecompileTools: @compile_workload using Random: Random, AbstractRNG, default_rng, randperm using SparseArrays: SparseArrays, + AbstractSparseMatrixCSC, SparseMatrixCSC, dropzeros, dropzeros!, diff --git a/src/decompression.jl b/src/decompression.jl index 1528c885..f400f543 100644 --- a/src/decompression.jl +++ b/src/decompression.jl @@ -586,7 +586,7 @@ function decompress!( end function decompress!( - A::SparseMatrixCSC{R}, + A::AbstractSparseMatrixCSC{R}, B::AbstractMatrix{R}, result::TreeSetColoringResult, uplo::Symbol=:F, diff --git a/src/matrices.jl b/src/matrices.jl index 453e3062..836f0e30 100644 --- a/src/matrices.jl +++ b/src/matrices.jl @@ -86,7 +86,7 @@ function compatible_pattern(A::AbstractMatrix, ag::AdjacencyGraph, uplo::Symbol) return size(A) == size(ag.S) end -function compatible_pattern(A::SparseMatrixCSC, ag::AdjacencyGraph, uplo::Symbol) +function compatible_pattern(A::AbstractSparseMatrixCSC, ag::AdjacencyGraph, uplo::Symbol) nnzS = (uplo == :L || uplo == :U) ? (nb_edges(ag) + ag.nb_self_loops) : nnz(ag.S) return size(A) == size(ag.S) && nnz(A) == nnzS end From bd06fd3d95bccefaf9c0bdcc0cf4bbe25c24da87 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Legat?= Date: Wed, 25 Feb 2026 11:10:12 +0100 Subject: [PATCH 2/8] Define decompress_csc --- src/decompression.jl | 40 ++++++++++++++++++++++++++++++++++------ 1 file changed, 34 insertions(+), 6 deletions(-) diff --git a/src/decompression.jl b/src/decompression.jl index f400f543..3cd4b12f 100644 --- a/src/decompression.jl +++ b/src/decompression.jl @@ -585,8 +585,23 @@ function decompress!( return A end -function decompress!( - A::AbstractSparseMatrixCSC{R}, +""" + function decompress_csc!( + nzA::AbstractVector{R}, + A_colptr::AbstractVector, + B::AbstractMatrix{R}, + result::TreeSetColoringResult, + uplo::Symbol=:F, + ) where {R<:Real} + +Decompress the values of `B` into the vector of nonzero entries `nzA` of a +sparse matrix with column pointers `colptr`. This function assumes that the +row indices are sorted in increasing order and are the same as those of the +sparse matrix given to the `coloring` function that returned `result`. +""" +function decompress_csc!( + nzA::AbstractVector{R}, + A_colptr::AbstractVector{<:Integer}, B::AbstractMatrix{R}, result::TreeSetColoringResult, uplo::Symbol=:F, @@ -603,10 +618,6 @@ function decompress!( upper_triangle_offsets, buffer, ) = result - (; S) = ag - A_colptr = A.colptr - nzA = nonzeros(A) - check_compatible_pattern(A, ag, uplo) if eltype(buffer) == R buffer_right_type = buffer @@ -696,6 +707,23 @@ function decompress!( #! format: on end end + return +end + +function decompress!( + A::AbstractSparseMatrixCSC{R}, + B::AbstractMatrix{R}, + result::TreeSetColoringResult, + uplo::Symbol=:F, +) where {R<:Real} + check_compatible_pattern(A, result.ag, uplo) + decompress_csc!( + A.colptr, + nonzeros(A), + B, + result, + uplo, + ) return A end From c351e792a5cae9042726ab9df2bdce83240add9f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Legat?= Date: Fri, 27 Feb 2026 15:13:21 +0100 Subject: [PATCH 3/8] Remove unused import of AbstractSparseMatrixCSC --- src/SparseMatrixColorings.jl | 1 - 1 file changed, 1 deletion(-) diff --git a/src/SparseMatrixColorings.jl b/src/SparseMatrixColorings.jl index b14d5950..481c8584 100644 --- a/src/SparseMatrixColorings.jl +++ b/src/SparseMatrixColorings.jl @@ -31,7 +31,6 @@ using PrecompileTools: @compile_workload using Random: Random, AbstractRNG, default_rng, randperm using SparseArrays: SparseArrays, - AbstractSparseMatrixCSC, SparseMatrixCSC, dropzeros, dropzeros!, From b8451af86d59d0af4d8d19b14c41fd513ecd9dcc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Legat?= Date: Fri, 27 Feb 2026 15:13:47 +0100 Subject: [PATCH 4/8] Apply suggestion from @blegat --- src/matrices.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/matrices.jl b/src/matrices.jl index 836f0e30..453e3062 100644 --- a/src/matrices.jl +++ b/src/matrices.jl @@ -86,7 +86,7 @@ function compatible_pattern(A::AbstractMatrix, ag::AdjacencyGraph, uplo::Symbol) return size(A) == size(ag.S) end -function compatible_pattern(A::AbstractSparseMatrixCSC, ag::AdjacencyGraph, uplo::Symbol) +function compatible_pattern(A::SparseMatrixCSC, ag::AdjacencyGraph, uplo::Symbol) nnzS = (uplo == :L || uplo == :U) ? (nb_edges(ag) + ag.nb_self_loops) : nnz(ag.S) return size(A) == size(ag.S) && nnz(A) == nnzS end From d4a736afb3e43ba49073e48968a6fc93eb14a8d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Legat?= Date: Fri, 27 Feb 2026 15:21:28 +0100 Subject: [PATCH 5/8] Change return statement to return nothing --- src/decompression.jl | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/src/decompression.jl b/src/decompression.jl index 3cd4b12f..e48daec9 100644 --- a/src/decompression.jl +++ b/src/decompression.jl @@ -707,23 +707,17 @@ function decompress_csc!( #! format: on end end - return + return nothing end function decompress!( - A::AbstractSparseMatrixCSC{R}, + A::SparseMatrixCSC{R}, B::AbstractMatrix{R}, result::TreeSetColoringResult, uplo::Symbol=:F, ) where {R<:Real} check_compatible_pattern(A, result.ag, uplo) - decompress_csc!( - A.colptr, - nonzeros(A), - B, - result, - uplo, - ) + decompress_csc!(A.colptr, nonzeros(A), B, result, uplo) return A end From 6ad9a2fa3c15dae0185f4c785522623185761df8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Legat?= Date: Fri, 27 Feb 2026 18:15:26 +0100 Subject: [PATCH 6/8] Apply suggestion from @blegat --- src/decompression.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/decompression.jl b/src/decompression.jl index e48daec9..23a73b55 100644 --- a/src/decompression.jl +++ b/src/decompression.jl @@ -717,7 +717,7 @@ function decompress!( uplo::Symbol=:F, ) where {R<:Real} check_compatible_pattern(A, result.ag, uplo) - decompress_csc!(A.colptr, nonzeros(A), B, result, uplo) + decompress_csc!(nonzeros(A), A.colptr, B, result, uplo) return A end From a029f8353fd5b82bc12d48db10f203b594a4e4fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Legat?= Date: Sat, 28 Feb 2026 08:04:11 +0100 Subject: [PATCH 7/8] Add to docs --- docs/src/api.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/src/api.md b/docs/src/api.md index f90c888f..57307be4 100644 --- a/docs/src/api.md +++ b/docs/src/api.md @@ -46,6 +46,7 @@ compress decompress decompress! decompress_single_color! +decompress_csc! ``` ## Orders From e93a786df5cb70e7aca4eb0261b10bc775545809 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Legat?= Date: Mon, 9 Mar 2026 15:07:51 +0100 Subject: [PATCH 8/8] Apply suggestion from @gdalle Co-authored-by: Guillaume Dalle <22795598+gdalle@users.noreply.github.com> --- src/decompression.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/decompression.jl b/src/decompression.jl index 23a73b55..849f0f6b 100644 --- a/src/decompression.jl +++ b/src/decompression.jl @@ -586,7 +586,7 @@ function decompress!( end """ - function decompress_csc!( + decompress_csc!( nzA::AbstractVector{R}, A_colptr::AbstractVector, B::AbstractMatrix{R},