@@ -49,7 +49,19 @@ struct HessOp{S}
4949 end
5050end
5151
52- export HessDense, HessSparse, HessSparseCOO, HessOp
52+ """
53+ HessGaussNewtonOp(::AbstractNLSModel{T,S}, n)
54+ Return a structure used for the evaluation of the Hessian matrix as an operator.
55+ """
56+ struct HessGaussNewtonOp{S}
57+ Jv:: S
58+ Jtv:: S
59+ function HessGaussNewtonOp (nls:: AbstractNLSModel{T,S} , n) where {T,S}
60+ return new {S} (S (undef, nls. nls_meta. nequ), S (undef, n))
61+ end
62+ end
63+
64+ export HessDense, HessSparse, HessSparseCOO, HessOp, HessGaussNewtonOp
5365
5466"""
5567 hessian!(workspace::HessDense, nlp, x)
@@ -67,6 +79,11 @@ function hessian!(workspace::HessOp, nlp, x)
6779 return hess_op! (nlp, x, workspace. Hv)
6880end
6981
82+ function hessian! (workspace:: HessGaussNewtonOp , nlp, x)
83+ Jx = jac_op_residual! (nlp, x, workspace. Jv, workspace. Jtv)
84+ return Jx' * Jx
85+ end
86+
7087function hessian! (workspace:: HessSparse , nlp, x)
7188 hess_coord! (nlp, x, workspace. vals)
7289 n = nlp. meta. nvar
0 commit comments