2
SUBROUTINE DHEQR (A, LDA, N, Q, INFO, IJOB)
3
C***BEGIN PROLOGUE DHEQR
5
C***PURPOSE Internal routine for DGMRES.
6
C***LIBRARY SLATEC (SLAP)
7
C***CATEGORY D2A4, D2B4
8
C***TYPE DOUBLE PRECISION (SHEQR-S, DHEQR-D)
9
C***KEYWORDS GENERALIZED MINIMUM RESIDUAL, ITERATIVE PRECONDITION,
10
C NON-SYMMETRIC LINEAR SYSTEM, SLAP, SPARSE
11
C***AUTHOR Brown, Peter, (LLNL), pnbrown@llnl.gov
12
C Hindmarsh, Alan, (LLNL), alanh@llnl.gov
13
C Seager, Mark K., (LLNL), seager@llnl.gov
14
C Lawrence Livermore National Laboratory
16
C Livermore, CA 94550 (510) 423-3141
18
C This routine performs a QR decomposition of an upper
19
C Hessenberg matrix A using Givens rotations. There are two
20
C options available: 1) Performing a fresh decomposition 2)
21
C updating the QR factors by adding a row and a column to the
25
C INTEGER LDA, N, INFO, IJOB
26
C DOUBLE PRECISION A(LDA,N), Q(2*N)
28
C CALL DHEQR(A, LDA, N, Q, INFO, IJOB)
31
C A :INOUT Double Precision A(LDA,N)
32
C On input, the matrix to be decomposed.
33
C On output, the upper triangular matrix R.
34
C The factorization can be written Q*A = R, where
35
C Q is a product of Givens rotations and R is upper
38
C The leading dimension of the array A.
40
C A is an (N+1) by N Hessenberg matrix.
41
C Q :OUT Double Precision Q(2*N)
42
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 = 1 means that a fresh decomposition of the
52
C matrix A is desired.
53
C .ge. 2 means that the current decomposition of A
54
C will be updated by the addition of a row
58
C***ROUTINES CALLED (NONE)
59
C***REVISION HISTORY (YYMMDD)
61
C 890404 Previous REVISION DATE
62
C 890915 Made changes requested at July 1989 CML Meeting. (MKS)
63
C 890922 Numerous changes to prologue to make closer to SLATEC
65
C 890929 Numerous changes to reduce SP/DP differences. (FNF)
66
C 910411 Prologue converted to Version 4.0 format. (BAB)
67
C 910506 Made subsidiary to DGMRES. (FNF)
68
C 920511 Added complete declaration section. (WRB)
69
C***END PROLOGUE DHEQR
70
C The following is for optimized compilation on LLNL/LTSS Crays.
72
C .. Scalar Arguments ..
73
INTEGER IJOB, INFO, LDA, N
74
C .. Array Arguments ..
75
DOUBLE PRECISION A(LDA,*), Q(*)
77
DOUBLE PRECISION C, S, T, T1, T2
78
INTEGER I, IQ, J, K, KM1, KP1, NM1
79
C .. Intrinsic Functions ..
81
C***FIRST EXECUTABLE STATEMENT DHEQR
82
IF (IJOB .GT. 1) GO TO 70
83
C -------------------------------------------------------------------
84
C A new factorization is desired.
85
C -------------------------------------------------------------------
86
C QR decomposition without pivoting.
93
C Compute K-th column of R.
94
C First, multiply the K-th column of A by the previous
95
C K-1 Givens rotations.
97
IF (KM1 .LT. 1) GO TO 20
105
A(J+1,K) = S*T1 + C*T2
108
C Compute Givens components C and S.
114
IF( T2.EQ.0.0D0 ) THEN
117
ELSEIF( ABS(T2).GE.ABS(T1) ) THEN
119
S = -1.0D0/SQRT(1.0D0+T*T)
123
C = 1.0D0/SQRT(1.0D0+T*T)
129
IF( A(K,K).EQ.0.0D0 ) INFO = K
132
C -------------------------------------------------------------------
133
C The old factorization of a will be updated. A row and a
134
C column has been added to the matrix A. N by N-1 is now
135
C the old size of the matrix.
136
C -------------------------------------------------------------------
139
C -------------------------------------------------------------------
140
C Multiply the new column by the N previous Givens rotations.
141
C -------------------------------------------------------------------
149
A(K+1,N) = S*T1 + C*T2
151
C -------------------------------------------------------------------
152
C Complete update of decomposition by forming last Givens
153
C rotation, and multiplying it times the column
154
C vector(A(N,N),A(NP1,N)).
155
C -------------------------------------------------------------------
159
IF ( T2.EQ.0.0D0 ) THEN
162
ELSEIF( ABS(T2).GE.ABS(T1) ) THEN
164
S = -1.0D0/SQRT(1.0D0+T*T)
168
C = 1.0D0/SQRT(1.0D0+T*T)
175
IF (A(N,N) .EQ. 0.0D0) INFO = N
177
C------------- LAST LINE OF DHEQR FOLLOWS ----------------------------