Skip to content

Commit c74f45c

Browse files
Fix non-vector input Jacobian creation (#128)
* Fix non-vector input Jacobian creation * Update abstract.jl Co-authored-by: Patrick Kofod Mogensen <[email protected]>
1 parent 254716e commit c74f45c

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

src/objective_types/abstract.jl

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,8 @@ function make_fdf(x, F::Number, f, g!)
1616
end
1717

1818
# Initialize an n-by-n Jacobian
19-
function alloc_DF(x, F)
20-
a = (Base.OneTo(length(F)), Base.OneTo(length(x)))
21-
df = similar(F, a)
22-
fill!(df, NaN)
23-
return df
24-
end
19+
alloc_DF(x, F) = eltype(x)(NaN) .* vec(F) .* vec(x)'
20+
2521
# Initialize a gradient shaped like x
2622
alloc_DF(x, F::T) where T<:Number = x_of_nans(x, promote_type(eltype(x), T))
2723
# Initialize an n-by-n Hessian

0 commit comments

Comments
 (0)