@@ -347,7 +347,7 @@ function TreeSetColoringResult(
347347 end
348348
349349 # continue until all leaves are treated
350- while queue_start ≤ queue_end
350+ while queue_start <= queue_end
351351 leaf = queue[queue_start]
352352 queue_start += 1
353353
@@ -373,29 +373,30 @@ function TreeSetColoringResult(
373373 j = neighbor
374374 col_i = view (rv, nzrange (S, i))
375375 col_j = view (rv, nzrange (S, j))
376- index_ij = S. colptr[j] - 1 + searchsortedfirst (col_j, i) # S.nzval[index_ij] = S[i,j]
377- @assert S. nzval[index_ij] == S[i,j]
378- index_ji = S. colptr[i] - 1 + searchsortedfirst (col_i, j) # S.nzval[index_ji] = S[j,i]
379- @assert S. nzval[index_ji] == S[j,i]
380376 index_offsets += 1
381377
378+ # ! format: off
379+ # S[i,j] is in the lower triangular part of S
382380 if in_triangle (i, j, :L )
383381 # uplo = :L or uplo = :F
384- # A [i,j] is stored at index_ij = (A .colptr[j+1] - offset_L) in A .nzval
385- lower_triangle_offsets[index_offsets] = S . colptr[j + 1 ] - index_ij
382+ # S [i,j] is stored at index_ij = (S .colptr[j+1] - offset_L) in S .nzval
383+ lower_triangle_offsets[index_offsets] = length (col_j) - searchsortedfirst (col_j, i) + 1
386384
387385 # uplo = :U or uplo = :F
388- # A[j,i] is stored at index_ji = (A.colptr[i] + offset_U) in A.nzval
389- upper_triangle_offsets[index_offsets] = index_ji - S. colptr[i]
390- else
391- # uplo = :L or uplo = :F
392- # A[j,i] is stored at index_ji = (A.colptr[i+1] - offset_L) in A.nzval
393- lower_triangle_offsets[index_offsets] = S. colptr[i + 1 ] - index_ji
386+ # S[j,i] is stored at index_ji = (S.colptr[i] + offset_U) in S.nzval
387+ upper_triangle_offsets[index_offsets] = searchsortedfirst (col_i, j):: Int - 1
394388
389+ # S[i,j] is in the upper triangular part of S
390+ else
395391 # uplo = :U or uplo = :F
396- # A[i,j] is stored at index_ij = (A.colptr[j] + offset_U) in A.nzval
397- upper_triangle_offsets[index_offsets] = index_ij - S. colptr[j]
392+ # S[i,j] is stored at index_ij = (S.colptr[j] + offset_U) in S.nzval
393+ upper_triangle_offsets[index_offsets] = searchsortedfirst (col_j, i):: Int - 1
394+
395+ # uplo = :L or uplo = :F
396+ # S[j,i] is stored at index_ji = (S.colptr[i+1] - offset_L) in S.nzval
397+ lower_triangle_offsets[index_offsets] = length (col_i) - searchsortedfirst (col_i, j) + 1
398398 end
399+ # ! format: on
399400 end
400401 end
401402 end
0 commit comments