OpenRadioss 2025.1.11
OpenRadioss project
Loading...
Searching...
No Matches
pzunmql.f File Reference

Go to the source code of this file.

Functions/Subroutines

subroutine pzunmql (side, trans, m, n, k, a, ia, ja, desca, tau, c, ic, jc, descc, work, lwork, info)

Function/Subroutine Documentation

◆ pzunmql()

subroutine pzunmql ( character side,
character trans,
integer m,
integer n,
integer k,
complex*16, dimension( * ) a,
integer ia,
integer ja,
integer, dimension( * ) desca,
complex*16, dimension( * ) tau,
complex*16, dimension( * ) c,
integer ic,
integer jc,
integer, dimension( * ) descc,
complex*16, dimension( * ) work,
integer lwork,
integer info )

Definition at line 1 of file pzunmql.f.

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, LWORK, M, N
12* ..
13* .. Array Arguments ..
14 INTEGER DESCA( * ), DESCC( * )
15 COMPLEX*16 A( * ), C( * ), TAU( * ), WORK( * )
16* ..
17*
18* Purpose
19* =======
20*
21* PZUNMQL 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(k) . . . H(2) H(1)
32*
33* as returned by PZGEQLF. 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* A (local input) COMPLEX*16 pointer into the local memory
115* to an array of dimension (LLD_A,LOCc(JA+K-1)). On entry, the
116* j-th column must contain the vector which defines the elemen-
117* tary reflector H(j), JA <= j <= JA+K-1, as returned by
118* PZGEQLF in the K columns of its distributed matrix
119* argument A(IA:*,JA:JA+K-1). A(IA:*,JA:JA+K-1) is modified by
120* the routine but restored on exit.
121* If SIDE = 'L', LLD_A >= MAX( 1, LOCr(IA+M-1) ),
122* if SIDE = 'R', LLD_A >= MAX( 1, LOCr(IA+N-1) ).
123*
124* IA (global input) INTEGER
125* The row index in the global array A indicating the first
126* row of sub( A ).
127*
128* JA (global input) INTEGER
129* The column index in the global array A indicating the
130* first column of sub( A ).
131*
132* DESCA (global and local input) INTEGER array of dimension DLEN_.
133* The array descriptor for the distributed matrix A.
134*
135* TAU (local input) COMPLEX*16, array, dimension LOCc(JA+N-1)
136* This array contains the scalar factors TAU(j) of the
137* elementary reflectors H(j) as returned by PZGEQLF.
138* TAU is tied to the distributed matrix A.
139*
140* C (local input/local output) COMPLEX*16 pointer into the
141* local memory to an array of dimension (LLD_C,LOCc(JC+N-1)).
142* On entry, the local pieces of the distributed matrix sub(C).
143* On exit, sub( C ) is overwritten by Q*sub( C ) or Q'*sub( C )
144* or sub( C )*Q' or sub( C )*Q.
145*
146* IC (global input) INTEGER
147* The row index in the global array C indicating the first
148* row of sub( C ).
149*
150* JC (global input) INTEGER
151* The column index in the global array C indicating the
152* first column of sub( C ).
153*
154* DESCC (global and local input) INTEGER array of dimension DLEN_.
155* The array descriptor for the distributed matrix C.
156*
157* WORK (local workspace/local output) COMPLEX*16 array,
158* dimension (LWORK)
159* On exit, WORK(1) returns the minimal and optimal LWORK.
160*
161* LWORK (local or global input) INTEGER
162* The dimension of the array WORK.
163* LWORK is local input and must be at least
164* If SIDE = 'L',
165* LWORK >= MAX( (NB_A*(NB_A-1))/2, (NqC0 + MpC0)*NB_A ) +
166* NB_A * NB_A
167* else if SIDE = 'R',
168* LWORK >= MAX( (NB_A*(NB_A-1))/2, ( NqC0 + MAX( NpA0 +
169* NUMROC( NUMROC( N+ICOFFC, NB_A, 0, 0, NPCOL ),
170* NB_A, 0, 0, LCMQ ), MpC0 ) )*NB_A ) +
171* NB_A * NB_A
172* end if
173*
174* where LCMQ = LCM / NPCOL with LCM = ICLM( NPROW, NPCOL ),
175*
176* IROFFA = MOD( IA-1, MB_A ), ICOFFA = MOD( JA-1, NB_A ),
177* IAROW = INDXG2P( IA, MB_A, MYROW, RSRC_A, NPROW ),
178* NpA0 = NUMROC( N+IROFFA, MB_A, MYROW, IAROW, NPROW ),
179*
180* IROFFC = MOD( IC-1, MB_C ), ICOFFC = MOD( JC-1, NB_C ),
181* ICROW = INDXG2P( IC, MB_C, MYROW, RSRC_C, NPROW ),
182* ICCOL = INDXG2P( JC, NB_C, MYCOL, CSRC_C, NPCOL ),
183* MpC0 = NUMROC( M+IROFFC, MB_C, MYROW, ICROW, NPROW ),
184* NqC0 = NUMROC( N+ICOFFC, NB_C, MYCOL, ICCOL, NPCOL ),
185*
186* ILCM, INDXG2P and NUMROC are ScaLAPACK tool functions;
187* MYROW, MYCOL, NPROW and NPCOL can be determined by calling
188* the subroutine BLACS_GRIDINFO.
189*
190* If LWORK = -1, then LWORK is global input and a workspace
191* query is assumed; the routine only calculates the minimum
192* and optimal size for all work arrays. Each of these
193* values is returned in the first entry of the corresponding
194* work array, and no error message is issued by PXERBLA.
195*
196*
197* INFO (global output) INTEGER
198* = 0: successful exit
199* < 0: If the i-th argument is an array and the j-entry had
200* an illegal value, then INFO = -(i*100+j), if the i-th
201* argument is a scalar and had an illegal value, then
202* INFO = -i.
203*
204* Alignment requirements
205* ======================
206*
207* The distributed submatrices A(IA:*, JA:*) and C(IC:IC+M-1,JC:JC+N-1)
208* must verify some alignment properties, namely the following
209* expressions should be true:
210*
211* If SIDE = 'L',
212* ( MB_A.EQ.MB_C .AND. IROFFA.EQ.IROFFC .AND. IAROW.EQ.ICROW )
213* If SIDE = 'R',
214* ( MB_A.EQ.NB_C .AND. IROFFA.EQ.ICOFFC )
215*
216* =====================================================================
217*
218* .. Parameters ..
219 INTEGER BLOCK_CYCLIC_2D, CSRC_, CTXT_, DLEN_, DTYPE_,
220 $ LLD_, MB_, M_, NB_, N_, RSRC_
221 parameter( block_cyclic_2d = 1, dlen_ = 9, dtype_ = 1,
222 $ ctxt_ = 2, m_ = 3, n_ = 4, mb_ = 5, nb_ = 6,
223 $ rsrc_ = 7, csrc_ = 8, lld_ = 9 )
224* ..
225* .. Local Scalars ..
226 LOGICAL LEFT, LQUERY, NOTRAN
227 CHARACTER COLBTOP, ROWBTOP
228 INTEGER IAROW, ICCOL, ICOFFC, ICROW, ICTXT, IINFO, IPW,
229 $ IROFFA, IROFFC, J, J1, J2, J3, JB, LCM, LCMQ,
230 $ LWMIN, MI, MPC0, MYCOL, MYROW, NI, NPA0, NPCOL,
231 $ NPROW, NQ, NQC0
232* ..
233* .. Local Arrays ..
234 INTEGER IDUM1( 4 ), IDUM2( 4 )
235* ..
236* .. External Subroutines ..
237 EXTERNAL blacs_gridinfo, chk1mat, pchk2mat, pb_topget,
238 $ pb_topset, pxerbla, pzlarfb, pzlarft,
239 $ pzunm2l
240* ..
241* .. External Functions ..
242 LOGICAL LSAME
243 INTEGER ICEIL, ILCM, INDXG2P, NUMROC
244 EXTERNAL iceil, ilcm, indxg2p, lsame, numroc
245* ..
246* .. Intrinsic Functions ..
247 INTRINSIC dble, dcmplx, ichar, max, min, mod
248* ..
249* .. Executable Statements ..
250*
251* Get grid parameters
252*
253 ictxt = desca( ctxt_ )
254 CALL blacs_gridinfo( ictxt, nprow, npcol, myrow, mycol )
255*
256* Test the input parameters
257*
258 info = 0
259 IF( nprow.EQ.-1 ) THEN
260 info = -(900+ctxt_)
261 ELSE
262 left = lsame( side, 'l' )
263 NOTRAN = LSAME( TRANS, 'n' )
264*
265* NQ is the order of Q
266*
267 IF( LEFT ) THEN
268 NQ = M
269 CALL CHK1MAT( M, 3, K, 5, IA, JA, DESCA, 9, INFO )
270 ELSE
271 NQ = N
272 CALL CHK1MAT( N, 4, K, 5, IA, JA, DESCA, 9, INFO )
273 END IF
274 CALL CHK1MAT( M, 3, N, 4, IC, JC, DESCC, 14, INFO )
275.EQ. IF( INFO0 ) THEN
276 IROFFA = MOD( IA-1, DESCA( MB_ ) )
277 IROFFC = MOD( IC-1, DESCC( MB_ ) )
278 ICOFFC = MOD( JC-1, DESCC( NB_ ) )
279 IAROW = INDXG2P( IA, DESCA( MB_ ), MYROW, DESCA( RSRC_ ),
280 $ NPROW )
281 ICROW = INDXG2P( IC, DESCC( MB_ ), MYROW, DESCC( RSRC_ ),
282 $ NPROW )
283 ICCOL = INDXG2P( JC, DESCC( NB_ ), MYCOL, DESCC( CSRC_ ),
284 $ NPCOL )
285 MPC0 = NUMROC( M+IROFFC, DESCC( MB_ ), MYROW, ICROW, NPROW )
286 NQC0 = NUMROC( N+ICOFFC, DESCC( NB_ ), MYCOL, ICCOL, NPCOL )
287*
288 IF( LEFT ) THEN
289 LWMIN = MAX( ( DESCA( NB_ ) * ( DESCA( NB_ ) - 1 ) ) / 2,
290 $ ( MPC0 + NQC0 ) * DESCA( NB_ ) ) +
291 $ DESCA( NB_ ) * DESCA( NB_ )
292 ELSE
293 NPA0 = NUMROC( N+IROFFA, DESCA( MB_ ), MYROW, IAROW,
294 $ NPROW )
295 LCM = ILCM( NPROW, NPCOL )
296 LCMQ = LCM / NPCOL
297 LWMIN = MAX( ( DESCA( NB_ ) * ( DESCA( NB_ ) - 1 ) )
298 $ / 2, ( NQC0 + MAX( NPA0 + NUMROC( NUMROC(
299 $ N+ICOFFC, DESCA( NB_ ), 0, 0, NPCOL ),
300 $ DESCA( NB_ ), 0, 0, LCMQ ), MPC0 ) ) *
301 $ DESCA( NB_ ) ) + DESCA( NB_ ) * DESCA( NB_ )
302 END IF
303*
304 WORK( 1 ) = DCMPLX( DBLE( LWMIN ) )
305.EQ. LQUERY = ( LWORK-1 )
306.NOT..AND..NOT. IF( LEFT LSAME( SIDE, 'r' ) ) THEN
307 INFO = -1
308.NOT..AND..NOT. ELSE IF( NOTRAN LSAME( TRANS, 'c' ) ) THEN
309 INFO = -2
310.LT..OR..GT. ELSE IF( K0 KNQ ) THEN
311 INFO = -5
312.NOT..AND..NE. ELSE IF( LEFT DESCA( MB_ )DESCC( NB_ ) ) THEN
313 INFO = -(900+NB_)
314.AND..NE. ELSE IF( LEFT IROFFAIROFFC ) THEN
315 INFO = -12
316.AND..NE. ELSE IF( LEFT IAROWICROW ) THEN
317 INFO = -12
318.NOT..AND..NE. ELSE IF( LEFT IROFFAICOFFC ) THEN
319 INFO = -13
320.AND..NE. ELSE IF( LEFT DESCA( MB_ )DESCC( MB_ ) ) THEN
321 INFO = -(1400+MB_)
322.NE. ELSE IF( ICTXTDESCC( CTXT_ ) ) THEN
323 INFO = -(1400+CTXT_)
324.LT..AND..NOT. ELSE IF( LWORKLWMIN LQUERY ) THEN
325 INFO = -16
326 END IF
327 END IF
328*
329 IF( LEFT ) THEN
330 IDUM1( 1 ) = ICHAR( 'l' )
331 ELSE
332 IDUM1( 1 ) = ICHAR( 'r' )
333 END IF
334 IDUM2( 1 ) = 1
335 IF( NOTRAN ) THEN
336 IDUM1( 2 ) = ICHAR( 'n' )
337 ELSE
338 IDUM1( 2 ) = ICHAR( 'c' )
339 END IF
340 IDUM2( 2 ) = 2
341 IDUM1( 3 ) = K
342 IDUM2( 3 ) = 5
343.EQ. IF( LWORK-1 ) THEN
344 IDUM1( 4 ) = -1
345 ELSE
346 IDUM1( 4 ) = 1
347 END IF
348 IDUM2( 4 ) = 16
349 IF( LEFT ) THEN
350 CALL PCHK2MAT( M, 3, K, 5, IA, JA, DESCA, 9, M, 3, N, 4, IC,
351 $ JC, DESCC, 14, 4, IDUM1, IDUM2, INFO )
352 ELSE
353 CALL PCHK2MAT( N, 4, K, 5, IA, JA, DESCA, 9, M, 3, N, 4, IC,
354 $ JC, DESCC, 14, 4, IDUM1, IDUM2, INFO )
355 END IF
356 END IF
357*
358.NE. IF( INFO0 ) THEN
359 CALL PXERBLA( ICTXT, 'pzunmql', -INFO )
360 RETURN
361 ELSE IF( LQUERY ) THEN
362 RETURN
363 END IF
364*
365* Quick return if possible
366*
367.EQ..OR..EQ..OR..EQ. IF( M0 N0 K0 )
368 $ RETURN
369*
370 CALL PB_TOPGET( ICTXT, 'broadcast', 'rowwise', ROWBTOP )
371 CALL PB_TOPGET( ICTXT, 'broadcast', 'columnwise', COLBTOP )
372*
373.AND..OR. IF( ( LEFT NOTRAN )
374.NOT..AND..NOT. $ ( LEFT NOTRAN ) ) THEN
375 J1 = MIN( ICEIL( JA, DESCA( NB_ ) )*DESCA( NB_ ), JA+K-1 ) + 1
376 J2 = JA+K-1
377 J3 = DESCA( NB_ )
378 ELSE
379 J1 = MAX( ( (JA+K-2) / DESCA( NB_ ) ) * DESCA( NB_ ) + 1, JA )
380 J2 = MIN( ICEIL( JA, DESCA( NB_ ) )*DESCA( NB_ ), JA+K-1 ) + 1
381 J3 = -DESCA( NB_ )
382 END IF
383*
384 IF( LEFT ) THEN
385 NI = N
386 IF( NOTRAN ) THEN
387 CALL PB_TOPSET( ICTXT, 'broadcast', 'rowwise', 'i-ring' )
388 ELSE
389 CALL PB_TOPSET( ICTXT, 'broadcast', 'rowwise', 'd-ring' )
390 END IF
391 CALL PB_TOPSET( ICTXT, 'broadcast', 'columnwise', ' ' )
392 ELSE
393 MI = M
394 END IF
395*
396* Use unblocked code for the first block if necessary
397*
398.AND..OR. IF( ( LEFT NOTRAN )
399.NOT..AND..NOT. $ ( LEFT NOTRAN ) ) THEN
400 JB = J1 - JA
401 IF( LEFT ) THEN
402 MI = M - K + JB
403 ELSE
404 NI = N - K + JB
405 END IF
406 CALL PZUNM2L( SIDE, TRANS, MI, NI, JB, A, IA, JA, DESCA, TAU,
407 $ C, IC, JC, DESCC, WORK, LWORK, IINFO )
408 END IF
409*
410 IPW = DESCA( NB_ ) * DESCA( NB_ ) + 1
411 DO 10 J = J1, J2, J3
412 JB = MIN( DESCA( NB_ ), K-J+JA )
413*
414* Form the triangular factor of the block reflector
415* H = H(j+jb-1) . . . H(j+1) H(j)
416*
417 CALL PZLARFT( 'backward', 'columnwise', NQ-K+J+JB-JA, JB,
418 $ A, IA, J, DESCA, TAU, WORK, WORK( IPW ) )
419 IF( LEFT ) THEN
420*
421* H or H' is applied to C(ic:ic+m-k+j+jb-ja-1,jc:jc+n-1)
422*
423 MI = M - K + J + JB - JA
424 ELSE
425*
426* H or H' is applied to C(ic:ic+m-1,jc:jc+n-k+j+jb-ja-1)
427*
428 NI = N - K + J + JB - JA
429 END IF
430*
431* Apply H or H'
432*
433 CALL PZLARFB( SIDE, TRANS, 'backward', 'columnwise', MI, NI,
434 $ JB, A, IA, J, DESCA, WORK, C, IC, JC, DESCC,
435 $ WORK( IPW ) )
436 10 CONTINUE
437*
438.AND..NOT..OR. IF( ( LEFT NOTRAN )
439.NOT..AND. $ ( LEFT NOTRAN ) ) THEN
440 JB = J2 - JA
441 IF( LEFT ) THEN
442 MI = M - K + JB
443 ELSE
444 NI = N - K + JB
445 END IF
446 CALL PZUNM2L( SIDE, TRANS, MI, NI, JB, A, IA, JA, DESCA, TAU,
447 $ C, IC, JC, DESCC, WORK, LWORK, IINFO )
448 END IF
449*
450 CALL PB_TOPSET( ICTXT, 'broadcast', 'rowwise', ROWBTOP )
451 CALL PB_TOPSET( ICTXT, 'broadcast', 'columnwise', COLBTOP )
452*
453 WORK( 1 ) = DCMPLX( DBLE( LWMIN ) )
454*
455 RETURN
456*
457* End of PZUNMQL
458*
logical function lsame(ca, cb)
LSAME
Definition lsame.f:53
integer function iceil(inum, idenom)
Definition iceil.f:2
integer function ilcm(m, n)
Definition ilcm.f:2
#define min(a, b)
Definition macros.h:20
#define max(a, b)
Definition macros.h:21
integer function indxg2p(indxglob, nb, iproc, isrcproc, nprocs)
Definition mpi.f:947
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 pchk2mat(ma, mapos0, na, napos0, ia, ja, desca, descapos0, mb, mbpos0, nb, nbpos0, ib, jb, descb, descbpos0, nextra, ex, expos, info)
Definition mpi.f:1588
subroutine blacs_gridinfo(cntxt, nprow, npcol, myrow, mycol)
Definition mpi.f:754
integer function numroc(n, nb, iproc, isrcproc, nprocs)
Definition mpi.f:786
subroutine pzlarfb(side, trans, direct, storev, m, n, k, v, iv, jv, descv, t, c, ic, jc, descc, work)
Definition pzlarfb.f:3
subroutine pzlarft(direct, storev, n, k, v, iv, jv, descv, tau, t, work)
Definition pzlarft.f:3
subroutine pzunm2l(side, trans, m, n, k, a, ia, ja, desca, tau, c, ic, jc, descc, work, lwork, info)
Definition pzunm2l.f:3
subroutine pzunmql(side, trans, m, n, k, a, ia, ja, desca, tau, c, ic, jc, descc, work, lwork, info)
Definition pzunmql.f:3