1 SUBROUTINE pzlarft( DIRECT, STOREV, N, K, V, IV, JV, DESCV, TAU,
10 CHARACTER DIRECT, STOREV
15 COMPLEX*16 TAU( * ), T( * ), V( * ), WORK( * )
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 )
179 parameter( one = ( 1.0d+0, 0.0d+0 ),
180 $ zero = ( 0.0d+0, 0.0d+0 ) )
184 INTEGER ICOFF, ICTXT, II, IIV, IROFF, IVCOL, IVROW,
185 $ itmp0, itmp1, iw, jj, jjv, ldv, micol, mirow,
186 $ mycol, myrow, np, npcol, nprow, nq
190 EXTERNAL blacs_gridinfo,
infog2l, zcopy, zgemv,
191 $ zgsum2d, zlacgv, zlaset, ztrmv
195 INTEGER INDXG2P, NUMROC
196 EXTERNAL indxg2p, lsame, numroc
205 IF( n.LE.0 .OR. k.LE.0 )
208 ictxt = descv( ctxt_ )
209 CALL blacs_gridinfo( ictxt, nprow, npcol, myrow, mycol )
211 forward = lsame( direct,
'F' )
212 CALL infog2l( iv, jv, descv, nprow, npcol, myrow, mycol,
213 $ iiv, jjv, ivrow, ivcol )
215 IF( lsame( storev,
'C' ) .AND. mycol.EQ.ivcol )
THEN
219 iroff = mod( iv-1, descv( mb_ ) )
225 np = numroc( n+iroff, descv( mb_ ), myrow, ivrow, nprow )
226 IF( myrow.EQ.ivrow )
THEN
232 IF( iroff+1.EQ.descv( mb_ ) )
THEN
233 mirow = mod( ivrow+1, nprow )
239 DO 10 jj = jjv+1, jjv+k-1
241 IF( myrow.EQ.mirow )
THEN
242 vii = v( ii+(jj-1)*ldv )
243 v( ii+(jj-1)*ldv ) = one
250 IF( np-ii+iiv.GT.0 )
THEN
251 CALL zgemv(
'Conjugate transpose', np-ii+iiv, itmp0,
252 $ -tau( jj ), v( ii+(jjv-1)*ldv ), ldv,
253 $ v( ii+(jj-1)*ldv ), 1, zero,
256 CALL zlaset(
'All', itmp0, 1, zero, zero, work( iw ),
261 IF( myrow.EQ.mirow )
THEN
262 v( ii+(jj-1)*ldv ) = vii
266 IF( mod( iv+itmp0, descv( mb_ ) ).EQ.0 )
267 $ mirow = mod( mirow+1, nprow )
271 CALL zgsum2d( ictxt,
'Columnwise',
' ', iw-1, 1, work, iw-1,
274 IF( myrow.EQ.ivrow )
THEN
280 t( itmp1 ) = tau( jjv )
282 DO 20 jj = jjv+1, jjv+k-1
287 itmp1 = itmp1 + descv( nb_ )
288 CALL zcopy( itmp0, work( iw ), 1, t( itmp1 ), 1 )
291 CALL ztrmv(
'Upper',
'No transpose',
'Non-unit',
292 $ itmp0, t, descv( nb_ ), t( itmp1 ), 1 )
293 t(itmp1+itmp0) = tau( jj )
303 np = numroc( n+iroff-1, descv( mb_ ), myrow, ivrow, nprow )
306 mirow = indxg2p( iv+n-2, descv( mb_ ), myrow,
307 $ descv( rsrc_ ), nprow )
311 DO 30 jj = jjv+k-2, jjv, -1
313 IF( myrow.EQ.mirow )
THEN
314 vii = v( ii+(jj-1)*ldv )
315 v( ii+(jj-1)*ldv ) = one
322 IF( ii-iiv+1.GT.0 )
THEN
323 CALL zgemv(
'Conjugate transpose', ii-iiv+1, itmp0,
324 $ -tau( jj ), v( iiv+jj*ldv ), ldv,
325 $ v( iiv+(jj-1)*ldv ), 1, zero,
328 CALL zlaset(
'All', itmp0, 1, zero, zero, work( iw ),
333 IF( myrow.EQ.mirow )
THEN
334 v( ii+(jj-1)*ldv ) = vii
338 IF( mod( iv+n-itmp0-2, descv(mb_) ).EQ.0 )
339 $ mirow = mod( mirow+nprow-1, nprow )
343 CALL zgsum2d( ictxt,
'Columnwise',
' ', iw-1, 1, work, iw-1,
346 IF( myrow.EQ.ivrow )
THEN
350 itmp1 = k + 1 + (k-1) * descv( nb_ )
352 t( itmp1-1 ) = tau( jjv+k-1 )
354 DO 40 jj = jjv+k-2, jjv, -1
359 itmp1 = itmp1 - descv( nb_ ) - 1
360 CALL zcopy( itmp0, work( iw ), 1, t( itmp1 ), 1 )
363 CALL ztrmv(
'Lower',
'No transpose',
'Non-unit',
364 $ itmp0, t( itmp1+descv( nb_ ) ),
365 $ descv( nb_ ), t( itmp1 ), 1 )
366 t( itmp1-1 ) = tau( jj )
374 ELSE IF( lsame( storev,
'R' ) .AND. myrow.EQ.ivrow )
THEN
378 icoff = mod( jv-1, descv( nb_ ) )
384 nq = numroc( n+icoff, descv( nb_ ), mycol, ivcol, npcol )
385 IF( mycol.EQ.ivcol )
THEN
391 IF( icoff+1.EQ.descv( nb_ ) )
THEN
392 micol = mod( ivcol+1, npcol )
398 DO 50 ii = iiv+1, iiv+k-1
400 IF( mycol.EQ.micol )
THEN
401 vii = v( ii+(jj-1)*ldv )
402 v( ii+(jj-1)*ldv ) = one
409 IF( nq-jj+jjv.GT.0 )
THEN
410 CALL zlacgv( nq-jj+jjv, v( ii+(jj-1)*ldv ), ldv )
411 CALL zgemv(
'No transpose', itmp0, nq-jj+jjv,
412 $ -tau(ii), v( iiv+(jj-1)*ldv ), ldv,
413 $ v( ii+(jj-1)*ldv ), ldv, zero,
415 CALL zlacgv( nq-jj+jjv, v( ii+(jj-1)*ldv ), ldv )
417 CALL zlaset(
'All', itmp0, 1, zero, zero,
418 $ work( iw ), itmp0 )
422 IF( mycol.EQ.micol )
THEN
423 v( ii+(jj-1)*ldv ) = vii
427 IF( mod( jv+itmp0, descv( nb_ ) ).EQ.0 )
428 $ micol = mod( micol+1, npcol )
432 CALL zgsum2d( ictxt,
'Rowwise',
' ', iw-1, 1, work, iw-1,
435 IF( mycol.EQ.ivcol )
THEN
441 t( itmp1 ) = tau( iiv )
443 DO 60 ii = iiv+1, iiv+k-1
448 itmp1 = itmp1 + descv( mb_ )
449 CALL zcopy( itmp0, work( iw ), 1, t( itmp1 ), 1 )
452 CALL ztrmv(
'Upper',
'No transpose',
'Non-unit',
453 $ itmp0, t, descv( mb_ ), t( itmp1 ), 1 )
454 t( itmp1+itmp0 ) = tau( ii )
464 nq = numroc( n+icoff-1, descv( nb_ ), mycol, ivcol, npcol )
467 micol = indxg2p( jv+n-2, descv( nb_ ), mycol,
468 $ descv( csrc_ ), npcol )
472 DO 70 ii = iiv+k-2, iiv, -1
474 IF( mycol.EQ.micol )
THEN
475 vii = v( ii+(jj-1)*ldv )
476 v( ii+(jj-1)*ldv ) = one
483 IF( jj-jjv+1.GT.0 )
THEN
484 CALL zlacgv( jj-jjv+1, v( ii+(jjv-1)*ldv ), ldv )
485 CALL zgemv(
'No transpose', itmp0, jj-jjv+1,
486 $ -tau( ii ), v( ii+1+(jjv-1)*ldv ), ldv,
487 $ v( ii+(jjv-1)*ldv ), ldv, zero,
489 CALL zlacgv( jj-jjv+1, v( ii+(jjv-1)*ldv ), ldv )
491 CALL zlaset(
'All', itmp0, 1, zero, zero,
492 $ work( iw ), itmp0 )
496 IF( mycol.EQ.micol )
THEN
497 v( ii+(jj-1)*ldv ) = vii
501 IF( mod( jv+n-itmp0-2, descv( nb_ ) ).EQ.0 )
502 $ micol = mod( micol+npcol-1, npcol )
506 CALL zgsum2d( ictxt,
'Rowwise',
' ', iw-1, 1, work, iw-1,
509 IF( mycol.EQ.ivcol )
THEN
513 itmp1 = k + 1 + (k-1) * descv( mb_ )
515 t( itmp1-1 ) = tau( iiv+k-1 )
517 DO 80 ii = iiv+k-2, iiv, -1
522 itmp1 = itmp1 - descv( mb_ ) - 1
523 CALL zcopy( itmp0, work( iw ), 1, t( itmp1 ), 1 )
526 CALL ztrmv(
'Lower',
'No transpose',
'Non-unit',
527 $ itmp0, t( itmp1+descv( mb_ ) ),
528 $ descv( mb_ ), t( itmp1 ), 1 )
529 t( itmp1-1 ) = tau( ii )