RcdMathLib_doc
Open Source Library for Linear and Non-linear Algebra
levenberg_marquardt.c File Reference

Implement the Levenberg–Marquardt (LVM) algorithm. More...

#include <stdio.h>
#include <math.h>
#include <float.h>
#include <inttypes.h>
#include "levenberg_marquardt.h"
#include "matrix.h"
#include "vector.h"
#include "solve.h"
#include "utils.h"

Go to the source code of this file.

Functions

matrix_t opt_levenberg_marquardt_correction (uint8_t f_length, uint8_t n, matrix_t x_vec[n], matrix_t data_vec[f_length], matrix_t mu, matrix_t s[n], void(*get_f_error)(vector_t x_vec[], vector_t data_vec[], vector_t f_vec[]), void(*get_jacobian)(vector_t x_vec[], matrix_t J[][n]))
 Implements the correction-function of the Levenberg–Marquardt (LVM) algorithm. More...
 
uint8_t opt_levenberg_marquardt (uint8_t f_length, uint8_t n, vector_t x0_vec[n], vector_t data_vec[f_length], matrix_t eps, matrix_t tau, matrix_t beta0, matrix_t beta1, uint8_t max_iter_num, vector_t est_x_vec[n], void(*get_f_error)(vector_t x0_vec[], vector_t data_vec[], vector_t f_vec[]), void(*get_jacobian)(vector_t x0_vec[], matrix_t J[][n]))
 Implements the Levenberg–Marquardt (LVM) algorithm. More...
 
matrix_t opt_levenberg_marquardt_get_mu0 (uint8_t n, matrix_t tau, matrix_t JTJ[][n])
 Compute the initial value $ \mu_0 $ of the Levenberg–Marquardt (LVM) algorithm. More...
 

Detailed Description

Implement the Levenberg–Marquardt (LVM) algorithm.

Note
This function is generally implemented.
Author
Zakaria Kasmi zkasm.nosp@m.i@in.nosp@m.f.fu-.nosp@m.berl.nosp@m.in.de
Naouar Guerchali

Definition in file levenberg_marquardt.c.

Function Documentation

◆ opt_levenberg_marquardt()

uint8_t opt_levenberg_marquardt ( uint8_t  f_length,
uint8_t  n,
vector_t  x0_vec[n],
vector_t  data_vec[f_length],
matrix_t  eps,
matrix_t  tau,
matrix_t  beta0,
matrix_t  beta1,
uint8_t  max_iter_num,
vector_t  est_x_vec[n],
void(*)(vector_t x0_vec[], vector_t data_vec[], vector_t f_vec[])  get_f_error,
void(*)(vector_t x0_vec[], matrix_t J[][n])  get_jacobian 
)

Implements the Levenberg–Marquardt (LVM) algorithm.

The user should provide pointers to the error and Jacobian functions.

Note
This function is generally implemented.
Parameters
[in]f_lengthlength of the error functions vector.
[in]nlength of the start vector.
[in]x0_vec[]start vector.
[in]data_vec[]data vector.
[in]epsaccuracy bound.
[in]tau$ \tau $ factor.
[in]beta0$ \beta_0 $ factor.
[in]beta1$ \beta_1 $ factor.
[in]max_iter_nummaximal iteration number of the LVM algorithm.
[out]est_x_vec[]estimated (optimized) vector.
[in](*get_f_error)pointer to the error function.
[in](*get_jacobian)pointer to the Jacobian matrix.
Returns
required iteration number.

Definition at line 143 of file levenberg_marquardt.c.

References matrix_add_to_diag(), matrix_mul_scalar(), matrix_t, matrix_trans_mul_itself(), matrix_trans_mul_vec(), opt_levenberg_marquardt_correction(), opt_levenberg_marquardt_get_mu0(), solve_householder(), vector_add(), vector_copy(), vector_get_norm2(), and vector_t.

Referenced by optimization_exponential_data_test(), optimization_sinusoidal_data_test(), and optimization_test().

◆ opt_levenberg_marquardt_correction()

matrix_t opt_levenberg_marquardt_correction ( uint8_t  f_length,
uint8_t  n,
matrix_t  x_vec[n],
matrix_t  data_vec[f_length],
matrix_t  mu,
matrix_t  s[n],
void(*)(vector_t x_vec[], vector_t data_vec[], vector_t f_vec[])  get_f_error,
void(*)(vector_t x_vec[], matrix_t J[][n])  get_jacobian 
)

Implements the correction-function of the Levenberg–Marquardt (LVM) algorithm.

The user should provide pointers to the error and Jacobian functions.

Note
This function is generally implemented.
Parameters
[in]f_lengthlength of the error functions vector.
[in]nlength of the start vector.
[in]x_vec[]start vector.
[in]data_vec[]data vector.
[in]muregularization parameter $ \mu $.
[out]s[]correction vector.
[in](*get_f_error)pointer to the error function that calculates the matrix $ J_f^{T} J_{f} $.
[in](*get_jacobian)pointer to the Jacobian matrix.
Returns
the parameter $ \rho_{\mu} $

Definition at line 53 of file levenberg_marquardt.c.

References matrix_add_to_diag(), matrix_mul_scalar(), matrix_mul_vec(), matrix_t, matrix_trans_mul_itself(), matrix_trans_mul_vec(), solve_householder(), vector_add(), vector_get_scalar_product(), and vector_t.

Referenced by opt_levenberg_marquardt().

◆ opt_levenberg_marquardt_get_mu0()

matrix_t opt_levenberg_marquardt_get_mu0 ( uint8_t  n,
matrix_t  tau,
matrix_t  JTJ[][n] 
)

Compute the initial value $ \mu_0 $ of the Levenberg–Marquardt (LVM) algorithm.

The user should provide a pointer to the matrix $ J_f^{T} J_{f} $.

Parameters
[in]ncolumn number of the matrix $J_f^T J_f$.
[in]tau$ \tau $ factor.
[in]JTJ[][]pointer to the matrix $J_f^T J_f$.
Returns
parameter $ \rho_{\mu} $

Definition at line 227 of file levenberg_marquardt.c.

References matrix_t.

Referenced by opt_levenberg_marquardt().