|
RcdMathLib_doc
Open Source Library for Linear and Non-linear Algebra
|
Vector computations. More...
#include <inttypes.h>#include <stdbool.h>Go to the source code of this file.
Macros | |
| #define | vector_t double |
| Define the data type of the vector elements. | |
Functions | |
| void | vector_clear (uint8_t size, vector_t arr[]) |
| Clear all the elements of the vector. More... | |
| void | vector_copy (uint8_t size, vector_t src_arr[], vector_t dest_arr[]) |
| Copy the elements of the source vector to the destination vector. More... | |
| vector_t | vector_get_norm2 (uint8_t length, vector_t arr[]) |
| Compute the 2-norm norm of a vector. More... | |
| vector_t | vector_get_square_norm2 (uint8_t length, vector_t arr[]) |
| Compute the squared 2-norm norm of a vector . More... | |
| vector_t | vector_get_sum (uint8_t length, vector_t arr[]) |
| Compute the sum of the elements of a vector. More... | |
| vector_t | vector_get_mean_value (uint8_t length, vector_t arr[]) |
| Compute the average or mean value of a vector. More... | |
| void | vector_sub (uint8_t size, vector_t a_vec[], vector_t b_vec[], vector_t a_minus_b[]) |
| Compute the subtraction of two vectors. More... | |
| void | vector_add (uint8_t size, vector_t a_vec[size], vector_t b_vec[size], vector_t a_plus_b_vec[size]) |
| Compute the addition of two vectors. More... | |
| void | vector_mul (uint8_t size, vector_t a_vec[size], vector_t b_vec[size], vector_t a_mul_b_vec[size]) |
| Compute the multiplication of two vectors. More... | |
| void | vector_square (uint8_t n, vector_t vec[n], vector_t square_vec[n]) |
| Compute the square of a vector. More... | |
| void | vector_in_place_scalar_mul (uint8_t size, vector_t a_vec[size], vector_t scl) |
| Compute the product of a vector with a real number. More... | |
| void | vector_scalar_mul (uint8_t size, vector_t src_vec[size], vector_t scl, vector_t dest_vec[]) |
| Compute the product of a vector with a real number. More... | |
| void | vector_scalar_div (uint8_t size, vector_t a_vec[size], vector_t scl) |
| Compute the division of a vector with a real number. More... | |
| vector_t | vector_get_euclidean_distance (uint8_t length, vector_t vec1[], vector_t vec2[]) |
| Compute the Euclidean distance between two vectors. More... | |
| vector_t | vector_get_scalar_product (uint8_t n, vector_t vec1[n], vector_t vec2[n]) |
| Compute the dot product of two vectors. More... | |
| bool | vector_is_equal (uint16_t length, vector_t vec_1[], vector_t vec_2[]) |
| Determine the equality of two vectors. More... | |
| bool | vector_uint32_is_equal (uint32_t length, uint32_t vec_1[], uint32_t vec_2[]) |
| Determine the equality of two vectors of type uint32_t. More... | |
| void | vector_get_index_vector (uint8_t k, uint8_t n, vector_t unsorted_vector[n], vector_t sorted_vector[n], uint8_t index_vector[n]) |
| Determine the index of the vector elements before sorting. More... | |
| vector_t | vector_get_max_and_index (uint8_t length, vector_t vec[], uint8_t *index) |
| Compute the maximal value and its index of a vector. More... | |
| vector_t | vector_get_residual (uint8_t length, vector_t a_vec[], vector_t b_vec[]) |
| Compute the residual of two vectors. More... | |
| void | vector_get_elements (vector_t src_vec[], uint8_t k, uint8_t index_vec[], vector_t dst_vec[]) |
| Get the elements of the vector by an index vector. More... | |
| void | vector_print (uint32_t length, vector_t arr[]) |
| Display the values of the vector's elements. More... | |
| void | vector_print_u8_array (uint32_t length, uint8_t arr[]) |
| Display the values of the vector's elements of type uint8_t. More... | |
| void | vector_flex_print (uint32_t length, vector_t arr[], uint8_t before_dot, uint8_t after_dot) |
| Display the values of the vector's elements. More... | |
Vector computations.
Vector computations include operations such as addition, subtraction, and inner product (dot product).
Definition in file vector.h.
| void vector_add | ( | uint8_t | size, |
| vector_t | a_vec[size], | ||
| vector_t | b_vec[size], | ||
| vector_t | a_plus_b_vec[size] | ||
| ) |
Compute the addition of two vectors.
Add b_vec to a_vec and return the result in a_plus_b.
| [in] | size | number of elements to subtract. |
| [in] | a_vec[] | pointer to the first vector. |
| [in] | b_vec[] | pointer to the second vector. |
| [out] | a_plus_b_vec[] | pointer to the destination vector. |
Definition at line 104 of file vector.c.
Referenced by damped_newton_raphson(), loc_levenberg_marquardt(), loc_levenberg_marquardt_correction(), opt_levenberg_marquardt(), opt_levenberg_marquardt_correction(), and vector_test().
| void vector_clear | ( | uint8_t | size, |
| vector_t | arr[] | ||
| ) |
Clear all the elements of the vector.
| [in] | size | size of the vector. |
| [in] | arr[] | pointer to the vector. |
Definition at line 32 of file vector.c.
References vector_t.
Referenced by dist_based_jacobian_get_JTf(), fsolve_test(), optimization_exponential_data_test(), optimization_sinusoidal_data_test(), optimization_test(), position_optimization_test(), and vector_test().
Copy the elements of the source vector to the destination vector.
| [in] | size | number of elements to copy. |
| [in] | src_arr[] | pointer to the source vector. |
| [in] | dest_arr[] | pointer to the destination vector. |
Definition at line 37 of file vector.c.
References vector_t.
Referenced by damped_newton_raphson(), loc_gauss_newton(), loc_levenberg_marquardt(), modified_gauss_newton(), multipath_algo_own_norm_distr_test(), newton_raphson(), opt_levenberg_marquardt(), recog_mitigate_multipath(), and vector_test().
| void vector_flex_print | ( | uint32_t | length, |
| vector_t | arr[], | ||
| uint8_t | before_dot, | ||
| uint8_t | after_dot | ||
| ) |
Display the values of the vector's elements.
This function allows the user to determine the precision as well as the with of the numbers to display.
| [in] | length | size of the vector to display. |
| [in] | arr | pointer to the vector. |
| [in] | before_dot | the number of digits to be printed before the decimal point. |
| [in] | after_dot | the number of digits to be printed after the decimal point. |
Definition at line 284 of file vector.c.
References utils_printf().
Referenced by distance_based_test(), fsolve_test(), magnetic_based_get_magnetic_field(), magnetic_based_test(), multipath_algo_own_norm_distr_test(), optimization_test(), position_optimization_test(), solve_big_matrix_test(), solve_test(), utils_test(), and vector_test().
Get the elements of the vector by an index vector.
| [in] | src_vec[] | pointer to source vector. |
| [in] | k | size of the index vector. |
| [in] | index_vec[] | pointer to the index vector. |
| [out] | dst_vec[] | pointer to the destination vector |
Definition at line 235 of file vector.c.
Referenced by multipath_algo_own_norm_distr_test().
Compute the Euclidean distance between two vectors.
| [in] | length | size of the vector. |
| [in] | vec1[] | pointer to the first vector. |
| [in] | vec2[] | pointer to the second vector. |
Definition at line 163 of file vector.c.
References vector_get_norm2(), vector_sub(), and vector_t.
Referenced by loc_gauss_newton(), modified_gauss_newton(), newton_raphson(), and vector_test().
| void vector_get_index_vector | ( | uint8_t | k, |
| uint8_t | n, | ||
| vector_t | unsorted_vector[n], | ||
| vector_t | sorted_vector[n], | ||
| uint8_t | index_vector[n] | ||
| ) |
Determine the index of the vector elements before sorting.
Determine the index of the elements of a sorted vector. These indices correspond to the positions of the elements in the unsorted vector.
| [in] | k | size of the unsorted vector. |
| [in] | n | size of the sorted vector. |
| [in] | unsorted_vector[] | pointer to the unsorted vector. |
| [in] | sorted_vector[] | pointer to the sorted vector. |
| [out] | index_vector[] | pointer to the index vector. |
Definition at line 214 of file vector.c.
Referenced by recog_mitigate_multipath().
Compute the average or mean value of a vector.
| [in] | length | size of the vector. |
| [in] | arr[] | pointer to the vector. |
Definition at line 78 of file vector.c.
References vector_t.
Referenced by vector_test().
Compute the 2-norm norm of a vector.
| [in] | length | size of the vector. |
| [in] | arr[] | pointer to the vector. |
Definition at line 42 of file vector.c.
References vector_t.
Referenced by damped_newton_raphson(), dist_based_get_distance_to_anchor(), get_damped_norm(), loc_gauss_newton(), loc_levenberg_marquardt(), magnetic_based_get_distances_to_anchors(), modified_gauss_newton(), opt_levenberg_marquardt(), recog_mitigate_multipath(), vector_get_euclidean_distance(), vector_get_residual(), and vector_test().
Compute the residual of two vectors.
| [in] | length | vector size. |
| [in] | a_vec[] | pointer to the first vector. |
| [in] | b_vec[] | pointer to the second vector. |
Definition at line 227 of file vector.c.
References vector_get_norm2(), vector_sub(), and vector_t.
Compute the dot product of two vectors.
| [in] | n | size of the vectors. |
| [in] | vec1[] | pointer to the first vector. |
| [in] | vec2[] | pointer to the second vector. |
Definition at line 190 of file vector.c.
References vector_t.
Referenced by loc_levenberg_marquardt_correction(), opt_levenberg_marquardt_correction(), and vector_test().
Compute the squared 2-norm norm of a vector .
| [in] | length | size of the vector. |
| [in] | arr[] | pointer to the vector. |
Definition at line 54 of file vector.c.
References vector_t.
Referenced by vector_test().
Compute the sum of the elements of a vector.
| [in] | length | size of the vector. |
| [in] | arr[] | pointer to the vector. |
Definition at line 66 of file vector.c.
References vector_t.
Referenced by vector_test().
Compute the product of a vector with a real number.
Multiple the elements of a vector with a scalar and return the result in the vector itself.
| [in] | size | number of elements to multiply with a scalar. |
| [in,out] | a_vec[] | pointer to the source/destination vector. |
| [in] | scl | a scalar. |
Definition at line 131 of file vector.c.
Referenced by get_delta_x().
Determine the equality of two vectors.
| [in] | length | size of the vector. |
| [in] | vec_1[] | pointer to the first vector. |
| [in] | vec_2[] | pointer to the second vector. |
Definition at line 202 of file vector.c.
Referenced by vector_test().
| void vector_mul | ( | uint8_t | size, |
| vector_t | a_vec[size], | ||
| vector_t | b_vec[size], | ||
| vector_t | a_mul_b_vec[size] | ||
| ) |
Compute the multiplication of two vectors.
Multiple vectors a_vec and b_vec element by element and return the result in a_mul_b.
| [in] | size | number of elements to multiply. |
| [in] | a_vec[] | pointer to the first vector. |
| [in] | b_vec[] | pointer to the second vector. |
| [out] | a_mul_b_vec[] | pointer to the destination vector. |
Definition at line 114 of file vector.c.
Referenced by vector_test().
| void vector_print | ( | uint32_t | length, |
| vector_t | arr[] | ||
| ) |
| void vector_print_u8_array | ( | uint32_t | length, |
| uint8_t | arr[] | ||
| ) |
Compute the division of a vector with a real number.
Divide the elements of a vector with a scalar and return the result in the vector itself.
| [in] | size | number of elements to divide with a scalar. |
| [in,out] | a_vec[] | pointer to the source/destination vector. |
| [in] | scl | a scalar. |
Compute the product of a vector with a real number.
Multiple the elements of a vector with a scalar and return the result in other vector.
| [in] | size | number of elements to multiply with a scalar. |
| [in] | src_vec[] | pointer to the source vector. |
| [in] | scl | a scalar. |
| [out] | dest_vec | pointer to the destination vector. |
Definition at line 141 of file vector.c.
Referenced by damped_newton_raphson().
Compute the square of a vector.
Square the elements of vector vec and return the result in square_vec.
| [in] | n | number of elements to square. |
| [in] | vec[] | pointer to the source vector. |
| [out] | square_vec[] | pointer to the destination vector. |
Definition at line 124 of file vector.c.
Referenced by recog_mitigate_multipath().
Compute the subtraction of two vectors.
Substact b_vec from a_vec and return the result in a_minus_b.
| [in] | size | number of elements to subtract. |
| [in] | a_vec[] | pointer to the first vector. |
| [in] | b_vec[] | pointer to the second vector. |
| [out] | a_minus_b[] | pointer to the destination vector. |
Definition at line 94 of file vector.c.
Referenced by dist_based_get_distance_to_anchor(), loc_gauss_newton(), magnetic_based_get_distances_to_anchors(), modified_gauss_newton(), newton_raphson(), recog_mitigate_multipath(), vector_get_euclidean_distance(), vector_get_residual(), and vector_test().
| bool vector_uint32_is_equal | ( | uint32_t | length, |
| uint32_t | vec_1[], | ||
| uint32_t | vec_2[] | ||
| ) |