Adelsbach/VSIPL
Core Programming Reference Guide
DD-00016-015
Core

This manual is preliminary and incomplete.
While our Core implementation implements all functions given in the standard we are still working on completing this documentation.

Please refer to the VSIPL standard for a complete function reference of the Core profile until we have completed work on this documentation.

6.2.3 vsip_dllsqsol_p - Solve Linear Least Squares Problem

int vsip_llsqsol_f(const vsip_mview_f* A, const vsip_vview_f* b, const vsip_vview_f* x); 
int vsip_cllsqsol_f(const vsip_cmview_f* A, const vsip_cvview_f* b, const vsip_cvview_f* x);
Description

This function solves the linear least squares problem:

min∥Ax -b∥2
 x

where A is an M  ×N matrix with M ≥ N, b is an M-dimensional vector, and x is the N-dimensional solution vector that minimizes the Euclidean norm of the residual vector.

The function uses QR decomposition with column pivoting to solve the least squares problem, which provides a numerically stable solution even when matrix A is rank-deficient.

Parameters
Return Value
Example

vsip_mview_f *A;             // M×N coefficient matrix 
vsip_vview_f *b;             // M-dimensional right-hand side vector 
vsip_vview_f *x;             // N-dimensional solution vector 
int result; 
 
// Assuming A, b, and x have been properly initialized with appropriate dimensions 
result = vsip_llsqsol_f(A, b, x); 
 
if (result != 0) { 
    // Handle error 
}
Notes