Community
cancel
Showing results for 
Search instead for 
Did you mean: 
89 Views

How to solve least squares problem? For dummies.

Jump to solution
Hello,

I'm trying to solve least squares problem. Given matrix A(mxn), m > n, minimize (Ax - b)2. MKL Reference suggests to use QR Factorization. And all calculation is done in several steps - factorization itself, normalizing matrix form, multiplying rhs, etc.

However, its a little complicated and I found no straightforward explanation on how to compute result x from given A and b. For now I don't even sure how to acquire matrix R. Should I manually multiply A with QT? Or should I extract it somehow from QR result?

I think it'd be pretty convenient to provide manual with simple code example of function

SolveLSP(int m, int n, float* A, float* b, float* x);

using LAPACKE_sgeqrf(), LAPACKE_sorgqr() etc. calls, which is exactly my problem. One may assume matrix_order to be LAPACK_ROW_MAJOR.

E.g. ippmQRDecomp reference is great. Even with picture and enough explanation on storage, though one should not be concerned of it granted with simple ippmQRBackSubst function.

Would you please grant me with such example or with some simple explanation of what functions should I call in what order?

Thanks a lot.
0 Kudos
1 Solution
mecej4
Black Belt
89 Views
If you are interested only in obtaining a least-squares solution rather than in the intermediate results such as Q and R, please look at the LAPACKE_?gels routines, and the several examples in the ../mkl/examples/lapacke/source directory.

View solution in original post

2 Replies
mecej4
Black Belt
90 Views
If you are interested only in obtaining a least-squares solution rather than in the intermediate results such as Q and R, please look at the LAPACKE_?gels routines, and the several examples in the ../mkl/examples/lapacke/source directory.

View solution in original post

89 Views
This is the best answer I didn't even dare to hear :)

Thanks!
Reply