1 REAL FUNCTION PSQRT17( TRANS, IRESID, M, N, NRHS, A,
2 $ IA, JA, DESCA, X, IX, JX,
3 $ DESCX, B, IB, JB, DESCB, WORK,
13 INTEGER ia, ib, iresid, ix, ja, jb, jx, m, n, nrhs
16 INTEGER desca( * ), descb( * ), descx( * )
17 REAL a( * ), b( * ), work( * ), x( * )
201 INTEGER block_cyclic_2d, csrc_, ctxt_, dlen_, dtype_,
202 $ lld_, mb_, m_, nb_, n_, rsrc_
203 parameter( block_cyclic_2d = 1, dlen_ = 9, dtype_ = 1,
204 $ ctxt_ = 2, m_ = 3, n_ = 4, mb_ = 5, nb_ = 6,
205 $ rsrc_ = 7, csrc_ = 8, lld_ = 9 )
207 parameter( zero = 0.0e0, one = 1.0e0 )
210 INTEGER iacol, ibcol, ibrow, icoffb, ictxt, info,
211 $ ioffa, iroffb, iscl, iw, iw2, jw, jw2, mycol,
212 $ nrhsq, nrhsp, myrow, ncols, npcol, nprow,
214 REAL err, norma, normb, normrs, normx, smlnum
217 INTEGER descw( dlen_ ), descw2( dlen_ )
238 ictxt = desca( ctxt_ )
239 CALL blacs_gridinfo( ictxt, nprow, npcol, myrow, mycol )
242 IF(
lsame( trans,
'N' ) )
THEN
245 ioffa = mod( ja-1, desca( nb_ ) )
246 ELSE IF(
lsame( trans,
'T' ) )
THEN
249 ioffa = mod( ia-1, desca( mb_ ) )
251 CALL pxerbla( ictxt,
'PSQRT17', -1 )
255 IF( m.LE.0 .OR. n.LE.0 .OR. nrhs.LE.0 )
258 iroffb = mod( ia-1, desca( mb_ ) )
259 icoffb = mod( ja-1, desca( nb_ ) )
260 ibrow =
indxg2p( ib, descb( mb_ ), myrow, descb( rsrc_ ),
262 iacol =
indxg2p( ja, desca( nb_ ), mycol, desca( csrc_ ),
264 ibcol =
indxg2p( jb, descb( nb_ ), mycol, descb( csrc_ ),
267 nrhsq =
numroc( nrhs+icoffb, descb( nb_ ), mycol, ibcol, npcol )
268 nrhsp =
numroc( nrhs+iroffb, descb( nb_ ), myrow, ibrow, nprow )
269 nrowsp =
numroc( nrows+iroffb, desca( mb_ ), myrow, ibrow, nprow )
274 CALL descset( descw, nrows+iroffb, nrhs+icoffb, descb( mb_ ),
275 $ descb( nb_ ), ibrow, ibcol, ictxt,
max( 1,
281 CALL descset( descw2, nrhs+icoffb, ncols+ioffa, descx( nb_ ),
282 $ descx( mb_ ), ibrow, iacol, ictxt,
max( 1,
285 norma =
pslange(
'One-norm', m, n, a, ia, ja, desca, rwork )
286 smlnum =
pslamch( ictxt,
'Safe minimum' )
287 smlnum = smlnum /
pslamch( ictxt,
'Precision' )
294 CALL pslacpy(
'All', nrows, nrhs, b, ib, jb, descb, work, iw, jw,
296 CALL psgemm( trans,
'No transpose', nrows, nrhs, ncols, -one, a,
297 $ ia, ja, desca, x, ix, jx, descx, one, work, iw, jw,
299 normrs =
pslange(
'Max', nrows, nrhs, work, iw, jw, descw,
301 IF( normrs.GT.smlnum )
THEN
303 CALL pslascl(
'General', normrs, one, nrows, nrhs, work,
304 $ iw, jw, descw, info )
311 CALL psgemm(
'Transpose', trans, nrhs, ncols, nrows, one, work,
312 $ iw, jw, descw, a, ia, ja, desca, zero,
313 $ work( nrowsp*nrhsq+1 ), iw2, jw2, descw2 )
317 err =
pslange(
'One-norm', nrhs, ncols, work( nrowsp*nrhsq+1 ),
318 $ iw2, jw2, descw2, rwork )
325 IF( iresid.EQ.1 )
THEN
326 normb =
pslange(
'One-norm', nrows, nrhs, b, ib, jb, descb,
331 normx =
pslange(
'One-norm', ncols, nrhs, x, ix, jx, descx,
338 $ real(
max( m, n, nrhs ) ) )