1 SUBROUTINE psgeqr2( M, N, A, IA, JA, DESCA, TAU, WORK, LWORK,
10 INTEGER IA, INFO, JA, LWORK, M, N
14 REAL A( * ), TAU( * ), WORK( * )
164 INTEGER BLOCK_CYCLIC_2D, CSRC_, CTXT_, DLEN_, DTYPE_,
165 $ lld_, mb_, m_, nb_, n_, rsrc_
166 parameter( block_cyclic_2d = 1, dlen_ = 9, dtype_ = 1,
167 $ ctxt_ = 2, m_ = 3, n_ = 4, mb_ = 5, nb_ = 6,
168 $ rsrc_ = 7, csrc_ = 8, lld_ = 9 )
170 parameter( one = 1.0e+0 )
174 CHARACTER COLBTOP, ROWBTOP
175 INTEGER I, II, IACOL, IAROW, ICTXT, J, JJ, K, LWMIN,
176 $ mp, mycol, myrow, npcol, nprow, nq
182 $ pb_topset,
pxerbla, sgebr2d, sgebs2d,
186 INTEGER INDXG2P, NUMROC
187 EXTERNAL 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( m, 1, n, 2, ia, ja, desca, 6, info )
207 iarow = indxg2p( ia, desca( mb_ ), myrow, desca( rsrc_ ),
209 iacol = indxg2p( ja, desca( nb_ ), mycol, desca( csrc_ ),
211 mp = numroc( m+mod( ia-1, desca( mb_ ) ), desca( mb_ ),
212 $ myrow, iarow, nprow )
213 nq = numroc( n+mod( ja-1, desca( nb_ ) ), desca( nb_ ),
214 $ mycol, iacol, npcol )
215 lwmin = mp +
max( 1, nq )
217 work( 1 ) = real( lwmin )
218 lquery = ( lwork.EQ.-1 )
219 IF( lwork.LT.lwmin .AND. .NOT.lquery )
225 CALL pxerbla( ictxt,
'PSGEQR2', -info )
226 CALL blacs_abort( ictxt, 1 )
228 ELSE IF( lquery )
THEN
234 IF( m.EQ.0 .OR. n.EQ.0 )
237 CALL pb_topget( ictxt,
'Broadcast',
'Rowwise', rowbtop )
238 CALL pb_topget( ictxt,
'Broadcast',
'Columnwise', colbtop )
239 CALL pb_topset( ictxt,
'Broadcast',
'Rowwise',
'I-ring' )
240 CALL pb_topset( ictxt,
'Broadcast',
'Columnwise',
' ' )
242 IF( desca( m_ ).EQ.1 )
THEN
243 CALL infog2l( ia, ja, desca, nprow, npcol, myrow, mycol, ii,
245 IF( myrow.EQ.iarow )
THEN
246 nq = numroc( ja+n-1, desca( nb_ ), mycol, desca( csrc_ ),
248 i = ii+(jj-1)*desca( lld_ )
249 IF( mycol.EQ.iacol )
THEN
251 CALL slarfg( 1, ajj, a( i ), 1, tau( jj ) )
253 alpha = one - tau( jj )
254 CALL sgebs2d( ictxt,
'Rowwise',
' ', 1, 1, alpha, 1 )
255 CALL sscal( nq-jj, alpha, a( i+desca( lld_ ) ),
258 CALL sgebs2d( ictxt,
'Columnwise',
' ', 1, 1, tau( jj ),
263 CALL sgebr2d( ictxt,
'Rowwise',
' ', 1, 1, alpha,
265 CALL sscal( nq-jj+1, alpha, a( i ), desca( lld_ ) )
268 ELSE IF( mycol.EQ.iacol )
THEN
269 CALL sgebr2d( ictxt,
'Columnwise',
' ', 1, 1, tau( jj ), 1,
282 CALL pslarfg( m-j+ja, ajj, i, j, a,
min( i+1, ia+m-1 ), j,
284 IF( j.LT.ja+n-1 )
THEN
288 CALL pselset( a, i, j, desca, one )
290 CALL pslarf(
'Left', m-j+ja, n-j+ja-1, a, i, j, desca, 1,
291 $ tau, a, i, j+1, desca, work )
293 CALL pselset( a, i, j, desca, ajj )
299 CALL pb_topset( ictxt,
'Broadcast',
'Rowwise', rowbtop )
300 CALL pb_topset( ictxt,
'Broadcast',
'Columnwise', colbtop )
302 work( 1 ) = real( lwmin )