@@ -251,7 +251,9 @@ function build_loss(f::OptimizationFunction, prob, cb)
251251 end
252252end
253253
254- # TODO : What does the “true” mean here?
254+ # cf. https://github.com/SciML/SciMLBase.jl/blob/master/src/problems/optimization_problems.jl
255+ # {iip} is the parameter here – nowhere explained but very much probably “is in place”
256+ # so this refers to whether the gradient/hessian is computed in place or not
255257function build_gradF (f:: OptimizationFunction{true} )
256258 function g (M:: AbstractManifold , G, θ)
257259 f. grad (G, θ)
@@ -268,14 +270,16 @@ end
268270function build_hessF (f:: OptimizationFunction{true} )
269271 function h (M:: AbstractManifold , H1, θ, X)
270272 H = zeros (eltype (θ), length (θ))
273+ # an Optimization function has both hess (the matrix) and hv (Hessian with direction)
274+ # we need hv here
271275 f. hv (H, θ, X)
272276 G = zeros (eltype (θ), length (θ))
273277 f. grad (G, θ)
274278 riemannian_Hessian! (M, H1, θ, G, H, X)
275279 end
276280 function h (M:: AbstractManifold , θ, X)
277- H = zeros (eltype (θ), length (θ), length (θ) )
278- f. hess (H, θ)
281+ H = zeros (eltype (θ), length (θ))
282+ f. hv (H, θ, X )
279283 G = zeros (eltype (θ), length (θ))
280284 f. grad (G, θ)
281285 return riemannian_Hessian (M, θ, G, H, X)
0 commit comments