1 SUBROUTINE pstrcon( NORM, UPLO, DIAG, N, A, IA, JA, DESCA, RCOND,
2 $ WORK, LWORK, IWORK, LIWORK, INFO )
11 CHARACTER DIAG, NORM, UPLO
12 INTEGER IA, JA, INFO, LIWORK, LWORK, N
16 INTEGER DESCA( * ), IWORK( * )
17 REAL A( * ), WORK( * )
182 INTEGER BLOCK_CYCLIC_2D, CSRC_, CTXT_, DLEN_, DTYPE_,
183 $ lld_, mb_, m_, nb_, n_, rsrc_
184 parameter( block_cyclic_2d = 1, dlen_ = 9, dtype_ = 1,
185 $ ctxt_ = 2, m_ = 3, n_ = 4, mb_ = 5, nb_ = 6,
186 $ rsrc_ = 7, csrc_ = 8, lld_ = 9 )
188 parameter( one = 1.0e+0, zero = 0.0e+0 )
191 LOGICAL LQUERY, NOUNIT, ONENRM, UPPER
192 CHARACTER CBTOP, COLCTOP, NORMIN, ROWCTOP
193 INTEGER IACOL, IAROW, ICOFF, ICTXT, IIA, IPN, IPV, IPW,
194 $ ipx, iroff, iv, ix, ixx, jja, jv, jx, kase,
195 $ kase1, liwmin, lwmin, mycol, myrow, np, npcol,
196 $ npmod, nprow, nq, nqmod
197 REAL AINVNM, ANORM, SCALE, SMLNUM
201 INTEGER DESCV( DLEN_ ), DESCX( DLEN_ ), IDUM1( 5 ),
212 INTEGER ICEIL, INDXG2P, NUMROC
213 REAL PSLAMCH, PSLANTR
214 EXTERNAL iceil, indxg2p, lsame, numroc, pslamch,
218 INTRINSIC abs, ichar,
max, mod, real
224 ictxt = desca( ctxt_ )
225 CALL blacs_gridinfo( ictxt, nprow, npcol, myrow, mycol )
230 IF( nprow.EQ.-1 )
THEN
231 info = -( 800 + ctxt_ )
233 CALL chk1mat( n, 4, n, 4, ia, ja, desca, 8, info )
235 upper = lsame( uplo,
'U' )
236 onenrm = norm.EQ.
'1' .OR. lsame( norm,
'O' )
237 nounit = lsame( diag,
'N' )
238 iarow = indxg2p( ia, desca( mb_ ), myrow, desca( rsrc_ ),
240 iacol = indxg2p( ja, desca( nb_ ), mycol, desca( csrc_ ),
242 npmod = numroc( n + mod( ia-1, desca( mb_ ) ), desca( mb_ ),
243 $ myrow, iarow, nprow )
244 nqmod = numroc( n + mod( ja-1, desca( nb_ ) ), desca( nb_ ),
245 $ mycol, iacol, npcol )
246 lwmin = 2*npmod + nqmod +
247 $
max( 2,
max( desca( nb_ )*
248 $
max( 1, iceil( nprow-1, npcol ) ), nqmod +
250 $
max( 1, iceil( npcol-1, nprow ) ) ) )
251 work( 1 ) = real( lwmin )
254 lquery = ( lwork.EQ.-1 .OR. liwork.EQ.-1 )
256 IF( .NOT.onenrm .AND. .NOT.lsame( norm,
'I' ) )
THEN
258 ELSE IF( .NOT.upper .AND. .NOT.lsame( uplo,
'L' ) )
THEN
260 ELSE IF( .NOT.nounit .AND. .NOT.lsame( diag,
'U' ) )
THEN
262 ELSE IF( lwork.LT.lwmin .AND. .NOT.lquery )
THEN
264 ELSE IF( liwork.LT.liwmin .AND. .NOT.lquery )
THEN
270 idum1( 1 ) = ichar(
'1' )
272 idum1( 1 ) = ichar(
'I' )
276 idum1( 2 ) = ichar(
'U' )
278 idum1( 2 ) = ichar(
'L' )
282 idum1( 3 ) = ichar(
'N' )
284 idum1( 3 ) = ichar(
'U' )
287 IF( lwork.EQ.-1 )
THEN
293 IF( liwork.EQ.-1 )
THEN
299 CALL pchk1mat( n, 4, n, 4, ia, ja, desca, 8, 5, idum1, idum2,
304 CALL pxerbla( ictxt,
'PSTRCON', -info )
306 ELSE IF( lquery )
THEN
317 CALL pb_topget( ictxt,
'Combine',
'Columnwise', colctop )
318 CALL pb_topget( ictxt,
'Combine',
'Rowwise', rowctop )
319 CALL pb_topset( ictxt,
'Combine',
'Columnwise',
'1-tree' )
320 CALL pb_topset( ictxt,
'Combine',
'Rowwise',
'1-tree' )
323 smlnum = pslamch( ictxt,
'Safe minimum' )*real(
max( 1, n ) )
324 CALL infog2l( ia, ja, desca, nprow, npcol, myrow, mycol, iia, jja,
326 iroff = mod( ia-1, desca( mb_ ) )
327 icoff = mod( ja-1, desca( nb_ ) )
328 np = numroc( n+iroff, desca( mb_ ), myrow, iarow, nprow )
329 nq = numroc( n+icoff, desca( nb_ ), mycol, iacol, npcol )
340 CALL descset( descv, n+iroff, 1, desca( mb_ ), 1, iarow, mycol,
341 $ ictxt,
max( 1, np ) )
342 CALL descset( descx, n+iroff, 1, desca( mb_ ), 1, iarow, mycol,
343 $ ictxt,
max( 1, np ) )
347 anorm = pslantr( norm, uplo, diag, n, n, a, ia, ja, desca, work )
351 IF( anorm.GT.zero )
THEN
364 CALL pslacon( n, work( ipv ), iv, jv, descv, work( ipx ),
365 $ ix, jx, descx, iwork, ainvnm, kase )
367 IF( kase.EQ.kase1 )
THEN
371 descx( csrc_ ) = iacol
372 CALL pslatrs( uplo,
'No transpose', diag, normin,
373 $ n, a, ia, ja, desca, work( ipx ), ix, jx,
374 $ descx, scale, work( ipn ), work( ipw ) )
375 descx( csrc_ ) = mycol
380 descx( csrc_ ) = iacol
381 CALL pslatrs( uplo,
'Transpose', diag, normin,
382 $ n, a, ia, ja, desca, work( ipx ), ix, jx,
383 $ descx, scale, work( ipn ), work( ipw ) )
384 descx( csrc_ ) = mycol
390 IF( scale.NE.one )
THEN
391 CALL psamax( n, wmax, ixx, work( ipx ), ix, jx,
393 IF( descx( m_ ).EQ.1 .AND. n.EQ.1 )
THEN
394 CALL pb_topget( ictxt,
'Broadcast',
'Columnwise',
396 IF( myrow.EQ.iarow )
THEN
397 CALL sgebs2d( ictxt,
'Column', cbtop, 1, 1, wmax,
400 CALL sgebr2d( ictxt,
'Column', cbtop, 1, 1, wmax,
404 IF( scale.LT.abs( wmax )*smlnum .OR. scale.EQ.zero )
406 CALL psrscl( n, scale, work( ipx ), ix, jx, descx, 1 )
414 $ rcond = ( one / anorm ) / ainvnm
419 CALL pb_topset( ictxt,
'Combine',
'Columnwise', colctop )
420 CALL pb_topset( ictxt,
'Combine',
'Rowwise', rowctop )