Skip to content

Commit 9aebbe6

Browse files
blegatgdalle
andauthored
Accept AbstractSparseMatrixCSC for decompression (#298)
* Accept AbstractSparseMatrixCSC for decompression * Define decompress_csc * Remove unused import of AbstractSparseMatrixCSC * Apply suggestion from @blegat * Change return statement to return nothing * Apply suggestion from @blegat * Add to docs * Apply suggestion from @gdalle Co-authored-by: Guillaume Dalle <22795598+gdalle@users.noreply.github.com> * Move to internals --------- Co-authored-by: Guillaume Dalle <22795598+gdalle@users.noreply.github.com>
1 parent f56da29 commit 9aebbe6

File tree

2 files changed

+29
-6
lines changed

2 files changed

+29
-6
lines changed

docs/src/dev.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ SparseMatrixColorings.TreeSetColoringResult
4141
SparseMatrixColorings.LinearSystemColoringResult
4242
SparseMatrixColorings.BicoloringResult
4343
SparseMatrixColorings.remap_colors
44+
SparseMatrixColorings.decompress_csc!
4445
```
4546

4647
## Testing

src/decompression.jl

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -585,8 +585,23 @@ function decompress!(
585585
return A
586586
end
587587

588-
function decompress!(
589-
A::SparseMatrixCSC{R},
588+
"""
589+
decompress_csc!(
590+
nzA::AbstractVector{R},
591+
A_colptr::AbstractVector,
592+
B::AbstractMatrix{R},
593+
result::TreeSetColoringResult,
594+
uplo::Symbol=:F,
595+
) where {R<:Real}
596+
597+
Decompress the values of `B` into the vector of nonzero entries `nzA` of a
598+
sparse matrix with column pointers `colptr`. This function assumes that the
599+
row indices are sorted in increasing order and are the same as those of the
600+
sparse matrix given to the `coloring` function that returned `result`.
601+
"""
602+
function decompress_csc!(
603+
nzA::AbstractVector{R},
604+
A_colptr::AbstractVector{<:Integer},
590605
B::AbstractMatrix{R},
591606
result::TreeSetColoringResult,
592607
uplo::Symbol=:F,
@@ -603,10 +618,6 @@ function decompress!(
603618
upper_triangle_offsets,
604619
buffer,
605620
) = result
606-
(; S) = ag
607-
A_colptr = A.colptr
608-
nzA = nonzeros(A)
609-
check_compatible_pattern(A, ag, uplo)
610621

611622
if eltype(buffer) == R
612623
buffer_right_type = buffer
@@ -696,6 +707,17 @@ function decompress!(
696707
#! format: on
697708
end
698709
end
710+
return nothing
711+
end
712+
713+
function decompress!(
714+
A::SparseMatrixCSC{R},
715+
B::AbstractMatrix{R},
716+
result::TreeSetColoringResult,
717+
uplo::Symbol=:F,
718+
) where {R<:Real}
719+
check_compatible_pattern(A, result.ag, uplo)
720+
decompress_csc!(nonzeros(A), A.colptr, B, result, uplo)
699721
return A
700722
end
701723

0 commit comments

Comments
 (0)