Skip to content

Commit 8948993

Browse files
SebastianM-Cclaude
andcommitted
Fix Hessian buffer types to use Float64 instead of Bool
Ensure Hessian buffers are created with numeric type T instead of inheriting Bool from sparsity prototypes. Fixes InexactError when storing Hessian values. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
1 parent b96a578 commit 8948993

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

lib/OptimizationMadNLP/src/OptimizationMadNLP.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ function NLPModelsAdaptor(
8787
n = size(hess_proto, 1)
8888
hess_rows, hess_cols = _enumerate_lower_triangle(n)
8989
# For dense, store the full matrix but we'll extract values later
90-
hess_buffer = similar(hess_proto)
90+
hess_buffer = similar(hess_proto, T)
9191
else
9292
# No prototype - create dense structure
9393
n = meta.nvar
@@ -169,7 +169,7 @@ function NLPModels.hess_coord!(
169169

170170
if !isnothing(nlp.cache.f.cons_h) && !isempty(y)
171171
# Add weighted constraint Hessians
172-
cons_hessians = [similar(nlp.hess_buffer) for _ in 1:length(y)]
172+
cons_hessians = [similar(nlp.hess_buffer, eltype(nlp.hess_buffer)) for _ in 1:length(y)]
173173
nlp.cache.f.cons_h(cons_hessians, x)
174174
for (λ, H_cons) in zip(y, cons_hessians)
175175
nlp.hess_buffer .+= λ .* H_cons

0 commit comments

Comments
 (0)