1 DOUBLE PRECISION FUNCTION pdqrt14( TRANS, M, N, NRHS, A, IA, JA,
2 $ DESCA, X, IX, JX, DESCX, WORK )
11 INTEGER ia, ix, ja, jx, m, n, nrhs
14 INTEGER desca( * ), descx( * )
15 DOUBLE PRECISION a( * ), work( * ), x( * )
173 INTEGER block_cyclic_2d, csrc_, ctxt_, dlen_, dtype_,
174 $ lld_, mb_, m_, nb_, n_, rsrc_
175 parameter( block_cyclic_2d = 1, dlen_ = 9, dtype_ = 1,
176 $ ctxt_ = 2, m_ = 3, n_ = 4, mb_ = 5, nb_ = 6,
177 $ rsrc_ = 7, csrc_ = 8, lld_ = 9 )
178 DOUBLE PRECISION one, zero
179 parameter( zero = 0.0d+0, one = 1.0d+0 )
183 INTEGER iacol, iarow, icoffa, ictxt, idum, iia, info,
184 $ iptau, ipw, ipwa, iroffa, iwa, iwx, j, jja,
185 $ jwa, jwx, ldw, lwork, mpwa, mpw, mqw, mycol,
186 $ myrow, npcol, nprow, npw, nqwa, nqw
187 DOUBLE PRECISION amax, anrm, err, xnrm
190 INTEGER descw( dlen_ ), idum1( 1 ), idum2( 1 )
191 DOUBLE PRECISION rwork( 1 )
205 INTRINSIC abs, dble,
max,
min, mod
211 ictxt = desca( ctxt_ )
212 CALL blacs_gridinfo( ictxt, nprow, npcol, myrow, mycol )
217 iroffa = mod( ia-1, desca( mb_ ) )
218 icoffa = mod( ja-1, desca( nb_ ) )
221 CALL infog2l( ia, ja, desca, nprow, npcol, myrow, mycol, iia,
222 $ jja, iarow, iacol )
223 mpwa =
numroc( m+iroffa, desca( mb_ ), myrow, iarow, nprow )
224 nqwa =
numroc( n+icoffa, desca( nb_ ), mycol, iacol, npcol )
227 IF(
lsame( trans,
'N' ) )
THEN
228 IF( n.LE.0 .OR. nrhs.LE.0 )
231 mpw =
numroc( m+nrhs+iroffa, desca( mb_ ), myrow, iarow,
241 CALL descset( descw, m+nrhs+iroffa, n+icoffa, desca( mb_ ),
242 $ desca( nb_ ), iarow, iacol, ictxt, ldw )
244 ELSE IF(
lsame( trans,
'T' ) )
THEN
245 IF( m.LE.0 .OR. nrhs.LE.0 )
249 nqw =
numroc( n+nrhs+icoffa, desca( nb_ ), mycol, iacol,
258 CALL descset( descw, m+iroffa, n+nrhs+icoffa, desca( mb_ ),
259 $ desca( nb_ ), iarow, iacol, ictxt, ldw )
261 CALL pxerbla( ictxt,
'PDQRT14', -1 )
267 iptau = ipwa + mpw*nqw
268 CALL pdlacpy(
'All', m, n, a, ia, ja, desca, work( ipwa ), iwa,
271 anrm =
pdlange(
'M', m, n, work( ipwa ), iwa, jwa, descw, rwork )
273 $
CALL pdlascl(
'G', anrm, one, m, n, work( ipwa ), iwa,
283 CALL pdcopy( m, x, ix, jx+j-1, descx, 1, work( ipwa ), iwx,
284 $ jwx+j-1, descw, 1 )
286 xnrm =
pdlange(
'M', m, nrhs, work( ipwa ), iwx, jwx, descw,
289 $
CALL pdlascl(
'G', xnrm, one, m, nrhs, work( ipwa ), iwx,
294 mqw =
numroc( m+icoffa, desca( nb_ ), mycol, iacol, npcol )
295 ipw = iptau +
min( mqw, nqw )
296 lwork = descw( nb_ ) * ( mpw + nqw + descw( nb_ ) )
297 CALL pdgeqrf( m, n+nrhs, work( ipwa ), iwa, jwa, descw,
298 $ work( iptau ), work( ipw ), lwork, info )
305 DO 20 j = jwx, jwa+n+nrhs-1
306 CALL pdamax(
min(m-n,j-jwx+1), amax, idum, work( ipwa ),
307 $ iwa+n, j, descw, 1 )
308 err =
max( err, abs( amax ) )
311 CALL dgamx2d( ictxt,
'All',
' ', 1, 1, err, 1, idum1, idum2,
319 CALL pdcopy( n, x, ix, jx+j-1, descx, 1, work( ipwa ),
320 $ iwx+j-1, jwx, descw, descw( m_ ) )
323 xnrm =
pdlange(
'M', nrhs, n, work( ipwa ), iwx, jwx, descw,
326 $
CALL pdlascl(
'G', xnrm, one, nrhs, n, work( ipwa ), iwx,
331 npw =
numroc( n+iroffa, desca( mb_ ), myrow, iarow, nprow )
332 ipw = iptau +
min( mpw, npw )
333 lwork = descw( mb_ ) * ( mpw + nqw + descw( mb_ ) )
334 CALL pdgelqf( m+nrhs, n, work( ipwa ), iwa, jwa, descw,
335 $ work( iptau ), work( ipw ), lwork, info )
341 DO 40 j = jwa+m,
min( jwa+n-1, jwa+m+nrhs-1 )
342 CALL pdamax( jwa+m+nrhs-j, amax, idum, work( ipwa ),
343 $ iwx+j-jwa-m, j, descw, 1 )
344 err =
max( err, abs( amax ) )
346 CALL dgamx2d( ictxt,
'All',
' ', 1, 1, err, 1, idum1, idum2,
352 $
pdlamch( ictxt,
'Epsilon' ) )