RcdMathLib_doc
Open Source Library for Linear and Non-linear Algebra
utils.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2020 Zakaria Kasmi <zkasmi@inf.fu-berlin.de>
3  * 2020 Freie Universität Berlin
4  *
5  * This file is subject to the terms and conditions of the GNU Lesser General
6  * Public License v2.1. See the file LICENSE in the top level directory for more
7  * details.
8  */
9 
24 #ifndef UTILS_H_
25 #define UTILS_H_
26 
27 #include <inttypes.h>
28 #include "vector.h"
29 
31 #ifndef M_PI
32 #define M_PI 3.14159265358979323846
33 #endif
34 
43 double utils_to_radian(double deg_angle);
44 
55 double utils_sind(double deg_angle);
56 
64 void utils_swap(uint8_t *a, uint8_t *b);
65 
75 double utils_max(double a, double b);
76 
87 double utils_min(double a, double b);
88 
98 uint8_t utils_u8_max(uint8_t a, uint8_t b);
99 
109 uint8_t utils_u8_min(uint8_t a, uint8_t b);
110 
111 // Enables to use variable format string as well as argument lists
112 // Fixing error: format not a string literal.
113 
124 void utils_printf(char *format_str, ...);
125 
135 double utils_mean(uint8_t arr_size, vector_t in_arr[]);
136 
146 void utils_moving_average(uint8_t arr_size, vector_t in_arr[],
147  uint8_t window_size,
148  vector_t out_arr[]);
149 
159 double utils_get_median(vector_t arr[], uint8_t length);
160 
170 double utils_get_save_square_root(double x, double y);
171 
172 #endif /* UTILS_H_ */
utils_to_radian
double utils_to_radian(double deg_angle)
Convert the angle from degrees to radians.
Definition: utils.c:31
utils_u8_min
uint8_t utils_u8_min(uint8_t a, uint8_t b)
Returns the smaller of two numbers from type uint8_t.
Definition: utils.c:85
vector_t
#define vector_t
Define the data type of the vector elements.
Definition: vector.h:33
utils_min
double utils_min(double a, double b)
Returns the smaller of two real numbers.
Definition: utils.c:65
utils_u8_max
uint8_t utils_u8_max(uint8_t a, uint8_t b)
Returns the greater of two numbers from type uint8_t.
Definition: utils.c:75
utils_max
double utils_max(double a, double b)
Returns the greater of two real numbers.
Definition: utils.c:55
utils_printf
void utils_printf(char *format_str,...)
Print by using variable format string as well as argument lists.
Definition: utils.c:96
utils_sind
double utils_sind(double deg_angle)
Compute the sine of a variable in degrees.
Definition: utils.c:39
utils_mean
double utils_mean(uint8_t arr_size, vector_t in_arr[])
Compute the mean value of a data set.
Definition: utils.c:105
utils_get_median
double utils_get_median(vector_t arr[], uint8_t length)
Compute the median of a finite array of numbers.
Definition: utils.c:152
vector.h
Vector computations.
utils_swap
void utils_swap(uint8_t *a, uint8_t *b)
Interchange the values of two variables of type uint8_t.
Definition: utils.c:46
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.
Definition: utils.c:121
utils_get_save_square_root
double utils_get_save_square_root(double x, double y)
Compute the square root without under/overflow.
Definition: utils.c:168