Skip to content

Commit 8a0668a

Browse files
committed
More fixes
1 parent 7c3a2da commit 8a0668a

File tree

2 files changed

+21
-19
lines changed

2 files changed

+21
-19
lines changed

src/decompression.jl

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -728,16 +728,21 @@ function decompress!(
728728
fill!(A, zero(eltype(A)))
729729

730730
ind_Bc = 1
731+
ind_Br = nnz(S)
731732
rvS = rowvals(S)
732733
for j in axes(S, 2)
733734
for k in nzrange(S, j)
734735
i = rvS[k]
735-
index = compressed_indices[k]
736-
if A_indices[ind_Bc] == k && ind_Bc <= pos_Bc
737-
A[i, j] = Bc[index]
738-
ind_Bc += 1
736+
index_Bc = compressed_indices[ind_Bc]
737+
if A_indices[ind_Bc] == k
738+
A[i, j] = Bc[index_Bc]
739+
if ind_Bc < pos_Bc
740+
ind_Bc += 1
741+
end
739742
else
740-
A[i, j] = Br[index]
743+
index_Br = compressed_indices[ind_Br]
744+
A[i, j] = Br[index_Br]
745+
ind_Br -= 1
741746
end
742747
end
743748
end
@@ -806,13 +811,13 @@ function decompress!(
806811
(i, j) = reverse_bfs_orders[pos]
807812
cj = symmetric_color[j]
808813
if in_triangle(i, j, :L)
809-
val = Bc[i, symmetric_to_column[cj]] - buffer_right_type[i]
814+
val = Bc[i - n, symmetric_to_column[cj]] - buffer_right_type[i]
810815
buffer_right_type[j] = buffer_right_type[j] + val
811-
A[i, j] = val
816+
A[i - n, j] = val
812817
else
813818
val = Br[symmetric_to_row[cj], i] - buffer_right_type[i]
814819
buffer_right_type[j] = buffer_right_type[j] + val
815-
A[j, i] = val
820+
A[j - n, i] = val
816821
end
817822
end
818823
end
@@ -865,13 +870,13 @@ function decompress!(
865870

866871
for pos in first:last
867872
(i, j) = reverse_bfs_orders[pos]
868-
counter += 1
869873
cj = symmetric_color[j]
874+
counter += 1
870875

871876
#! format: off
872877
# A[i,j] is in the lower triangular part of A
873878
if in_triangle(i, j, :L)
874-
val = Bc[i, symmetric_to_column[cj]] - buffer_right_type[i]
879+
val = Bc[i - n, symmetric_to_column[cj]] - buffer_right_type[i]
875880
buffer_right_type[j] = buffer_right_type[j] + val
876881

877882
# A[i,j] is stored at index_ij = A_indices[counter] in A.nzval

src/result.jl

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -647,9 +647,9 @@ function StarSetBicoloringResult(
647647
pos_Bc += 1
648648
A_indices[pos_Bc] = k
649649
compressed_indices[pos_Bc] = (symmetric_to_column[c] - 1) * m + i
650-
else # i == h
651-
# i is the hub and j is the spoke
652-
c = symmetric_color[i]
650+
else # i + n == h
651+
# (i + n) is the hub and j is the spoke
652+
c = symmetric_color[i + n]
653653

654654
# A[i, j] = Br[symmetric_to_row[c], j]
655655
pos_Br -= 1
@@ -752,26 +752,23 @@ function TreeSetBicoloringResult(
752752

753753
for pos in first:last
754754
(leaf, neighbor) = reverse_bfs_orders[pos]
755-
index += 1
756-
757755
i = leaf
758756
j = neighbor
759-
col_i = view(rv, nzrange(S, i))
760-
col_j = view(rv, nzrange(S, j))
757+
index += 1
761758

762759
#! format: off
763760
# S[i,j] is in the lower triangular part of S
764761
if in_triangle(i, j, :L)
765762
# S[i,j] is stored at index_ij = (S.colptr[j] + offset) in S.nzval
766763
col_j = view(rv, nzrange(S, j))
767-
offset = searchsortedfirst(col_j, i)::Int - 1
764+
offset = searchsortedfirst(col_j, i-n)::Int - 1
768765
A_indices[index] = S.colptr[j] + offset
769766

770767
# S[i,j] is in the upper triangular part of S
771768
else
772769
# S[j,i] is stored at index_ji = (S.colptr[i] + offset) in S.nzval
773770
col_i = view(rv, nzrange(S, i))
774-
offset = searchsortedfirst(col_i, j)::Int - 1
771+
offset = searchsortedfirst(col_i, j-n)::Int - 1
775772
A_indices[index] = S.colptr[i] + offset
776773
end
777774
#! format: on

0 commit comments

Comments
 (0)