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

◆ dsytrd_sb2st()

subroutine dsytrd_sb2st ( character stage1,
character vect,
character uplo,
integer n,
integer kd,
double precision, dimension( ldab, * ) ab,
integer ldab,
double precision, dimension( * ) d,
double precision, dimension( * ) e,
double precision, dimension( * ) hous,
integer lhous,
double precision, dimension( * ) work,
integer lwork,
integer info )

DSYTRD_SB2ST reduces a real symmetric band matrix A to real symmetric tridiagonal form T

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

Purpose:
!>
!> DSYTRD_SB2ST reduces a real symmetric band matrix A to real symmetric
!> tridiagonal form T by a orthogonal similarity transformation:
!> Q**T * A * Q = T.
!> 
Parameters
[in]STAGE1
!>          STAGE1 is CHARACTER*1
!>          = 'N':  : to mention that the stage 1 of the reduction
!>                  from dense to band using the dsytrd_sy2sb routine
!>                  was not called before this routine to reproduce AB.
!>                  In other term this routine is called as standalone.
!>          = 'Y':  : to mention that the stage 1 of the
!>                  reduction from dense to band using the dsytrd_sy2sb
!>                  routine has been called to produce AB (e.g., AB is
!>                  the output of dsytrd_sy2sb.
!> 
[in]VECT
!>          VECT is CHARACTER*1
!>          = 'N':  No need for the Housholder representation,
!>                  and thus LHOUS is of size max(1, 4*N);
!>          = 'V':  the Householder representation is needed to
!>                  either generate or to apply Q later on,
!>                  then LHOUS is to be queried and computed.
!>                  (NOT AVAILABLE IN THIS RELEASE).
!> 
[in]UPLO
!>          UPLO is CHARACTER*1
!>          = 'U':  Upper triangle of A is stored;
!>          = 'L':  Lower triangle of A is stored.
!> 
[in]N
!>          N is INTEGER
!>          The order of the matrix A.  N >= 0.
!> 
[in]KD
!>          KD is INTEGER
!>          The number of superdiagonals of the matrix A if UPLO = 'U',
!>          or the number of subdiagonals if UPLO = 'L'.  KD >= 0.
!> 
[in,out]AB
!>          AB is DOUBLE PRECISION array, dimension (LDAB,N)
!>          On entry, the upper or lower triangle of the symmetric band
!>          matrix A, stored in the first KD+1 rows of the array.  The
!>          j-th column of A is stored in the j-th column of the array AB
!>          as follows:
!>          if UPLO = 'U', AB(kd+1+i-j,j) = A(i,j) for max(1,j-kd)<=i<=j;
!>          if UPLO = 'L', AB(1+i-j,j)    = A(i,j) for j<=i<=min(n,j+kd).
!>          On exit, the diagonal elements of AB are overwritten by the
!>          diagonal elements of the tridiagonal matrix T; if KD > 0, the
!>          elements on the first superdiagonal (if UPLO = 'U') or the
!>          first subdiagonal (if UPLO = 'L') are overwritten by the
!>          off-diagonal elements of T; the rest of AB is overwritten by
!>          values generated during the reduction.
!> 
[in]LDAB
!>          LDAB is INTEGER
!>          The leading dimension of the array AB.  LDAB >= KD+1.
!> 
[out]D
!>          D is DOUBLE PRECISION array, dimension (N)
!>          The diagonal elements of the tridiagonal matrix T.
!> 
[out]E
!>          E is DOUBLE PRECISION array, dimension (N-1)
!>          The off-diagonal elements of the tridiagonal matrix T:
!>          E(i) = T(i,i+1) if UPLO = 'U'; E(i) = T(i+1,i) if UPLO = 'L'.
!> 
[out]HOUS
!>          HOUS is DOUBLE PRECISION array, dimension (MAX(1,LHOUS))
!>          Stores the Householder representation.
!> 
[in]LHOUS
!>          LHOUS is INTEGER
!>          The dimension of the array HOUS.
!>          If N = 0 or KD <= 1, LHOUS >= 1, else LHOUS = MAX(1, dimension).
!>
!>          If LWORK = -1, or LHOUS = -1,
!>          then a query is assumed; the routine
!>          only calculates the optimal size of the HOUS array, returns
!>          this value as the first entry of the HOUS array, and no error
!>          message related to LHOUS is issued by XERBLA.
!>          LHOUS = MAX(1, dimension) where
!>          dimension = 4*N if VECT='N'
!>          not available now if VECT='H'
!> 
[out]WORK
!>          WORK is DOUBLE PRECISION 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.
!>          If N = 0 or KD <= 1, LWORK >= 1, else LWORK = MAX(1, dimension).
!>
!>          If LWORK = -1, or LHOUS = -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.
!>          LWORK = MAX(1, dimension) where
!>          dimension   = (2KD+1)*N + KD*NTHREADS
!>          where KD is the blocking size of the reduction,
!>          FACTOPTNB is the blocking used by the QR or LQ
!>          algorithm, usually FACTOPTNB=128 is a good choice
!>          NTHREADS is the number of threads used when
!>          openMP compilation is enabled, otherwise =1.
!> 
[out]INFO
!>          INFO is INTEGER
!>          = 0:  successful exit
!>          < 0:  if INFO = -i, the i-th argument had an illegal value
!> 
Author
Univ. of Tennessee
Univ. of California Berkeley
Univ. of Colorado Denver
NAG Ltd.
Further Details:
!>
!>  Implemented by Azzam Haidar.
!>
!>  All details are available on technical report, SC11, SC13 papers.
!>
!>  Azzam Haidar, Hatem Ltaief, and Jack Dongarra.
!>  Parallel reduction to condensed forms for symmetric eigenvalue problems
!>  using aggregated fine-grained and memory-aware kernels. In Proceedings
!>  of 2011 International Conference for High Performance Computing,
!>  Networking, Storage and Analysis (SC '11), New York, NY, USA,
!>  Article 8 , 11 pages.
!>  http://doi.acm.org/10.1145/2063384.2063394
!>
!>  A. Haidar, J. Kurzak, P. Luszczek, 2013.
!>  An improved parallel singular value algorithm and its implementation
!>  for multicore hardware, In Proceedings of 2013 International Conference
!>  for High Performance Computing, Networking, Storage and Analysis (SC '13).
!>  Denver, Colorado, USA, 2013.
!>  Article 90, 12 pages.
!>  http://doi.acm.org/10.1145/2503210.2503292
!>
!>  A. Haidar, R. Solca, S. Tomov, T. Schulthess and J. Dongarra.
!>  A novel hybrid CPU-GPU generalized eigensolver for electronic structure
!>  calculations based on fine-grained memory aware tasks.
!>  International Journal of High Performance Computing Applications.
!>  Volume 28 Issue 2, Pages 196-209, May 2014.
!>  http://hpc.sagepub.com/content/28/2/196
!>
!> 

Definition at line 231 of file dsytrd_sb2st.F.

233*
234#if defined(_OPENMP)
235 use omp_lib
236#endif
237*
238 IMPLICIT NONE
239*
240* -- LAPACK computational routine --
241* -- LAPACK is a software package provided by Univ. of Tennessee, --
242* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
243*
244* .. Scalar Arguments ..
245 CHARACTER STAGE1, UPLO, VECT
246 INTEGER N, KD, LDAB, LHOUS, LWORK, INFO
247* ..
248* .. Array Arguments ..
249 DOUBLE PRECISION D( * ), E( * )
250 DOUBLE PRECISION AB( LDAB, * ), HOUS( * ), WORK( * )
251* ..
252*
253* =====================================================================
254*
255* .. Parameters ..
256 DOUBLE PRECISION RZERO
257 DOUBLE PRECISION ZERO, ONE
258 parameter( rzero = 0.0d+0,
259 $ zero = 0.0d+0,
260 $ one = 1.0d+0 )
261* ..
262* .. Local Scalars ..
263 LOGICAL LQUERY, WANTQ, UPPER, AFTERS1
264 INTEGER I, M, K, IB, SWEEPID, MYID, SHIFT, STT, ST,
265 $ ED, STIND, EDIND, BLKLASTIND, COLPT, THED,
266 $ STEPERCOL, GRSIZ, THGRSIZ, THGRNB, THGRID,
267 $ NBTILES, TTYPE, TID, NTHREADS,
268 $ ABDPOS, ABOFDPOS, DPOS, OFDPOS, AWPOS,
269 $ INDA, INDW, APOS, SIZEA, LDA, INDV, INDTAU,
270 $ SIDEV, SIZETAU, LDV, LHMIN, LWMIN
271* ..
272* .. External Subroutines ..
273 EXTERNAL dsb2st_kernels, dlacpy,
274 $ dlaset, xerbla
275* ..
276* .. Intrinsic Functions ..
277 INTRINSIC min, max, ceiling, real
278* ..
279* .. External Functions ..
280 LOGICAL LSAME
281 INTEGER ILAENV2STAGE
282 EXTERNAL lsame, ilaenv2stage
283* ..
284* .. Executable Statements ..
285*
286* Determine the minimal workspace size required.
287* Test the input parameters
288*
289 info = 0
290 afters1 = lsame( stage1, 'Y' )
291 wantq = lsame( vect, 'V' )
292 upper = lsame( uplo, 'U' )
293 lquery = ( lwork.EQ.-1 ) .OR. ( lhous.EQ.-1 )
294*
295* Determine the block size, the workspace size and the hous size.
296*
297 ib = ilaenv2stage( 2, 'DSYTRD_SB2ST', vect, n, kd,
298 $ -1, -1 )
299 IF( n.EQ.0 .OR. kd.LE.1 ) THEN
300 lhmin = 1
301 lwmin = 1
302 ELSE
303 lhmin = ilaenv2stage( 3, 'DSYTRD_SB2ST', vect, n, kd, ib,
304 $ -1 )
305 lwmin = ilaenv2stage( 4, 'DSYTRD_SB2ST', vect, n, kd, ib,
306 $ -1 )
307 END IF
308*
309 IF( .NOT.afters1 .AND. .NOT.lsame( stage1, 'N' ) ) THEN
310 info = -1
311 ELSE IF( .NOT.lsame( vect, 'N' ) ) THEN
312 info = -2
313 ELSE IF( .NOT.upper .AND. .NOT.lsame( uplo, 'L' ) ) THEN
314 info = -3
315 ELSE IF( n.LT.0 ) THEN
316 info = -4
317 ELSE IF( kd.LT.0 ) THEN
318 info = -5
319 ELSE IF( ldab.LT.(kd+1) ) THEN
320 info = -7
321 ELSE IF( lhous.LT.lhmin .AND. .NOT.lquery ) THEN
322 info = -11
323 ELSE IF( lwork.LT.lwmin .AND. .NOT.lquery ) THEN
324 info = -13
325 END IF
326*
327 IF( info.EQ.0 ) THEN
328 hous( 1 ) = lhmin
329 work( 1 ) = lwmin
330 END IF
331*
332 IF( info.NE.0 ) THEN
333 CALL xerbla( 'DSYTRD_SB2ST', -info )
334 RETURN
335 ELSE IF( lquery ) THEN
336 RETURN
337 END IF
338*
339* Quick return if possible
340*
341 IF( n.EQ.0 ) THEN
342 hous( 1 ) = 1
343 work( 1 ) = 1
344 RETURN
345 END IF
346*
347* Determine pointer position
348*
349 ldv = kd + ib
350 sizetau = 2 * n
351 sidev = 2 * n
352 indtau = 1
353 indv = indtau + sizetau
354 lda = 2 * kd + 1
355 sizea = lda * n
356 inda = 1
357 indw = inda + sizea
358 nthreads = 1
359 tid = 0
360*
361 IF( upper ) THEN
362 apos = inda + kd
363 awpos = inda
364 dpos = apos + kd
365 ofdpos = dpos - 1
366 abdpos = kd + 1
367 abofdpos = kd
368 ELSE
369 apos = inda
370 awpos = inda + kd + 1
371 dpos = apos
372 ofdpos = dpos + 1
373 abdpos = 1
374 abofdpos = 2
375
376 ENDIF
377*
378* Case KD=0:
379* The matrix is diagonal. We just copy it (convert to "real" for
380* real because D is double and the imaginary part should be 0)
381* and store it in D. A sequential code here is better or
382* in a parallel environment it might need two cores for D and E
383*
384 IF( kd.EQ.0 ) THEN
385 DO 30 i = 1, n
386 d( i ) = ( ab( abdpos, i ) )
387 30 CONTINUE
388 DO 40 i = 1, n-1
389 e( i ) = rzero
390 40 CONTINUE
391*
392 hous( 1 ) = 1
393 work( 1 ) = 1
394 RETURN
395 END IF
396*
397* Case KD=1:
398* The matrix is already Tridiagonal. We have to make diagonal
399* and offdiagonal elements real, and store them in D and E.
400* For that, for real precision just copy the diag and offdiag
401* to D and E while for the COMPLEX case the bulge chasing is
402* performed to convert the hermetian tridiagonal to symmetric
403* tridiagonal. A simpler conversion formula might be used, but then
404* updating the Q matrix will be required and based if Q is generated
405* or not this might complicate the story.
406*
407 IF( kd.EQ.1 ) THEN
408 DO 50 i = 1, n
409 d( i ) = ( ab( abdpos, i ) )
410 50 CONTINUE
411*
412 IF( upper ) THEN
413 DO 60 i = 1, n-1
414 e( i ) = ( ab( abofdpos, i+1 ) )
415 60 CONTINUE
416 ELSE
417 DO 70 i = 1, n-1
418 e( i ) = ( ab( abofdpos, i ) )
419 70 CONTINUE
420 ENDIF
421*
422 hous( 1 ) = 1
423 work( 1 ) = 1
424 RETURN
425 END IF
426*
427* Main code start here.
428* Reduce the symmetric band of A to a tridiagonal matrix.
429*
430 thgrsiz = n
431 grsiz = 1
432 shift = 3
433 nbtiles = ceiling( real(n)/real(kd) )
434 stepercol = ceiling( real(shift)/real(grsiz) )
435 thgrnb = ceiling( real(n-1)/real(thgrsiz) )
436*
437 CALL dlacpy( "A", kd+1, n, ab, ldab, work( apos ), lda )
438 CALL dlaset( "A", kd, n, zero, zero, work( awpos ), lda )
439*
440*
441* openMP parallelisation start here
442*
443#if defined(_OPENMP)
444!$OMP PARALLEL PRIVATE( TID, THGRID, BLKLASTIND )
445!$OMP$ PRIVATE( THED, I, M, K, ST, ED, STT, SWEEPID )
446!$OMP$ PRIVATE( MYID, TTYPE, COLPT, STIND, EDIND )
447!$OMP$ SHARED ( UPLO, WANTQ, INDV, INDTAU, HOUS, WORK)
448!$OMP$ SHARED ( N, KD, IB, NBTILES, LDA, LDV, INDA )
449!$OMP$ SHARED ( STEPERCOL, THGRNB, THGRSIZ, GRSIZ, SHIFT )
450!$OMP MASTER
451#endif
452*
453* main bulge chasing loop
454*
455 DO 100 thgrid = 1, thgrnb
456 stt = (thgrid-1)*thgrsiz+1
457 thed = min( (stt + thgrsiz -1), (n-1))
458 DO 110 i = stt, n-1
459 ed = min( i, thed )
460 IF( stt.GT.ed ) EXIT
461 DO 120 m = 1, stepercol
462 st = stt
463 DO 130 sweepid = st, ed
464 DO 140 k = 1, grsiz
465 myid = (i-sweepid)*(stepercol*grsiz)
466 $ + (m-1)*grsiz + k
467 IF ( myid.EQ.1 ) THEN
468 ttype = 1
469 ELSE
470 ttype = mod( myid, 2 ) + 2
471 ENDIF
472
473 IF( ttype.EQ.2 ) THEN
474 colpt = (myid/2)*kd + sweepid
475 stind = colpt-kd+1
476 edind = min(colpt,n)
477 blklastind = colpt
478 ELSE
479 colpt = ((myid+1)/2)*kd + sweepid
480 stind = colpt-kd+1
481 edind = min(colpt,n)
482 IF( ( stind.GE.edind-1 ).AND.
483 $ ( edind.EQ.n ) ) THEN
484 blklastind = n
485 ELSE
486 blklastind = 0
487 ENDIF
488 ENDIF
489*
490* Call the kernel
491*
492#if defined(_OPENMP) && _OPENMP >= 201307
493 IF( ttype.NE.1 ) THEN
494!$OMP TASK DEPEND(in:WORK(MYID+SHIFT-1))
495!$OMP$ DEPEND(in:WORK(MYID-1))
496!$OMP$ DEPEND(out:WORK(MYID))
497 tid = omp_get_thread_num()
498 CALL dsb2st_kernels(
499 $ uplo, wantq, ttype,
500 $ stind, edind, sweepid, n, kd, ib,
501 $ work( inda ), lda,
502 $ hous( indv ), hous( indtau ), ldv,
503 $ work( indw + tid*kd ) )
504!$OMP END TASK
505 ELSE
506!$OMP TASK DEPEND(in:WORK(MYID+SHIFT-1))
507!$OMP$ DEPEND(out:WORK(MYID))
508 tid = omp_get_thread_num()
509 CALL dsb2st_kernels(
510 $ uplo, wantq, ttype,
511 $ stind, edind, sweepid, n, kd, ib,
512 $ work( inda ), lda,
513 $ hous( indv ), hous( indtau ), ldv,
514 $ work( indw + tid*kd ) )
515!$OMP END TASK
516 ENDIF
517#else
518 CALL dsb2st_kernels(
519 $ uplo, wantq, ttype,
520 $ stind, edind, sweepid, n, kd, ib,
521 $ work( inda ), lda,
522 $ hous( indv ), hous( indtau ), ldv,
523 $ work( indw ) )
524#endif
525 IF ( blklastind.GE.(n-1) ) THEN
526 stt = stt + 1
527 EXIT
528 ENDIF
529 140 CONTINUE
530 130 CONTINUE
531 120 CONTINUE
532 110 CONTINUE
533 100 CONTINUE
534*
535#if defined(_OPENMP)
536!$OMP END MASTER
537!$OMP END PARALLEL
538#endif
539*
540* Copy the diagonal from A to D. Note that D is REAL thus only
541* the Real part is needed, the imaginary part should be zero.
542*
543 DO 150 i = 1, n
544 d( i ) = ( work( dpos+(i-1)*lda ) )
545 150 CONTINUE
546*
547* Copy the off diagonal from A to E. Note that E is REAL thus only
548* the Real part is needed, the imaginary part should be zero.
549*
550 IF( upper ) THEN
551 DO 160 i = 1, n-1
552 e( i ) = ( work( ofdpos+i*lda ) )
553 160 CONTINUE
554 ELSE
555 DO 170 i = 1, n-1
556 e( i ) = ( work( ofdpos+(i-1)*lda ) )
557 170 CONTINUE
558 ENDIF
559*
560 work( 1 ) = lwmin
561 RETURN
562*
563* End of DSYTRD_SB2ST
564*
subroutine xerbla(srname, info)
Definition cblat2.f:3285
subroutine dsb2st_kernels(uplo, wantz, ttype, st, ed, sweep, n, nb, ib, a, lda, v, tau, ldvt, work)
DSB2ST_KERNELS
integer function ilaenv2stage(ispec, name, opts, n1, n2, n3, n4)
ILAENV2STAGE
subroutine dlacpy(uplo, m, n, a, lda, b, ldb)
DLACPY copies all or part of one two-dimensional array to another.
Definition dlacpy.f:101
subroutine dlaset(uplo, m, n, alpha, beta, a, lda)
DLASET initializes the off-diagonal elements and the diagonal elements of a matrix to given values.
Definition dlaset.f:108
logical function lsame(ca, cb)
LSAME
Definition lsame.f:48
Here is the call graph for this function:
Here is the caller graph for this function: