LAPACK 3.12.1
LAPACK: Linear Algebra PACKage
Loading...
Searching...
No Matches

◆ slaqz4()

subroutine slaqz4 ( logical, intent(in) ilschur,
logical, intent(in) ilq,
logical, intent(in) ilz,
integer, intent(in) n,
integer, intent(in) ilo,
integer, intent(in) ihi,
integer, intent(in) nshifts,
integer, intent(in) nblock_desired,
real, dimension( * ), intent(inout) sr,
real, dimension( * ), intent(inout) si,
real, dimension( * ), intent(inout) ss,
real, dimension( lda, * ), intent(inout) a,
integer, intent(in) lda,
real, dimension( ldb, * ), intent(inout) b,
integer, intent(in) ldb,
real, dimension( ldq, * ), intent(inout) q,
integer, intent(in) ldq,
real, dimension( ldz, * ), intent(inout) z,
integer, intent(in) ldz,
real, dimension( ldqc, * ), intent(inout) qc,
integer, intent(in) ldqc,
real, dimension( ldzc, * ), intent(inout) zc,
integer, intent(in) ldzc,
real, dimension( * ), intent(inout) work,
integer, intent(in) lwork,
integer, intent(out) info )

SLAQZ4

Download SLAQZ4 + dependencies [TGZ] [ZIP] [TXT]

Purpose:
!>
!> SLAQZ4 Executes a single multishift QZ sweep
!> 
Parameters
[in]ILSCHUR
!>          ILSCHUR is LOGICAL
!>              Determines whether or not to update the full Schur form
!> 
[in]ILQ
!>          ILQ is LOGICAL
!>              Determines whether or not to update the matrix Q
!> 
[in]ILZ
!>          ILZ is LOGICAL
!>              Determines whether or not to update the matrix Z
!> 
[in]N
!>          N is INTEGER
!>          The order of the matrices A, B, Q, and Z.  N >= 0.
!> 
[in]ILO
!>          ILO is INTEGER
!> 
[in]IHI
!>          IHI is INTEGER
!> 
[in]NSHIFTS
!>          NSHIFTS is INTEGER
!>          The desired number of shifts to use
!> 
[in]NBLOCK_DESIRED
!>          NBLOCK_DESIRED is INTEGER
!>          The desired size of the computational windows
!> 
[in]SR
!>          SR is REAL array. SR contains
!>          the real parts of the shifts to use.
!> 
[in]SI
!>          SI is REAL array. SI contains
!>          the imaginary parts of the shifts to use.
!> 
[in]SS
!>          SS is REAL array. SS contains
!>          the scale of the shifts to use.
!> 
[in,out]A
!>          A is REAL array, dimension (LDA, N)
!> 
[in]LDA
!>          LDA is INTEGER
!>          The leading dimension of the array A.  LDA >= max( 1, N ).
!> 
[in,out]B
!>          B is REAL array, dimension (LDB, N)
!> 
[in]LDB
!>          LDB is INTEGER
!>          The leading dimension of the array B.  LDB >= max( 1, N ).
!> 
[in,out]Q
!>          Q is REAL array, dimension (LDQ, N)
!> 
[in]LDQ
!>          LDQ is INTEGER
!> 
[in,out]Z
!>          Z is REAL array, dimension (LDZ, N)
!> 
[in]LDZ
!>          LDZ is INTEGER
!> 
[in,out]QC
!>          QC is REAL array, dimension (LDQC, NBLOCK_DESIRED)
!> 
[in]LDQC
!>          LDQC is INTEGER
!> 
[in,out]ZC
!>          ZC is REAL array, dimension (LDZC, NBLOCK_DESIRED)
!> 
[in]LDZC
!>          LDZ is INTEGER
!> 
[out]WORK
!>          WORK is REAL array, dimension (MAX(1,LWORK))
!>          On exit, if INFO >= 0, WORK(1) returns the optimal LWORK.
!> 
[in]LWORK
!>          LWORK is INTEGER
!>          The dimension of the array WORK.  LWORK >= max(1,N).
!>
!>          If LWORK = -1, then a workspace query is assumed; the routine
!>          only calculates the optimal size of the WORK array, returns
!>          this value as the first entry of the WORK array, and no error
!>          message related to LWORK is issued by XERBLA.
!> 
[out]INFO
!>          INFO is INTEGER
!>          = 0: successful exit
!>          < 0: if INFO = -i, the i-th argument had an illegal value
!> 
Author
Thijs Steel, KU Leuven
Date
May 2020

