Linear solver based on matf32_t data type of the Matf32 Library. The following methods are available for the solver: LU, QR, Cholesky, Forward Substitution, Backward Subtitution and SVD.
More...
|
| void | linsolve_print_method (linsolve_method_t lsm) |
| | Prints string representing the linear method.
|
| linsolve_method_t | linsolve_get_method (const matf32_t *const p_a) |
| | Defines which method is the best to use depending on the shape ant type of matrix in the system.
|
| err_status_t | linsolve_forward_substitution (const matf32_t *const p_l, const matf32_t *const p_b, matf32_t *p_x) |
| | Solves a linear system through forward substitution.
|
| err_status_t | linsolve_backward_substitution (const matf32_t *const p_u, const matf32_t *const p_b, matf32_t *p_x) |
| | Solves a system a linear system through backward substitution.
|
| err_status_t | linsolve_cholesky (matf32_t *const p_c, const matf32_t *const p_b, matf32_t *const p_x) |
| | Solves a linear system through Cholesky factorization. The factorization must be performed before executing this routine.
|
| err_status_t | linsolve_qr (matf32_t *const p_q, matf32_t *const p_r, const matf32_t *const p_b, matf32_t *const p_x, linsolve_method_t qr_shape) |
| | Solves a linear system through QR factorization. The factorization must be computed before using this routine. Can be applied to systems with either square or rectangular matrices, by introducing the QR_SQUARE or QR_RECT, respectively, in the linsolve_method_t argument. The system is solved as follows:
|
| err_status_t | linsolve_lu (const matf32_t *const p_l, const matf32_t *const p_u, const matf32_t *const p_b, matf32_t *const p_x, uint16_t *p_index) |
| | Solves a linear system through LU factorization. The factorization must be computed before executing this routine, as the factorization's matrices are introduced as arguments. The system is solved as follows:
|
| err_status_t | linsolve_svd (const matf32_t *const p_u, const matf32_t *const p_s, const matf32_t *const p_v, const matf32_t *const p_b, matf32_t *const p_x) |
| | Solves a linear system through SVD Factorization. The SVD must be computed before executing this routine as it receives the matrices of the decomposition as arguments. The solution to the system is computed as \( \textbf{x} = \textbf{V}\textbf{S}^{-1}\textbf{U}^\top\textbf{b} \).
|
| err_status_t | linsolve (const matf32_t *const p_a, const matf32_t *const p_b, matf32_t *const p_x) |
| | Solve a linear system of the form \( \textbf{Ax} = \textbf{b} \), automatically selecting the method to use based on the shape and type of input matrix.
|
| err_status_t | linsolve_method (const matf32_t *const p_a, const matf32_t *const p_b, matf32_t *p_x, linsolve_method_t method) |
| | Solve a linear system of the form \( \textbf{Ax} = \textbf{b} \) with a specific method selected in the arguments.
|
Linear solver based on matf32_t data type of the Matf32 Library. The following methods are available for the solver: LU, QR, Cholesky, Forward Substitution, Backward Subtitution and SVD.
- Date
- Created on: 2022 By: Daniel Pineda
Last modified: 14 jan. 2026 By: Andrea Pineda
◆ linsolve_method_t
Enumerated list for the available methods of the linear solver.
| Enumerator |
|---|
| FORWARD_SUBS | Solve system with Forward Substitution
|
| BACKWARD_SUBS | Solve system with Backward Substitution
|
| CHOLESKY | Solve system with Cholesky Factorization
|
| QR_SQUARE | Solve system with QR Factorization for square matrices
|
| QR_RECT | Solve system with QR Factorization for rectangular matrices (vertical or horitzontal)
|
| LU | Solve system with LU Factorization
|
| SVD | Solve system with the Singular Value Decomposition (SVD)
|
◆ linsolve()
Solve a linear system of the form \( \textbf{Ax} = \textbf{b} \), automatically selecting the method to use based on the shape and type of input matrix.
- Warning
- This solver does uses QR only for systems with rectangular matrices. To solve square matrix systems with QR, use linsolve_method instead. Additionally, the ill-conditioned theshold can be modified in constants.h, according to your needs.
- Parameters
-
| [in] | p_a | Points to system matrix. |
| [in] | p_b | Points to b vector. |
| [in,out] | p_x | Points to output x vector. |
- Returns
- Returns execution status err_status_t: MATH_SUCCESS : Operation successful, MATH_SIZE_MISMATCH : Matrix size check failed, MATH_DECOMPOSITION_FAILURE : Failed decomposition method, MATH_ARGUMENT_ERROR : Incorrect arguments passed.
◆ linsolve_backward_substitution()
Solves a system a linear system through backward substitution.
- Warning
- Only applicable to systems where the matrix is upper triangular.
- Parameters
-
| [in] | p_u | Points to lower triangular matrix. |
| [in] | p_b | Points to b vector. |
| [in,out] | p_x | Points to output x vector. |
- Returns
- Returns execution status err_status_t: MATH_SUCCESS : Operation successful, MATH_ARGUMENT_ERROR : Upper triangular matrix check failed.
◆ linsolve_cholesky()
Solves a linear system through Cholesky factorization. The factorization must be performed before executing this routine.
- Solve \( \textbf{L}\textbf{y} = \textbf{b} \)
- Solve \( \textbf{L$^\top$}\textbf{x} = \textbf{y} \)
- Warning
- This method assumes that the Cholesky factor matrix is introduced as an upper triangular matrix, exactly as the matf32_cholesky algorithm generates it. The solution to the system will be incorrect if the Cholesky Factor is introduced as a lower triangular matrix into the function.
- Parameters
-
| [in] | p_c | Points to upper triangular matrix. |
| [in] | p_b | Points to b vector. |
| [in,out] | p_x | Points to output vector x. |
- Returns
- Returns execution status err_status_t: MATH_SUCCESS : Operation successful, MATH_ARGUMENT_ERROR : Input matrix checks in forward or backward substitution failed.
◆ linsolve_forward_substitution()
Solves a linear system through forward substitution.
- Warning
- Only applicable to systems where the matrix is lower triangular.
- Parameters
-
| [in] | p_l | Points to lower triangular matrix. |
| [in] | p_b | Points to b vector. |
| [in,out] | p_x | Points to output x vector. |
- Returns
- Returns execution status err_status_t: MATH_SUCCESS : Operation successful, MATH_ARGUMENT_ERROR : Lower triangular matrix check failed.
◆ linsolve_get_method()
Defines which method is the best to use depending on the shape ant type of matrix in the system.
- Parameters
-
| [in] | p_a | Points to system matrix. |
- Returns
- Returns a value of type linsolve_method_t: FORWARD_SUBS : Forward substitution, BACKWARD_SUBS : Backward substitution, CHOLESKY : Cholesky factorization, QR_SQUARE : QR factorization for square matrices, QR_RECT : QR factorization for rectangular matrices, LU : LU factorization, SVD : Singular Values Decomposition.
◆ linsolve_lu()
Solves a linear system through LU factorization. The factorization must be computed before executing this routine, as the factorization's matrices are introduced as arguments. The system is solved as follows:
- Solve the system \( \textbf{Ly} = \textbf{b} \)
- Then solve the system \( \textbf{Ux} = \textbf{y} \)
- Parameters
-
| [in] | p_l | Points to matrix L from LU decomposition of A. |
| [in] | p_u | Points to matrix U from LU decomposition of A. |
| [in] | p_b | Points to b vector. |
| [in,out] | p_x | Points to output vector x. |
| [in] | p_index | List of permutations executed during the LU decomposition of A. |
- Returns
- Returns execution status err_status_t: MATH_SUCESS : Operation successful, MATH_ARGUMENT_ERROR : Input matrix checks in forward or backward substitution failed.
◆ linsolve_method()
Solve a linear system of the form \( \textbf{Ax} = \textbf{b} \) with a specific method selected in the arguments.
- Parameters
-
| [in] | p_a | Points to system matrix. |
| [in] | p_b | Points to b vector. |
| [in,out] | p_x | Points to output x vector. |
| [in] | method | Method to use. |
- Returns
- Returns execution status err_status_t: MATH_SUCCESS : Operation successful, MATH_SIZE_MISMATCH : Matrix size check failed, MATH_DECOMPOSITION_FAILURE : Failed decomposition method, MATH_ARGUMENT_ERROR : Incorrect arguments passed.
◆ linsolve_print_method()
Prints string representing the linear method.
- Parameters
-
- Returns
- None.
◆ linsolve_qr()
Solves a linear system through QR factorization. The factorization must be computed before using this routine. Can be applied to systems with either square or rectangular matrices, by introducing the QR_SQUARE or QR_RECT, respectively, in the linsolve_method_t argument. The system is solved as follows:
- Compute the vector \( \textbf{y} = \textbf{Q}^\top \textbf{b} \)
- Solve the system \( \textbf{Rx} = \textbf{y} \)
- Parameters
-
| [in] | p_q | Points to matrix q from QR decomposition of A. |
| [in] | p_r | Points to matrix R from QR decomposition of A. |
| [in] | p_b | Points to b vector. |
| [in,out] | p_x | Points to output vector x. |
- Returns
- Returns execution status err_status_t: MATH_SUCCESS : Operation successful, MATH_ARGUMENT_ERROR : Input matrix check in backward substitution failed.
◆ linsolve_svd()
Solves a linear system through SVD Factorization. The SVD must be computed before executing this routine as it receives the matrices of the decomposition as arguments. The solution to the system is computed as \( \textbf{x} = \textbf{V}\textbf{S}^{-1}\textbf{U}^\top\textbf{b} \).
- Parameters
-
| [in] | p_u | Points to matrix U from SVD of A |
| [in] | p_s | Points to matrix S from SVD of A |
| [in] | p_v | Points to matrix V from SVD of A |
| [in] | p_b | Points to b vector |
| [in,out] | p_x | Points to output vector x |
- Returns
- Returns execution status err_status_t: MATH_SUCCESS : Operation successful