From 811d4b7ca3bfcabbc98b58cdc1f655f03617f397 Mon Sep 17 00:00:00 2001 From: Charles Kawczynski Date: Sat, 6 Jun 2020 14:04:09 -0700 Subject: [PATCH 1/2] Allocate df with similar, fixes GPU support --- src/objective_types/abstract.jl | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/objective_types/abstract.jl b/src/objective_types/abstract.jl index 7a63ec0..6695005 100644 --- a/src/objective_types/abstract.jl +++ b/src/objective_types/abstract.jl @@ -16,7 +16,12 @@ function make_fdf(x, F::Number, f, g!) end # Initialize an n-by-n Jacobian -alloc_DF(x, F) = fill(eltype(F)(NaN), length(F), length(x)) +function alloc_DF(x, F) + a = (Base.OneTo(length(F)), Base.OneTo(length(x))) + df = similar(F, a) + fill!(df, NaN) + return df +end # 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 From 2260e7bfc9123fbb0c97998ed1e8aeb492544ddb Mon Sep 17 00:00:00 2001 From: Patrick Kofod Mogensen Date: Wed, 10 Jun 2020 21:38:51 +0200 Subject: [PATCH 2/2] Change H allocator. --- src/objective_types/abstract.jl | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/objective_types/abstract.jl b/src/objective_types/abstract.jl index 6695005..e010377 100644 --- a/src/objective_types/abstract.jl +++ b/src/objective_types/abstract.jl @@ -25,4 +25,6 @@ end # 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 -alloc_H(x, F::T) where T<:Number = alloc_DF(x, promote_type(eltype(x), T).(x)) +function alloc_H(x, F::T) where T<:Number + eltype(x)(NaN).*x*x' +end