|
RcdMathLib_doc
Open Source Library for Linear and Non-linear Algebra
|
Matrix computations. More...
#include <inttypes.h>#include <stdbool.h>Go to the source code of this file.
Data Structures | |
| struct | matrix_dim_t |
| A structure to define the row and column number of a matrix. More... | |
Macros | |
| #define | matrix_t double |
| Define the data type of the matrix elements. More... | |
| #define | MACHEPS 2E-16 |
| #define | M_PI 3.14159265358979323846 |
Functions | |
| void | matrix_init (uint8_t m, uint8_t n, matrix_t matrix[m][n], matrix_t value) |
| Initialize all the elements of the matrix with a specified value. More... | |
| void | matrix_clear (uint8_t m, uint8_t n, matrix_t matrix[m][n]) |
| Clear all the elements of the vector. More... | |
| void | matrix_transpose (uint8_t m, uint8_t n, matrix_t src_matrix[m][n], matrix_t dest_matrix[n][m]) |
| Computes the transpose of a matrix. More... | |
| void | matrix_in_place_transpose (uint8_t m, matrix_t matrix[][m]) |
| Computes the in-place transpose of a matrix. More... | |
| void | matrix_copy (uint8_t m, uint8_t n, matrix_t src_matrix[m][n], matrix_t dest_matrix[m][n]) |
| Copy the elements of a matrix to another matrix. More... | |
| void | matrix_part_copy (uint8_t m, uint8_t n, matrix_t src_matrix[m][n], uint8_t start_row_ind, uint8_t end_row_ind, uint8_t start_col_ind, uint8_t end_col_ind, uint8_t dest_row_num, uint8_t dest_col_num, matrix_t dest_matrix[][dest_col_num]) |
| Copy a part of a matrix to another matrix or sub-matrix. More... | |
| uint8_t | matrix_get_rank (uint8_t m, uint8_t n, matrix_t singl_values_arr[], uint8_t length) |
| Compute the rank of a matrix. More... | |
| void | matrix_add (uint8_t m, uint8_t n, matrix_t A[m][n], matrix_t B[m][n], matrix_t A_plus_B[m][n]) |
| Compute the addition of two matrices. More... | |
| void | matrix_add_to_diag (uint8_t n, matrix_t A[][n], uint8_t diag_el_num, matrix_t value) |
| Add a number to diagonal elements of a matrix. More... | |
| void | matrix_sub (uint8_t m, uint8_t n, matrix_t A[m][n], matrix_t B[m][n], matrix_t A_minus_B[m][n]) |
| Compute the subtraction of two matrices. More... | |
| void | matrix_mul (uint8_t a_line_num, uint8_t a_col_num, matrix_t a_matrix[a_line_num][a_col_num], uint8_t b_line_num, uint8_t b_col_num, matrix_t b_matrix[b_line_num][b_col_num], matrix_t dest_matrix[a_line_num][b_col_num]) |
| Compute the multiplication of two matrices. More... | |
| void | matrix_part_mul (uint8_t a_col_num_max, matrix_t a_matrix[][a_col_num_max], uint8_t b_col_num_max, matrix_t b_matrix[][b_col_num_max], uint8_t a_start_row_ind, uint8_t a_end_row_ind, uint8_t a_start_col_ind, uint8_t a_end_col_ind, uint8_t b_start_row_ind, uint8_t b_end_row_ind, uint8_t b_start_col_ind, uint8_t b_end_col_ind, uint8_t dest_col_size, matrix_t dest_matrix[][dest_col_size]) |
| Compute the partial multiplication of two matrices. More... | |
| void | matrix_mul_vec (uint8_t m, uint8_t n, matrix_t matrix[m][n], matrix_t vec[n], matrix_t dst_arr[m]) |
| Compute the multiplication of a matrix with a column vector. More... | |
| void | matrix_trans_mul_vec (uint8_t m, uint8_t n, matrix_t A[m][n], uint8_t b_size, matrix_t b_vec[m], matrix_t c_vec[n]) |
| Compute the multiplication of transposed matrix with column vector. More... | |
| void | matrix_mul_col_vec_row_vec (uint8_t m, matrix_t col_vec[m], uint8_t n, matrix_t row_vec[n], uint8_t max_n, matrix_t res_mat[][max_n]) |
| Compute the multiplication of a column and row vector. More... | |
| void | matrix_vec_mul_matr (uint8_t m, uint8_t n, matrix_t vec[m], matrix_t matrix[m][n], matrix_t dst_arr[n]) |
| Compute the multiplication of row vector and a matrix. More... | |
| void | matrix_mul_scalar_vec_matr (uint8_t m, uint8_t n, matrix_t scalar, matrix_t vec[m], matrix_t matrix[m][n], matrix_t dst_arr[n]) |
| Compute the multiplication of a scalar with row vector and a matrix. More... | |
| void | matrix_trans_mul_itself (uint8_t m, uint8_t n, matrix_t A[m][n], matrix_t AT_mul_A[n][n]) |
| Compute the multiplication of the transpose of a matrix with itself. More... | |
| void | matrix_set_diag_elements (uint8_t m, uint8_t n, matrix_t value, matrix_t diag_matrix[m][n]) |
| Set all the diagonal elements of a matrix with a specified value. More... | |
| void | matrix_get_diag_mat_new (uint8_t m, uint8_t n, matrix_t diag_matrix[m][n], uint8_t length, matrix_t vec[]) |
| Set all the diagonal elements of a matrix with values that are saved in a vector. More... | |
| void | matrix_get_diag_mat (uint8_t m, uint8_t n, matrix_t value, matrix_t diag_matrix[m][n]) |
| Create a diagonal matrix with a specified value. More... | |
| void | matrix_mul_scalar (uint8_t m, uint8_t n, matrix_t mat_src[m][n], matrix_t value, matrix_t mat_dest[m][n]) |
| Multiply all elements of a matrix with a specified value. More... | |
| void | matrix_get_column_vec (uint8_t m, uint8_t n, matrix_t matrix[m][n], uint8_t col_num, matrix_t col_vec[m]) |
| Get a column of a matrix. More... | |
| void | matrix_get_part_column_vec (uint8_t max_m, uint8_t max_n, matrix_t matrix[max_m][max_n], uint8_t col_num, uint8_t offset, matrix_t col_vec[max_m - offset]) |
| Get a part of a column of a matrix. More... | |
| matrix_t | matrix_get_max_elem_in_column (uint8_t m, uint8_t n, matrix_t matrix[m][n], uint8_t col_num) |
| Get the largest element of a column vector in a matrix. More... | |
| matrix_t | matrix_get_abs_max_elem_in_column (uint8_t m, uint8_t n, matrix_t matrix[m][n], uint8_t col_num) |
| Get the maximum absolute value of a column vector in a matrix. More... | |
| matrix_t | matrix_get_max_elem_in_part_column (uint8_t max_m, uint8_t max_n, matrix_t matrix[max_m][max_n], uint8_t row_num, uint8_t col_num) |
| Get the largest element of a column vector in a sub-matrix. More... | |
| matrix_t | matrix_get_abs_max_elem_in_part_column (uint8_t max_m, uint8_t max_n, matrix_t matrix[max_m][max_n], uint8_t row_num, uint8_t col_num) |
| Get the maximum absolute value of a column vector in a sub-matrix. More... | |
| matrix_t | matrix_get_abs_max_elem_and_index_in_part_column (uint8_t max_m, uint8_t max_n, matrix_t matrix[max_m][max_n], uint8_t row_num, uint8_t col_num, uint8_t *index) |
| Get the maximum absolute value and its position in a column vector in a sub-matrix. More... | |
| void | matrix_swap_rows (uint8_t n, matrix_t matrix[][n], uint8_t i, uint8_t j) |
| Swaps two rows of a matrix. More... | |
| void | matrix_part_swap_rows (uint8_t n, matrix_t matrix[][n], uint8_t i, uint8_t j, uint8_t col_begin, uint8_t col_end) |
| Swaps two rows of a sub-matrix. More... | |
| double | matrix_get_two_norm (uint8_t m, uint8_t n, matrix_t A[][n]) |
| Get the 2-norm of a matrix that is equal to the largest singular value. More... | |
| double | matrix_get_frob_norm (uint8_t m, uint8_t n, matrix_t A[][n]) |
| Get the Frobenius norm of a matrix. More... | |
| void | matrix_get_inv_upp_triang (uint8_t m, uint8_t n, matrix_t U[][n], matrix_t inv_U[][m]) |
| Computes the inverse an upper triangular matrix. More... | |
| void | matrix_get_inv_low_triang (uint8_t m, uint8_t n, matrix_t L[][n], matrix_t inv_L[][m]) |
| Computes the inverse a lower triangular matrix. More... | |
| void | matrix_get_upp_triang (uint8_t m, uint8_t n, matrix_t A[][n], matrix_t tr_up_A[][n]) |
| Gets the upper triangular part of a matrix. More... | |
| void | matrix_get_low_triang (uint8_t m, uint8_t n, matrix_t A[][n], matrix_t tr_low_A[][n]) |
| Gets the lower triangular part of a matrix. More... | |
| void | matrix_print (uint8_t m, uint8_t n, matrix_t matrix[m][n]) |
| Display the values of the matrix elements. More... | |
| void | matrix_part_print (uint8_t m, uint8_t n, matrix_t matrix[m][n], uint8_t start_row_ind, uint8_t end_row_ind, uint8_t start_col_ind, uint8_t end_col_ind) |
| Display the values of the sub-matrix elements. More... | |
| void | matrix_flex_print (uint8_t m, uint8_t n, matrix_t matrix[m][n], uint8_t before_dec, uint8_t after_dec) |
| Display the values of the matrix elements. More... | |
| void | matrix_flex_part_print (uint8_t m, uint8_t n, matrix_t matrix[m][n], uint8_t start_row_ind, uint8_t end_row_ind, uint8_t start_col_ind, uint8_t end_col_ind, uint8_t before_dot, uint8_t after_dot) |
| Display the values of the sub-matrix elements. More... | |
| void | matrix_part_mul_scalar_vec_matr (uint8_t max_m, uint8_t max_n, matrix_t scalar, matrix_t vec[max_m], matrix_t matrix[max_m][max_n], uint8_t begin_row, uint8_t begin_column, matrix_t dst_arr[max_n - begin_row]) |
| Compute the multiplication of a scalar with row vector and a sub-matrix. More... | |
| matrix_t | matrix_read (uint8_t m, uint8_t n, matrix_t matrix[m][n], uint8_t i, uint8_t j) |
| Get the value of a matrix at the position (i,j). More... | |
| void | matrix_write (uint8_t m, uint8_t n, matrix_t matrix[m][n], uint8_t i, uint8_t j, matrix_t val) |
| Write a value in a matrix at the position (i,j). More... | |
Matrix computations.
Matrix computations include operations such as addition, subtraction, and transposition.
Definition in file matrix.h.
| #define M_PI 3.14159265358979323846 |
| #define MACHEPS 2E-16 |
| #define matrix_t double |
| void matrix_add | ( | uint8_t | m, |
| uint8_t | n, | ||
| matrix_t | A[m][n], | ||
| matrix_t | B[m][n], | ||
| matrix_t | A_plus_B[m][n] | ||
| ) |
Compute the addition of two matrices.
Add matrix B to matrix A and return the result in A_plus_B matrix.
| [in] | m | row number of the matrix to add. |
| [in] | n | column number of the matrix to add. |
| [in] | A[][] | pointer to the first matrix. |
| [in] | B[][] | pointer to the second matrix. |
| [out] | A_plus_B[][] | pointer to the destination matrix. |
Definition at line 341 of file matrix.c.
Referenced by matrix_test().
Add a number to diagonal elements of a matrix.
| [in] | n | column number of the matrix. |
| [in,out] | A[][] | pointer to the matrix. |
| [in] | diag_el_num | number of diagonal elements to overwrite. |
| [in] | value | the value to add to the diagonal elements. |
Definition at line 353 of file matrix.c.
Referenced by opt_levenberg_marquardt(), and opt_levenberg_marquardt_correction().
| void matrix_clear | ( | uint8_t | m, |
| uint8_t | n, | ||
| matrix_t | matrix[m][n] | ||
| ) |
Clear all the elements of the vector.
| [in] | m | row number of the matrix. |
| [in] | n | column number of the matrix. |
| [out] | matrix[][] | pointer to the matrix. |
Definition at line 46 of file matrix.c.
Referenced by dist_based_jacobian_get_JTJ(), householder_test(), matrix_get_diag_mat(), matrix_get_diag_mat_new(), matrix_get_inv_low_triang(), matrix_get_inv_upp_triang(), and qr_givens_decomp().
Copy the elements of a matrix to another matrix.
| [in] | m | row number of the matrix to copy. |
| [in] | n | column number of the matrix to copy. |
| [in] | src_matrix[][] | pointer to the source matrix |
| [out] | dest_matrix[][] | pointer to the destination matrix. |
Definition at line 83 of file matrix.c.
References matrix_t.
Referenced by givens_test(), householder_test(), matrix_get_two_norm(), solve_big_matrix_test(), solve_test(), and triangular_matrices_test().
| void matrix_flex_part_print | ( | uint8_t | m, |
| uint8_t | n, | ||
| matrix_t | matrix[m][n], | ||
| uint8_t | start_row_ind, | ||
| uint8_t | end_row_ind, | ||
| uint8_t | start_col_ind, | ||
| uint8_t | end_col_ind, | ||
| uint8_t | before_dot, | ||
| uint8_t | after_dot | ||
| ) |
Display the values of the sub-matrix elements.
This function allows the user to determine the precision as well as the with of the numbers to display.
| [in] | m | total row number of the matrix. |
| [in] | n | total column number of the matrix. |
| [in] | matrix[][] | pointer to the entire matrix. |
| [in] | start_row_ind | start row number of the sub-matrix. |
| [in] | end_row_ind | end row number of the sub-matrix. |
| [in] | start_col_ind | start column number of the sub-matrix. |
| [in] | end_col_ind | end column number of the sub-matrix. |
| [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 247 of file matrix.c.
References utils_printf().
Referenced by matrix_test().
| void matrix_flex_print | ( | uint8_t | m, |
| uint8_t | n, | ||
| matrix_t | matrix[m][n], | ||
| uint8_t | before_dec, | ||
| uint8_t | after_dec | ||
| ) |
Display the values of the matrix elements.
This function allows the user to determine the precision as well as the with of the numbers to display.
| [in] | m | row number of the matrix. |
| [in] | n | column number of the matrix. |
| [in] | matrix[][] | pointer to the entire matrix. |
| [in] | before_dec | the number of digits to be printed before the decimal point. |
| [in] | after_dec | the number of digits to be printed after the decimal point. |
Definition at line 220 of file matrix.c.
References utils_printf().
Referenced by givens_test(), householder_test(), inv_triangular_matrices_test(), lu_decomp_test(), matrix_test(), moore_penrose_pinv_compute_print(), optimization_test(), pos_algos_common_test(), solve_big_matrix_test(), solve_test(), and triangular_matrices_test().
| matrix_t matrix_get_abs_max_elem_and_index_in_part_column | ( | uint8_t | max_m, |
| uint8_t | max_n, | ||
| matrix_t | matrix[max_m][max_n], | ||
| uint8_t | row_num, | ||
| uint8_t | col_num, | ||
| uint8_t * | index | ||
| ) |
Get the maximum absolute value and its position in a column vector in a sub-matrix.
| [in] | max_m | total row number of the matrix. |
| [in] | max_n | total column number of the matrix. |
| [in] | matrix[][] | pointer to the entire matrix. |
| [in] | row_num | row number of the sub-matrix. |
| [in] | col_num | column number of the sub-matrix. |
| [out] | index | pointer to the variable holding the position of the maximum absolute value in the column vector of the sub-matrix. |
Definition at line 703 of file matrix.c.
References matrix_t.
Referenced by lu_decomp().
| matrix_t matrix_get_abs_max_elem_in_column | ( | uint8_t | m, |
| uint8_t | n, | ||
| matrix_t | matrix[m][n], | ||
| uint8_t | col_num | ||
| ) |
Get the maximum absolute value of a column vector in a matrix.
| [in] | m | row number of the matrix. |
| [in] | n | column number of the matrix. |
| [in] | matrix[][] | pointer to the matrix. |
| [in] | col_num | column number. |
Definition at line 651 of file matrix.c.
References matrix_t.
| matrix_t matrix_get_abs_max_elem_in_part_column | ( | uint8_t | max_m, |
| uint8_t | max_n, | ||
| matrix_t | matrix[max_m][max_n], | ||
| uint8_t | row_num, | ||
| uint8_t | col_num | ||
| ) |
Get the maximum absolute value of a column vector in a sub-matrix.
| [in] | max_m | total row number of the matrix. |
| [in] | max_n | total column number of the matrix. |
| [in] | matrix[][] | pointer to the entire matrix. |
| [in] | row_num | row number of the sub-matrix. |
| [in] | col_num | column number of the sub-matrix. |
Definition at line 685 of file matrix.c.
References matrix_t.
| void matrix_get_column_vec | ( | uint8_t | m, |
| uint8_t | n, | ||
| matrix_t | matrix[m][n], | ||
| uint8_t | col_num, | ||
| matrix_t | col_vec[m] | ||
| ) |
Get a column of a matrix.
| [in] | m | row number of the matrix. |
| [in] | n | column number of the matrix. |
| [in] | matrix[][] | pointer to the matrix. |
| [in] | col_num | number of the requested column. |
| [out] | col_vec[] | pointer to the column vector. |
Definition at line 612 of file matrix.c.
Referenced by matrix_trans_mul_itself().
Create a diagonal matrix with a specified value.
| [in] | m | row number of the matrix. |
| [in] | n | column number of the matrix. |
| [in] | value | value of the diagonal elements. |
| [in,out] | diag_matrix[][] | pointer to the diagonal matrix. |
Definition at line 594 of file matrix.c.
References matrix_clear(), and matrix_set_diag_elements().
Referenced by lu_decomp(), and matrix_test().
| void matrix_get_diag_mat_new | ( | uint8_t | m, |
| uint8_t | n, | ||
| matrix_t | diag_matrix[m][n], | ||
| uint8_t | length, | ||
| matrix_t | vec[] | ||
| ) |
Set all the diagonal elements of a matrix with values that are saved in a vector.
| [in] | m | row number of the matrix. |
| [in] | n | column number of the matrix. |
| [in,out] | diag_matrix[][] | pointer to the matrix. |
| [in] | length | size of the vector. |
| [in] | vec | pointer to the vector containing diagonal elements. |
Definition at line 581 of file matrix.c.
References matrix_clear().
Referenced by matrix_test().
| double matrix_get_frob_norm | ( | uint8_t | m, |
| uint8_t | n, | ||
| matrix_t | A[][n] | ||
| ) |
Get the Frobenius norm of a matrix.
| [in] | m | row number of the matrix. |
| [in] | n | column number of the matrix. |
| [in] | A[][] | pointer to the matrix. |
Definition at line 782 of file matrix.c.
Referenced by matrix_test().
Computes the inverse a lower triangular matrix.
| [in] | m | row number of the matrix. |
| [in] | n | column number of the matrix. |
| [in] | L[][] | pointer to the matrix. |
| [out] | inv_L[][] | pointer to the inverse matrix. |
Definition at line 817 of file matrix.c.
References matrix_clear(), and matrix_t.
Referenced by inv_triangular_matrices_test(), and solve_lu_decomp().
Computes the inverse an upper triangular matrix.
| [in] | m | row number of the matrix. |
| [in] | n | column number of the matrix. |
| [in] | U[][] | pointer to the upper triangular matrix. |
| [out] | inv_U[][] | pointer to the inverse matrix. |
Definition at line 795 of file matrix.c.
References matrix_clear(), and matrix_t.
Referenced by inv_triangular_matrices_test().
Gets the lower triangular part of a matrix.
| [in] | m | row number of the matrix. |
| [in] | n | column number of the matrix. |
| [in] | A[][] | pointer to the matrix. |
| [out] | tr_low_A[][] | pointer to the lower triangular part of the matrix. |
Definition at line 868 of file matrix.c.
Referenced by triangular_matrices_test().
| matrix_t matrix_get_max_elem_in_part_column | ( | uint8_t | max_m, |
| uint8_t | max_n, | ||
| matrix_t | matrix[max_m][max_n], | ||
| uint8_t | row_num, | ||
| uint8_t | col_num | ||
| ) |
Get the largest element of a column vector in a sub-matrix.
| [in] | max_m | total row number of the matrix. |
| [in] | max_n | total column number of the matrix. |
| [in] | matrix[][] | pointer to the entire matrix. |
| [in] | row_num | row number of the sub-matrix. |
| [in] | col_num | column number of the sub-matrix. |
Definition at line 668 of file matrix.c.
References matrix_t.
| void matrix_get_part_column_vec | ( | uint8_t | max_m, |
| uint8_t | max_n, | ||
| matrix_t | matrix[max_m][max_n], | ||
| uint8_t | col_num, | ||
| uint8_t | offset, | ||
| matrix_t | col_vec[max_m - offset] | ||
| ) |
Get a part of a column of a matrix.
| [in] | max_m | row number of the matrix. |
| [in] | max_n | column number of the matrix. |
| [in] | matrix[][] | pointer to the matrix. |
| [in] | col_num | number of the requested column. |
| [in] | offset | points to the start position of the column vector. |
| [out] | col_vec[] | pointer to the column vector. |
| uint8_t matrix_get_rank | ( | uint8_t | m, |
| uint8_t | n, | ||
| matrix_t | singl_values_arr[], | ||
| uint8_t | length | ||
| ) |
Compute the rank of a matrix.
The SVD must be previously invoked to get the singular values of the matrix.
| [in] | m | row number of the source matrix. |
| [in] | n | column number of the source matrix. |
| [in] | singl_values_arr[] | array containing the singular values of the matrix. |
| [in] | length | length of the singular values array. |
Definition at line 312 of file matrix.c.
Referenced by trilateration_get_rank_and_homogeneous_solution().
| double matrix_get_two_norm | ( | uint8_t | m, |
| uint8_t | n, | ||
| matrix_t | A[][n] | ||
| ) |
Get the 2-norm of a matrix that is equal to the largest singular value.
| [in] | m | row number of the matrix. |
| [in] | n | column number of the matrix. |
| [in] | A[][] | pointer to the matrix. |
Definition at line 752 of file matrix.c.
References matrix_dim_t::col_num, matrix_copy(), matrix_print(), matrix_t, matrix_dim_t::row_num, svd(), svd_get_single_values_num(), and svd_get_U_dim().
Referenced by matrix_test().
Gets the upper triangular part of a matrix.
| [in] | m | row number of the matrix. |
| [in] | n | column number of the matrix. |
| [in] | A[][] | pointer to the matrix. |
| [out] | tr_up_A[][] | pointer to the upper triangular part of the matrix. |
Definition at line 841 of file matrix.c.
Referenced by qr_givens_decomp(), and triangular_matrices_test().
| void matrix_in_place_transpose | ( | uint8_t | m, |
| matrix_t | matrix[][m] | ||
| ) |
Computes the in-place transpose of a matrix.
Transpose the matrix without auxiliary memory.
| [in] | m | row and column number of the matrix. |
| [in,out] | matrix[][] | pointer to the matrix to transpose. |
Definition at line 69 of file matrix.c.
References matrix_t.
| void matrix_mul | ( | uint8_t | a_line_num, |
| uint8_t | a_col_num, | ||
| matrix_t | a_matrix[a_line_num][a_col_num], | ||
| uint8_t | b_line_num, | ||
| uint8_t | b_col_num, | ||
| matrix_t | b_matrix[b_line_num][b_col_num], | ||
| matrix_t | dest_matrix[a_line_num][b_col_num] | ||
| ) |
Compute the multiplication of two matrices.
| [in] | a_line_num | row number of the first matrix. |
| [in] | a_col_num | column number of the first matrix. |
| [in] | a_matrix[][] | pointer to the first matrix. |
| [in] | b_line_num | row number of the second matrix. |
| [in] | b_col_num | column number of the second matrix. |
| [in] | b_matrix[][] | pointer to the second matrix. |
| [out] | dest_matrix[][] | pointer to the destination matrix. |
Definition at line 363 of file matrix.c.
Referenced by get_PDOP(), matrix_test(), and solve_lu_decomp().
| void matrix_mul_col_vec_row_vec | ( | uint8_t | m, |
| matrix_t | col_vec[m], | ||
| uint8_t | n, | ||
| matrix_t | row_vec[n], | ||
| uint8_t | max_n, | ||
| matrix_t | res_mat[][max_n] | ||
| ) |
Compute the multiplication of a column and row vector.
Return Cm,1 * R1,n = Mm,n, where C is a m-dimensional column vector, R is a n-dimensional row vector, and the result is a (mxn)-matrix.
| [in] | m | row number of the column vector. |
| [in] | col_vec[] | pointer to the column vector. |
| [in] | n | column number of the row vector. |
| [in] | row_vec[] | pointer to the row vector. |
| [in] | max_n | column number of the result matrix. |
| [out] | res_mat[][] | pointer to the (mxn) result matrix. |
| void matrix_mul_scalar | ( | uint8_t | m, |
| uint8_t | n, | ||
| matrix_t | mat_src[m][n], | ||
| matrix_t | value, | ||
| matrix_t | mat_dest[m][n] | ||
| ) |
Multiply all elements of a matrix with a specified value.
| [in] | m | row number of the matrix. |
| [in] | n | column number of the matrix. |
| [in] | mat_src | pointer to the source matrix. |
| [in] | value | multiplication factor. |
| [out] | mat_dest[][] | pointer to the destination matrix. |
Definition at line 602 of file matrix.c.
Referenced by loc_levenberg_marquardt(), loc_levenberg_marquardt_correction(), opt_levenberg_marquardt(), and opt_levenberg_marquardt_correction().
| void matrix_mul_scalar_vec_matr | ( | uint8_t | m, |
| uint8_t | n, | ||
| matrix_t | scalar, | ||
| matrix_t | vec[m], | ||
| matrix_t | matrix[m][n], | ||
| matrix_t | dst_arr[n] | ||
| ) |
Compute the multiplication of a scalar with row vector and a matrix.
Return scal*R1,m * Am,n = R1,n, where scal is a scalar, R is a m-dimensional row vector, A is a (mxn)-matrix, and the result is a row vector of n-dimension.
| [in] | m | size of the row vector and row number of the matrix. |
| [in] | n | column number of the matrix. |
| [in] | scalar | scalar value. |
| [in] | vec[] | pointer to the row vector. |
| [in] | matrix[][] | pointer to the matrix. |
| [out] | dst_arr | pointer to the destination row vector of n-dimension. |
Definition at line 470 of file matrix.c.
References matrix_t.
| void matrix_mul_vec | ( | uint8_t | m, |
| uint8_t | n, | ||
| matrix_t | matrix[m][n], | ||
| matrix_t | vec[n], | ||
| matrix_t | dst_arr[m] | ||
| ) |
Compute the multiplication of a matrix with a column vector.
Return Am,n * Vn,1 = Bm,1, where the A is a (mxn)-matrix, V is a n-dimensional column vector, and the result is a m-dimensional column vector.
| [in] | m | row number of the matrix to multiply. |
| [in] | n | column number of the matrix to multiply. |
| [in] | matrix[][] | pointer to the matrix. |
| [in] | vec | pointer to the n-dimensional column vector. |
| [out] | dst_arr | pointer to the destination m-dimensional column vector. |
Definition at line 434 of file matrix.c.
References matrix_t.
Referenced by get_delta_x(), loc_gauss_newton(), modified_gauss_newton(), newton_raphson(), opt_levenberg_marquardt_correction(), solve(), solve_lu_decomp(), solve_test(), and trilateration_get_particular_solution().
| void matrix_part_copy | ( | uint8_t | m, |
| uint8_t | n, | ||
| matrix_t | src_matrix[m][n], | ||
| uint8_t | start_row_ind, | ||
| uint8_t | end_row_ind, | ||
| uint8_t | start_col_ind, | ||
| uint8_t | end_col_ind, | ||
| uint8_t | dest_row_num, | ||
| uint8_t | dest_col_num, | ||
| matrix_t | dest_matrix[][dest_col_num] | ||
| ) |
Copy a part of a matrix to another matrix or sub-matrix.
A part of the source matrix can be copied in a sub-part of the destination matrix (sub-matrix). The source and destination sub-matrices are limited by the row and column indices.
| [in] | m | row number of the source matrix. |
| [in] | n | column number of the source matrix. |
| [in] | src_matrix[][] | pointer to the source matrix. |
| [in] | start_row_ind | the start index of the rows of the source sub-matrix. |
| [in] | end_row_ind | the end index of the rows of the source sub-matrix. |
| [in] | start_col_ind | the start index of the columns of the source sub-matrix. |
| [in] | end_col_ind | the end index of the columns of the source sub-matrix. |
| [in] | dest_row_num | the row number of the destination sub-matrix. |
| [in] | dest_col_num | the column number of the destination sub-matrix. |
| [out] | dest_matrix[][] | pointer to the destination (sub)-matrix. |
Definition at line 89 of file matrix.c.
Referenced by qr_common_get_reduced_QR(), and qr_givens_decomp().
| void matrix_part_mul | ( | uint8_t | a_col_num_max, |
| matrix_t | a_matrix[][a_col_num_max], | ||
| uint8_t | b_col_num_max, | ||
| matrix_t | b_matrix[][b_col_num_max], | ||
| uint8_t | a_start_row_ind, | ||
| uint8_t | a_end_row_ind, | ||
| uint8_t | a_start_col_ind, | ||
| uint8_t | a_end_col_ind, | ||
| uint8_t | b_start_row_ind, | ||
| uint8_t | b_end_row_ind, | ||
| uint8_t | b_start_col_ind, | ||
| uint8_t | b_end_col_ind, | ||
| uint8_t | dest_col_size, | ||
| matrix_t | dest_matrix[][dest_col_size] | ||
| ) |
Compute the partial multiplication of two matrices.
Enables the calculation of matrix product of parts of two matrices.
| [in] | a_col_num_max | column number of the first matrix. |
| [in] | a_matrix[][] | pointer to the first matrix. |
| [in] | b_col_num_max | column number of the second matrix. |
| [in] | b_matrix[][] | pointer to the second matrix. |
| [in] | a_start_row_ind | row begin of the first, partial matrix. |
| [in] | a_end_row_ind | row end of the first, partial matrix. |
| [in] | a_start_col_ind | column begin of the first, partial matrix. |
| [in] | a_end_col_ind | column end of the first, partial matrix. |
| [in] | b_start_row_ind | row begin of the second, partial matrix. |
| [in] | b_end_row_ind | row end of the second, partial matrix. |
| [in] | b_start_col_ind | column begin of the second, partial matrix. |
| [in] | b_end_col_ind | column end of the second, partial matrix. |
| [in] | dest_col_size | column size of the destination matrix. |
| [out] | dest_matrix[][] | pointer to the destination matrix. |
Definition at line 391 of file matrix.c.
Referenced by matrix_test().
| void matrix_part_mul_scalar_vec_matr | ( | uint8_t | max_m, |
| uint8_t | max_n, | ||
| matrix_t | scalar, | ||
| matrix_t | vec[max_m], | ||
| matrix_t | matrix[max_m][max_n], | ||
| uint8_t | begin_row, | ||
| uint8_t | begin_column, | ||
| matrix_t | dst_arr[max_n - begin_row] | ||
| ) |
Compute the multiplication of a scalar with row vector and a sub-matrix.
Return scal*R1,m * Am,n = R1,n, where scal is a scalar, R is a m-dimensional row vector, A is a (mxn)-matrix, and the result is a row vector of n-dimension.
| [in] | max_m | size of the row vector and row number of the matrix. |
| [in] | max_n | column number of the matrix. |
| [in] | scalar | scalar value. |
| [in] | vec[] | pointer to the row vector. |
| [in] | matrix[][] | pointer to the matrix. |
| [in] | begin_row | start row number of the sub-matrix. |
| [in] | begin_column | start column number of the sub-matrix. |
| [out] | dst_arr | pointer to the destination row vector of n-dimension. |
Definition at line 489 of file matrix.c.
References matrix_t.
| void matrix_part_print | ( | uint8_t | m, |
| uint8_t | n, | ||
| matrix_t | matrix[m][n], | ||
| uint8_t | start_row_ind, | ||
| uint8_t | end_row_ind, | ||
| uint8_t | start_col_ind, | ||
| uint8_t | end_col_ind | ||
| ) |
Display the values of the sub-matrix elements.
| [in] | m | total row number of the matrix. |
| [in] | n | total column number of the matrix. |
| [in] | matrix[][] | pointer to the entire matrix. |
| [in] | start_row_ind | start row number of the sub-matrix. |
| [in] | end_row_ind | end row number of the sub-matrix. |
| [in] | start_col_ind | start column number of the sub-matrix. |
| [in] | end_col_ind | end column number of the sub-matrix. |
| void matrix_part_swap_rows | ( | uint8_t | n, |
| matrix_t | matrix[][n], | ||
| uint8_t | i, | ||
| uint8_t | j, | ||
| uint8_t | col_begin, | ||
| uint8_t | col_end | ||
| ) |
Swaps two rows of a sub-matrix.
Swaps the rows i and j of a part of a matrix.
| [in] | n | column number of the entire matrix. |
| [in,out] | matrix[][] | pointer to the entire matrix. |
| [in] | i | the i-the row of the sub-matrix. |
| [in] | j | the j-the row of the sub-matrix. |
| [in] | col_begin | the column begin of the sub-matrix. |
| [in] | col_end | the column end of the sub-matrix. |
Definition at line 736 of file matrix.c.
References matrix_t.
Referenced by lu_decomp().
| void matrix_print | ( | uint8_t | m, |
| uint8_t | n, | ||
| matrix_t | matrix[m][n] | ||
| ) |
Display the values of the matrix elements.
| [in] | m | row number of the matrix. |
| [in] | n | column number of the matrix. |
| [in] | matrix[][] | pointer to the entire matrix. |
Definition at line 141 of file matrix.c.
Referenced by matrix_get_two_norm(), and svd_compute_print_U_S_V_s().
Set all the diagonal elements of a matrix with a specified value.
| [in] | m | row number of the matrix. |
| [in] | n | column number of the matrix. |
| [in] | value | value to be set. |
| [in,out] | diag_matrix[][] | pointer to the matrix. |
Definition at line 565 of file matrix.c.
Referenced by matrix_get_diag_mat().
| void matrix_sub | ( | uint8_t | m, |
| uint8_t | n, | ||
| matrix_t | A[m][n], | ||
| matrix_t | B[m][n], | ||
| matrix_t | A_minus_B[m][n] | ||
| ) |
Compute the subtraction of two matrices.
Subtract matrix B from matrix A and return the result in A_minus_B matrix.
| [in] | m | row number of the matrix to add. |
| [in] | n | column number of the matrix to add. |
| [in] | A[][] | pointer to the first matrix. |
| [in] | B[][] | pointer to the second matrix. |
| [out] | A_minus_B[][] | pointer to the destination matrix. |
Definition at line 329 of file matrix.c.
Referenced by matrix_test().
| void matrix_swap_rows | ( | uint8_t | n, |
| matrix_t | matrix[][n], | ||
| uint8_t | i, | ||
| uint8_t | j | ||
| ) |
Swaps two rows of a matrix.
Swaps the rows i and j of a matrix.
| [in] | n | column number of the matrix. |
| [in] | matrix[][] | pointer to the matrix. |
| [in] | i | the i-the row of the matrix. |
| [in] | j | the j-the row of the matrix. |
Definition at line 725 of file matrix.c.
References matrix_t.
Referenced by lu_decomp(), and matrix_test().
Compute the multiplication of the transpose of a matrix with itself.
Transpose the matrix A and multiply it with the matrix A: A'*A.
| [in] | m | row number of the matrix. |
| [in] | n | column number of the matrix. |
| [in] | A[][] | pointer to the matrix. |
| [out] | AT_mul_A[][] | pointer to the destination matrix (A'*A). |
Definition at line 545 of file matrix.c.
References matrix_get_column_vec(), and matrix_t.
Referenced by magnetic_based_jacobian_get_JTJ(), modified_gauss_newton(), opt_levenberg_marquardt(), and opt_levenberg_marquardt_correction().
| void matrix_trans_mul_vec | ( | uint8_t | m, |
| uint8_t | n, | ||
| matrix_t | A[m][n], | ||
| uint8_t | b_size, | ||
| matrix_t | b_vec[m], | ||
| matrix_t | c_vec[n] | ||
| ) |
Compute the multiplication of transposed matrix with column vector.
Transpose A and return A'n,m * Vm,1 = Bn,1, where A is a (mxn)-matrix, V is a m-dimensional column vector, and the result is a n-dimensional column vector.
| [in] | m | row number of the matrix to transpose and multiply. |
| [in] | n | column number of the matrix to transpose and multiply. |
| [in] | A[][] | pointer to the matrix. |
| [in] | b_size | size of the column vector. |
| [in] | b_vec[] | pointer to the column vector of m-dimension. |
| [out] | c_vec[] | pointer to the destination, column vector of n-dimension. |
Definition at line 511 of file matrix.c.
Referenced by magnetic_based_jacobian_get_JTf(), modified_gauss_newton(), opt_levenberg_marquardt(), opt_levenberg_marquardt_correction(), solve_givens(), and solve_householder().
| void matrix_transpose | ( | uint8_t | m, |
| uint8_t | n, | ||
| matrix_t | src_matrix[m][n], | ||
| matrix_t | dest_matrix[n][m] | ||
| ) |
Computes the transpose of a matrix.
| [in] | m | row number of the matrix. |
| [in] | n | column number of the matrix. |
| [in] | src_matrix[][] | pointer to the matrix to transpose. |
| [out] | dest_matrix[][] | pointer to the destination matrix. |
Definition at line 56 of file matrix.c.
Referenced by get_PDOP(), matrix_test(), moore_penrose_get_pinv(), and triangular_matrices_test().
| void matrix_vec_mul_matr | ( | uint8_t | m, |
| uint8_t | n, | ||
| matrix_t | vec[m], | ||
| matrix_t | matrix[m][n], | ||
| matrix_t | dst_arr[n] | ||
| ) |
Compute the multiplication of row vector and a matrix.
Return R1,m * Am,n = R1,n, where R is a m-dimensional row vector, A is a (mxn)-matrix, and the result is a row vector of n-dimension.
| [in] | m | size of the row vector and row number of the matrix. |
| [in] | n | column number of the matrix. |
| [in] | vec[] | pointer to the row vector. |
| [in] | matrix[][] | pointer to the matrix. |
| [out] | dst_arr | pointer to the destination row vector of n-dimension. |
Definition at line 452 of file matrix.c.
References matrix_t.