SCALAPACK 2.2.2
LAPACK: Linear Algebra PACKage
Loading...
Searching...
No Matches
psormrz.f
Go to the documentation of this file.
1 SUBROUTINE psormrz( SIDE, TRANS, M, N, K, L, A, IA, JA, DESCA,
2 $ TAU, C, IC, JC, DESCC, WORK, LWORK, INFO )
3*
4* -- ScaLAPACK routine (version 1.7) --
5* University of Tennessee, Knoxville, Oak Ridge National Laboratory,
6* and University of California, Berkeley.
7* May 25, 2001
8*
9* .. Scalar Arguments ..
10 CHARACTER SIDE, TRANS
11 INTEGER IA, IC, INFO, JA, JC, K, L, LWORK, M, N
12* ..
13* .. Array Arguments ..
14 INTEGER DESCA( * ), DESCC( * )
15 REAL A( * ), C( * ), TAU( * ), WORK( * )
16* ..
17*
18* Purpose
19* =======
20*
21* PSORMRZ overwrites the general real M-by-N distributed matrix
22* sub( C ) = C(IC:IC+M-1,JC:JC+N-1) with
23*
24* SIDE = 'L' SIDE = 'R'
25* TRANS = 'N': Q * sub( C ) sub( C ) * Q
26* TRANS = 'T': Q**T * sub( C ) sub( C ) * Q**T
27*
28* where Q is a real orthogonal distributed matrix defined as the
29* product of K elementary reflectors
30*
31* Q = H(1) H(2) . . . H(k)
32*
33* as returned by PSTZRZF. Q is of order M if SIDE = 'L' and of order N
34* if SIDE = 'R'.
35*
36* Notes
37* =====
38*
39* Each global data object is described by an associated description
40* vector. This vector stores the information required to establish
41* the mapping between an object element and its corresponding process
42* and memory location.
43*
44* Let A be a generic term for any 2D block cyclicly distributed array.
45* Such a global array has an associated description vector DESCA.
46* In the following comments, the character _ should be read as
47* "of the global array".
48*
49* NOTATION STORED IN EXPLANATION
50* --------------- -------------- --------------------------------------
51* DTYPE_A(global) DESCA( DTYPE_ )The descriptor type. In this case,
52* DTYPE_A = 1.
53* CTXT_A (global) DESCA( CTXT_ ) The BLACS context handle, indicating
54* the BLACS process grid A is distribu-
55* ted over. The context itself is glo-
56* bal, but the handle (the integer
57* value) may vary.
58* M_A (global) DESCA( M_ ) The number of rows in the global
59* array A.
60* N_A (global) DESCA( N_ ) The number of columns in the global
61* array A.
62* MB_A (global) DESCA( MB_ ) The blocking factor used to distribute
63* the rows of the array.
64* NB_A (global) DESCA( NB_ ) The blocking factor used to distribute
65* the columns of the array.
66* RSRC_A (global) DESCA( RSRC_ ) The process row over which the first
67* row of the array A is distributed.
68* CSRC_A (global) DESCA( CSRC_ ) The process column over which the
69* first column of the array A is
70* distributed.
71* LLD_A (local) DESCA( LLD_ ) The leading dimension of the local
72* array. LLD_A >= MAX(1,LOCr(M_A)).
73*
74* Let K be the number of rows or columns of a distributed matrix,
75* and assume that its process grid has dimension p x q.
76* LOCr( K ) denotes the number of elements of K that a process
77* would receive if K were distributed over the p processes of its
78* process column.
79* Similarly, LOCc( K ) denotes the number of elements of K that a
80* process would receive if K were distributed over the q processes of
81* its process row.
82* The values of LOCr() and LOCc() may be determined via a call to the
83* ScaLAPACK tool function, NUMROC:
84* LOCr( M ) = NUMROC( M, MB_A, MYROW, RSRC_A, NPROW ),
85* LOCc( N ) = NUMROC( N, NB_A, MYCOL, CSRC_A, NPCOL ).
86* An upper bound for these quantities may be computed by:
87* LOCr( M ) <= ceil( ceil(M/MB_A)/NPROW )*MB_A
88* LOCc( N ) <= ceil( ceil(N/NB_A)/NPCOL )*NB_A
89*
90* Arguments
91* =========
92*
93* SIDE (global input) CHARACTER
94* = 'L': apply Q or Q**T from the Left;
95* = 'R': apply Q or Q**T from the Right.
96*
97* TRANS (global input) CHARACTER
98* = 'N': No transpose, apply Q;
99* = 'T': Transpose, apply Q**T.
100*
101* M (global input) INTEGER
102* The number of rows to be operated on i.e the number of rows
103* of the distributed submatrix sub( C ). M >= 0.
104*
105* N (global input) INTEGER
106* The number of columns to be operated on i.e the number of
107* columns of the distributed submatrix sub( C ). N >= 0.
108*
109* K (global input) INTEGER
110* The number of elementary reflectors whose product defines the
111* matrix Q. If SIDE = 'L', M >= K >= 0, if SIDE = 'R',
112* N >= K >= 0.
113*
114* L (global input) INTEGER
115* The columns of the distributed submatrix sub( A ) containing
116* the meaningful part of the Householder reflectors.
117* If SIDE = 'L', M >= L >= 0, if SIDE = 'R', N >= L >= 0.
118*
119* A (local input) REAL pointer into the local memory
120* to an array of dimension (LLD_A,LOCc(JA+M-1)) if SIDE='L',
121* and (LLD_A,LOCc(JA+N-1)) if SIDE='R', where
122* LLD_A >= MAX(1,LOCr(IA+K-1)); On entry, the i-th row must
123* contain the vector which defines the elementary reflector
124* H(i), IA <= i <= IA+K-1, as returned by PSTZRZF in the
125* K rows of its distributed matrix argument A(IA:IA+K-1,JA:*).
126* A(IA:IA+K-1,JA:*) is modified by the routine but restored on
127* exit.
128*
129* IA (global input) INTEGER
130* The row index in the global array A indicating the first
131* row of sub( A ).
132*
133* JA (global input) INTEGER
134* The column index in the global array A indicating the
135* first column of sub( A ).
136*
137* DESCA (global and local input) INTEGER array of dimension DLEN_.
138* The array descriptor for the distributed matrix A.
139*
140* TAU (local input) REAL, array, dimension LOCc(IA+K-1).
141* This array contains the scalar factors TAU(i) of the
142* elementary reflectors H(i) as returned by PSTZRZF.
143* TAU is tied to the distributed matrix A.
144*
145* C (local input/local output) REAL pointer into the
146* local memory to an array of dimension (LLD_C,LOCc(JC+N-1)).
147* On entry, the local pieces of the distributed matrix sub(C).
148* On exit, sub( C ) is overwritten by Q*sub( C ) or Q'*sub( C )
149* or sub( C )*Q' or sub( C )*Q.
150*
151* IC (global input) INTEGER
152* The row index in the global array C indicating the first
153* row of sub( C ).
154*
155* JC (global input) INTEGER
156* The column index in the global array C indicating the
157* first column of sub( C ).
158*
159* DESCC (global and local input) INTEGER array of dimension DLEN_.
160* The array descriptor for the distributed matrix C.
161*
162* WORK (local workspace/local output) REAL array,
163* dimension (LWORK)
164* On exit, WORK(1) returns the minimal and optimal LWORK.
165*
166* LWORK (local or global input) INTEGER
167* The dimension of the array WORK.
168* LWORK is local input and must be at least
169* if SIDE = 'L',
170* LWORK >= MAX( (MB_A*(MB_A-1))/2, ( MpC0 + MAX( MqA0 +
171* NUMROC( NUMROC( M+IROFFC, MB_A, 0, 0, NPROW ),
172* MB_A, 0, 0, LCMP ), NqC0 ) )*MB_A ) +
173* MB_A * MB_A
174* else if SIDE = 'R',
175* LWORK >= MAX( (MB_A*(MB_A-1))/2, (MpC0 + NqC0)*MB_A ) +
176* MB_A * MB_A
177* end if
178*
179* where LCMP = LCM / NPROW with LCM = ICLM( NPROW, NPCOL ),
180*
181* IROFFA = MOD( IA-1, MB_A ), ICOFFA = MOD( JA-1, NB_A ),
182* IACOL = INDXG2P( JA, NB_A, MYCOL, CSRC_A, NPCOL ),
183* MqA0 = NUMROC( M+ICOFFA, NB_A, MYCOL, IACOL, NPCOL ),
184*
185* IROFFC = MOD( IC-1, MB_C ), ICOFFC = MOD( JC-1, NB_C ),
186* ICROW = INDXG2P( IC, MB_C, MYROW, RSRC_C, NPROW ),
187* ICCOL = INDXG2P( JC, NB_C, MYCOL, CSRC_C, NPCOL ),
188* MpC0 = NUMROC( M+IROFFC, MB_C, MYROW, ICROW, NPROW ),
189* NqC0 = NUMROC( N+ICOFFC, NB_C, MYCOL, ICCOL, NPCOL ),
190*
191* ILCM, INDXG2P and NUMROC are ScaLAPACK tool functions;
192* MYROW, MYCOL, NPROW and NPCOL can be determined by calling
193* the subroutine BLACS_GRIDINFO.
194*
195* If LWORK = -1, then LWORK is global input and a workspace
196* query is assumed; the routine only calculates the minimum
197* and optimal size for all work arrays. Each of these
198* values is returned in the first entry of the corresponding
199* work array, and no error message is issued by PXERBLA.
200*
201*
202* INFO (global output) INTEGER
203* = 0: successful exit
204* < 0: If the i-th argument is an array and the j-entry had
205* an illegal value, then INFO = -(i*100+j), if the i-th
206* argument is a scalar and had an illegal value, then
207* INFO = -i.
208*
209* Alignment requirements
210* ======================
211*
212* The distributed submatrices A(IA:*, JA:*) and C(IC:IC+M-1,JC:JC+N-1)
213* must verify some alignment properties, namely the following
214* expressions should be true:
215*
216* If SIDE = 'L',
217* ( NB_A.EQ.MB_C .AND. ICOFFA.EQ.IROFFC )
218* If SIDE = 'R',
219* ( NB_A.EQ.NB_C .AND. ICOFFA.EQ.ICOFFC .AND. IACOL.EQ.ICCOL )
220*
221* =====================================================================
222*
223* .. Parameters ..
224 INTEGER BLOCK_CYCLIC_2D, CSRC_, CTXT_, DLEN_, DTYPE_,
225 $ lld_, mb_, m_, nb_, n_, rsrc_
226 parameter( block_cyclic_2d = 1, dlen_ = 9, dtype_ = 1,
227 $ ctxt_ = 2, m_ = 3, n_ = 4, mb_ = 5, nb_ = 6,
228 $ rsrc_ = 7, csrc_ = 8, lld_ = 9 )
229* ..
230* .. Local Scalars ..
231 LOGICAL LEFT, LQUERY, NOTRAN
232 CHARACTER COLBTOP, ROWBTOP, TRANST
233 INTEGER I, I1, I2, I3, IACOL, IB, ICC, ICCOL, ICOFFA,
234 $ icoffc, icrow, ictxt, iinfo, ipw, iroffc, jaa,
235 $ jcc, lcm, lcmp, lwmin, mi, mpc0, mqa0, mycol,
236 $ myrow, ni, npcol, nprow, nq, nqc0
237* ..
238* .. Local Arrays ..
239 INTEGER IDUM1( 5 ), IDUM2( 5 )
240* ..
241* .. External Subroutines ..
242 EXTERNAL blacs_gridinfo, chk1mat, pchk2mat, pslarzb,
243 $ pslarzt, psormr3, pb_topget, pb_topset, pxerbla
244* ..
245* .. External Functions ..
246 LOGICAL LSAME
247 INTEGER ICEIL, ILCM, INDXG2P, NUMROC
248 EXTERNAL iceil, ilcm, indxg2p, lsame, numroc
249* ..
250* .. Intrinsic Functions ..
251 INTRINSIC ichar, max, min, mod, real
252* ..
253* .. Executable Statements ..
254*
255* Get grid parameters
256*
257 ictxt = desca( ctxt_ )
258 CALL blacs_gridinfo( ictxt, nprow, npcol, myrow, mycol )
259*
260* Test the input parameters
261*
262 info = 0
263 IF( nprow.EQ.-1 ) THEN
264 info = -(900+ctxt_)
265 ELSE
266 left = lsame( side, 'L' )
267 notran = lsame( trans, 'N' )
268*
269* NQ is the order of Q
270*
271 IF( left ) THEN
272 nq = m
273 CALL chk1mat( k, 5, m, 3, ia, ja, desca, 10, info )
274 ELSE
275 nq = n
276 CALL chk1mat( k, 5, n, 4, ia, ja, desca, 10, info )
277 END IF
278 CALL chk1mat( m, 3, n, 4, ic, jc, descc, 15, info )
279 IF( info.EQ.0 ) THEN
280 icoffa = mod( ja-1, desca( nb_ ) )
281 iroffc = mod( ic-1, descc( mb_ ) )
282 icoffc = mod( jc-1, descc( nb_ ) )
283 iacol = indxg2p( ja, desca( nb_ ), mycol, desca( csrc_ ),
284 $ npcol )
285 icrow = indxg2p( ic, descc( mb_ ), myrow, descc( rsrc_ ),
286 $ nprow )
287 iccol = indxg2p( jc, descc( nb_ ), mycol, descc( csrc_ ),
288 $ npcol )
289 mpc0 = numroc( m+iroffc, descc( mb_ ), myrow, icrow, nprow )
290 nqc0 = numroc( n+icoffc, descc( nb_ ), mycol, iccol, npcol )
291*
292 IF( left ) THEN
293 mqa0 = numroc( m+icoffa, desca( nb_ ), mycol, iacol,
294 $ npcol )
295 lcm = ilcm( nprow, npcol )
296 lcmp = lcm / nprow
297 lwmin = max( ( desca( mb_ ) * ( desca( mb_ ) - 1 ) )
298 $ / 2, ( mpc0 + max( mqa0 + numroc( numroc(
299 $ m+iroffc, desca( mb_ ), 0, 0, nprow ),
300 $ desca( mb_ ), 0, 0, lcmp ), nqc0 ) ) *
301 $ desca( mb_ ) ) + desca( mb_ ) * desca( mb_ )
302 ELSE
303 lwmin = max( ( desca( mb_ ) * ( desca( mb_ ) - 1 ) ) / 2,
304 $ ( mpc0 + nqc0 ) * desca( mb_ ) ) +
305 $ desca( mb_ ) * desca( mb_ )
306 END IF
307*
308 work( 1 ) = real( lwmin )
309 lquery = ( lwork.EQ.-1 )
310 IF( .NOT.left .AND. .NOT.lsame( side, 'R' ) ) THEN
311 info = -1
312 ELSE IF( .NOT.notran .AND. .NOT.lsame( trans, 'T' ) ) THEN
313 info = -2
314 ELSE IF( k.LT.0 .OR. k.GT.nq ) THEN
315 info = -5
316 ELSE IF( k.LT.0 .OR. k.GT.nq ) THEN
317 info = -6
318 ELSE IF( left .AND. desca( nb_ ).NE.descc( mb_ ) ) THEN
319 info = -(1000+nb_)
320 ELSE IF( left .AND. icoffa.NE.iroffc ) THEN
321 info = -13
322 ELSE IF( .NOT.left .AND. icoffa.NE.icoffc ) THEN
323 info = -14
324 ELSE IF( .NOT.left .AND. iacol.NE.iccol ) THEN
325 info = -14
326 ELSE IF( .NOT.left .AND. desca( nb_ ).NE.descc( nb_ ) ) THEN
327 info = -(1500+nb_)
328 ELSE IF( ictxt.NE.descc( ctxt_ ) ) THEN
329 info = -(1500+ctxt_)
330 ELSE IF( lwork.LT.lwmin .AND. .NOT.lquery ) THEN
331 info = -17
332 END IF
333 END IF
334 IF( left ) THEN
335 idum1( 1 ) = ichar( 'L' )
336 ELSE
337 idum1( 1 ) = ichar( 'R' )
338 END IF
339 idum2( 1 ) = 1
340 IF( notran ) THEN
341 idum1( 2 ) = ichar( 'N' )
342 ELSE
343 idum1( 2 ) = ichar( 'T' )
344 END IF
345 idum2( 2 ) = 2
346 idum1( 3 ) = k
347 idum2( 3 ) = 5
348 idum1( 4 ) = l
349 idum2( 4 ) = 6
350 IF( lwork.EQ.-1 ) THEN
351 idum1( 5 ) = -1
352 ELSE
353 idum1( 5 ) = 1
354 END IF
355 idum2( 5 ) = 17
356 IF( left ) THEN
357 CALL pchk2mat( k, 5, m, 3, ia, ja, desca, 10, m, 3, n, 4,
358 $ ic, jc, descc, 15, 5, idum1, idum2, info )
359 ELSE
360 CALL pchk2mat( k, 5, n, 4, ia, ja, desca, 10, m, 3, n, 4,
361 $ ic, jc, descc, 15, 5, idum1, idum2, info )
362 END IF
363 END IF
364*
365 IF( info.NE.0 ) THEN
366 CALL pxerbla( ictxt, 'PSORMRZ', -info )
367 RETURN
368 ELSE IF( lquery ) THEN
369 RETURN
370 END IF
371*
372* Quick return if possible
373*
374 IF( m.EQ.0 .OR. n.EQ.0 .OR. k.EQ.0 )
375 $ RETURN
376*
377 CALL pb_topget( ictxt, 'Broadcast', 'Rowwise', rowbtop )
378 CALL pb_topget( ictxt, 'Broadcast', 'Columnwise', colbtop )
379*
380 IF( ( left .AND. .NOT.notran ) .OR.
381 $ ( .NOT.left .AND. notran ) ) THEN
382 i1 = min( iceil( ia, desca( mb_ ) ) * desca( mb_ ), ia+k-1 )
383 $ + 1
384 i2 = ia + k - 1
385 i3 = desca( mb_ )
386 ELSE
387 i1 = max( ( (ia+k-2) / desca( mb_ ) ) * desca( mb_ ) + 1, ia )
388 i2 = min( iceil( ia, desca( mb_ ) ) * desca( mb_ ), ia+k-1 )
389 $ + 1
390 i3 = -desca( mb_ )
391 END IF
392*
393 IF( left ) THEN
394 ni = n
395 jcc = jc
396 jaa = ja + m - l
397 ELSE
398 mi = m
399 icc = ic
400 jaa = ja + n - l
401 CALL pb_topset( ictxt, 'Broadcast', 'Rowwise', ' ' )
402 IF( notran ) THEN
403 CALL pb_topset( ictxt, 'Broadcast', 'Columnwise', 'I-ring' )
404 ELSE
405 CALL pb_topset( ictxt, 'Broadcast', 'Columnwise', 'D-ring' )
406 END IF
407 END IF
408*
409 IF( notran ) THEN
410 transt = 'T'
411 ELSE
412 transt = 'N'
413 END IF
414*
415 IF( ( left .AND. .NOT.notran ) .OR.
416 $ ( .NOT.left .AND. notran ) ) THEN
417 ib = i1 - ia
418 IF( left ) THEN
419 mi = m
420 ELSE
421 ni = n
422 END IF
423 CALL psormr3( side, trans, mi, ni, ib, l, a, ia, ja, desca,
424 $ tau, c, ic, jc, descc, work, lwork, iinfo )
425 END IF
426*
427 ipw = desca( mb_ )*desca( mb_ ) + 1
428 DO 10 i = i1, i2, i3
429 ib = min( desca( mb_ ), k-i+ia )
430*
431* Form the triangular factor of the block reflector
432* H = H(i+ib-1) . . . H(i+1) H(i)
433*
434 CALL pslarzt( 'Backward', 'Rowwise', l, ib, a, i, jaa, desca,
435 $ tau, work, work( ipw ) )
436 IF( left ) THEN
437*
438* H or H' is applied to C(ic+i-ia:ic+m-1,jc:jc+n-1)
439*
440 mi = m - i + ia
441 icc = ic + i - ia
442 ELSE
443*
444* H or H' is applied to C(ic:ic+m-1,jc+i-ia:jc+n-1)
445*
446 ni = n - i + ia
447 jcc = jc + i - ia
448 END IF
449*
450* Apply H or H'
451*
452 CALL pslarzb( side, transt, 'Backward', 'Rowwise', mi, ni, ib,
453 $ l, a, i, jaa, desca, work, c, icc, jcc, descc,
454 $ work( ipw ) )
455 10 CONTINUE
456*
457 IF( ( left .AND. .NOT.notran ) .OR.
458 $ ( .NOT.left .AND. notran ) ) THEN
459 ib = i2 - ia
460 IF( left ) THEN
461 mi = m
462 ELSE
463 ni = n
464 END IF
465 CALL psormr3( side, trans, mi, ni, ib, l, a, ia, ja, desca,
466 $ tau, c, ic, jc, descc, work, lwork, iinfo )
467 END IF
468*
469 CALL pb_topset( ictxt, 'Broadcast', 'Rowwise', rowbtop )
470 CALL pb_topset( ictxt, 'Broadcast', 'Columnwise', colbtop )
471*
472 work( 1 ) = real( lwmin )
473*
474 RETURN
475*
476* End of PSORMRZ
477*
478 END
subroutine chk1mat(ma, mapos0, na, napos0, ia, ja, desca, descapos0, info)
Definition chk1mat.f:3
#define max(A, B)
Definition pcgemr.c:180
#define min(A, B)
Definition pcgemr.c:181
subroutine pchk2mat(ma, mapos0, na, napos0, ia, ja, desca, descapos0, mb, mbpos0, nb, nbpos0, ib, jb, descb, descbpos0, nextra, ex, expos, info)
Definition pchkxmat.f:175
subroutine pslarzb(side, trans, direct, storev, m, n, k, l, v, iv, jv, descv, t, c, ic, jc, descc, work)
Definition pslarzb.f:3
subroutine pslarzt(direct, storev, n, k, v, iv, jv, descv, tau, t, work)
Definition pslarzt.f:3
subroutine psormr3(side, trans, m, n, k, l, a, ia, ja, desca, tau, c, ic, jc, descc, work, lwork, info)
Definition psormr3.f:3
subroutine psormrz(side, trans, m, n, k, l, a, ia, ja, desca, tau, c, ic, jc, descc, work, lwork, info)
Definition psormrz.f:3
subroutine pxerbla(ictxt, srname, info)
Definition pxerbla.f:2