@@ -549,22 +549,28 @@ function decompress!(
549549 # Reset the buffer to zero for the root vertex
550550 (_, root) = reverse_bfs_orders[k][end ]
551551 buffer_right_type[root] = zero (R)
552- end
553552
554- for (i, j) in reverse_bfs_orders[k]
555- if ! is_star[k]
556- # the tree is not a star
553+ # The tree is not a star
554+ for (i, j) in reverse_bfs_orders[k]
557555 val = B[i, color[j]] - buffer_right_type[i]
558556 buffer_right_type[j] = buffer_right_type[j] + val
559- else
560- # the tree is a trivial or non-trivial star
561- val = B[i, color[j]]
562- end
563- if in_triangle (i, j, uplo)
564- A[i, j] = val
557+ if in_triangle (i, j, uplo)
558+ A[i, j] = val
559+ end
560+ if in_triangle (j, i, uplo)
561+ A[ j, i] = val
562+ end
565563 end
566- if in_triangle (j, i, uplo)
567- A[j, i] = val
564+ else
565+ # The tree is a star (trivial or non-trivial)
566+ for (i, j) in reverse_bfs_orders[k]
567+ val = B[i, color[j]]
568+ if in_triangle (i, j, uplo)
569+ A[i, j] = val
570+ end
571+ if in_triangle (j, i, uplo)
572+ A[j, i] = val
573+ end
568574 end
569575 end
570576 end
@@ -635,53 +641,89 @@ function decompress!(
635641 # Reset the buffer to zero for the root vertex
636642 (_, root) = reverse_bfs_orders[k][end ]
637643 buffer_right_type[root] = zero (R)
638- end
639644
640- for (i, j) in reverse_bfs_orders[k]
641- counter += 1
642- if ! is_star[k]
643- # the tree is not a star
645+ # The tree is not a star
646+ for (i, j) in reverse_bfs_orders[k]
647+ counter += 1
644648 val = B[i, color[j]] - buffer_right_type[i]
645649 buffer_right_type[j] = buffer_right_type[j] + val
646- else
647- # the tree is a trivial or non-trivial star
648- val = B[i, color[j]]
649- end
650650
651- # ! format: off
652- # A[i,j] is in the lower triangular part of A
653- if in_triangle (i, j, :L )
654- # uplo = :L or uplo = :F
655- # A[i,j] is stored at index_ij = (A.colptr[j+1] - offset_L) in A.nzval
656- if uplo != :U
657- nzind = A_colptr[j + 1 ] - lower_triangle_offsets[counter]
658- nzA[nzind] = val
659- end
660-
661- # uplo = :U or uplo = :F
662- # A[j,i] is stored at index_ji = (A.colptr[i] + offset_U) in A.nzval
663- if uplo != :L
664- nzind = A_colptr[i] + upper_triangle_offsets[counter]
665- nzA[nzind] = val
666- end
667-
668- # A[i,j] is in the upper triangular part of A
669- else
670- # uplo = :U or uplo = :F
671- # A[i,j] is stored at index_ij = (A.colptr[j] + offset_U) in A.nzval
672- if uplo != :L
673- nzind = A_colptr[j] + upper_triangle_offsets[counter]
674- nzA[nzind] = val
651+ # ! format: off
652+ # A[i,j] is in the lower triangular part of A
653+ if in_triangle (i, j, :L )
654+ # uplo = :L or uplo = :F
655+ # A[i,j] is stored at index_ij = (A.colptr[j+1] - offset_L) in A.nzval
656+ if uplo != :U
657+ nzind = A_colptr[j + 1 ] - lower_triangle_offsets[counter]
658+ nzA[nzind] = val
659+ end
660+
661+ # uplo = :U or uplo = :F
662+ # A[j,i] is stored at index_ji = (A.colptr[i] + offset_U) in A.nzval
663+ if uplo != :L
664+ nzind = A_colptr[i] + upper_triangle_offsets[counter]
665+ nzA[nzind] = val
666+ end
667+
668+ # A[i,j] is in the upper triangular part of A
669+ else
670+ # uplo = :U or uplo = :F
671+ # A[i,j] is stored at index_ij = (A.colptr[j] + offset_U) in A.nzval
672+ if uplo != :L
673+ nzind = A_colptr[j] + upper_triangle_offsets[counter]
674+ nzA[nzind] = val
675+ end
676+
677+ # uplo = :L or uplo = :F
678+ # A[j,i] is stored at index_ji = (A.colptr[i+1] - offset_L) in A.nzval
679+ if uplo != :U
680+ nzind = A_colptr[i + 1 ] - lower_triangle_offsets[counter]
681+ nzA[nzind] = val
682+ end
675683 end
684+ # ! format: on
685+ end
686+ else
687+ # The tree is a star (trivial or non-trivial)
688+ for (i, j) in reverse_bfs_orders[k]
689+ counter += 1
690+ val = B[i, color[j]]
676691
677- # uplo = :L or uplo = :F
678- # A[j,i] is stored at index_ji = (A.colptr[i+1] - offset_L) in A.nzval
679- if uplo != :U
680- nzind = A_colptr[i + 1 ] - lower_triangle_offsets[counter]
681- nzA[nzind] = val
692+ # ! format: off
693+ # A[i,j] is in the lower triangular part of A
694+ if in_triangle (i, j, :L )
695+ # uplo = :L or uplo = :F
696+ # A[i,j] is stored at index_ij = (A.colptr[j+1] - offset_L) in A.nzval
697+ if uplo != :U
698+ nzind = A_colptr[j + 1 ] - lower_triangle_offsets[counter]
699+ nzA[nzind] = val
700+ end
701+
702+ # uplo = :U or uplo = :F
703+ # A[j,i] is stored at index_ji = (A.colptr[i] + offset_U) in A.nzval
704+ if uplo != :L
705+ nzind = A_colptr[i] + upper_triangle_offsets[counter]
706+ nzA[nzind] = val
707+ end
708+
709+ # A[i,j] is in the upper triangular part of A
710+ else
711+ # uplo = :U or uplo = :F
712+ # A[i,j] is stored at index_ij = (A.colptr[j] + offset_U) in A.nzval
713+ if uplo != :L
714+ nzind = A_colptr[j] + upper_triangle_offsets[counter]
715+ nzA[nzind] = val
716+ end
717+
718+ # uplo = :L or uplo = :F
719+ # A[j,i] is stored at index_ji = (A.colptr[i+1] - offset_L) in A.nzval
720+ if uplo != :U
721+ nzind = A_colptr[i + 1 ] - lower_triangle_offsets[counter]
722+ nzA[nzind] = val
723+ end
682724 end
725+ # ! format: on
683726 end
684- # ! format: on
685727 end
686728 end
687729 return A
0 commit comments