SCALAPACK 2.2.2
LAPACK: Linear Algebra PACKage
Loading...
Searching...
No Matches

◆ pzgerqf()

subroutine pzgerqf ( integer  m,
integer  n,
complex*16, dimension( * )  a,
integer  ia,
integer  ja,
integer, dimension( * )  desca,
complex*16, dimension( * )  tau,
complex*16, dimension( * )  work,
integer  lwork,
integer  info 
)

Definition at line 1 of file pzgerqf.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 INTEGER IA, INFO, JA, LWORK, M, N
11* ..
12* .. Array Arguments ..
13 INTEGER DESCA( * )
14 COMPLEX*16 A( * ), TAU( * ), WORK( * )
15* ..
16*
17* Purpose
18* =======
19*
20* PZGERQF computes a RQ factorization of a complex distributed M-by-N
21* matrix sub( A ) = A(IA:IA+M-1,JA:JA+N-1) = R * Q.
22*
23* Notes
24* =====
25*
26* Each global data object is described by an associated description
27* vector. This vector stores the information required to establish
28* the mapping between an object element and its corresponding process
29* and memory location.
30*
31* Let A be a generic term for any 2D block cyclicly distributed array.
32* Such a global array has an associated description vector DESCA.
33* In the following comments, the character _ should be read as
34* "of the global array".
35*
36* NOTATION STORED IN EXPLANATION
37* --------------- -------------- --------------------------------------
38* DTYPE_A(global) DESCA( DTYPE_ )The descriptor type. In this case,
39* DTYPE_A = 1.
40* CTXT_A (global) DESCA( CTXT_ ) The BLACS context handle, indicating
41* the BLACS process grid A is distribu-
42* ted over. The context itself is glo-
43* bal, but the handle (the integer
44* value) may vary.
45* M_A (global) DESCA( M_ ) The number of rows in the global
46* array A.
47* N_A (global) DESCA( N_ ) The number of columns in the global
48* array A.
49* MB_A (global) DESCA( MB_ ) The blocking factor used to distribute
50* the rows of the array.
51* NB_A (global) DESCA( NB_ ) The blocking factor used to distribute
52* the columns of the array.
53* RSRC_A (global) DESCA( RSRC_ ) The process row over which the first
54* row of the array A is distributed.
55* CSRC_A (global) DESCA( CSRC_ ) The process column over which the
56* first column of the array A is
57* distributed.
58* LLD_A (local) DESCA( LLD_ ) The leading dimension of the local
59* array. LLD_A >= MAX(1,LOCr(M_A)).
60*
61* Let K be the number of rows or columns of a distributed matrix,
62* and assume that its process grid has dimension p x q.
63* LOCr( K ) denotes the number of elements of K that a process
64* would receive if K were distributed over the p processes of its
65* process column.
66* Similarly, LOCc( K ) denotes the number of elements of K that a
67* process would receive if K were distributed over the q processes of
68* its process row.
69* The values of LOCr() and LOCc() may be determined via a call to the
70* ScaLAPACK tool function, NUMROC:
71* LOCr( M ) = NUMROC( M, MB_A, MYROW, RSRC_A, NPROW ),
72* LOCc( N ) = NUMROC( N, NB_A, MYCOL, CSRC_A, NPCOL ).
73* An upper bound for these quantities may be computed by:
74* LOCr( M ) <= ceil( ceil(M/MB_A)/NPROW )*MB_A
75* LOCc( N ) <= ceil( ceil(N/NB_A)/NPCOL )*NB_A
76*
77* Arguments
78* =========
79*
80* M (global input) INTEGER
81* The number of rows to be operated on, i.e. the number of rows
82* of the distributed submatrix sub( A ). M >= 0.
83*
84* N (global input) INTEGER
85* The number of columns to be operated on, i.e. the number of
86* columns of the distributed submatrix sub( A ). N >= 0.
87*
88* A (local input/local output) COMPLEX*16 pointer into the
89* local memory to an array of dimension (LLD_A, LOCc(JA+N-1)).
90* On entry, the local pieces of the M-by-N distributed matrix
91* sub( A ) which is to be factored. On exit, if M <= N, the
92* upper triangle of A( IA:IA+M-1, JA+N-M:JA+N-1 ) contains the
93* M by M upper triangular matrix R; if M >= N, the elements on
94* and above the (M-N)-th subdiagonal contain the M by N upper
95* trapezoidal matrix R; the remaining elements, with the array
96* TAU, represent the unitary matrix Q as a product of
97* elementary reflectors (see Further Details).
98*
99* IA (global input) INTEGER
100* The row index in the global array A indicating the first
101* row of sub( A ).
102*
103* JA (global input) INTEGER
104* The column index in the global array A indicating the
105* first column of sub( A ).
106*
107* DESCA (global and local input) INTEGER array of dimension DLEN_.
108* The array descriptor for the distributed matrix A.
109*
110* TAU (local output) COMPLEX*16, array, dimension LOCr(IA+M-1)
111* This array contains the scalar factors of the elementary
112* reflectors. TAU is tied to the distributed matrix A.
113*
114* WORK (local workspace/local output) COMPLEX*16 array,
115* dimension (LWORK)
116* On exit, WORK(1) returns the minimal and optimal LWORK.
117*
118* LWORK (local or global input) INTEGER
119* The dimension of the array WORK.
120* LWORK is local input and must be at least
121* LWORK >= MB_A * ( Mp0 + Nq0 + MB_A ), where
122*
123* IROFF = MOD( IA-1, MB_A ), ICOFF = MOD( JA-1, NB_A ),
124* IAROW = INDXG2P( IA, MB_A, MYROW, RSRC_A, NPROW ),
125* IACOL = INDXG2P( JA, NB_A, MYCOL, CSRC_A, NPCOL ),
126* Mp0 = NUMROC( M+IROFF, MB_A, MYROW, IAROW, NPROW ),
127* Nq0 = NUMROC( N+ICOFF, NB_A, MYCOL, IACOL, NPCOL ),
128*
129* and NUMROC, INDXG2P are ScaLAPACK tool functions;
130* MYROW, MYCOL, NPROW and NPCOL can be determined by calling
131* the subroutine BLACS_GRIDINFO.
132*
133* If LWORK = -1, then LWORK is global input and a workspace
134* query is assumed; the routine only calculates the minimum
135* and optimal size for all work arrays. Each of these
136* values is returned in the first entry of the corresponding
137* work array, and no error message is issued by PXERBLA.
138*
139* INFO (global output) INTEGER
140* = 0: successful exit
141* < 0: If the i-th argument is an array and the j-entry had
142* an illegal value, then INFO = -(i*100+j), if the i-th
143* argument is a scalar and had an illegal value, then
144* INFO = -i.
145*
146* Further Details
147* ===============
148*
149* The matrix Q is represented as a product of elementary reflectors
150*
151* Q = H(ia)' H(ia+1)' . . . H(ia+k-1)', where k = min(m,n).
152*
153* Each H(i) has the form
154*
155* H(i) = I - tau * v * v'
156*
157* where tau is a complex scalar, and v is a complex vector with
158* v(n-k+i+1:n) = 0 and v(n-k+i) = 1; conjg(v(1:n-k+i-1)) is stored on
159* exit in A(ia+m-k+i-1,ja:ja+n-k+i-2), and tau in TAU(ia+m-k+i-1).
160*
161* =====================================================================
162*
163* .. Parameters ..
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 )
169* ..
170* .. Local Scalars ..
171 LOGICAL LQUERY
172 CHARACTER COLBTOP, ROWBTOP
173 INTEGER I, IACOL, IAROW, IB, ICTXT, IINFO, IL, IN, IPW,
174 $ K, LWMIN, MP0, MU, MYCOL, MYROW, NPCOL, NPROW,
175 $ NQ0, NU
176* ..
177* .. Local Arrays ..
178 INTEGER IDUM1( 1 ), IDUM2( 1 )
179* ..
180* .. External Subroutines ..
181 EXTERNAL blacs_gridinfo, chk1mat, pchk1mat, pb_topget,
182 $ pb_topset, pxerbla, pzgerq2, pzlarfb,
183 $ pzlarft
184* ..
185* .. External Functions ..
186 INTEGER ICEIL, INDXG2P, NUMROC
187 EXTERNAL iceil, indxg2p, numroc
188* ..
189* .. Intrinsic Functions ..
190 INTRINSIC dble, dcmplx, max, min, mod
191* ..
192* .. Executable Statements ..
193*
194* Get grid parameters
195*
196 ictxt = desca( ctxt_ )
197 CALL blacs_gridinfo( ictxt, nprow, npcol, myrow, mycol )
198*
199* Test the input parameters
200*
201 info = 0
202 IF( nprow.EQ.-1 ) THEN
203 info = -(600+ctxt_)
204 ELSE
205 CALL chk1mat( m, 1, n, 2, ia, ja, desca, 6, info )
206 IF( info.EQ.0 ) THEN
207 iarow = indxg2p( ia, desca( mb_ ), myrow, desca( rsrc_ ),
208 $ nprow )
209 iacol = indxg2p( ja, desca( nb_ ), mycol, desca( csrc_ ),
210 $ npcol )
211 mp0 = numroc( m+mod( ia-1, desca( mb_ ) ), desca( mb_ ),
212 $ myrow, iarow, nprow )
213 nq0 = numroc( n+mod( ja-1, desca( nb_ ) ), desca( nb_ ),
214 $ mycol, iacol, npcol )
215 lwmin = desca( mb_ ) * ( mp0 + nq0 + desca( mb_ ) )
216*
217 work( 1 ) = dcmplx( dble( lwmin ) )
218 lquery = ( lwork.EQ.-1 )
219 IF( lwork.LT.lwmin .AND. .NOT.lquery )
220 $ info = -9
221 END IF
222 IF( lquery ) THEN
223 idum1( 1 ) = -1
224 ELSE
225 idum1( 1 ) = 1
226 END IF
227 idum2( 1 ) = 9
228 CALL pchk1mat( m, 1, n, 2, ia, ja, desca, 6, 1, idum1, idum2,
229 $ info )
230 END IF
231*
232 IF( info.NE.0 ) THEN
233 CALL pxerbla( ictxt, 'PZGERQF', -info )
234 RETURN
235 ELSE IF( lquery ) THEN
236 RETURN
237 END IF
238*
239* Quick return if possible
240*
241 IF( m.EQ.0 .OR. n.EQ.0 )
242 $ RETURN
243*
244 k = min( m, n )
245 ipw = desca( mb_ ) * desca( mb_ ) + 1
246 in = min( iceil( ia+m-k, desca( mb_ ) ) * desca( mb_ ), ia+m-1 )
247 il = max( ( (ia+m-2) / desca( mb_ ) ) * desca( mb_ ) + 1, ia )
248 CALL pb_topget( ictxt, 'Broadcast', 'Rowwise', rowbtop )
249 CALL pb_topget( ictxt, 'Broadcast', 'Columnwise', colbtop )
250 CALL pb_topset( ictxt, 'Broadcast', 'Rowwise', ' ' )
251 CALL pb_topset( ictxt, 'Broadcast', 'Columnwise', 'D-ring' )
252*
253 IF( il.GE.in+1 ) THEN
254*
255* Use blocked code initially
256*
257 DO 10 i = il, in+1, -desca( mb_ )
258 ib = min( ia+m-i, desca( mb_ ) )
259*
260* Compute the RQ factorization of the current block
261* A(i:i+ib-1,ja:ja+n-m+i+ib-ia-1)
262*
263 CALL pzgerq2( ib, n-m+i+ib-ia, a, i, ja, desca, tau, work,
264 $ lwork, iinfo )
265*
266 IF( i.GT.ia ) THEN
267*
268* Form the triangular factor of the block reflector
269* H = H(i+ib-1) . . . H(i+1) H(i)
270*
271 CALL pzlarft( 'Backward', 'Rowwise', n-m+i+ib-ia, ib, a,
272 $ i, ja, desca, tau, work, work( ipw ) )
273*
274* Apply H to A(ia:i-1,ja:ja+n-m+i+ib-ia-1) from the
275* right
276*
277 CALL pzlarfb( 'Right', 'No transpose', 'Backward',
278 $ 'Rowwise', i-ia, n-m+i+ib-ia, ib, a, i, ja,
279 $ desca, work, a, ia, ja, desca,
280 $ work( ipw ) )
281 END IF
282*
283 10 CONTINUE
284*
285 mu = in - ia + 1
286 nu = n - m + in - ia + 1
287*
288 ELSE
289*
290 mu = m
291 nu = n
292*
293 END IF
294*
295* Use unblocked code to factor the last or only block
296*
297 IF( mu.GT.0 .AND. nu.GT.0 )
298 $ CALL pzgerq2( mu, nu, a, ia, ja, desca, tau, work, lwork,
299 $ iinfo )
300*
301 CALL pb_topset( ictxt, 'Broadcast', 'Rowwise', rowbtop )
302 CALL pb_topset( ictxt, 'Broadcast', 'Columnwise', colbtop )
303*
304 work( 1 ) = dcmplx( dble( lwmin ) )
305*
306 RETURN
307*
308* End of PZGERQF
309*
subroutine chk1mat(ma, mapos0, na, napos0, ia, ja, desca, descapos0, info)
Definition chk1mat.f:3
integer function iceil(inum, idenom)
Definition iceil.f:2
integer function indxg2p(indxglob, nb, iproc, isrcproc, nprocs)
Definition indxg2p.f:2
integer function numroc(n, nb, iproc, isrcproc, nprocs)
Definition numroc.f:2
#define max(A, B)
Definition pcgemr.c:180
#define min(A, B)
Definition pcgemr.c:181
subroutine pchk1mat(ma, mapos0, na, napos0, ia, ja, desca, descapos0, nextra, ex, expos, info)
Definition pchkxmat.f:3
subroutine pxerbla(ictxt, srname, info)
Definition pxerbla.f:2
subroutine pzgerq2(m, n, a, ia, ja, desca, tau, work, lwork, info)
Definition pzgerq2.f:3
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
Here is the call graph for this function:
Here is the caller graph for this function: