Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 12 additions & 6 deletions src/decompression.jl
Original file line number Diff line number Diff line change
Expand Up @@ -592,6 +592,8 @@ function decompress!(
diagonal_nzind,
lower_triangle_offsets,
upper_triangle_offsets,
compressed_diag,
compressed_indices,
buffer,
) = result
(; S) = ag
Expand All @@ -608,21 +610,24 @@ function decompress!(
# Recover the diagonal coefficients of A
if has_diagonal(ag)
if uplo == :L
for i in diagonal_indices
for (k, i) in enumerate(diagonal_indices)
# A[i, i] is the first element in column i
nzind = A_colptr[i]
nzA[nzind] = B[i, color[i]]
pos = compressed_diag[k]
nzA[nzind] = B[pos]
end
elseif uplo == :U
for i in diagonal_indices
for (k, i) in enumerate(diagonal_indices)
# A[i, i] is the last element in column i
nzind = A_colptr[i + 1] - 1
nzA[nzind] = B[i, color[i]]
pos = compressed_diag[k]
nzA[nzind] = B[pos]
end
else # uplo == :F
for (k, i) in enumerate(diagonal_indices)
nzind = diagonal_nzind[k]
nzA[nzind] = B[i, color[i]]
pos = compressed_diag[k]
nzA[nzind] = B[pos]
end
end
end
Expand All @@ -642,7 +647,8 @@ function decompress!(

for (i, j) in reverse_bfs_orders[k]
counter += 1
val = B[i, color[j]] - buffer_right_type[i]
pos = compressed_indices[counter]
val = B[pos] - buffer_right_type[i]
buffer_right_type[j] = buffer_right_type[j] + val

#! format: off
Expand Down
11 changes: 10 additions & 1 deletion src/result.jl
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,8 @@ struct TreeSetColoringResult{M<:AbstractMatrix,G<:AdjacencyGraph,V,R} <:
diagonal_nzind::Vector{Int}
lower_triangle_offsets::Vector{Int}
upper_triangle_offsets::Vector{Int}
compressed_diag::Vector{Int}
compressed_indices::Vector{Int}
buffer::Vector{R}
end

Expand All @@ -302,6 +304,7 @@ function TreeSetColoringResult(
# Vector for the decompression of the diagonal coefficients
diagonal_indices = Int[]
diagonal_nzind = Int[]
compressed_diag = Int[]
ndiag = 0

if has_diagonal(ag)
Expand All @@ -311,6 +314,7 @@ function TreeSetColoringResult(
if i == j
push!(diagonal_indices, i)
push!(diagonal_nzind, k)
push!(compressed_diag, (color[i] - 1) * nvertices + i)
ndiag += 1
end
end
Expand All @@ -321,8 +325,9 @@ function TreeSetColoringResult(
nedges = (nnz(S) - ndiag) ÷ 2
lower_triangle_offsets = Vector{Int}(undef, nedges)
upper_triangle_offsets = Vector{Int}(undef, nedges)
compressed_indices = Vector{Int}(undef, nedges)

# Index in lower_triangle_offsets and upper_triangle_offsets
# Index in compressed_indices, lower_triangle_offsets and upper_triangle_offsets
index_offsets = 0

for k in eachindex(reverse_bfs_orders)
Expand All @@ -334,6 +339,8 @@ function TreeSetColoringResult(
col_j = view(rv, nzrange(S, j))
index_offsets += 1

compressed_indices[index_offsets] = (color[j] - 1) * nvertices + i

#! format: off
# S[i,j] is in the lower triangular part of S
if in_triangle(i, j, :L)
Expand Down Expand Up @@ -373,6 +380,8 @@ function TreeSetColoringResult(
diagonal_nzind,
lower_triangle_offsets,
upper_triangle_offsets,
compressed_diag,
compressed_indices,
buffer,
)
end
Expand Down
Loading