forked from Reference-LAPACK/lapack
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdlaqz1.f
194 lines (194 loc) · 5.01 KB
/
dlaqz1.f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
*> \brief \b DLAQZ1
*
* =========== DOCUMENTATION ===========
*
* Online html documentation available at
* http://www.netlib.org/lapack/explore-html/
*
*> \htmlonly
*> Download DLAQZ1 + dependencies
*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/dlaqz1.f">
*> [TGZ]</a>
*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/dlaqz1.f">
*> [ZIP]</a>
*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/dlaqz1.f">
*> [TXT]</a>
*> \endhtmlonly
*
* Definition:
* ===========
*
* SUBROUTINE DLAQZ1( A, LDA, B, LDB, SR1, SR2, SI, BETA1, BETA2,
* $ V )
* IMPLICIT NONE
*
* Arguments
* INTEGER, INTENT( IN ) :: LDA, LDB
* DOUBLE PRECISION, INTENT( IN ) :: A( LDA, * ), B( LDB, * ), SR1,
* $ SR2, SI, BETA1, BETA2
* DOUBLE PRECISION, INTENT( OUT ) :: V( * )
* ..
*
*
*> \par Purpose:
* =============
*>
*> \verbatim
*>
*> Given a 3-by-3 matrix pencil (A,B), DLAQZ1 sets v to a
*> scalar multiple of the first column of the product
*>
*> (*) K = (A - (beta2*sr2 - i*si)*B)*B^(-1)*(beta1*A - (sr2 + i*si2)*B)*B^(-1).
*>
*> It is assumed that either
*>
*> 1) sr1 = sr2
*> or
*> 2) si = 0.
*>
*> This is useful for starting double implicit shift bulges
*> in the QZ algorithm.
*> \endverbatim
*
*
* Arguments:
* ==========
*
*> \param[in] A
*> \verbatim
*> A is DOUBLE PRECISION array, dimension (LDA,N)
*> The 3-by-3 matrix A in (*).
*> \endverbatim
*>
*> \param[in] LDA
*> \verbatim
*> LDA is INTEGER
*> The leading dimension of A as declared in
*> the calling procedure.
*> \endverbatim
*
*> \param[in] B
*> \verbatim
*> B is DOUBLE PRECISION array, dimension (LDB,N)
*> The 3-by-3 matrix B in (*).
*> \endverbatim
*>
*> \param[in] LDB
*> \verbatim
*> LDB is INTEGER
*> The leading dimension of B as declared in
*> the calling procedure.
*> \endverbatim
*>
*> \param[in] SR1
*> \verbatim
*> SR1 is DOUBLE PRECISION
*> \endverbatim
*>
*> \param[in] SR2
*> \verbatim
*> SR2 is DOUBLE PRECISION
*> \endverbatim
*>
*> \param[in] SI
*> \verbatim
*> SI is DOUBLE PRECISION
*> \endverbatim
*>
*> \param[in] BETA1
*> \verbatim
*> BETA1 is DOUBLE PRECISION
*> \endverbatim
*>
*> \param[in] BETA2
*> \verbatim
*> BETA2 is DOUBLE PRECISION
*> \endverbatim
*>
*> \param[out] V
*> \verbatim
*> V is DOUBLE PRECISION array, dimension (N)
*> A scalar multiple of the first column of the
*> matrix K in (*).
*> \endverbatim
*
* Authors:
* ========
*
*> \author Thijs Steel, KU Leuven
*
*> \date May 2020
*
*> \ingroup doubleGEcomputational
*>
* =====================================================================
SUBROUTINE DLAQZ1( A, LDA, B, LDB, SR1, SR2, SI, BETA1, BETA2,
$ V )
IMPLICIT NONE
*
* Arguments
INTEGER, INTENT( IN ) :: LDA, LDB
DOUBLE PRECISION, INTENT( IN ) :: A( LDA, * ), B( LDB, * ), SR1,
$ SR2, SI, BETA1, BETA2
DOUBLE PRECISION, INTENT( OUT ) :: V( * )
*
* Parameters
DOUBLE PRECISION :: ZERO, ONE, HALF
PARAMETER( ZERO = 0.0D0, ONE = 1.0D0, HALF = 0.5D0 )
*
* Local scalars
DOUBLE PRECISION :: W( 2 ), SAFMIN, SAFMAX, SCALE1, SCALE2
*
* External Functions
DOUBLE PRECISION, EXTERNAL :: DLAMCH
LOGICAL, EXTERNAL :: DISNAN
*
SAFMIN = DLAMCH( 'SAFE MINIMUM' )
SAFMAX = ONE/SAFMIN
*
* Calculate first shifted vector
*
W( 1 ) = BETA1*A( 1, 1 )-SR1*B( 1, 1 )
W( 2 ) = BETA1*A( 2, 1 )-SR1*B( 2, 1 )
SCALE1 = SQRT( ABS( W( 1 ) ) ) * SQRT( ABS( W( 2 ) ) )
IF( SCALE1 .GE. SAFMIN .AND. SCALE1 .LE. SAFMAX ) THEN
W( 1 ) = W( 1 )/SCALE1
W( 2 ) = W( 2 )/SCALE1
END IF
*
* Solve linear system
*
W( 2 ) = W( 2 )/B( 2, 2 )
W( 1 ) = ( W( 1 )-B( 1, 2 )*W( 2 ) )/B( 1, 1 )
SCALE2 = SQRT( ABS( W( 1 ) ) ) * SQRT( ABS( W( 2 ) ) )
IF( SCALE2 .GE. SAFMIN .AND. SCALE2 .LE. SAFMAX ) THEN
W( 1 ) = W( 1 )/SCALE2
W( 2 ) = W( 2 )/SCALE2
END IF
*
* Apply second shift
*
V( 1 ) = BETA2*( A( 1, 1 )*W( 1 )+A( 1, 2 )*W( 2 ) )-SR2*( B( 1,
$ 1 )*W( 1 )+B( 1, 2 )*W( 2 ) )
V( 2 ) = BETA2*( A( 2, 1 )*W( 1 )+A( 2, 2 )*W( 2 ) )-SR2*( B( 2,
$ 1 )*W( 1 )+B( 2, 2 )*W( 2 ) )
V( 3 ) = BETA2*( A( 3, 1 )*W( 1 )+A( 3, 2 )*W( 2 ) )-SR2*( B( 3,
$ 1 )*W( 1 )+B( 3, 2 )*W( 2 ) )
*
* Account for imaginary part
*
V( 1 ) = V( 1 )+SI*SI*B( 1, 1 )/SCALE1/SCALE2
*
* Check for overflow
*
IF( ABS( V( 1 ) ).GT.SAFMAX .OR. ABS( V( 2 ) ) .GT. SAFMAX .OR.
$ ABS( V( 3 ) ).GT.SAFMAX .OR. DISNAN( V( 1 ) ) .OR.
$ DISNAN( V( 2 ) ) .OR. DISNAN( V( 3 ) ) ) THEN
V( 1 ) = ZERO
V( 2 ) = ZERO
V( 3 ) = ZERO
END IF
*
* End of DLAQZ1
*
END SUBROUTINE