1 SUBROUTINE pchengst( IBTYPE, UPLO, N, A, IA, JA, DESCA, B, IB, JB,
2 $ DESCB, SCALE, WORK, LWORK, INFO )
11 INTEGER IA, IB, IBTYPE, INFO, JA, JB, LWORK, N
15 INTEGER DESCA( * ), DESCB( * )
16 COMPLEX A( * ), B( * ), WORK( * )
208 COMPLEX ONEHALF, ONE, MONE
210 parameter( onehalf = ( 0.5e0, 0.0e0 ),
211 $ one = ( 1.0e0, 0.0e0 ),
212 $ mone = ( -1.0e0, 0.0e0 ), rone = 1.0e0 )
213 INTEGER DLEN_, CTXT_, MB_, NB_, RSRC_, CSRC_, LLD_
214 parameter( dlen_ = 9, ctxt_ = 2, mb_ = 5, nb_ = 6,
215 $ rsrc_ = 7, csrc_ = 8, lld_ = 9 )
218 LOGICAL LQUERY, UPPER
219 INTEGER I, IACOL, IAROW, IBCOL, IBROW, ICOFFA, ICOFFB,
220 $ ictxt, indaa, indg, indr, indrt, iroffa,
221 $ iroffb, j, k, kb, lwmin, lwopt, mycol, myrow,
222 $ nb, np0, npcol, npk, nprow, nq0, postk
225 INTEGER DESCAA( DLEN_ ), DESCG( DLEN_ ),
226 $ descr( dlen_ ), descrt( dlen_ ), idum1( 2 ),
231 INTEGER INDXG2P, NUMROC
232 EXTERNAL lsame, indxg2p, numroc
243 ictxt = desca( ctxt_ )
244 CALL blacs_gridinfo( ictxt, nprow, npcol, myrow, mycol )
253 IF( nprow.EQ.-1 )
THEN
254 info = -( 700+ctxt_ )
256 upper = lsame( uplo,
'U' )
257 CALL chk1mat( n, 3, n, 3, ia, ja, desca, 7, info )
258 CALL chk1mat( n, 3, n, 3, ib, jb, descb, 11, info )
260 iarow = indxg2p( ia, desca( mb_ ), myrow, desca( rsrc_ ),
262 ibrow = indxg2p( ib, descb( mb_ ), myrow, descb( rsrc_ ),
264 iacol = indxg2p( ja, desca( nb_ ), mycol, desca( csrc_ ),
266 ibcol = indxg2p( jb, descb( nb_ ), mycol, descb( csrc_ ),
268 iroffa = mod( ia-1, desca( mb_ ) )
269 icoffa = mod( ja-1, desca( nb_ ) )
270 iroffb = mod( ib-1, descb( mb_ ) )
271 icoffb = mod( jb-1, descb( nb_ ) )
272 np0 = numroc( n, nb, 0, 0, nprow )
273 nq0 = numroc( n, nb, 0, 0, npcol )
274 lwmin =
max( nb*( np0+1 ), 3*nb )
275 IF( ibtype.EQ.1 .AND. .NOT.upper )
THEN
276 lwopt = 2*np0*nb + nq0*nb + nb*nb
280 work( 1 ) =
cmplx( real( lwopt ) )
281 lquery = ( lwork.EQ.-1 )
282 IF( ibtype.LT.1 .OR. ibtype.GT.3 )
THEN
284 ELSE IF( .NOT.upper .AND. .NOT.lsame( uplo,
'L' ) )
THEN
286 ELSE IF( n.LT.0 )
THEN
288 ELSE IF( iroffa.NE.0 )
THEN
290 ELSE IF( icoffa.NE.0 )
THEN
292 ELSE IF( desca( mb_ ).NE.desca( nb_ ) )
THEN
294 ELSE IF( iroffb.NE.0 .OR. ibrow.NE.iarow )
THEN
296 ELSE IF( icoffb.NE.0 .OR. ibcol.NE.iacol )
THEN
298 ELSE IF( descb( mb_ ).NE.desca( mb_ ) )
THEN
300 ELSE IF( descb( nb_ ).NE.desca( nb_ ) )
THEN
302 ELSE IF( ictxt.NE.descb( ctxt_ ) )
THEN
303 info = -( 1100+ctxt_ )
304 ELSE IF( lwork.LT.lwmin .AND. .NOT.lquery )
THEN
311 idum1( 2 ) = ichar(
'U' )
313 idum1( 2 ) = ichar(
'L' )
316 CALL pchk2mat( n, 3, n, 3, ia, ja, desca, 7, n, 3, n, 3, ib,
317 $ jb, descb, 11, 2, idum1, idum2, info )
321 CALL pxerbla( ictxt,
'PCHENGST', -info )
323 ELSE IF( lquery )
THEN
333 IF( ibtype.NE.1 .OR. upper .OR. lwork.LT.lwopt )
THEN
334 CALL pchegst( ibtype, uplo, n, a, ia, ja, desca, b, ib, jb,
335 $ descb, scale, info )
339 CALL descset( descg, n, nb, nb, nb, iarow, iacol, ictxt, np0 )
340 CALL descset( descr, n, nb, nb, nb, iarow, iacol, ictxt, np0 )
341 CALL descset( descrt, nb, n, nb, nb, iarow, iacol, ictxt, nb )
342 CALL descset( descaa, nb, nb, nb, nb, iarow, iacol, ictxt, nb )
345 indr = indg + descg( lld_ )*nb
346 indaa = indr + descr( lld_ )*nb
347 indrt = indaa + descaa( lld_ )*nb
351 kb =
min( n-k+1, nb )
356 CALL pclacpy(
'A', n-postk+1, kb, b, postk+ib-1, k+jb-1, descb,
357 $ work( indg ), postk, 1, descg )
358 CALL pclacpy(
'A', n-postk+1, kb, a, postk+ia-1, k+ja-1, desca,
359 $ work( indr ), postk, 1, descr )
360 CALL pclacpy(
'A', kb, k-1, a, k+ia-1, ja, desca,
361 $ work( indrt ), 1, 1, descrt )
363 CALL pclacpy(
'L', kb, kb, a, k+ia-1, k+ja-1, desca,
364 $ work( indr ), k, 1, descr )
365 CALL pctrsm(
'Right',
'L',
'N',
'N', npk, kb, mone, b, k+ib-1,
366 $ k+jb-1, descb, work( indg ), postk, 1, descg )
368 CALL pchemm(
'Right',
'L', npk, kb, onehalf, a, k+ia-1, k+ja-1,
369 $ desca, work( indg ), postk, 1, descg, one,
370 $ work( indr ), postk, 1, descr )
372 CALL pcher2k(
'Lower',
'No T', npk, kb, one, work( indg ),
373 $ postk, 1, descg, work( indr ), postk, 1, descr,
374 $ rone, a, postk+ia-1, postk+ja-1, desca )
376 CALL pcgemm(
'No T',
'No Conj', npk, k-1, kb, one,
377 $ work( indg ), postk, 1, descg, work( indrt ), 1,
378 $ 1, descrt, one, a, postk+ia-1, ja, desca )
380 CALL pchemm(
'Right',
'L', npk, kb, one, work( indr ), k, 1,
381 $ descr, work( indg ), postk, 1, descg, one, a,
382 $ postk+ia-1, k+ja-1, desca )
384 CALL pctrsm(
'Left',
'Lower',
'No Conj',
'Non-unit', kb, k-1,
385 $ one, b, k+ib-1, k+jb-1, descb, a, k+ia-1, ja,
388 CALL pclacpy(
'L', kb, kb, a, k+ia-1, k+ja-1, desca,
389 $ work( indaa ), 1, 1, descaa )
391 IF( myrow.EQ.descaa( rsrc_ ) .AND. mycol.EQ.descaa( csrc_ ) )
395 work( indaa+j-1+( i-1 )*descaa( lld_ ) )
396 $ = conjg( work( indaa+i-1+( j-1 )*descaa( lld_ ) ) )
401 CALL pctrsm(
'Left',
'Lower',
'No Conj',
'Non-unit', kb, kb,
402 $ one, b, k+ib-1, k+jb-1, descb, work( indaa ), 1,
405 CALL pctrsm(
'Right',
'Lower',
'Conj',
'Non-unit', kb, kb, one,
406 $ b, k+ib-1, k+jb-1, descb, work( indaa ), 1, 1,
409 CALL pclacpy(
'L', kb, kb, work( indaa ), 1, 1, descaa, a,
410 $ k+ia-1, k+ja-1, desca )
412 CALL pctrsm(
'Right',
'Lower',
'Conj',
'Non-unit', npk, kb,
413 $ one, b, k+ib-1, k+jb-1, descb, a, postk+ia-1,
416 descr( csrc_ ) = mod( descr( csrc_ )+1, npcol )
417 descg( csrc_ ) = mod( descg( csrc_ )+1, npcol )
418 descrt( rsrc_ ) = mod( descrt( rsrc_ )+1, nprow )
419 descaa( rsrc_ ) = mod( descaa( rsrc_ )+1, nprow )
420 descaa( csrc_ ) = mod( descaa( csrc_ )+1, npcol )
423 work( 1 ) =
cmplx( real( lwopt ) )