Skip to content

Commit

Permalink
Implement stylistic suggestions by antoine-levitt
Browse files Browse the repository at this point in the history
  • Loading branch information
kagalenko-m-b committed Oct 28, 2020
1 parent 9f71a63 commit ac17672
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
Manifest.toml
benchmarks/graphs/*
*~
*.kate-swp
6 changes: 3 additions & 3 deletions src/levenberg_marquardt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ function levenberg_marquardt(df::OnceDifferentiable, initial_x::AbstractVector{T
value_jacobian!!(df, initial_x)

if isfinite(tau)
lambda = tau*maximum(abs.(jacobian(df)'*jacobian(df)))
lambda = tau*maximum(real, jacobian(df)'*jacobian(df))
end


Expand Down Expand Up @@ -102,7 +102,7 @@ function levenberg_marquardt(df::OnceDifferentiable, initial_x::AbstractVector{T
# argmin 0.5*||J(x)*delta_x + f(x)||^2 + lambda*||diagm(J'*J)*delta_x||^2
Q,R,p = qr(J, Val(true))
rhs = -Matrix(Q)'*value(df)
if isreal(R)
if eltype(J) <: Real
RR = vcat(R, lambda*I)
rhs = vcat(rhs, zeros(T, n))
else
Expand All @@ -111,7 +111,7 @@ function levenberg_marquardt(df::OnceDifferentiable, initial_x::AbstractVector{T
end
v[p] = (RR\rhs)

if avv! != nothing && isreal(J) # Geodesic acceleration for complex Jacobian
if avv! != nothing && isreal(J) # Geodesic acceleration for complex Jacobian needs to be verified for correctness. It might work as is.
#GEODESIC ACCELERATION PART
avv!(dir_deriv, x, v)
mul!(a, J', dir_deriv)
Expand Down

0 comments on commit ac17672

Please sign in to comment.