From 0e7cd4d289113ab973a824a45d3840ef1486a46f Mon Sep 17 00:00:00 2001 From: Ronny Bergmann Date: Fri, 3 Jan 2025 15:16:59 +0100 Subject: [PATCH] Resolve the m-n-d confusion. The number of residuals/components in LM is now unified to m. --- src/documentation_glossary.jl | 4 ++-- src/plans/nonlinear_least_squares_plan.jl | 2 +- src/solvers/LevenbergMarquardt.jl | 14 +++++++------- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/documentation_glossary.jl b/src/documentation_glossary.jl index 24f947a6ed..4d8dbc5cc0 100644 --- a/src/documentation_glossary.jl +++ b/src/documentation_glossary.jl @@ -267,10 +267,10 @@ define!( :NonLinearLeastSquares, (; M="M", p="p") -> """ ```math -$(_tex(:argmin))_{$p ∈ $(_math(:M; M=M))} $(_tex(:frac,1,2)) $(_tex(:sum))_{i=1}^n $(_tex(:abs, "f_i($p)"))^2 +$(_tex(:argmin))_{$p ∈ $(_math(:M; M=M))} $(_tex(:frac,1,2)) $(_tex(:sum))_{i=1}^m $(_tex(:abs, "f_i($p)"))^2 ``` -where ``f: $(_math(:M; M=M)) → ℝ^n`` is written with component functions ``f_i: $(_math(:M; M=M)) → ℝ``, +where ``f: $(_math(:M; M=M)) → ℝ^m`` is written with component functions ``f_i: $(_math(:M; M=M)) → ℝ``, ``i=1,…,m``, and each component function is continuously differentiable. """, ) diff --git a/src/plans/nonlinear_least_squares_plan.jl b/src/plans/nonlinear_least_squares_plan.jl index f78cd42928..c7bfb7a697 100644 --- a/src/plans/nonlinear_least_squares_plan.jl +++ b/src/plans/nonlinear_least_squares_plan.jl @@ -138,7 +138,7 @@ _doc_get_residuals_nlso = """ get_residuals(M::AbstractManifold, nlso::NonlinearLeastSquaresObjective, p) get_residuals!(M::AbstractManifold, V, nlso::NonlinearLeastSquaresObjective, p) -Compute the vector of residuals ``f_i(p)``, ``i=1,…,n`` given the manifold `M`, +Compute the vector of residuals ``f_i(p)``, ``i=1,…,m`` given the manifold `M`, the [`NonlinearLeastSquaresObjective`](@ref) `nlso` and a current point ``p`` on `M`. """ diff --git a/src/solvers/LevenbergMarquardt.jl b/src/solvers/LevenbergMarquardt.jl index 0c7164b052..b7f963f38d 100644 --- a/src/solvers/LevenbergMarquardt.jl +++ b/src/solvers/LevenbergMarquardt.jl @@ -16,20 +16,20 @@ The second block of signatures perform the optimization in-place of `p`. # Input $(_var(:Argument, :M; type=true)) -* `f`: a cost function ``f: $(_math(:M))→ℝ^d``. +* `f`: a cost function ``f: $(_math(:M))→ℝ^m``. The cost function can be provided in two different ways - * as a single function returning a vector ``f(p) ∈ ℝ^d`` + * as a single function returning a vector ``f(p) ∈ ℝ^m`` * as a vector of functions, where each single function returns a scalar ``f_i(p) ∈ ℝ`` The type is determined by the `function_type=` keyword argument. * `jacobian_f`: the Jacobian of ``f``. The Jacobian can be provided in three different ways - * as a single function returning a vector of gradient vectors ``$(_tex(:grad)) f_i(p)`` - * as a vector of functions, where each single function returns a gradient vector ``$(_tex(:grad)) f_i(p)`` - * as a single function returning a (coefficient) matrix with respect to an [`AbstractBasis`](@extref `ManifoldsBase.AbstractBasis`) - of the tangent space at `p`. + * as a single function returning a vector of gradient vectors ``$(_tex(:bigl))($(_tex(:grad)) f_i(p)$(_tex(:bigr)))_{i=1}^m + * as a vector of functions, where each single function returns a gradient vector ``$(_tex(:grad)) f_i(p)``, , ``i=1,…m`` + * as a single function returning a (coefficient) matrix ``J ∈ ℝ^{m×d}``, where ``d`` is the dimension of the manifold. + These coefficients are given with respect to an [`AbstractBasis`](@extref `ManifoldsBase.AbstractBasis`) of the tangent space at `p`. The type is determined by the `jacobian_type=` keyword argument. $(_var(:Argument, :p)) -* `num_components`: length of the vector returned by the cost function (`d`). +* `num_components`: length ``m`` of the vector returned by the cost function. By default its value is -1 which means that it is determined automatically by calling `f` one additional time. This is only possible when `evaluation` is [`AllocatingEvaluation`](@ref), for mutating evaluation this value must be explicitly specified.