Skip to content

Commit

Permalink
Enable Hessian cache choice in only_fgh.
Browse files Browse the repository at this point in the history
  • Loading branch information
pkofod committed Mar 31, 2018
1 parent bd1586d commit 0e75230
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
16 changes: 12 additions & 4 deletions src/objective_types/incomplete.jl
Expand Up @@ -85,18 +85,26 @@ function OnceDifferentiable(t::Union{InplaceObjective, NotInplaceObjective}, x::
OnceDifferentiable(f, df, fdf, x, F)
end

function TwiceDifferentiable(t::InplaceObjective{<: Void, <: Void, H}, x::AbstractArray{T,1}, F::Real = real(zero(eltype(x)))) where {H, T}
function TwiceDifferentiable(t::InplaceObjective{<: Void, <: Void, TH}, x::AbstractArray{T,1}, F::Real = real(zero(eltype(x))), G::TG = similar(x), H = alloc_H(x)) where {TG, TH, T}
f = x -> t.fgh(F, nothing, nothing, x)
df = (G, x) -> t.fgh(nothing, G, nothing, x)
fdf = (G, x) -> t.fgh(F, G, nothing, x)
h = (H, x) -> t.fgh(F, nothing, H, x)
TwiceDifferentiable(f, df, fdf, h, x, F)
TwiceDifferentiable(f, df, fdf, h, x, F, G, H)
end

function TwiceDifferentiable(t::InplaceObjective{<: Void, <: Void, H}, x::AbstractArray{T}, F::Real = real(zero(eltype(x)))) where {H, T}
function TwiceDifferentiable(t::InplaceObjective{<: Void, <: Void, TH}, x::AbstractArray{T,1}, F::Real = real(zero(eltype(x))), G::AbstractVector = similar(x), H = alloc_H(x)) where {TH, T}
f = x -> t.fgh(F, nothing, nothing, x)
df = (G, x) -> t.fgh(nothing, G, nothing, x)
fdf = (G, x) -> t.fgh(F, G, nothing, x)
h = (H, x) -> t.fgh(F, nothing, H, x)
TwiceDifferentiable(f, df, fdf, h, x, F, G, H)
end

function TwiceDifferentiable(t::InplaceObjective{<: Void, <: Void, TH}, x::AbstractArray{T}, F::Real = real(zero(eltype(x))), G::TG = similar(x), H = alloc_H(x)) where {TG, TH, T}
f = x -> t.fgh(F, nothing, nothing, x)
df = (G, x) -> t.fgh(nothing, G, nothing, x)
fdf = (G, x) -> t.fgh(F, G, nothing, x)
h = (H, x) -> t.fgh(H, nothing, F, x)
TwiceDifferentiable(f, df, fdf, h, x, F)
TwiceDifferentiable(f, df, fdf, h, x, F, G, H)
end
4 changes: 2 additions & 2 deletions src/objective_types/twicedifferentiable.jl
Expand Up @@ -24,7 +24,7 @@ function TwiceDifferentiable(f, g!, fg!, h!, x::TX, F::T = real(zero(eltype(x)))
[0,], [0,], [0,])
end

function TwiceDifferentiable(f, g!, h!, x::AbstractVector, F = real(zero(eltype(x))), G = similar(x), H = alloc_H(x))
function TwiceDifferentiable(f, g!, h!, x::AbstractVector{TX}, F::T = real(zero(eltype(x))), G = similar(x), H = alloc_H(x)) where {TX, T}
fg! = make_fdf(x, F, f, g!)
return TwiceDifferentiable(f, g!, fg!, h!, x, F, G, H)
end
end

0 comments on commit 0e75230

Please sign in to comment.