1 SUBROUTINE pcinvchk( MATTYP, N, A, IA, JA, DESCA, IASEED, ANORM,
2 $ FRESID, RCOND, WORK )
10 INTEGER IA, IASEED, JA, N
11 REAL ANORM, FRESID, RCOND
16 COMPLEX A( * ), WORK( * )
136 INTEGER BLOCK_CYCLIC_2D, CSRC_, CTXT_, DLEN_, DTYPE_,
137 $ lld_, mb_, m_, nb_, n_, rsrc_
138 parameter( block_cyclic_2d = 1, dlen_ = 9, dtype_ = 1,
139 $ ctxt_ = 2, m_ = 3, n_ = 4, mb_ = 5, nb_ = 6,
140 $ rsrc_ = 7, csrc_ = 8, lld_ = 9 )
142 parameter( zero = 0.0e+0, one = 1.0e+0 )
145 CHARACTER AFORM, DIAG, UPLO
146 INTEGER ICTXT, ICURCOL, ICURROW, II, IIA, IPW, IROFF,
147 $ iw, j, jb, jja, jn, kk, mycol, myrow, np,
149 REAL AUXNORM, EPS, NRMINVAXA, TEMP
152 INTEGER DESCW( DLEN_ )
160 INTEGER ICEIL, NUMROC
161 REAL PCLANGE, PCLANHE, PCLANTR, PSLAMCH
162 EXTERNAL iceil, lsamen, numroc, pclange, pclanhe,
170 eps = pslamch( desca( ctxt_ ),
'eps' )
174 ictxt = desca( ctxt_ )
175 CALL blacs_gridinfo( ictxt, nprow, npcol, myrow, mycol )
179 IF( lsamen( 1, mattyp( 1:1 ),
'U' ) )
THEN
185 IF( lsamen( 3, mattyp,
'GEN' ) )
THEN
189 auxnorm = pclange(
'1', n, n, a, ia, ja, desca, work )
191 ELSE IF( lsamen( 2, mattyp( 2:3 ),
'TR' ) )
THEN
195 auxnorm = pclantr(
'1', uplo,
'Non unit', n, n, a, ia, ja,
197 ELSE IF( lsamen( 2, mattyp( 2:3 ),
'PD' ) )
THEN
201 auxnorm = pclanhe(
'1', uplo, n, a, ia, ja, desca, work )
204 rcond = anorm*auxnorm
208 CALL infog2l( ia, ja, desca, nprow, npcol, myrow, mycol, iia, jja,
213 iroff = mod( ia-1, desca( mb_ ) )
214 np = numroc( n+iroff, desca( mb_ ), myrow, icurrow, nprow )
215 CALL descset( descw, n+iroff, desca( nb_ ), desca( mb_ ),
216 $ desca( nb_ ), icurrow, icurcol, desca( ctxt_ ),
218 ipw = descw( lld_ ) * descw( nb_ ) + 1
220 IF( myrow.EQ.icurrow )
THEN
226 jn =
min( iceil( ja, desca( nb_ ) ) * desca( nb_ ), ja+n-1 )
232 IF( mycol.EQ.icurcol )
THEN
233 IF( lsamen( 2, mattyp( 2:3 ),
'TR' ) )
THEN
234 CALL pcmatgen( ictxt, aform, diag, desca( m_ ), desca( n_ ),
235 $ descw( mb_ ), descw( nb_ ), work,
236 $ descw( lld_ ), desca( rsrc_ ),
237 $ desca( csrc_ ), iaseed, iia-1, np,
238 $ jja-1, jb, myrow, mycol, nprow, npcol )
239 IF( lsamen( 3, mattyp,
'UTR' ) )
THEN
240 CALL pclaset(
'Lower', n-1, jb, zero, zero, work, iw+1,
243 CALL pclaset(
'Upper', jb-1, jb-1, zero, zero, work, iw,
247 CALL pcmatgen( ictxt, aform, diag, desca( m_ ), desca( n_ ),
248 $ descw( mb_ ), descw( nb_ ), work( ipw ),
249 $ descw( lld_ ), desca( rsrc_ ),
250 $ desca( csrc_ ), iaseed,
251 $ iia-1, np, jja-1, jb, myrow, mycol, nprow,
258 IF( lsamen( 3, mattyp,
'GEN' ) )
THEN
260 CALL pcgemm(
'No tranpose',
'No transpose', n, jb, n, one, a,
261 $ ia, ja, desca, work( ipw ), iw, 1, descw, zero,
262 $ work, iw, 1, descw )
264 ELSE IF( lsamen( 2, mattyp( 2:3 ),
'TR' ) )
THEN
266 CALL pctrmm(
'Left', uplo,
'No tranpose',
'Non unit', n, jb,
267 $ one, a, ia, ja, desca, work, iw, 1, descw )
269 ELSE IF( lsamen( 2, mattyp( 2:3 ),
'PD' ) )
THEN
271 CALL pchemm(
'Left', uplo, n, jb, one, a, ia, ja, desca,
272 $ work(ipw), iw, 1, descw, zero, work, iw, 1,
279 IF( myrow.EQ.icurrow .AND. mycol.EQ.icurcol )
THEN
281 work( ii+kk*(descw(lld_)+1) ) =
282 $ work( ii+kk*(descw( lld_ )+1) )-one
286 nrminvaxa = pclange(
'1', n, jb, work, iw, 1, descw, work( ipw ) )
288 IF( myrow.EQ.icurrow )
290 IF( mycol.EQ.icurcol )
292 icurrow = mod( icurrow+1, nprow )
293 icurcol = mod( icurcol+1, npcol )
294 descw( csrc_ ) = icurcol
296 DO 30 j = jn+1, ja+n-1, desca( nb_ )
298 jb =
min( n-j+ja, desca( nb_ ) )
302 IF( mycol.EQ.icurcol )
THEN
303 IF( lsamen( 2, mattyp( 2:3 ),
'TR' ) )
THEN
304 CALL pcmatgen( ictxt, aform, diag, desca( m_ ),
305 $ desca( n_ ), descw( mb_ ), descw( nb_ ),
306 $ work, descw( lld_ ), desca( rsrc_ ),
308 $ iaseed, iia-1, np, jja-1, jb, myrow,
309 $ mycol, nprow, npcol )
310 IF( lsamen( 3, mattyp,
'UTR' ) )
THEN
311 CALL pclaset(
'Lower', ja+n-j-1, jb, zero, zero,
312 $ work, iw+j-ja+1, 1, descw )
314 CALL pclaset(
'All', j-ja, jb, zero, zero, work, iw,
316 CALL pclaset(
'Upper', jb-1, jb-1, zero, zero,
317 $ work, iw+j-ja, 2, descw )
320 CALL pcmatgen( ictxt, aform, diag, desca( m_ ),
321 $ desca( n_ ), descw( mb_ ), descw( nb_ ),
322 $ work( ipw ), descw( lld_ ),
323 $ desca( rsrc_ ), desca( csrc_ ), iaseed,
325 $ jja-1, jb, myrow, mycol, nprow, npcol )
331 IF( lsamen( 3, mattyp,
'GEN' ) )
THEN
333 CALL pcgemm(
'No tranpose',
'No transpose', n, jb, n, one,
334 $ a, ia, ja, desca, work( ipw ), iw, 1, descw,
335 $ zero, work, iw, 1, descw )
337 ELSE IF( lsamen( 2, mattyp(2:3),
'TR' ) )
THEN
339 CALL pctrmm(
'Left', uplo,
'No tranpose',
'Non unit', n, jb,
340 $ one, a, ia, ja, desca, work, iw, 1, descw )
342 ELSE IF( lsamen( 2, mattyp( 2:3 ),
'PD' ) )
THEN
344 CALL pchemm(
'Left', uplo, n, jb, one, a, ia, ja, desca,
345 $ work(ipw), iw, 1, descw, zero, work, iw, 1,
353 IF( myrow.EQ.icurrow .AND. mycol.EQ.icurcol )
THEN
355 work( ii+kk*(descw( lld_ )+1) ) =
356 $ work( ii+kk*(descw( lld_ )+1) ) - one
362 temp = pclange(
'1', n, jb, work, iw, 1, descw, work( ipw ) )
363 nrminvaxa =
max( temp, nrminvaxa )
365 IF( myrow.EQ.icurrow )
367 IF( mycol.EQ.icurcol )
369 icurrow = mod( icurrow+1, nprow )
370 icurcol = mod( icurcol+1, npcol )
371 descw( csrc_ ) = icurcol
377 fresid = nrminvaxa / ( n * eps * anorm )