OpenRadioss 2025.1.11
OpenRadioss project
Loading...
Searching...
No Matches
pcunmr3.f
Go to the documentation of this file.
1 SUBROUTINE pcunmr3( 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 COMPLEX A( * ), C( * ), TAU( * ), WORK( * )
16* ..
17*
18* Purpose
19* =======
20*
21* PCUNMR3 overwrites the general complex 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 = 'C': Q**H * sub( C ) sub( C ) * Q**H
27*
28* where Q is a complex unitary 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 PCTZRZF. 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**H from the Left;
95* = 'R': apply Q or Q**H from the Right.
96*
97* TRANS (global input) CHARACTER
98* = 'N': No transpose, apply Q;
99* = 'C': Conjugate transpose, apply Q**H.
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) COMPLEX 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 PCTZRZF 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) COMPLEX, 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 PCTZRZF.
143* TAU is tied to the distributed matrix A.
144*
145* C (local input/local output) COMPLEX 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) COMPLEX 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', LWORK >= MpC0 + MAX( MAX( 1, NqC0 ), NUMROC(
170* NUMROC( M+IROFFC,MB_A,0,0,NPROW ),MB_A,0,0,LCMP ) );
171* if SIDE = 'R', LWORK >= NqC0 + MAX( 1, MpC0 );
172*
173* where LCMP = LCM / NPROW with LCM = ICLM( NPROW, NPCOL ),
174*
175* IROFFC = MOD( IC-1, MB_C ), ICOFFC = MOD( JC-1, NB_C ),
176* ICROW = INDXG2P( IC, MB_C, MYROW, RSRC_C, NPROW ),
177* ICCOL = INDXG2P( JC, NB_C, MYCOL, CSRC_C, NPCOL ),
178* MpC0 = NUMROC( M+IROFFC, MB_C, MYROW, ICROW, NPROW ),
179* NqC0 = NUMROC( N+ICOFFC, NB_C, MYCOL, ICCOL, NPCOL ),
180*
181* ILCM, INDXG2P and NUMROC are ScaLAPACK tool functions;
182* MYROW, MYCOL, NPROW and NPCOL can be determined by calling
183* the subroutine BLACS_GRIDINFO.
184*
185* If LWORK = -1, then LWORK is global input and a workspace
186* query is assumed; the routine only calculates the minimum
187* and optimal size for all work arrays. Each of these
188* values is returned in the first entry of the corresponding
189* work array, and no error message is issued by PXERBLA.
190*
191*
192* INFO (local output) INTEGER
193* = 0: successful exit
194* < 0: If the i-th argument is an array and the j-entry had
195* an illegal value, then INFO = -(i*100+j), if the i-th
196* argument is a scalar and had an illegal value, then
197* INFO = -i.
198*
199* Alignment requirements
200* ======================
201*
202* The distributed submatrices A(IA:*, JA:*) and C(IC:IC+M-1,JC:JC+N-1)
203* must verify some alignment properties, namely the following
204* expressions should be true:
205*
206* If SIDE = 'L',
207* ( NB_A.EQ.MB_C .AND. ICOFFA.EQ.IROFFC )
208* If SIDE = 'R',
209* ( NB_A.EQ.NB_C .AND. ICOFFA.EQ.ICOFFC .AND. IACOL.EQ.ICCOL )
210*
211* =====================================================================
212*
213* .. Parameters ..
214 INTEGER BLOCK_CYCLIC_2D, CSRC_, CTXT_, DLEN_, DTYPE_,
215 $ lld_, mb_, m_, nb_, n_, rsrc_
216 parameter( block_cyclic_2d = 1, dlen_ = 9, dtype_ = 1,
217 $ ctxt_ = 2, m_ = 3, n_ = 4, mb_ = 5, nb_ = 6,
218 $ rsrc_ = 7, csrc_ = 8, lld_ = 9 )
219* ..
220* .. Local Scalars ..
221 LOGICAL LEFT, LQUERY, NOTRAN
222 CHARACTER COLBTOP, ROWBTOP
223 INTEGER I, I1, I2, I3, IACOL, ICC, ICCOL, ICOFFA,
224 $ icoffc, icrow, ictxt, iroffc, jaa, jcc, lcm,
225 $ lcmp, lwmin, mi, mpc0, mycol, myrow, ni, npcol,
226 $ nprow, nq, nqc0
227* ..
228* .. External Subroutines ..
229 EXTERNAL blacs_abort, blacs_gridinfo, chk1mat, pclarz,
230 $ pclarzc, pb_topget, pb_topset, pxerbla
231* ..
232* .. External Functions ..
233 LOGICAL LSAME
234 INTEGER ILCM, INDXG2P, NUMROC
235 EXTERNAL ilcm, indxg2p, lsame, numroc
236* ..
237* .. Intrinsic Functions ..
238 INTRINSIC cmplx, max, mod, real
239* ..
240* .. Executable Statements ..
241*
242* Get grid parameters
243*
244 ictxt = desca( ctxt_ )
245 CALL blacs_gridinfo( ictxt, nprow, npcol, myrow, mycol )
246*
247* Test the input parameters
248*
249 info = 0
250 IF( nprow.EQ.-1 ) THEN
251 info = -(900+ctxt_)
252 ELSE
253 left = lsame( side, 'l' )
254 NOTRAN = LSAME( TRANS, 'n' )
255*
256* NQ is the order of Q
257*
258 IF( LEFT ) THEN
259 NQ = M
260 CALL CHK1MAT( K, 5, M, 3, IA, JA, DESCA, 10, INFO )
261 ELSE
262 NQ = N
263 CALL CHK1MAT( K, 5, N, 4, IA, JA, DESCA, 10, INFO )
264 END IF
265 CALL CHK1MAT( M, 3, N, 4, IC, JC, DESCC, 15, INFO )
266.EQ. IF( INFO0 ) THEN
267 ICOFFA = MOD( JA-1, DESCA( NB_ ) )
268 IROFFC = MOD( IC-1, DESCC( MB_ ) )
269 ICOFFC = MOD( JC-1, DESCC( NB_ ) )
270 IACOL = INDXG2P( JA, DESCA( NB_ ), MYCOL, DESCA( CSRC_ ),
271 $ NPCOL )
272 ICROW = INDXG2P( IC, DESCC( MB_ ), MYROW, DESCC( RSRC_ ),
273 $ NPROW )
274 ICCOL = INDXG2P( JC, DESCC( NB_ ), MYCOL, DESCC( CSRC_ ),
275 $ NPCOL )
276 MPC0 = NUMROC( M+IROFFC, DESCC( MB_ ), MYROW, ICROW, NPROW )
277 NQC0 = NUMROC( N+ICOFFC, DESCC( NB_ ), MYCOL, ICCOL, NPCOL )
278*
279 IF( LEFT ) THEN
280 LCM = ILCM( NPROW, NPCOL )
281 LCMP = LCM / NPROW
282 LWMIN = MPC0 + MAX( MAX( 1, NQC0 ), NUMROC( NUMROC(
283 $ M+IROFFC, DESCA( MB_ ), 0, 0, NPROW ),
284 $ DESCA( MB_ ), 0, 0, LCMP ) )
285 ELSE
286 LWMIN = NQC0 + MAX( 1, MPC0 )
287 END IF
288*
289 WORK( 1 ) = CMPLX( REAL( LWMIN ) )
290.EQ. LQUERY = ( LWORK-1 )
291.NOT..AND..NOT. IF( LEFT LSAME( SIDE, 'r' ) ) THEN
292 INFO = -1
293.NOT..AND..NOT. ELSE IF( NOTRAN LSAME( TRANS, 'c' ) ) THEN
294 INFO = -2
295.LT..OR..GT. ELSE IF( K0 KNQ ) THEN
296 INFO = -5
297.LT..OR..GT. ELSE IF( L0 LNQ ) THEN
298 INFO = -6
299.AND..NE. ELSE IF( LEFT DESCA( NB_ )DESCC( MB_ ) ) THEN
300 INFO = -(1000+NB_)
301.AND..NE. ELSE IF( LEFT ICOFFAIROFFC ) THEN
302 INFO = -13
303.NOT..AND..NE. ELSE IF( LEFT ICOFFAICOFFC ) THEN
304 INFO = -14
305.NOT..AND..NE. ELSE IF( LEFT IACOLICCOL ) THEN
306 INFO = -14
307.NOT..AND..NE. ELSE IF( LEFT DESCA( NB_ )DESCC( NB_ ) ) THEN
308 INFO = -(1500+NB_)
309.NE. ELSE IF( ICTXTDESCC( CTXT_ ) ) THEN
310 INFO = -(1500+CTXT_)
311.LT..AND..NOT. ELSE IF( LWORKLWMIN LQUERY ) THEN
312 INFO = -17
313 END IF
314 END IF
315 END IF
316*
317.NE. IF( INFO0 ) THEN
318 CALL PXERBLA( ICTXT, 'pcunmr3', -info )
319 CALL blacs_abort( ictxt, 1 )
320 RETURN
321 ELSE IF( lquery ) THEN
322 RETURN
323 END IF
324*
325* Quick return if possible
326*
327 IF( m.EQ.0 .OR. n.EQ.0 .OR. k.EQ.0 )
328 $ RETURN
329*
330 CALL pb_topget( ictxt, 'Broadcast', 'Rowwise', rowbtop )
331 CALL pb_topget( ictxt, 'Broadcast', 'Columnwise', colbtop )
332*
333 IF( ( left .AND. .NOT.notran .OR. .NOT.left .AND. notran ) ) THEN
334 i1 = ia
335 i2 = ia + k - 1
336 i3 = 1
337 ELSE
338 i1 = ia + k - 1
339 i2 = ia
340 i3 = -1
341 END IF
342*
343 IF( left ) THEN
344 ni = n
345 jcc = jc
346 jaa = ja + m - l
347 ELSE
348 mi = m
349 icc = ic
350 jaa = ja + n - l
351 CALL pb_topset( ictxt, 'Broadcast', 'Rowwise', ' ' )
352 IF( notran ) THEN
353 CALL pb_topset( ictxt, 'Broadcast', 'Columnwise', 'I-ring' )
354 ELSE
355 CALL pb_topset( ictxt, 'Broadcast', 'Columnwise', 'D-ring' )
356 END IF
357 END IF
358*
359 DO 10 i = i1, i2, i3
360 IF( left ) THEN
361*
362* H(i) or H(i)' is applied to C(ic+i-ia:icc+m-1,jc:jc+n-1)
363*
364 mi = m - i + ia
365 icc = ic + i - ia
366 ELSE
367*
368* H(i) or H(i)' is applied to C(ic:ic+m-1,jc+i-ia:jc+n-1)
369*
370 ni = n - i + ia
371 jcc = jc + i - ia
372 END IF
373*
374* Apply H(i) or H(i)'
375*
376 IF( notran ) THEN
377 CALL pclarz( side, mi, ni, l, a, i, jaa, desca, desca( m_ ),
378 $ tau, c, icc, jcc, descc, work )
379 ELSE
380 CALL pclarzc( side, mi, ni, l, a, i, jaa, desca,
381 $ desca( m_ ), tau, c, icc, jcc, descc, work )
382 END IF
383*
384 10 CONTINUE
385*
386 CALL pb_topset( ictxt, 'Broadcast', 'Rowwise', rowbtop )
387 CALL pb_topset( ictxt, 'Broadcast', 'Columnwise', colbtop )
388*
389 work( 1 ) = cmplx( real( lwmin ) )
390*
391 RETURN
392*
393* End of PCUNMR3
394*
395 END
float cmplx[2]
Definition pblas.h:136
#define max(a, b)
Definition macros.h:21
subroutine chk1mat(ma, mapos0, na, napos0, ia, ja, desca, descapos0, info)
Definition mpi.f:1577
subroutine pxerbla(contxt, srname, info)
Definition mpi.f:1600
subroutine blacs_gridinfo(cntxt, nprow, npcol, myrow, mycol)
Definition mpi.f:754
subroutine pclarz(side, m, n, l, v, iv, jv, descv, incv, tau, c, ic, jc, descc, work)
Definition pclarz.f:3
subroutine pclarzc(side, m, n, l, v, iv, jv, descv, incv, tau, c, ic, jc, descc, work)
Definition pclarzc.f:3
subroutine pcunmr3(side, trans, m, n, k, l, a, ia, ja, desca, tau, c, ic, jc, descc, work, lwork, info)
Definition pcunmr3.f:3