Skip to content

Commit b82e7c1

Browse files
committed
Fix: map local Hessian indices back to global indices in _hessian_color_preprocess
The function was returning I/J in local variable indices but callers use them as global variable indices (for hessian_lagrangian_structure). This caused wrong sparsity patterns when a function depends on non-contiguous variables (e.g., variables 4 and 5 out of 5 total). https://claude.ai/code/session_01WBu9hZukriWDSSybN9gfBq
1 parent f8af260 commit b82e7c1

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

src/coloring.jl

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,12 @@ function _hessian_color_preprocess(
7878
# Wrap result with local_indices
7979
result = ColoringResult(tree_result, local_indices)
8080

81-
# Get CSC-ordered indices directly from the sparse matrix
82-
I_sorted, J_sorted, _ = SparseArrays.findnz(mat)
81+
# Get CSC-ordered indices from the sparse matrix, then map back to global
82+
I_local, J_local, _ = SparseArrays.findnz(mat)
83+
I_global = [local_indices[i] for i in I_local]
84+
J_global = [local_indices[j] for j in J_local]
8385

84-
return copy(mat.colptr), I_sorted, J_sorted, result
86+
return copy(mat.colptr), I_global, J_global, result
8587
end
8688

8789
"""

0 commit comments

Comments
 (0)