1 SUBROUTINE pdsyev( JOBZ, UPLO, N, A, IA, JA, DESCA, W,
2 $ Z, IZ, JZ, DESCZ, WORK, LWORK, INFO )
11 INTEGER IA, INFO, IZ, JA, JZ, LWORK, N
14 INTEGER DESCA( * ), DESCZ( * )
15 DOUBLE PRECISION A( * ), W( * ), WORK( * ), Z( * )
237 INTEGER BLOCK_CYCLIC_2D, DLEN_, DTYPE_, CTXT_, M_, N_,
238 $ mb_, nb_, rsrc_, csrc_, lld_
239 parameter( block_cyclic_2d = 1, dlen_ = 9, dtype_ = 1,
240 $ ctxt_ = 2, m_ = 3, n_ = 4, mb_ = 5, nb_ = 6,
241 $ rsrc_ = 7, csrc_ = 8, lld_ = 9 )
242 DOUBLE PRECISION FIVE, ONE, TEN, ZERO
243 parameter( zero = 0.0d+0, one = 1.0d+0,
244 $ ten = 10.0d+0, five = 5.0d+0 )
245 INTEGER IERREIN, IERRCLS, IERRSPC, IERREBZ, ITHVAL
246 parameter( ierrein = 1, ierrcls = 2, ierrspc = 4,
247 $ ierrebz = 8, ithval = 10 )
251 INTEGER CONTEXTC, CSRC_A, I, IACOL, IAROW, ICOFFA,
252 $ iinfo, indd, indd2, inde, inde2, indtau,
253 $ indwork, indwork2, iroffa, iroffz, iscale,
254 $ izrow, j, k, ldc, llwork, lwmin, mb_a, mb_z,
255 $ mycol, mypcolc, myprowc, myrow, nb, nb_a, nb_z,
256 $ np, npcol, npcolc, nprocs, nprow, nprowc, nq,
257 $ nrc, qrmem, rsrc_a, rsrc_z, sizemqrleft,
259 DOUBLE PRECISION ANRM, BIGNUM, EPS, RMAX, RMIN, SAFMIN, SIGMA,
263 INTEGER DESCQR( 9 ), IDUM1( 3 ), IDUM2( 3 )
267 INTEGER INDXG2P, NUMROC, SL_GRIDRESHAPE
268 DOUBLE PRECISION PDLAMCH, PDLANSY
269 EXTERNAL lsame, numroc, pdlamch, pdlansy,
273 EXTERNAL blacs_gridexit, blacs_gridinfo,
chk1mat, dcopy,
279 INTRINSIC abs, dble, ichar,
max,
min, mod, sqrt, int
283 IF( block_cyclic_2d*csrc_*ctxt_*dlen_*dtype_*lld_*mb_*m_*nb_*n_*
292 CALL blacs_gridinfo( desca( ctxt_ ), nprow, npcol, myrow, mycol )
295 wantz = lsame( jobz,
'V' )
296 IF( nprow.EQ.-1 )
THEN
297 info = -( 700+ctxt_ )
298 ELSE IF( wantz )
THEN
299 IF( desca( ctxt_ ).NE.descz( ctxt_ ) )
THEN
300 info = -( 1200+ctxt_ )
303 IF( info .EQ. 0 )
THEN
304 CALL chk1mat( n, 3, n, 3, ia, ja, desca, 7, info )
306 $
CALL chk1mat( n, 3, n, 3, iz, jz, descz, 12, info )
312 safmin = pdlamch( desca( ctxt_ ),
'Safe minimum' )
313 eps = pdlamch( desca( ctxt_ ),
'Precision' )
314 smlnum = safmin / eps
315 bignum = one / smlnum
316 rmin = sqrt( smlnum )
317 rmax =
min( sqrt( bignum ), one / sqrt( sqrt( safmin ) ) )
323 lower = lsame( uplo,
'L' )
325 rsrc_a = desca( rsrc_ )
326 csrc_a = desca( csrc_ )
327 iroffa = mod( ia-1, mb_a )
328 icoffa = mod( ja-1, nb_a )
329 iarow = indxg2p( 1, nb_a, myrow, rsrc_a, nprow )
330 iacol = indxg2p( 1, mb_a, mycol, csrc_a, npcol )
331 np = numroc( n+iroffa, nb, myrow, iarow, nprow )
332 nq = numroc( n+icoffa, nb, mycol, iacol, npcol )
337 rsrc_z = descz( rsrc_ )
338 iroffz = mod( iz-1, mb_a )
339 izrow = indxg2p( 1, nb_a, myrow, rsrc_z, nprow )
340 sizemqrleft =
max( ( nb_a*( nb_a-1 ) ) / 2, ( np+nq )*
347 sizesytrd =
max( nb * ( np +1 ), 3 * nb )
357 contextc = sl_gridreshape( desca( ctxt_ ), 0, 1, 1,
359 CALL blacs_gridinfo( contextc, nprowc, npcolc, myprowc,
361 nrc = numroc( n, nb_a, myprowc, 0, nprocs)
363 CALL descinit( descqr, n, n, nb, nb, 0, 0, contextc,
376 indwork2 = indwork + n*ldc
377 llwork = lwork - indwork + 1
383 lwmin = 5*n + n*ldc +
max( sizemqrleft, qrmem ) + 1
385 lwmin = 5*n + sizesytrd + 1
390 IF( .NOT.( wantz .OR. lsame( jobz,
'N' ) ) )
THEN
392 ELSE IF( .NOT.( lower .OR. lsame( uplo,
'U' ) ) )
THEN
394 ELSE IF( lwork.LT.lwmin .AND. lwork.NE.-1 )
THEN
396 ELSE IF( iroffa.NE.0 )
THEN
398 ELSE IF( desca( mb_ ).NE.desca( nb_ ) )
THEN
402 IF( iroffa.NE.iroffz )
THEN
404 ELSE IF( iarow.NE.izrow )
THEN
406 ELSE IF( desca( m_ ).NE.descz( m_ ) )
THEN
408 ELSE IF( desca( n_ ).NE.descz( n_ ) )
THEN
410 ELSE IF( desca( mb_ ).NE.descz( mb_ ) )
THEN
412 ELSE IF( desca( nb_ ).NE.descz( nb_ ) )
THEN
414 ELSE IF( desca( rsrc_ ).NE.descz( rsrc_ ) )
THEN
415 info = -( 1200+rsrc_ )
416 ELSE IF( desca( ctxt_ ).NE.descz( ctxt_ ) )
THEN
417 info = -( 1200+ctxt_ )
422 idum1( 1 ) = ichar(
'V' )
424 idum1( 1 ) = ichar(
'N' )
428 idum1( 2 ) = ichar(
'L' )
430 idum1( 2 ) = ichar(
'U' )
433 IF( lwork.EQ.-1 )
THEN
439 IF( lsame( jobz,
'V' ) )
THEN
440 CALL pchk2mat( n, 3, n, 3, ia, ja, desca, 7, n, 3, n, 3,
441 $ iz, jz, descz, 12, 3, idum1, idum2, info )
443 CALL pchk1mat( n, 3, n, 3, ia, ja, desca, 7, 3, idum1,
449 work( 1 ) = dble( lwmin )
453 CALL pxerbla( desca( ctxt_ ),
'PDSYEV', -info )
454 IF( wantz )
CALL blacs_gridexit( contextc )
456 ELSE IF( lwork .EQ. -1 )
THEN
457 IF( wantz )
CALL blacs_gridexit( contextc )
465 anrm = pdlansy(
'M', uplo, n, a, ia, ja, desca, work( indwork ) )
468 IF( anrm.GT.zero .AND. anrm.LT.rmin )
THEN
471 ELSE IF( anrm.GT.rmax )
THEN
476 IF( iscale.EQ.1 )
THEN
477 CALL pdlascl( uplo, one, sigma, n, n, a, ia, ja, desca, iinfo )
482 CALL pdsytrd( uplo, n, a, ia, ja, desca, work( indd ),
483 $ work( inde ), work( indtau ), work( indwork ),
489 CALL pdelget(
'A',
' ', work(indd2+i-1), a,
490 $ i+ia-1, i+ja-1, desca )
492 IF( lsame( uplo,
'U') )
THEN
494 CALL pdelget(
'A',
' ', work(inde2+i-1), a,
495 $ i+ia-1, i+ja, desca )
499 CALL pdelget(
'A',
' ', work(inde2+i-1), a,
500 $ i+ia, i+ja-1, desca )
506 CALL pdlaset(
'Full', n, n, zero, one, work( indwork ), 1, 1,
513 CALL dsteqr2(
'I', n, work( indd2 ), work( inde2 ),
514 $ work( indwork ), ldc, nrc, work( indwork2 ),
517 CALL pdgemr2d( n, n, work( indwork ), 1, 1, descqr, z, ia, ja,
520 CALL pdormtr(
'L', uplo,
'N', n, n, a, ia, ja, desca,
521 $ work( indtau ), z, iz, jz, descz,
522 $ work( indwork ), llwork, iinfo )
526 CALL dsteqr2(
'N', n, work( indd2 ), work( inde2 ),
527 $ work( indwork ), 1, 1, work( indwork2 ),
533 CALL dcopy( n, work( indd2 ), 1, w, 1 )
537 IF( iscale .EQ. 1 )
THEN
538 CALL dscal( n, one / sigma, w, 1 )
544 CALL blacs_gridexit( contextc )
550 IF( n.LE.ithval )
THEN
559 work( i+indtau ) = w( (i-1)*k+1 )
560 work( i+inde ) = w( (i-1)*k+1 )
563 CALL dgamn2d( desca( ctxt_ ),
'a',
' ', j, 1, work( 1+indtau ),
564 $ j, 1, 1, -1, -1, 0 )
565 CALL dgamx2d( desca( ctxt_ ),
'a',
' ', j, 1, work( 1+inde ),
566 $ j, 1, 1, -1, -1, 0 )
569 IF( info.EQ.0 .AND. ( work( i+indtau )-work( i+inde )