1 SUBROUTINE R1UPQF
(N
,S
,T
,QT
,R
,W
)
2 C ***** DECLARATIONS *****
4 C FUNCTION DECLARATIONS
6 DOUBLE PRECISION DDOT
, DNRM2
10 DOUBLE PRECISION C
, DEN
, ONE
, SS
, WW
, YY
, temp
11 INTEGER I
, INDEXR
, INDXR2
, J
, K
21 DOUBLE PRECISION S
(N
), QT
(N
,N
), R
(N*
(N
+1)/2),
24 C ***** END OF DECLARATIONS *****
26 C ***** COMPUTE THE QR FACTORIZATION Q- R- OF (R + T*S). THEN, *****
27 C Q+ = Q*Q-, AND R+ = R-.
29 C FIND THE LARGEST K SUCH THAT T(K) .NE. 0.
32 50 IF (T
(K
) .NE
. 0.0 .OR
. K
.LE
. 1) GOTO 60
37 C COMPUTE THE INDEX OF R(K-1,K-1).
39 INDEXR
= (N
+ N
- K
+ 3)*(K
- 2) / 2 + 1
41 C ***** TRANSFORM R+T*ST INTO AN UPPER HESSENBERG MATRIX *****
43 C DETERMINE JACOBI ROTATIONS WHICH WILL ZERO OUT ROWS
44 C N, N-1,...,2 OF THE MATRIX T*ST, AND APPLY THESE
45 C ROTATIONS TO R. (THIS IS EQUIVALENT TO APPLYING THE
46 C SAME ROTATIONS TO R+T*ST, EXCEPT FOR THE FIRST ROW.
47 C THUS, AFTER AN ADJUSTMENT FOR THE FIRST ROW, THE
48 C RESULT IS AN UPPER HESSENBERG MATRIX. THE
49 C SUBDIAGONAL ELEMENTS OF WHICH WILL BE STORED IN W.
51 C NOTE: ROWS N,N-1,...,K+1 ARE ALREADY ALL ZERO.
55 C DETERMINE THE JACOBI ROTATION WHICH WILL ZERO OUT
56 C ROW I+1 OF THE T*ST MATRIX.
58 IF (T
(I
) .EQ
. 0.0) THEN
60 C SS = SIGN(-T(I+1))= -T(I+1)/|T(I+1)|
61 SS
= -SIGN
(ONE
,T
(I
+1))
68 C PREMULTIPLY R BY THE JACOBI ROTATION.
72 R
(INDEXR
) = C*YY
- SS*WW
75 INDXR2
= INDEXR
+ N
- I
81 C R(I,J) = C*YY - SS*WW
82 C R(I+1,J) = SS*YY + C*WW
83 R
(INDEXR
) = C*YY
- SS*WW
84 R
(INDXR2
) = SS*YY
+ C*WW
89 C PREMULTIPLY QT BY THE JACOBI ROTATION.
94 QT
(I
,J
) = C*YY
- SS*WW
95 QT
(I
+1,J
) = SS*YY
+ C*WW
98 C UPDATE T(I) SO THAT T(I)*ST(J) IS THE (I,J)TH COMPONENT
99 C OF T*ST, PREMULTIPLIED BY ALL OF THE JACOBI ROTATIONS SO
102 IF (T
(I
) .EQ
. 0.0) THEN
105 T
(I
) = DNRM2
(2,T
(I
),1)
108 C LET INDEXR = THE INDEX OF R(I-1,I-1).
110 INDEXR
= INDEXR
- 2*(N
- I
) - 3
114 C UPDATE THE FIRST ROW OF R SO THAT R HOLDS (R+T*ST)
115 C PREMULTIPLIED BY ALL OF THE ABOVE JACOBI ROTATIONS.
118 CALL DAXPY
(N
,temp
,S
,1,R
,1)
120 C ***** END OF TRANSFORMATION TO UPPER HESSENBERG *****
123 C ***** TRANSFORM UPPER HESSENBERG MATRIX INTO UPPER *****
126 C INDEXR = INDEX OF R(1,1).
131 C DETERMINE APPROPRIATE JACOBI ROTATION TO ZERO OUT
134 IF (R
(INDEXR
) .EQ
. 0.0) THEN
136 SS
= -SIGN
(ONE
,W
(I
+1))
145 C PREMULTIPLY R BY JACOBI ROTATION.
149 R
(INDEXR
) = C*YY
- SS*WW
152 INDXR2
= INDEXR
+ N
- I
158 C R(I,J) = C*YY -SS*WW
159 C R(I+1,J) = SS*YY + C*WW
160 R
(INDEXR
) = C*YY
- SS*WW
161 R
(INDXR2
) = SS*YY
+ C*WW
166 C PREMULTIPLY QT BY JACOBI ROTATION.
171 QT
(I
,J
) = C*YY
- SS*WW
172 QT
(I
+1,J
) = SS*YY
+ C*WW
176 C ***** END OF TRANSFORMATION TO UPPER TRIANGULAR *****
179 C ***** END OF UPDATE *****
184 C ***** END OF SUBROUTINE UPQRQF *****