|
RcdMathLib_doc
Open Source Library for Linear and Non-linear Algebra
|
Algorithm for the Singular Value Decomposition (SVD). Provide necessary methods to compute the compact SVD of a matrix. A = U*S*V, where U is a (m x l) orthogonal matrix, S is a (l x l) diagonal matrix, V is a (l x n) orthogonal matrix, and l = min(m,n). The SVD is computed by using the Golub–Kahan–Reinsch algorithm that works in two phases: bidiagonalization and a reduction to the diagonal form phase. More...
#include <stdbool.h>#include <inttypes.h>#include <math.h>#include <string.h>#include <stdio.h>#include "svd.h"#include "matrix.h"#include "vector.h"Go to the source code of this file.
Functions | |
| void | svd_get_U_dim (uint8_t m, uint8_t n, matrix_dim_t *u_dim) |
| Calculate the dimension of the matrix U. More... | |
| void | svd_get_S_dim (uint8_t m, uint8_t n, matrix_dim_t *s_dim) |
| Calculate the dimension of the matrix S. More... | |
| void | svd_get_V_dim (uint8_t m, uint8_t n, matrix_dim_t *v_dim) |
| Calculate the dimension of the matrix V. More... | |
| uint8_t | svd_get_single_values_num (uint8_t m, uint8_t n) |
| Calculate the number of the singular values. More... | |
| void | svd (uint8_t m, uint8_t n, matrix_t A[m][n], uint8_t u_m, uint8_t u_n, matrix_t U[u_m][u_n], matrix_t S[u_n][n], matrix_t V[n][n], uint8_t sing_vec_length, matrix_t singl_values_vec[]) |
| Compute the Singular-Value Decomposition (SVD) of a matrix. More... | |
| void | svd_get_reciproc_singular_values (uint8_t m, uint8_t n, uint8_t length, matrix_t singl_values_arr[], matrix_t recip_singl_values_arr[]) |
| Compute the reciprocal singular values. More... | |
| void | svd_compute_print_U_S_V_s (uint8_t m, uint8_t n, matrix_t matrix_arr[m][n], uint8_t i) |
| Compute and print the SVD of a matrix. More... | |
Algorithm for the Singular Value Decomposition (SVD). Provide necessary methods to compute the compact SVD of a matrix. A = U*S*V, where U is a (m x l) orthogonal matrix, S is a (l x l) diagonal matrix, V is a (l x n) orthogonal matrix, and l = min(m,n). The SVD is computed by using the Golub–Kahan–Reinsch algorithm that works in two phases: bidiagonalization and a reduction to the diagonal form phase.
Definition in file svd.c.
| void svd | ( | uint8_t | m, |
| uint8_t | n, | ||
| matrix_t | A[m][n], | ||
| uint8_t | u_m, | ||
| uint8_t | u_n, | ||
| matrix_t | U[u_m][u_n], | ||
| matrix_t | S[u_n][n], | ||
| matrix_t | V[n][n], | ||
| uint8_t | sing_vec_length, | ||
| matrix_t | singl_values_vec[] | ||
| ) |
Compute the Singular-Value Decomposition (SVD) of a matrix.
Matrix A is transformed to A = U*S*V, where U and V are unitary matrices, and S is a diagonal matrix.
| [in] | m | row number of the matrix A. |
| [in] | n | column number of the matrix A. |
| [in,out] | A[][] | pointer to the matrix A. |
| [in] | u_m | row number of the matrix U. |
| [in] | u_n | column number of the matrix U. |
| [in,out] | U[][] | pointer to the matrix U. |
| [in,out] | S[][] | pointer to the matrix S. |
| [in,out] | V[][] | pointer to the matrix V. |
| [in] | sing_vec_length | length of the singular vector. |
| [in,out] | singl_values_vec[] | pointer to the vector saving the singular values. |
Definition at line 119 of file svd.c.
Referenced by matrix_get_two_norm(), svd_compute_print_U_S_V_s(), and trilateration_get_rank_and_homogeneous_solution().
| void svd_compute_print_U_S_V_s | ( | uint8_t | m, |
| uint8_t | n, | ||
| matrix_t | matrix_arr[m][n], | ||
| uint8_t | i | ||
| ) |
Compute and print the SVD of a matrix.
| [in] | m | row number of the matrix to transform in SVD. |
| [in] | n | column number of the matrix to transform in SVD. |
| [in] | matrix_arr[][] | pointer to the matrix. |
| [in] | i | label. |
Definition at line 766 of file svd.c.
References matrix_dim_t::col_num, matrix_print(), matrix_t, matrix_dim_t::row_num, svd(), svd_get_single_values_num(), and svd_get_U_dim().
Referenced by svd_test().
| void svd_get_reciproc_singular_values | ( | uint8_t | m, |
| uint8_t | n, | ||
| uint8_t | length, | ||
| matrix_t | singl_values_arr[], | ||
| matrix_t | recip_singl_values_arr[] | ||
| ) |
Compute the reciprocal singular values.
This method is based on the singular values.
| [in] | m | row number of the matrix to transform in SVD. |
| [in] | n | column number of the matrix to transform in SVD. |
| [in] | length | length of the array of single values. |
| [in] | singl_values_arr | pointer to the array of single values. |
| [out] | recip_singl_values_arr | pointer to the array of the reciprocal singular values. |
Definition at line 747 of file svd.c.
References matrix_t.
| void svd_get_S_dim | ( | uint8_t | m, |
| uint8_t | n, | ||
| matrix_dim_t * | s_dim | ||
| ) |
Calculate the dimension of the matrix S.
| [in] | m | row number of the matrix to decompose. |
| [in] | n | column number of the matrix to decompose. |
| [out] | s_dim | pointer to the dimension struct. |
Definition at line 102 of file svd.c.
References matrix_dim_t::row_num.
| uint8_t svd_get_single_values_num | ( | uint8_t | m, |
| uint8_t | n | ||
| ) |
Calculate the number of the singular values.
| [in] | m | row number of the matrix to decompose. |
| [in] | n | column number of the matrix to decompose. |
Definition at line 114 of file svd.c.
Referenced by matrix_get_two_norm(), moore_penrose_get_pinv(), svd_compute_print_U_S_V_s(), and trilateration_get_rank_and_homogeneous_solution().
| void svd_get_U_dim | ( | uint8_t | m, |
| uint8_t | n, | ||
| matrix_dim_t * | u_dim | ||
| ) |
Calculate the dimension of the matrix U.
| [in] | m | row number of the matrix to decompose. |
| [in] | n | column number of the matrix to decompose. |
| [out] | u_dim | pointer to the dimension struct. |
Definition at line 96 of file svd.c.
References matrix_dim_t::col_num, and matrix_dim_t::row_num.
Referenced by matrix_get_two_norm(), moore_penrose_get_pinv(), svd_compute_print_U_S_V_s(), and trilateration_get_rank_and_homogeneous_solution().
| void svd_get_V_dim | ( | uint8_t | m, |
| uint8_t | n, | ||
| matrix_dim_t * | v_dim | ||
| ) |
Calculate the dimension of the matrix V.
| [in] | m | row number of the matrix to decompose. |
| [in] | n | column number of the matrix to decompose. |
| [out] | v_dim | pointer to the dimension struct. |
Definition at line 108 of file svd.c.
References matrix_dim_t::col_num, and matrix_dim_t::row_num.