LAPACK 3.12.1
LAPACK: Linear Algebra PACKage
Loading...
Searching...
No Matches
slaqz2.f
Go to the documentation of this file.
1*> \brief \b SLAQZ2
2*
3* =========== DOCUMENTATION ===========
4*
5* Online html documentation available at
6* http://www.netlib.org/lapack/explore-html/
7*
8*> Download SLAQZ2 + dependencies
9*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/slaqz2.f">
10*> [TGZ]</a>
11*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/slaqz2.f">
12*> [ZIP]</a>
13*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/slaqz2.f">
14*> [TXT]</a>
15*
16* Definition:
17* ===========
18*
19* SUBROUTINE SLAQZ2( ILQ, ILZ, K, ISTARTM, ISTOPM, IHI, A, LDA, B,
20* $ LDB, NQ, QSTART, Q, LDQ, NZ, ZSTART, Z, LDZ )
21* IMPLICIT NONE
22*
23* Arguments
24* LOGICAL, INTENT( IN ) :: ILQ, ILZ
25* INTEGER, INTENT( IN ) :: K, LDA, LDB, LDQ, LDZ, ISTARTM, ISTOPM,
26* $ NQ, NZ, QSTART, ZSTART, IHI
27* REAL :: A( LDA, * ), B( LDB, * ), Q( LDQ, * ), Z( LDZ, * )
28* ..
29*
30*
31*> \par Purpose:
32* =============
33*>
34*> \verbatim
35*>
36*> SLAQZ2 chases a 2x2 shift bulge in a matrix pencil down a single position
37*> \endverbatim
38*
39*
40* Arguments:
41* ==========
42*
43*>
44*> \param[in] ILQ
45*> \verbatim
46*> ILQ is LOGICAL
47*> Determines whether or not to update the matrix Q
48*> \endverbatim
49*>
50*> \param[in] ILZ
51*> \verbatim
52*> ILZ is LOGICAL
53*> Determines whether or not to update the matrix Z
54*> \endverbatim
55*>
56*> \param[in] K
57*> \verbatim
58*> K is INTEGER
59*> Index indicating the position of the bulge.
60*> On entry, the bulge is located in
61*> (A(k+1:k+2,k:k+1),B(k+1:k+2,k:k+1)).
62*> On exit, the bulge is located in
63*> (A(k+2:k+3,k+1:k+2),B(k+2:k+3,k+1:k+2)).
64*> \endverbatim
65*>
66*> \param[in] ISTARTM
67*> \verbatim
68*> ISTARTM is INTEGER
69*> \endverbatim
70*>
71*> \param[in] ISTOPM
72*> \verbatim
73*> ISTOPM is INTEGER
74*> Updates to (A,B) are restricted to
75*> (istartm:k+3,k:istopm). It is assumed
76*> without checking that istartm <= k+1 and
77*> k+2 <= istopm
78*> \endverbatim
79*>
80*> \param[in] IHI
81*> \verbatim
82*> IHI is INTEGER
83*> \endverbatim
84*>
85*> \param[inout] A
86*> \verbatim
87*> A is REAL array, dimension (LDA,N)
88*> \endverbatim
89*>
90*> \param[in] LDA
91*> \verbatim
92*> LDA is INTEGER
93*> The leading dimension of A as declared in
94*> the calling procedure.
95*> \endverbatim
96*
97*> \param[inout] B
98*> \verbatim
99*> B is REAL array, dimension (LDB,N)
100*> \endverbatim
101*>
102*> \param[in] LDB
103*> \verbatim
104*> LDB is INTEGER
105*> The leading dimension of B as declared in
106*> the calling procedure.
107*> \endverbatim
108*>
109*> \param[in] NQ
110*> \verbatim
111*> NQ is INTEGER
112*> The order of the matrix Q
113*> \endverbatim
114*>
115*> \param[in] QSTART
116*> \verbatim
117*> QSTART is INTEGER
118*> Start index of the matrix Q. Rotations are applied
119*> To columns k+2-qStart:k+4-qStart of Q.
120*> \endverbatim
121*
122*> \param[inout] Q
123*> \verbatim
124*> Q is REAL array, dimension (LDQ,NQ)
125*> \endverbatim
126*>
127*> \param[in] LDQ
128*> \verbatim
129*> LDQ is INTEGER
130*> The leading dimension of Q as declared in
131*> the calling procedure.
132*> \endverbatim
133*>
134*> \param[in] NZ
135*> \verbatim
136*> NZ is INTEGER
137*> The order of the matrix Z
138*> \endverbatim
139*>
140*> \param[in] ZSTART
141*> \verbatim
142*> ZSTART is INTEGER
143*> Start index of the matrix Z. Rotations are applied
144*> To columns k+1-qStart:k+3-qStart of Z.
145*> \endverbatim
146*
147*> \param[inout] Z
148*> \verbatim
149*> Z is REAL array, dimension (LDZ,NZ)
150*> \endverbatim
151*>
152*> \param[in] LDZ
153*> \verbatim
154*> LDZ is INTEGER
155*> The leading dimension of Q as declared in
156*> the calling procedure.
157*> \endverbatim
158*
159* Authors:
160* ========
161*
162*> \author Thijs Steel, KU Leuven
163*
164*> \date May 2020
165*
166*> \ingroup laqz2
167*>
168* =====================================================================
169 SUBROUTINE slaqz2( ILQ, ILZ, K, ISTARTM, ISTOPM, IHI, A, LDA,
170 $ B,
171 $ LDB, NQ, QSTART, Q, LDQ, NZ, ZSTART, Z, LDZ )
172 IMPLICIT NONE
173*
174* Arguments
175 LOGICAL, INTENT( IN ) :: ILQ, ILZ
176 INTEGER, INTENT( IN ) :: K, LDA, LDB, LDQ, LDZ, ISTARTM, ISTOPM,
177 $ nq, nz, qstart, zstart, ihi
178 REAL :: A( LDA, * ), B( LDB, * ), Q( LDQ, * ), Z( LDZ, * )
179*
180* Parameters
181 REAL :: ZERO, ONE, HALF
182 PARAMETER( ZERO = 0.0, one = 1.0, half = 0.5 )
183*
184* Local variables
185 REAL :: H( 2, 3 ), C1, S1, C2, S2, TEMP
186*
187* External functions
188 EXTERNAL :: slartg, srot
189*
190 IF( k+2 .EQ. ihi ) THEN
191* Shift is located on the edge of the matrix, remove it
192 h = b( ihi-1:ihi, ihi-2:ihi )
193* Make H upper triangular
194 CALL slartg( h( 1, 1 ), h( 2, 1 ), c1, s1, temp )
195 h( 2, 1 ) = zero
196 h( 1, 1 ) = temp
197 CALL srot( 2, h( 1, 2 ), 2, h( 2, 2 ), 2, c1, s1 )
198*
199 CALL slartg( h( 2, 3 ), h( 2, 2 ), c1, s1, temp )
200 CALL srot( 1, h( 1, 3 ), 1, h( 1, 2 ), 1, c1, s1 )
201 CALL slartg( h( 1, 2 ), h( 1, 1 ), c2, s2, temp )
202*
203 CALL srot( ihi-istartm+1, b( istartm, ihi ), 1, b( istartm,
204 $ ihi-1 ), 1, c1, s1 )
205 CALL srot( ihi-istartm+1, b( istartm, ihi-1 ), 1,
206 $ b( istartm,
207 $ ihi-2 ), 1, c2, s2 )
208 b( ihi-1, ihi-2 ) = zero
209 b( ihi, ihi-2 ) = zero
210 CALL srot( ihi-istartm+1, a( istartm, ihi ), 1, a( istartm,
211 $ ihi-1 ), 1, c1, s1 )
212 CALL srot( ihi-istartm+1, a( istartm, ihi-1 ), 1,
213 $ a( istartm,
214 $ ihi-2 ), 1, c2, s2 )
215 IF ( ilz ) THEN
216 CALL srot( nz, z( 1, ihi-zstart+1 ), 1, z( 1,
217 $ ihi-1-zstart+
218 $ 1 ), 1, c1, s1 )
219 CALL srot( nz, z( 1, ihi-1-zstart+1 ), 1, z( 1,
220 $ ihi-2-zstart+1 ), 1, c2, s2 )
221 END IF
222*
223 CALL slartg( a( ihi-1, ihi-2 ), a( ihi, ihi-2 ), c1, s1,
224 $ temp )
225 a( ihi-1, ihi-2 ) = temp
226 a( ihi, ihi-2 ) = zero
227 CALL srot( istopm-ihi+2, a( ihi-1, ihi-1 ), lda, a( ihi,
228 $ ihi-1 ), lda, c1, s1 )
229 CALL srot( istopm-ihi+2, b( ihi-1, ihi-1 ), ldb, b( ihi,
230 $ ihi-1 ), ldb, c1, s1 )
231 IF ( ilq ) THEN
232 CALL srot( nq, q( 1, ihi-1-qstart+1 ), 1, q( 1,
233 $ ihi-qstart+
234 $ 1 ), 1, c1, s1 )
235 END IF
236*
237 CALL slartg( b( ihi, ihi ), b( ihi, ihi-1 ), c1, s1, temp )
238 b( ihi, ihi ) = temp
239 b( ihi, ihi-1 ) = zero
240 CALL srot( ihi-istartm, b( istartm, ihi ), 1, b( istartm,
241 $ ihi-1 ), 1, c1, s1 )
242 CALL srot( ihi-istartm+1, a( istartm, ihi ), 1, a( istartm,
243 $ ihi-1 ), 1, c1, s1 )
244 IF ( ilz ) THEN
245 CALL srot( nz, z( 1, ihi-zstart+1 ), 1, z( 1,
246 $ ihi-1-zstart+
247 $ 1 ), 1, c1, s1 )
248 END IF
249*
250 ELSE
251*
252* Normal operation, move bulge down
253*
254 h = b( k+1:k+2, k:k+2 )
255*
256* Make H upper triangular
257*
258 CALL slartg( h( 1, 1 ), h( 2, 1 ), c1, s1, temp )
259 h( 2, 1 ) = zero
260 h( 1, 1 ) = temp
261 CALL srot( 2, h( 1, 2 ), 2, h( 2, 2 ), 2, c1, s1 )
262*
263* Calculate Z1 and Z2
264*
265 CALL slartg( h( 2, 3 ), h( 2, 2 ), c1, s1, temp )
266 CALL srot( 1, h( 1, 3 ), 1, h( 1, 2 ), 1, c1, s1 )
267 CALL slartg( h( 1, 2 ), h( 1, 1 ), c2, s2, temp )
268*
269* Apply transformations from the right
270*
271 CALL srot( k+3-istartm+1, a( istartm, k+2 ), 1, a( istartm,
272 $ k+1 ), 1, c1, s1 )
273 CALL srot( k+3-istartm+1, a( istartm, k+1 ), 1, a( istartm,
274 $ k ), 1, c2, s2 )
275 CALL srot( k+2-istartm+1, b( istartm, k+2 ), 1, b( istartm,
276 $ k+1 ), 1, c1, s1 )
277 CALL srot( k+2-istartm+1, b( istartm, k+1 ), 1, b( istartm,
278 $ k ), 1, c2, s2 )
279 IF ( ilz ) THEN
280 CALL srot( nz, z( 1, k+2-zstart+1 ), 1, z( 1, k+1-zstart+
281 $ 1 ), 1, c1, s1 )
282 CALL srot( nz, z( 1, k+1-zstart+1 ), 1, z( 1,
283 $ k-zstart+1 ),
284 $ 1, c2, s2 )
285 END IF
286 b( k+1, k ) = zero
287 b( k+2, k ) = zero
288*
289* Calculate Q1 and Q2
290*
291 CALL slartg( a( k+2, k ), a( k+3, k ), c1, s1, temp )
292 a( k+2, k ) = temp
293 a( k+3, k ) = zero
294 CALL slartg( a( k+1, k ), a( k+2, k ), c2, s2, temp )
295 a( k+1, k ) = temp
296 a( k+2, k ) = zero
297*
298* Apply transformations from the left
299*
300 CALL srot( istopm-k, a( k+2, k+1 ), lda, a( k+3, k+1 ), lda,
301 $ c1, s1 )
302 CALL srot( istopm-k, a( k+1, k+1 ), lda, a( k+2, k+1 ), lda,
303 $ c2, s2 )
304*
305 CALL srot( istopm-k, b( k+2, k+1 ), ldb, b( k+3, k+1 ), ldb,
306 $ c1, s1 )
307 CALL srot( istopm-k, b( k+1, k+1 ), ldb, b( k+2, k+1 ), ldb,
308 $ c2, s2 )
309 IF ( ilq ) THEN
310 CALL srot( nq, q( 1, k+2-qstart+1 ), 1, q( 1, k+3-qstart+
311 $ 1 ), 1, c1, s1 )
312 CALL srot( nq, q( 1, k+1-qstart+1 ), 1, q( 1, k+2-qstart+
313 $ 1 ), 1, c2, s2 )
314 END IF
315*
316 END IF
317*
318* End of SLAQZ2
319*
320 END SUBROUTINE
subroutine slaqz2(ilq, ilz, k, istartm, istopm, ihi, a, lda, b, ldb, nq, qstart, q, ldq, nz, zstart, z, ldz)
SLAQZ2
Definition slaqz2.f:172
subroutine slartg(f, g, c, s, r)
SLARTG generates a plane rotation with real cosine and real sine.
Definition slartg.f90:111
subroutine srot(n, sx, incx, sy, incy, c, s)
SROT
Definition srot.f:92