PDA

View Full Version : Is there any Fortran code for solving such a linear system with least square method?


passionfly
Oct30-10, 03:33 AM
Dear all:

For a standard linear system, y(n*1)=A(n*n)x(n*1)

If y is exact and A is well-conditioned, it is easy to calculate x.

However, if y has some disturbances or some errors, at the same time, A matrix is ill-conditioned. It is difficult to accurately obtain vector x. Alternatively, we can measure more components of y (becomes m*1, where m>n) and use the least square method to calculate the approximate x vector.

It is a common problem so I guess there should be some ready-to-use Fortran codes. Anybody knows where can I find this algorithms or codes? Any advice or suggestion is welcomed!

Thank you very much and with best wishes,
Thomas

jasonRF
Nov1-10, 05:44 AM
LAPACK is the standard Fortran package to do this. The subroutines you will want end in GELS or GELSS (SGELS is single precision real; DGELS is double precision real, CGELS is single complex, ZGELS is double complex) . LAPACK is free - google will find the package and all the documentation you should need.

_GELS uses QR factorization, I believe. _GELSS uses SVD.

Good luck.

jason