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

Utilities for linear algebra. Utility-functions are needed by the linear algebra-module as well as other modules such as the position algorithm-module. More...

#include <math.h>
#include <stdarg.h>
#include <stdio.h>
#include "utils.h"
#include "shell_sort.h"

Go to the source code of this file.

Functions

double utils_to_radian (double deg_angle)
 Convert the angle from degrees to radians. More...
 
double utils_sind (double deg_angle)
 Compute the sine of a variable in degrees. More...
 
void utils_swap (uint8_t *a, uint8_t *b)
 Interchange the values of two variables of type uint8_t. More...
 
double utils_max (double a, double b)
 Returns the greater of two real numbers. More...
 
double utils_min (double a, double b)
 Returns the smaller of two real numbers. More...
 
uint8_t utils_u8_max (uint8_t a, uint8_t b)
 Returns the greater of two numbers from type uint8_t. More...
 
uint8_t utils_u8_min (uint8_t a, uint8_t b)
 Returns the smaller of two numbers from type uint8_t. More...
 
void utils_printf (char *format_str,...)
 Print by using variable format string as well as argument lists. More...
 
double utils_mean (uint8_t arr_size, vector_t in_arr[])
 Compute the mean value of a data set. More...
 
void utils_moving_average (uint8_t arr_size, vector_t in_arr[], uint8_t window_size, vector_t out_arr[])
 Compute the moving average of a data set. More...
 
double utils_get_median (vector_t arr[], uint8_t length)
 Compute the median of a finite array of numbers. More...
 
double utils_get_save_square_root (double x, double y)
 sqrt(a^2 + b^2) without under/overflow. More...
 

Detailed Description

Utilities for linear algebra. Utility-functions are needed by the linear algebra-module as well as other modules such as the position algorithm-module.

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

Definition in file utils.c.

Function Documentation

◆ utils_get_median()

double utils_get_median ( vector_t  arr[],
uint8_t  length 
)

Compute the median of a finite array of numbers.

Parameters
[in]arr[]pointer to the data set.
[in]lengthsize of the data set.
Returns
the median value of the data set.

Definition at line 152 of file utils.c.

References shell_sort().

Referenced by utils_test().

◆ utils_get_save_square_root()

double utils_get_save_square_root ( double  x,
double  y 
)

sqrt(a^2 + b^2) without under/overflow.

Compute the square root without under/overflow.

Definition at line 168 of file utils.c.

Referenced by qr_householder_decomp().

◆ utils_max()

double utils_max ( double  a,
double  b 
)

Returns the greater of two real numbers.

Parameters
[in]athe first value to compare.
[in]bthe second value to compare.
Returns
the greater of a and b.

Definition at line 55 of file utils.c.

Referenced by loc_gauss_newton(), modified_gauss_newton(), and utils_test().

◆ utils_mean()

double utils_mean ( uint8_t  arr_size,
vector_t  in_arr[] 
)

Compute the mean value of a data set.

Parameters
[in]arr_sizesize of the data set.
[in]in_arr[]pointer to the data set.
Returns
the mean value of the data set.

Definition at line 105 of file utils.c.

Referenced by utils_test().

◆ utils_min()

double utils_min ( double  a,
double  b 
)

Returns the smaller of two real numbers.

Parameters
[in]athe first value to compare.
[in]bthe second value to compare.
Returns
the smaller of a and b.

Definition at line 65 of file utils.c.

Referenced by utils_test().

◆ utils_moving_average()

void utils_moving_average ( uint8_t  arr_size,
vector_t  in_arr[],
uint8_t  window_size,
vector_t  out_arr[] 
)

Compute the moving average of a data set.

Parameters
[in]arr_sizesize of the data set.
[in]in_arr[]pointer to the data set.
[in]window_sizewindow size.
[out]out_arrpointer to the values of the moving average.

Definition at line 121 of file utils.c.

Referenced by utils_test().

◆ utils_printf()

void utils_printf ( char *  format_str,
  ... 
)

Print by using variable format string as well as argument lists.

This function enables to print data by using a variable format string as well as argument list. Furthermore, it avoids the error: "format not a string literal", if printf is used.

Parameters
[in]*format_strformat string.
[in]...argument list.

Definition at line 96 of file utils.c.

Referenced by matrix_flex_part_print(), matrix_flex_print(), and vector_flex_print().

◆ utils_sind()

double utils_sind ( double  deg_angle)

Compute the sine of a variable in degrees.

Calculate the sine of the variable deg_angle, which is expressed in degrees.

Parameters
[in]deg_angleangle in degrees.
Returns
sine value.

Definition at line 39 of file utils.c.

References M_PI.

Referenced by utils_test().

◆ utils_swap()

void utils_swap ( uint8_t *  a,
uint8_t *  b 
)

Interchange the values of two variables of type uint8_t.

Parameters
[in]*apointer to first variable.
[in]*bpointer to second variable.

Definition at line 46 of file utils.c.

Referenced by utils_test().

◆ utils_to_radian()

double utils_to_radian ( double  deg_angle)

Convert the angle from degrees to radians.

Parameters
[in]deg_angleangle in degrees.
Returns
angle in radians.

Definition at line 31 of file utils.c.

References M_PI.

Referenced by magnetic_based_test(), and utils_test().

◆ utils_u8_max()

uint8_t utils_u8_max ( uint8_t  a,
uint8_t  b 
)

Returns the greater of two numbers from type uint8_t.

Parameters
[in]athe first value to compare.
[in]bthe second value to compare.
Returns
the greater of a and b.

Definition at line 75 of file utils.c.

◆ utils_u8_min()

uint8_t utils_u8_min ( uint8_t  a,
uint8_t  b 
)

Returns the smaller of two numbers from type uint8_t.

Parameters
[in]athe first value to compare.
[in]bthe second value to compare.
Returns
the smaller of a and b.

Definition at line 85 of file utils.c.