@@ -70,14 +70,14 @@ function CalcFactorResidualAP(fg::GraphsDFG, factorLabels::Vector{Symbol}, varIn
7070 return ArrayPartition {CalcFactorResidual, typeof(parts_tuple)} (parts_tuple)
7171end
7272
73- function (cfm:: CalcFactorResidual{T} )(p) where T
73+ function (cfm:: CalcFactorResidual )(p)
7474 meas = cfm. meas
7575 points = map (idx-> p[idx], cfm. varOrderIdxs)
76- return cfm. sqrt_iΣ * cfm (meas, points... ) # 0.654783 seconds (6.75 M allocations: 531.688 MiB, 14.41% gc time)
76+ return cfm. sqrt_iΣ * cfm (meas, points... )
7777end
7878
7979function (cfm:: CalcFactorResidual{T} )() where T
80- return cfm. sqrt_iΣ * cfm (cfm. meas, cfm. points... ) # 0.654783 seconds (6.75 M allocations: 531.688 MiB, 14.41% gc time)
80+ return cfm. sqrt_iΣ * cfm (cfm. meas, cfm. points... )
8181end
8282
8383# cost function f: M->ℝᵈ for Riemannian Levenberg-Marquardt
@@ -110,7 +110,12 @@ struct CostFres!{CFT}
110110 # add return_ranges to allow MultiThreaded
111111end
112112
113- function calcFactorResVec! (x:: Vector{T} , cfm_part:: Vector{<:CalcFactorResidual} , p:: AbstractArray{T} , st:: Int ) where T
113+ function calcFactorResVec! (
114+ x:: Vector{T} ,
115+ cfm_part:: Vector{<:CalcFactorResidual{FT}} ,
116+ p:: AbstractArray{T} ,
117+ st:: Int
118+ ) where {T,FT}
114119 l = getDimension (cfm_part[1 ]) # all should be the same
115120 for cfm in cfm_part
116121 x[st: st + l - 1 ] = cfm (p) # NOTE looks like do not broadcast here
@@ -289,7 +294,7 @@ function covarianceFiniteDiff(M, jacF!::JacF_RLM!, p0)
289294 end
290295 end
291296
292- @time H = FiniteDiff. finite_difference_hessian (costf, X0)
297+ H = FiniteDiff. finite_difference_hessian (costf, X0)
293298
294299 # inv(H)
295300 Σ = Matrix (H) \ Matrix {eltype(H)} (I, size (H)... )
@@ -356,7 +361,7 @@ function solve_RLM(
356361 else
357362 # TODO make sure J initial_jacobian_f is updated, otherwise recalc jacF!(M, J, lm_r) # lm_r === p0
358363 J = initial_jacobian_f
359- H = J' J
364+ H = J' J # approx
360365 Σ = H \ Matrix {eltype(H)} (I, size (H)... )
361366 # Σ = pinv(H)
362367 end
0 commit comments