Skip to content

Commit 848a6f3

Browse files
authored
Improve the decompression of star coloring for AbstractMatrix (#209)
* Improve the decompression of star coloring for AbstractMatrix * Fix decompression.jl
1 parent a7a4c37 commit 848a6f3

1 file changed

Lines changed: 6 additions & 21 deletions

File tree

src/decompression.jl

Lines changed: 6 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -431,31 +431,17 @@ end
431431
function decompress!(
432432
A::AbstractMatrix, B::AbstractMatrix, result::StarSetColoringResult, uplo::Symbol=:F
433433
)
434-
(; ag, color, star_set) = result
435-
(; star, hub, spokes) = star_set
434+
(; ag, compressed_indices) = result
436435
(; S) = ag
437436
uplo == :F && check_same_pattern(A, S)
438437
fill!(A, zero(eltype(A)))
439438

440-
# Recover the diagonal coefficients of A
441-
if has_diagonal(ag)
442-
for i in axes(A, 1)
443-
if !iszero(S[i, i])
444-
A[i, i] = B[i, color[i]]
445-
end
446-
end
447-
end
448-
449-
# Recover the off-diagonal coefficients of A
450-
for s in eachindex(hub, spokes)
451-
j = abs(hub[s])
452-
cj = color[j]
453-
for i in spokes[s]
439+
rvS = rowvals(S)
440+
for j in axes(S, 2)
441+
for k in nzrange(S, j)
442+
i = rvS[k]
454443
if in_triangle(i, j, uplo)
455-
A[i, j] = B[i, cj]
456-
end
457-
if in_triangle(j, i, uplo)
458-
A[j, i] = B[i, cj]
444+
A[i, j] = B[compressed_indices[k]]
459445
end
460446
end
461447
end
@@ -523,7 +509,6 @@ function decompress!(
523509
end
524510
end
525511
end
526-
@assert l == length(nonzeros(A))
527512
end
528513
return A
529514
end

0 commit comments

Comments
 (0)