Skip to content

Commit 5101b4f

Browse files
committed
Add a method decompress_single_color!
1 parent cba4d7b commit 5101b4f

1 file changed

Lines changed: 53 additions & 0 deletions

File tree

src/decompression.jl

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -537,6 +537,59 @@ function decompress!(
537537
return A
538538
end
539539

540+
function decompress_single_color!(
541+
A::SparseMatrixCSC,
542+
b::AbstractVector,
543+
c::Integer,
544+
result::StarSetColoringResult,
545+
uplo::Symbol=:F,
546+
)
547+
(; ag, compressed_indices, group) = result
548+
(; S) = ag
549+
if (result.decompression_uplo == :F) && (result.decompression_uplo != uplo)
550+
lower_index = (c - 1) * S.n + 1
551+
upper_index = c * S.n
552+
rvS = rowvals(S)
553+
for j in group[c]
554+
for k in nzrange(S, j)
555+
# Check if the color c is used to recover A[i,j] / A[j,i]
556+
if lower_index <= compressed_indices[k] <= upper_index
557+
i = rvS[k]
558+
if i == j
559+
# Recover the diagonal coefficients of A
560+
A[i, i] = b[i]
561+
else
562+
# Recover the off-diagonal coefficients of A
563+
if in_triangle(i, j, uplo)
564+
A[i, j] = b[i]
565+
end
566+
if in_triangle(j, i, uplo)
567+
A[j, i] = b[i]
568+
end
569+
end
570+
end
571+
end
572+
end
573+
else
574+
@assert result.decompression_uplo == uplo
575+
uplo == :F && check_same_pattern(A, S)
576+
lower_index = (c - 1) * S.n + 1
577+
upper_index = c * S.n
578+
rvA = rowvals(A)
579+
nzA = nonzeros(A)
580+
for j in group[c]
581+
for k in nzrange(A, j)
582+
# Check if the color c is used to recover A[i,j]
583+
if lower_index <= compressed_indices[k] <= upper_index
584+
i = rvA[k]
585+
nzA[k] = b[i]
586+
end
587+
end
588+
end
589+
end
590+
return A
591+
end
592+
540593
## TreeSetColoringResult
541594

542595
function decompress!(

0 commit comments

Comments
 (0)