Definition at line 208 of file slaqz4.f.

212 IMPLICIT NONE
213
214* Function arguments
215 LOGICAL, INTENT( IN ) :: ILSCHUR, ILQ, ILZ
216 INTEGER, INTENT( IN ) :: N, ILO, IHI, LDA, LDB, LDQ, LDZ, LWORK,
217 $ NSHIFTS, NBLOCK_DESIRED, LDQC, LDZC
218
219 REAL, INTENT( INOUT ) :: A( LDA, * ), B( LDB, * ), Q( LDQ, * ),
220 $ Z( LDZ, * ), QC( LDQC, * ), ZC( LDZC, * ), WORK( * ), SR( * ),
221 $ SI( * ), SS( * )
222
223 INTEGER, INTENT( OUT ) :: INFO
224
225* Parameters
226 REAL :: ZERO, ONE, HALF
227 parameter( zero = 0.0, one = 1.0, half = 0.5 )
228
229* Local scalars
230 INTEGER :: I, J, NS, ISTARTM, ISTOPM, SHEIGHT, SWIDTH, K, NP,
231 $ ISTARTB, ISTOPB, ISHIFT, NBLOCK, NPOS
232 REAL :: TEMP, V( 3 ), C1, S1, C2, S2, SWAP
233*
234* External functions
235 EXTERNAL :: xerbla, sgemm, slaqz1, slaqz2, slaset, slartg, srot,
236 $ slacpy
237 REAL, EXTERNAL :: SROUNDUP_LWORK
238
239 info = 0
240 IF ( nblock_desired .LT. nshifts+1 ) THEN
241 info = -8
242 END IF
243 IF ( lwork .EQ.-1 ) THEN
244* workspace query, quick return
245 work( 1 ) = sroundup_lwork(n*nblock_desired)
246 RETURN
247 ELSE IF ( lwork .LT. n*nblock_desired ) THEN
248 info = -25
249 END IF
250
251 IF( info.NE.0 ) THEN
252 CALL xerbla( 'SLAQZ4', -info )
253 RETURN
254 END IF
255
256* Executable statements
257
258 IF ( nshifts .LT. 2 ) THEN
259 RETURN
260 END IF
261
262 IF ( ilo .GE. ihi ) THEN
263 RETURN
264 END IF
265
266 IF ( ilschur ) THEN
267 istartm = 1
268 istopm = n
269 ELSE
270 istartm = ilo
271 istopm = ihi
272 END IF
273
274* Shuffle shifts into pairs of real shifts and pairs
275* of complex conjugate shifts assuming complex
276* conjugate shifts are already adjacent to one
277* another
278
279 DO i = 1, nshifts-2, 2
280 IF( si( i ).NE.-si( i+1 ) ) THEN
281*
282 swap = sr( i )
283 sr( i ) = sr( i+1 )
284 sr( i+1 ) = sr( i+2 )
285 sr( i+2 ) = swap
286
287 swap = si( i )
288 si( i ) = si( i+1 )
289 si( i+1 ) = si( i+2 )
290 si( i+2 ) = swap
291
292 swap = ss( i )
293 ss( i ) = ss( i+1 )
294 ss( i+1 ) = ss( i+2 )
295 ss( i+2 ) = swap
296 END IF
297 END DO
298
299* NSHFTS is supposed to be even, but if it is odd,
300* then simply reduce it by one. The shuffle above
301* ensures that the dropped shift is real and that
302* the remaining shifts are paired.
303
304 ns = nshifts-mod( nshifts, 2 )
305 npos = max( nblock_desired-ns, 1 )
306
307* The following block introduces the shifts and chases
308* them down one by one just enough to make space for
309* the other shifts. The near-the-diagonal block is
310* of size (ns+1) x ns.
311
312 CALL slaset( 'FULL', ns+1, ns+1, zero, one, qc, ldqc )
313 CALL slaset( 'FULL', ns, ns, zero, one, zc, ldzc )
314
315 DO i = 1, ns, 2
316* Introduce the shift
317 CALL slaqz1( a( ilo, ilo ), lda, b( ilo, ilo ), ldb,
318 $ sr( i ),
319 $ sr( i+1 ), si( i ), ss( i ), ss( i+1 ), v )
320
321 temp = v( 2 )
322 CALL slartg( temp, v( 3 ), c1, s1, v( 2 ) )
323 CALL slartg( v( 1 ), v( 2 ), c2, s2, temp )
324
325 CALL srot( ns, a( ilo+1, ilo ), lda, a( ilo+2, ilo ), lda,
326 $ c1,
327 $ s1 )
328 CALL srot( ns, a( ilo, ilo ), lda, a( ilo+1, ilo ), lda, c2,
329 $ s2 )
330 CALL srot( ns, b( ilo+1, ilo ), ldb, b( ilo+2, ilo ), ldb,
331 $ c1,
332 $ s1 )
333 CALL srot( ns, b( ilo, ilo ), ldb, b( ilo+1, ilo ), ldb, c2,
334 $ s2 )
335 CALL srot( ns+1, qc( 1, 2 ), 1, qc( 1, 3 ), 1, c1, s1 )
336 CALL srot( ns+1, qc( 1, 1 ), 1, qc( 1, 2 ), 1, c2, s2 )
337
338* Chase the shift down
339 DO j = 1, ns-1-i
340
341 CALL slaqz2( .true., .true., j, 1, ns, ihi-ilo+1, a( ilo,
342 $ ilo ), lda, b( ilo, ilo ), ldb, ns+1, 1, qc,
343 $ ldqc, ns, 1, zc, ldzc )
344
345 END DO
346
347 END DO
348
349* Update the rest of the pencil
350
351* Update A(ilo:ilo+ns,ilo+ns:istopm) and B(ilo:ilo+ns,ilo+ns:istopm)
352* from the left with Qc(1:ns+1,1:ns+1)'
353 sheight = ns+1
354 swidth = istopm-( ilo+ns )+1
355 IF ( swidth > 0 ) THEN
356 CALL sgemm( 'T', 'N', sheight, swidth, sheight, one, qc,
357 $ ldqc,
358 $ a( ilo, ilo+ns ), lda, zero, work, sheight )
359 CALL slacpy( 'ALL', sheight, swidth, work, sheight, a( ilo,
360 $ ilo+ns ), lda )
361 CALL sgemm( 'T', 'N', sheight, swidth, sheight, one, qc,
362 $ ldqc,
363 $ b( ilo, ilo+ns ), ldb, zero, work, sheight )
364 CALL slacpy( 'ALL', sheight, swidth, work, sheight, b( ilo,
365 $ ilo+ns ), ldb )
366 END IF
367 IF ( ilq ) THEN
368 CALL sgemm( 'N', 'N', n, sheight, sheight, one, q( 1, ilo ),
369 $ ldq, qc, ldqc, zero, work, n )
370 CALL slacpy( 'ALL', n, sheight, work, n, q( 1, ilo ), ldq )
371 END IF
372
373* Update A(istartm:ilo-1,ilo:ilo+ns-1) and B(istartm:ilo-1,ilo:ilo+ns-1)
374* from the right with Zc(1:ns,1:ns)
375 sheight = ilo-1-istartm+1
376 swidth = ns
377 IF ( sheight > 0 ) THEN
378 CALL sgemm( 'N', 'N', sheight, swidth, swidth, one,
379 $ a( istartm,
380 $ ilo ), lda, zc, ldzc, zero, work, sheight )
381 CALL slacpy( 'ALL', sheight, swidth, work, sheight,
382 $ a( istartm,
383 $ ilo ), lda )
384 CALL sgemm( 'N', 'N', sheight, swidth, swidth, one,
385 $ b( istartm,
386 $ ilo ), ldb, zc, ldzc, zero, work, sheight )
387 CALL slacpy( 'ALL', sheight, swidth, work, sheight,
388 $ b( istartm,
389 $ ilo ), ldb )
390 END IF
391 IF ( ilz ) THEN
392 CALL sgemm( 'N', 'N', n, swidth, swidth, one, z( 1, ilo ),
393 $ ldz,
394 $ zc, ldzc, zero, work, n )
395 CALL slacpy( 'ALL', n, swidth, work, n, z( 1, ilo ), ldz )
396 END IF
397
398* The following block chases the shifts down to the bottom
399* right block. If possible, a shift is moved down npos
400* positions at a time
401
402 k = ilo
403 DO WHILE ( k < ihi-ns )
404 np = min( ihi-ns-k, npos )
405* Size of the near-the-diagonal block
406 nblock = ns+np
407* istartb points to the first row we will be updating
408 istartb = k+1
409* istopb points to the last column we will be updating
410 istopb = k+nblock-1
411
412 CALL slaset( 'FULL', ns+np, ns+np, zero, one, qc, ldqc )
413 CALL slaset( 'FULL', ns+np, ns+np, zero, one, zc, ldzc )
414
415* Near the diagonal shift chase
416 DO i = ns-1, 0, -2
417 DO j = 0, np-1
418* Move down the block with index k+i+j-1, updating
419* the (ns+np x ns+np) block:
420* (k:k+ns+np,k:k+ns+np-1)
421 CALL slaqz2( .true., .true., k+i+j-1, istartb, istopb,
422 $ ihi, a, lda, b, ldb, nblock, k+1, qc, ldqc,
423 $ nblock, k, zc, ldzc )
424 END DO
425 END DO
426
427* Update rest of the pencil
428
429* Update A(k+1:k+ns+np, k+ns+np:istopm) and
430* B(k+1:k+ns+np, k+ns+np:istopm)
431* from the left with Qc(1:ns+np,1:ns+np)'
432 sheight = ns+np
433 swidth = istopm-( k+ns+np )+1
434 IF ( swidth > 0 ) THEN
435 CALL sgemm( 'T', 'N', sheight, swidth, sheight, one, qc,
436 $ ldqc, a( k+1, k+ns+np ), lda, zero, work,
437 $ sheight )
438 CALL slacpy( 'ALL', sheight, swidth, work, sheight,
439 $ a( k+1,
440 $ k+ns+np ), lda )
441 CALL sgemm( 'T', 'N', sheight, swidth, sheight, one, qc,
442 $ ldqc, b( k+1, k+ns+np ), ldb, zero, work,
443 $ sheight )
444 CALL slacpy( 'ALL', sheight, swidth, work, sheight,
445 $ b( k+1,
446 $ k+ns+np ), ldb )
447 END IF
448 IF ( ilq ) THEN
449 CALL sgemm( 'N', 'N', n, nblock, nblock, one, q( 1,
450 $ k+1 ),
451 $ ldq, qc, ldqc, zero, work, n )
452 CALL slacpy( 'ALL', n, nblock, work, n, q( 1, k+1 ),
453 $ ldq )
454 END IF
455
456* Update A(istartm:k,k:k+ns+npos-1) and B(istartm:k,k:k+ns+npos-1)
457* from the right with Zc(1:ns+np,1:ns+np)
458 sheight = k-istartm+1
459 swidth = nblock
460 IF ( sheight > 0 ) THEN
461 CALL sgemm( 'N', 'N', sheight, swidth, swidth, one,
462 $ a( istartm, k ), lda, zc, ldzc, zero, work,
463 $ sheight )
464 CALL slacpy( 'ALL', sheight, swidth, work, sheight,
465 $ a( istartm, k ), lda )
466 CALL sgemm( 'N', 'N', sheight, swidth, swidth, one,
467 $ b( istartm, k ), ldb, zc, ldzc, zero, work,
468 $ sheight )
469 CALL slacpy( 'ALL', sheight, swidth, work, sheight,
470 $ b( istartm, k ), ldb )
471 END IF
472 IF ( ilz ) THEN
473 CALL sgemm( 'N', 'N', n, nblock, nblock, one, z( 1, k ),
474 $ ldz, zc, ldzc, zero, work, n )
475 CALL slacpy( 'ALL', n, nblock, work, n, z( 1, k ), ldz )
476 END IF
477
478 k = k+np
479
480 END DO
481
482* The following block removes the shifts from the bottom right corner
483* one by one. Updates are initially applied to A(ihi-ns+1:ihi,ihi-ns:ihi).
484
485 CALL slaset( 'FULL', ns, ns, zero, one, qc, ldqc )
486 CALL slaset( 'FULL', ns+1, ns+1, zero, one, zc, ldzc )
487
488* istartb points to the first row we will be updating
489 istartb = ihi-ns+1
490* istopb points to the last column we will be updating
491 istopb = ihi
492
493 DO i = 1, ns, 2
494* Chase the shift down to the bottom right corner
495 DO ishift = ihi-i-1, ihi-2
496 CALL slaqz2( .true., .true., ishift, istartb, istopb,
497 $ ihi,
498 $ a, lda, b, ldb, ns, ihi-ns+1, qc, ldqc, ns+1,
499 $ ihi-ns, zc, ldzc )
500 END DO
501
502 END DO
503
504* Update rest of the pencil
505
506* Update A(ihi-ns+1:ihi, ihi+1:istopm)
507* from the left with Qc(1:ns,1:ns)'
508 sheight = ns
509 swidth = istopm-( ihi+1 )+1
510 IF ( swidth > 0 ) THEN
511 CALL sgemm( 'T', 'N', sheight, swidth, sheight, one, qc,
512 $ ldqc,
513 $ a( ihi-ns+1, ihi+1 ), lda, zero, work, sheight )
514 CALL slacpy( 'ALL', sheight, swidth, work, sheight,
515 $ a( ihi-ns+1, ihi+1 ), lda )
516 CALL sgemm( 'T', 'N', sheight, swidth, sheight, one, qc,
517 $ ldqc,
518 $ b( ihi-ns+1, ihi+1 ), ldb, zero, work, sheight )
519 CALL slacpy( 'ALL', sheight, swidth, work, sheight,
520 $ b( ihi-ns+1, ihi+1 ), ldb )
521 END IF
522 IF ( ilq ) THEN
523 CALL sgemm( 'N', 'N', n, ns, ns, one, q( 1, ihi-ns+1 ), ldq,
524 $ qc, ldqc, zero, work, n )
525 CALL slacpy( 'ALL', n, ns, work, n, q( 1, ihi-ns+1 ), ldq )
526 END IF
527
528* Update A(istartm:ihi-ns,ihi-ns:ihi)
529* from the right with Zc(1:ns+1,1:ns+1)
530 sheight = ihi-ns-istartm+1
531 swidth = ns+1
532 IF ( sheight > 0 ) THEN
533 CALL sgemm( 'N', 'N', sheight, swidth, swidth, one,
534 $ a( istartm,
535 $ ihi-ns ), lda, zc, ldzc, zero, work, sheight )
536 CALL slacpy( 'ALL', sheight, swidth, work, sheight,
537 $ a( istartm,
538 $ ihi-ns ), lda )
539 CALL sgemm( 'N', 'N', sheight, swidth, swidth, one,
540 $ b( istartm,
541 $ ihi-ns ), ldb, zc, ldzc, zero, work, sheight )
542 CALL slacpy( 'ALL', sheight, swidth, work, sheight,
543 $ b( istartm,
544 $ ihi-ns ), ldb )
545 END IF
546 IF ( ilz ) THEN
547 CALL sgemm( 'N', 'N', n, ns+1, ns+1, one, z( 1, ihi-ns ), ldz,
548 $ zc,
549 $ ldzc, zero, work, n )
550 CALL slacpy( 'ALL', n, ns+1, work, n, z( 1, ihi-ns ), ldz )
551 END IF
552
subroutine xerbla(srname, info)
Definition cblat2.f:3285
subroutine sgemm(transa, transb, m, n, k, alpha, a, lda, b, ldb, beta, c, ldc)
SGEMM
Definition sgemm.f:188
subroutine slacpy(uplo, m, n, a, lda, b, ldb)
SLACPY copies all or part of one two-dimensional array to another.
Definition slacpy.f:101
subroutine slaqz1(a, lda, b, ldb, sr1, sr2, si, beta1, beta2, v)
SLAQZ1
Definition slaqz1.f:125
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 slaset(uplo, m, n, alpha, beta, a, lda)
SLASET initializes the off-diagonal elements and the diagonal elements of a matrix to given values.
Definition slaset.f:108
subroutine srot(n, sx, incx, sy, incy, c, s)
SROT
Definition srot.f:92
real function sroundup_lwork(lwork)
SROUNDUP_LWORK
Here is the call graph for this function:
Here is the caller graph for this function: