Skip to content

Commit

Permalink
Simplify code a bit.
Browse files Browse the repository at this point in the history
  • Loading branch information
kellertuer committed Dec 28, 2024
1 parent 346d7f5 commit 59b41a3
Showing 1 changed file with 3 additions and 12 deletions.
15 changes: 3 additions & 12 deletions src/solvers/LevenbergMarquardt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -199,16 +199,7 @@ end
# Solver functions
#
function initialize_solver!(
dmp::DefaultManoptProblem{mT,<:NonlinearLeastSquaresObjective{AllocatingEvaluation}},
lms::LevenbergMarquardtState,
) where {mT<:AbstractManifold}
M = get_manifold(dmp)
lms.residual_values = get_value(M, get_objective(dmp).objective, lms.p)
lms.X = get_gradient(dmp, lms.p)
return lms
end
function initialize_solver!(
dmp::DefaultManoptProblem{mT,<:NonlinearLeastSquaresObjective{InplaceEvaluation}},
dmp::DefaultManoptProblem{mT,<:NonlinearLeastSquaresObjective},
lms::LevenbergMarquardtState,
) where {mT<:AbstractManifold}
M = get_manifold(dmp)
Expand All @@ -229,10 +220,10 @@ function step_solver!(
nlso = get_objective(dmp)
# a new Jacobian is only needed if the last step was successful
if lms.last_step_successful
get_jacobian!(dmp, lms.jacobian, lms.p)
get_jacobian!(M, lms.jacobian, nlso, lms.p)
end
λk = lms.damping_term * norm(lms.residual_values)^2

basis_ox = get_jacobian_basis(nlso.objective)
JJ = transpose(lms.jacobian) * lms.jacobian + λk * I
# `cholesky` is technically not necessary but it's the fastest method to solve the
# problem because JJ is symmetric positive definite
Expand Down

0 comments on commit 59b41a3

Please sign in to comment.