Skip to content

Commit 685cd0e

Browse files
committed
add HessGaussNewtonOp
1 parent fc3761d commit 685cd0e

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

src/utils/hessian_rep.jl

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,19 @@ struct HessOp{S}
4949
end
5050
end
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)
6880
end
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+
7087
function hessian!(workspace::HessSparse, nlp, x)
7188
hess_coord!(nlp, x, workspace.vals)
7289
n = nlp.meta.nvar

0 commit comments

Comments
 (0)