2 SUBROUTINE DHEQR
(A
, LDA
, N
, Q
, INFO
, IJOB
)
3 INTEGER LDA
, N
, INFO
, IJOB
4 DOUBLE PRECISION A
(LDA
,*), Q
(*)
5 C-----------------------------------------------------------------------
6 C This routine performs a QR decomposition of an upper
7 C Hessenberg matrix A. There are two options available:
9 C (1) performing a fresh decomposition
10 C (2) updating the QR factors by adding a row and a
11 C column to the matrix A.
12 C-----------------------------------------------------------------------
13 C DHEQR decomposes an upper Hessenberg matrix by using Givens
18 C A DOUBLE PRECISION(LDA, N)
19 C the matrix to be decomposed.
22 C the leading dimension of the array A .
25 C A is an (N+1) by N Hessenberg matrix.
28 C = 1 means that a fresh decomposition of the
29 C matrix A is desired.
30 C .ge. 2 means that the current decomposition of A
31 C will be updated by the addition of a row
35 C A the upper triangular matrix R.
36 C The factorization can be written Q*A = R, where
37 C Q is a product of Givens rotations and R is upper
40 C Q DOUBLE PRECISION(2*N)
41 C the factors c and s of each Givens rotation used
46 C = k if A(k,k) .eq. 0.0 . This is not an error
47 C condition for this subroutine, but it does
48 C indicate that DHELS will divide by zero
51 C Modification of LINPACK, by Peter Brown, LLNL.
52 C Written 1/13/86. This version dated 6/20/01.
53 C-----------------------------------------------------------------------
54 INTEGER I
, IQ
, J
, K
, KM1
, KP1
, NM1
55 DOUBLE PRECISION C
, S
, T
, T1
, T2
57 IF (IJOB
.GT
. 1) GO TO 70
59 C A new facorization is desired.
61 C QR decomposition without pivoting
68 C Compute kth column of R.
69 C First, multiply the kth column of A by the previous
70 C k-1 Givens rotations.
72 IF (KM1
.LT
. 1) GO TO 20
80 A
(J
+1,K
) = S*T1
+ C*T2
83 C Compute Givens components c and s
89 IF (T2
.NE
. 0.0D0
) GO TO 30
94 IF (ABS
(T2
) .LT
. ABS
(T1
)) GO TO 40
96 S
= -1.0D0
/SQRT
(1.0D0
+T*T
)
101 C
= 1.0D0
/SQRT
(1.0D0
+T*T
)
107 IF (A
(K
,K
) .EQ
. 0.0D0
) INFO
= K
111 C The old factorization of A will be updated. A row and a column
112 C has been added to the matrix A.
113 C N by N-1 is now the old size of the matrix.
118 C Multiply the new column by the N previous Givens rotations.
127 A
(K
+1,N
) = S*T1
+ C*T2
130 C Complete update of decomposition by forming last Givens rotation,
131 C and multiplying it times the column vector (A(N,N), A(N+1,N)).
136 IF (T2
.NE
. 0.0D0
) GO TO 110
141 IF (ABS
(T2
) .LT
. ABS
(T1
)) GO TO 120
143 S
= -1.0D0
/SQRT
(1.0D0
+T*T
)
148 C
= 1.0D0
/SQRT
(1.0D0
+T*T
)
155 IF (A
(N
,N
) .EQ
. 0.0D0
) INFO
= N
157 C----------------------- End of Subroutine DHEQR -----------------------