root / synthbench / euroben-dm / mod2ci / lsqslv.f @ 0:839f52ef7657
History | View | Annotate | Download (1013 Bytes)
1 |
Subroutine lsqslv( m, n, a, x ) |
---|---|
2 |
! ---------------------------------------------------------------------- |
3 |
! --- lsqslv solves the rectangular upper diagonal system Ax = b in |
4 |
! the Least Squares sense: It is assumed that m <= n and |
5 |
! a(n,m) has only a non-zero upper triangle of order m. |
6 |
! On entry x contains the RHS. On exit it contains the |
7 |
! solution vector. |
8 |
! ---------------------------------------------------------------------- |
9 |
Use numerics |
10 |
Use floptime |
11 |
Implicit None |
12 |
|
13 |
Integer :: m, n |
14 |
Real(l_) :: a(n,m), x(m) |
15 |
|
16 |
Integer :: i, j |
17 |
Real(l_) :: tmp |
18 |
! ---------------------------------------------------------------------- |
19 |
Do j = m, 1, -1 |
20 |
x(j) = x(j)/a(j,j) |
21 |
tmp = x(j) |
22 |
Do i = j - 1, 1, -1 |
23 |
x(i) = x(i) - tmp*a(i,j) |
24 |
End Do |
25 |
End Do |
26 |
flops = flops + ( m*( m + 1 ) )/2 |
27 |
! ---------------------------------------------------------------------- |
28 |
End Subroutine lsqslv |
29 |
|