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

Implement the damped Newton–Raphson algorithm. More...

#include <stdio.h>
#include "moore_penrose_pseudo_inverse.h"
#include "damped_newton_raphson.h"
#include "vector.h"
#include "matrix.h"

Go to the source code of this file.

Functions

uint8_t damped_newton_raphson (uint8_t f_length, uint8_t n, vector_t x0_arr[], double min_lamda, double eps, uint8_t max_it_num, vector_t est_x_arr[], void(*get_non_lin_sys)(vector_t x_arr[], vector_t f_vec[]), void(*get_jacobian)(vector_t x_arr[], matrix_t J[][n]))
 Implements the damped Newton–Raphson algorithm. More...
 
double get_damped_norm (uint8_t m, uint8_t n, vector_t x_arr[], void(*get_non_lin_sys)(vector_t x_arr[], vector_t f_vec[]), void(*get_jacobian)(vector_t x_arr[], matrix_t J[][n]))
 Compute the norm of the damped Newton–Raphson algorithm. More...
 
void get_delta_x (uint8_t m, uint8_t n, vector_t x_arr[], void(*get_non_lin_sys)(vector_t x_arr[], vector_t f_vec[]), void(*get_jacobian)(vector_t x_arr[], matrix_t J[][n]), vector_t delta_x_arr[])
 Compute the correction vector the damped Newton–Raphson algorithm. More...
 

Detailed Description

Implement the damped Newton–Raphson algorithm.

The damped Newton–Raphson algorithm enables to solve multi-variant nonlinear equation systems.

Author
Zakaria Kasmi zkasm.nosp@m.i@in.nosp@m.f.fu-.nosp@m.berl.nosp@m.in.de

Definition in file damped_newton_raphson.c.

Function Documentation

◆ damped_newton_raphson()

uint8_t damped_newton_raphson ( uint8_t  f_length,
uint8_t  n,
vector_t  x0_arr[],
double  min_lamda,
double  eps,
uint8_t  max_it_num,
vector_t  est_x_arr[],
void(*)(vector_t x_arr[], vector_t f_vec[])  get_non_lin_sys,
void(*)(vector_t x_arr[], matrix_t J[][n])  get_jacobian 
)

Implements the damped Newton–Raphson algorithm.

The user should provide pointers to non-linear equation systems 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_arr[]start vector.
[in]min_lamdaminimal damping factor.
[in]epsaccuracy bound.
[in]max_it_nummaximal iteration number of the damped Newton–Raphson algorithm.
[out]est_x_arr[]estimated (solution) vector.
[in](*get_non_lin_sys)pointer to non-linear equation systems.
[in](*get_jacobian)pointer to the Jacobian matrix.
Returns
required iteration number.

Definition at line 32 of file damped_newton_raphson.c.

References get_damped_norm(), get_delta_x(), vector_add(), vector_copy(), vector_get_norm2(), vector_scalar_mul(), and vector_t.

Referenced by fsolve().

◆ get_damped_norm()

double get_damped_norm ( uint8_t  m,
uint8_t  n,
vector_t  x_arr[],
void(*)(vector_t x_arr[], vector_t f_vec[])  get_non_lin_sys,
void(*)(vector_t x_arr[], matrix_t J[][n])  get_jacobian 
)

Compute the norm of the damped Newton–Raphson algorithm.

The user should provide pointers to non-linear equation systems and Jacobian functions.

Note
This function is generally implemented.
Parameters
[in]mnumber of the non-linear equations.
[in]nlength of the guess vector.
[in]x_arr[]guess vector.
[in](*get_non_lin_sys)pointer to non-linear equation systems.
[in](*get_jacobian)pointer to the Jacobian matrix.
Returns
norm of the damped Newton–Raphson algorithm.

Definition at line 104 of file damped_newton_raphson.c.

References get_delta_x(), vector_get_norm2(), and vector_t.

Referenced by damped_newton_raphson().

◆ get_delta_x()

void get_delta_x ( uint8_t  m,
uint8_t  n,
vector_t  x_arr[],
void(*)(vector_t x_arr[], vector_t f_vec[])  get_non_lin_sys,
void(*)(vector_t x_arr[], matrix_t J[][n])  get_jacobian,
vector_t  delta_x_arr[] 
)

Compute the correction vector the damped Newton–Raphson algorithm.

The user should provide pointers to non-linear equation systems and Jacobian functions.

Note
This function is generally implemented.
Parameters
[in]mnumber of the non-linear equations.
[in]nlength of the guess vector.
[in]x_arr[]guess vector.
[in](*get_non_lin_sys)pointer to non-linear equation systems.
[in](*get_jacobian)pointer to the Jacobian matrix.
[in,out]delta_x_arr[]the correction vector (term).

Definition at line 120 of file damped_newton_raphson.c.

References matrix_mul_vec(), matrix_t, moore_penrose_get_pinv(), vector_in_place_scalar_mul(), and vector_t.

Referenced by damped_newton_raphson(), and get_damped_norm().