1 SUBROUTINE psgetri( N, A, IA, JA, DESCA, IPIV, WORK, LWORK,
2 $ IWORK, LIWORK, INFO )
11 INTEGER IA, INFO, JA, LIWORK, LWORK, N
14 INTEGER DESCA( * ), IPIV( * ), IWORK( * )
15 REAL A( * ), WORK( * )
163 INTEGER BLOCK_CYCLIC_2D, CSRC_, CTXT_, DLEN_, DTYPE_,
164 $ lld_, mb_, m_, nb_, n_, rsrc_
165 parameter( block_cyclic_2d = 1, dlen_ = 9, dtype_ = 1,
166 $ ctxt_ = 2, m_ = 3, n_ = 4, mb_ = 5, nb_ = 6,
167 $ rsrc_ = 7, csrc_ = 8, lld_ = 9 )
169 parameter( zero = 0.0e+0, one = 1.0e+0 )
173 INTEGER I, IACOL, IAROW, ICOFF, ICTXT, IROFF, IW, J,
174 $ jb, jn, lcm, liwmin, lwmin, mp, mycol, myrow,
175 $ nn, np, npcol, nprow, nq
178 INTEGER DESCW( DLEN_ ), IDUM1( 2 ), IDUM2( 2 )
186 INTEGER ICEIL, ILCM, INDXG2P, NUMROC
187 EXTERNAL iceil, ilcm, indxg2p, numroc
190 INTRINSIC max,
min, mod, real
196 ictxt = desca( ctxt_ )
197 CALL blacs_gridinfo( ictxt, nprow, npcol, myrow, mycol )
202 IF( nprow.EQ.-1 )
THEN
205 CALL chk1mat( n, 1, n, 1, ia, ja, desca, 5, info )
207 iroff = mod( ia-1, desca( mb_ ) )
208 icoff = mod( ja-1, desca( nb_ ) )
209 iarow = indxg2p( ia, desca( mb_ ), myrow, desca( rsrc_ ),
211 np = numroc( n+iroff, desca( mb_ ), myrow, iarow, nprow )
212 lwmin = np * desca( nb_ )
214 mp = numroc( desca( m_ ), desca( mb_ ), myrow,
215 $ desca( rsrc_ ), nprow )
216 nq = numroc( desca( n_ ), desca( nb_ ), mycol,
217 $ desca( csrc_ ), npcol )
218 IF( nprow.EQ.npcol )
THEN
219 liwmin = nq + desca( nb_ )
246 lcm = ilcm( nprow, npcol )
247 liwmin = numroc( desca( m_ ) + desca( mb_ ) * nprow
248 $ + mod( ia - 1, desca( mb_ ) ), desca( nb_ ),
249 $ mycol, desca( csrc_ ), npcol ) +
250 $
max( desca( mb_ ) * iceil( iceil(
251 $ numroc( desca( m_ ) + desca( mb_ ) * nprow,
252 $ desca( mb_ ), myrow, desca( rsrc_ ), nprow ),
253 $ desca( mb_ ) ), lcm / nprow ), desca( nb_ ) )
257 work( 1 ) = real( lwmin )
259 lquery = ( lwork.EQ.-1 .OR. liwork.EQ.-1 )
260 IF( iroff.NE.icoff .OR. iroff.NE.0 )
THEN
262 ELSE IF( desca( mb_ ).NE.desca( nb_ ) )
THEN
264 ELSE IF( lwork.LT.lwmin .AND. .NOT.lquery )
THEN
266 ELSE IF( liwork.LT.liwmin .AND. .NOT.lquery )
THEN
270 IF( lwork.EQ.-1 )
THEN
276 IF( liwork.EQ.-1 )
THEN
282 CALL pchk1mat( n, 1, n, 1, ia, ja, desca, 5, 2, idum1, idum2,
287 CALL pxerbla( ictxt,
'PSGETRI', -info )
289 ELSE IF( lquery )
THEN
301 CALL pstrtri(
'Upper',
'Non-unit', n, a, ia, ja, desca, info )
307 jn =
min( iceil( ja, desca( nb_ ) ) * desca( nb_ ), ja+n-1 )
308 nn = ( ( ja+n-2 ) / desca( nb_ ) ) * desca( nb_ ) + 1
309 iacol = indxg2p( nn, desca( nb_ ), mycol, desca( csrc_ ), npcol )
310 CALL descset( descw, n+iroff, desca( nb_ ), desca( mb_ ),
311 $ desca( nb_ ), iarow, iacol, ictxt,
max( 1, np ) )
316 DO 10 j = nn, jn+1, -desca( nb_ )
317 jb =
min( desca( nb_ ), ja+n-j )
322 CALL pslacpy(
'Lower', ja+n-1-j, jb, a, i+1, j, desca,
323 $ work, iw+j-ja+1, 1, descw )
324 CALL pslaset(
'Lower', ja+n-1-j, jb, zero, zero, a, i+1, j,
330 $
CALL psgemm(
'No transpose',
'No transpose', n, jb,
331 $ ja+n-j-jb, -one, a, ia, j+jb, desca, work,
332 $ iw+j+jb-ja, 1, descw, one, a, ia, j, desca )
333 CALL pstrsm(
'Right',
'Lower',
'No transpose',
'Unit', n, jb,
334 $ one, work, iw+j-ja, 1, descw, a, ia, j, desca )
335 descw( csrc_ ) = mod( descw( csrc_ ) + npcol - 1, npcol )
345 CALL pslacpy(
'Lower', n-1, jb, a, ia+1, ja, desca, work, iw+1,
347 CALL pslaset(
'Lower', n-1, jb, zero, zero, a, ia+1, ja, desca )
351 IF( ja+jb.LE.ja+n-1 )
352 $
CALL psgemm(
'No transpose',
'No transpose', n, jb,
353 $ n-jb, -one, a, ia, ja+jb, desca, work, iw+jb, 1,
354 $ descw, one, a, ia, ja, desca )
355 CALL pstrsm(
'Right',
'Lower',
'No transpose',
'Unit', n, jb,
356 $ one, work, iw, 1, descw, a, ia, ja, desca )
361 CALL descset( descw, desca( m_ ) + desca( mb_ )*nprow, 1,
362 $ desca( mb_ ), 1, desca( rsrc_ ), mycol, ictxt,
364 CALL pslapiv(
'Backward',
'Columns',
'Column', n, n, a, ia,
365 $ ja, desca, ipiv, ia, 1, descw, iwork )
367 work( 1 ) = real( lwmin )