@@ -20,9 +20,9 @@ function make_hessian_buffers(colorvec, x)
2020end
2121
2222function ForwardColorHesCache (f, x:: AbstractVector{<:Number} ,
23- colorvec:: AbstractVector{<:Integer} = eachindex (x),
24- sparsity:: Union{AbstractMatrix, Nothing} = nothing ,
25- g! = (G, x, grad_config) -> ForwardDiff. gradient! (G, f, x, grad_config))
23+ colorvec:: AbstractVector{<:Integer} = eachindex (x),
24+ sparsity:: Union{AbstractMatrix, Nothing} = nothing ,
25+ g! = (G, x, grad_config) -> ForwardDiff. gradient! (G, f, x, grad_config))
2626 ncolors, D, buffer, G, G2 = make_hessian_buffers (colorvec, x)
2727 grad_config = ForwardDiff. GradientConfig (f, x)
2828
@@ -46,7 +46,7 @@ function ForwardColorHesCache(f, x::AbstractVector{<:Number},
4646end
4747
4848function numauto_color_hessian! (H:: AbstractMatrix{<:Number} , f, x:: AbstractArray{<:Number} ,
49- hes_cache:: ForwardColorHesCache ; safe = true )
49+ hes_cache:: ForwardColorHesCache ; safe = true )
5050 ϵ = cbrt (eps (eltype (x)))
5151 for j in 1 : (hes_cache. ncolors)
5252 x .+ = ϵ .* @view hes_cache. D[:, j]
@@ -67,23 +67,23 @@ function numauto_color_hessian!(H::AbstractMatrix{<:Number}, f, x::AbstractArray
6767end
6868
6969function numauto_color_hessian! (H:: AbstractMatrix{<:Number} , f, x:: AbstractArray{<:Number} ,
70- colorvec:: AbstractVector{<:Integer} = eachindex (x),
71- sparsity:: Union{AbstractMatrix, Nothing} = nothing )
70+ colorvec:: AbstractVector{<:Integer} = eachindex (x),
71+ sparsity:: Union{AbstractMatrix, Nothing} = nothing )
7272 hes_cache = ForwardColorHesCache (f, x, colorvec, sparsity)
7373 numauto_color_hessian! (H, f, x, hes_cache)
7474 return H
7575end
7676
7777function numauto_color_hessian (f, x:: AbstractArray{<:Number} ,
78- hes_cache:: ForwardColorHesCache )
78+ hes_cache:: ForwardColorHesCache )
7979 H = convert .(eltype (x), hes_cache. sparsity)
8080 numauto_color_hessian! (H, f, x, hes_cache)
8181 return H
8282end
8383
8484function numauto_color_hessian (f, x:: AbstractArray{<:Number} ,
85- colorvec:: AbstractVector{<:Integer} = eachindex (x),
86- sparsity:: Union{AbstractMatrix, Nothing} = nothing )
85+ colorvec:: AbstractVector{<:Integer} = eachindex (x),
86+ sparsity:: Union{AbstractMatrix, Nothing} = nothing )
8787 hes_cache = ForwardColorHesCache (f, x, colorvec, sparsity)
8888 H = convert .(eltype (x), hes_cache. sparsity)
8989 numauto_color_hessian! (H, f, x, hes_cache)
102102struct AutoAutoTag end
103103
104104function ForwardAutoColorHesCache (f, x:: AbstractVector{V} ,
105- colorvec:: AbstractVector{<:Integer} = eachindex (x),
106- sparsity:: Union{AbstractMatrix, Nothing} = nothing ,
107- tag:: ForwardDiff.Tag = ForwardDiff. Tag (AutoAutoTag (), V)) where {V}
105+ colorvec:: AbstractVector{<:Integer} = eachindex (x),
106+ sparsity:: Union{AbstractMatrix, Nothing} = nothing ,
107+ tag:: ForwardDiff.Tag = ForwardDiff. Tag (AutoAutoTag (), V)) where {V}
108108 if sparsity === nothing
109109 sparsity = sparse (ones (length (x), length (x)))
110110 end
@@ -124,28 +124,28 @@ function ForwardAutoColorHesCache(f, x::AbstractVector{V},
124124end
125125
126126function autoauto_color_hessian! (H:: AbstractMatrix{<:Number} , f, x:: AbstractArray{<:Number} ,
127- hes_cache:: ForwardAutoColorHesCache )
127+ hes_cache:: ForwardAutoColorHesCache )
128128 forwarddiff_color_jacobian! (H, hes_cache. grad!, x, hes_cache. jac_cache)
129129end
130130
131131function autoauto_color_hessian! (H:: AbstractMatrix{<:Number} , f, x:: AbstractArray{<:Number} ,
132- colorvec:: AbstractVector{<:Integer} = eachindex (x),
133- sparsity:: Union{AbstractMatrix, Nothing} = nothing )
132+ colorvec:: AbstractVector{<:Integer} = eachindex (x),
133+ sparsity:: Union{AbstractMatrix, Nothing} = nothing )
134134 hes_cache = ForwardAutoColorHesCache (f, x, colorvec, sparsity)
135135 autoauto_color_hessian! (H, f, x, hes_cache)
136136 return H
137137end
138138
139139function autoauto_color_hessian (f, x:: AbstractArray{<:Number} ,
140- hes_cache:: ForwardAutoColorHesCache )
140+ hes_cache:: ForwardAutoColorHesCache )
141141 H = convert .(eltype (x), hes_cache. sparsity)
142142 autoauto_color_hessian! (H, f, x, hes_cache)
143143 return H
144144end
145145
146146function autoauto_color_hessian (f, x:: AbstractArray{<:Number} ,
147- colorvec:: AbstractVector{<:Integer} = eachindex (x),
148- sparsity:: Union{AbstractMatrix, Nothing} = nothing )
147+ colorvec:: AbstractVector{<:Integer} = eachindex (x),
148+ sparsity:: Union{AbstractMatrix, Nothing} = nothing )
149149 hes_cache = ForwardAutoColorHesCache (f, x, colorvec, sparsity)
150150 H = convert .(eltype (x), hes_cache. sparsity)
151151 autoauto_color_hessian! (H, f, x, hes_cache)
0 commit comments