Skip to content

Commit ac17672

Browse files
committed
Implement stylistic suggestions by antoine-levitt
1 parent 9f71a63 commit ac17672

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
Manifest.toml
12
benchmarks/graphs/*
23
*~
34
*.kate-swp

src/levenberg_marquardt.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ function levenberg_marquardt(df::OnceDifferentiable, initial_x::AbstractVector{T
4242
value_jacobian!!(df, initial_x)
4343

4444
if isfinite(tau)
45-
lambda = tau*maximum(abs.(jacobian(df)'*jacobian(df)))
45+
lambda = tau*maximum(real, jacobian(df)'*jacobian(df))
4646
end
4747

4848

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

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

0 commit comments

Comments
 (0)