From c74f45cd12c77f98472bf5827085717e582991d6 Mon Sep 17 00:00:00 2001 From: Christopher Rackauckas Date: Tue, 11 Aug 2020 10:51:10 -0400 Subject: [PATCH] Fix non-vector input Jacobian creation (#128) * Fix non-vector input Jacobian creation * Update abstract.jl Co-authored-by: Patrick Kofod Mogensen --- src/objective_types/abstract.jl | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/objective_types/abstract.jl b/src/objective_types/abstract.jl index e010377..11d2ce7 100644 --- a/src/objective_types/abstract.jl +++ b/src/objective_types/abstract.jl @@ -16,12 +16,8 @@ function make_fdf(x, F::Number, f, g!) end # Initialize an n-by-n Jacobian -function alloc_DF(x, F) - a = (Base.OneTo(length(F)), Base.OneTo(length(x))) - df = similar(F, a) - fill!(df, NaN) - return df -end +alloc_DF(x, F) = eltype(x)(NaN) .* vec(F) .* vec(x)' + # Initialize a gradient shaped like x alloc_DF(x, F::T) where T<:Number = x_of_nans(x, promote_type(eltype(x), T)) # Initialize an n-by-n Hessian