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