ScaLAPACK 2.1  2.1
ScaLAPACK: Scalable Linear Algebra PACKage
pdtzrzrv.f
Go to the documentation of this file.
1  SUBROUTINE pdtzrzrv( M, N, A, IA, JA, DESCA, TAU, WORK )
2 *
3 * -- ScaLAPACK routine (version 1.7) --
4 * University of Tennessee, Knoxville, Oak Ridge National Laboratory,
5 * and University of California, Berkeley.
6 * May 28, 2001
7 *
8 * .. Scalar Arguments ..
9  INTEGER IA, JA, M, N
10 * ..
11 * .. Array Arguments ..
12  INTEGER DESCA( * )
13  DOUBLE PRECISION A( * ), TAU( * ), WORK( * )
14 * ..
15 *
16 * Purpose
17 * =======
18 *
19 * PDTZRZRV computes sub( A ) = A(IA:IA+M-1,JA:JA+N-1) from T, Z
20 * computed by PDTZRZF.
21 *
22 * Notes
23 * =====
24 *
25 * Each global data object is described by an associated description
26 * vector. This vector stores the information required to establish
27 * the mapping between an object element and its corresponding process
28 * and memory location.
29 *
30 * Let A be a generic term for any 2D block cyclicly distributed array.
31 * Such a global array has an associated description vector DESCA.
32 * In the following comments, the character _ should be read as
33 * "of the global array".
34 *
35 * NOTATION STORED IN EXPLANATION
36 * --------------- -------------- --------------------------------------
37 * DTYPE_A(global) DESCA( DTYPE_ )The descriptor type. In this case,
38 * DTYPE_A = 1.
39 * CTXT_A (global) DESCA( CTXT_ ) The BLACS context handle, indicating
40 * the BLACS process grid A is distribu-
41 * ted over. The context itself is glo-
42 * bal, but the handle (the integer
43 * value) may vary.
44 * M_A (global) DESCA( M_ ) The number of rows in the global
45 * array A.
46 * N_A (global) DESCA( N_ ) The number of columns in the global
47 * array A.
48 * MB_A (global) DESCA( MB_ ) The blocking factor used to distribute
49 * the rows of the array.
50 * NB_A (global) DESCA( NB_ ) The blocking factor used to distribute
51 * the columns of the array.
52 * RSRC_A (global) DESCA( RSRC_ ) The process row over which the first
53 * row of the array A is distributed.
54 * CSRC_A (global) DESCA( CSRC_ ) The process column over which the
55 * first column of the array A is
56 * distributed.
57 * LLD_A (local) DESCA( LLD_ ) The leading dimension of the local
58 * array. LLD_A >= MAX(1,LOCr(M_A)).
59 *
60 * Let K be the number of rows or columns of a distributed matrix,
61 * and assume that its process grid has dimension p x q.
62 * LOCr( K ) denotes the number of elements of K that a process
63 * would receive if K were distributed over the p processes of its
64 * process column.
65 * Similarly, LOCc( K ) denotes the number of elements of K that a
66 * process would receive if K were distributed over the q processes of
67 * its process row.
68 * The values of LOCr() and LOCc() may be determined via a call to the
69 * ScaLAPACK tool function, NUMROC:
70 * LOCr( M ) = NUMROC( M, MB_A, MYROW, RSRC_A, NPROW ),
71 * LOCc( N ) = NUMROC( N, NB_A, MYCOL, CSRC_A, NPCOL ).
72 * An upper bound for these quantities may be computed by:
73 * LOCr( M ) <= ceil( ceil(M/MB_A)/NPROW )*MB_A
74 * LOCc( N ) <= ceil( ceil(N/NB_A)/NPCOL )*NB_A
75 *
76 * Arguments
77 * =========
78 *
79 * M (global input) INTEGER
80 * The number of rows to be operated on, i.e. the number of rows
81 * of the distributed submatrix sub( A ). M >= 0.
82 *
83 * N (global input) INTEGER
84 * The number of columns to be operated on, i.e. the number of
85 * columns of the distributed submatrix sub( A ). N >= M >= 0.
86 *
87 * A (local input/local output) DOUBLE PRECISION pointer into the
88 * local memory to an array of dimension (LLD_A, LOCc(JA+N-1)).
89 * On entry, sub( A ) contains the the factors T and Z computed
90 * by PDTZRZF. On exit, the original matrix is restored.
91 *
92 * IA (global input) INTEGER
93 * The row index in the global array A indicating the first
94 * row of sub( A ).
95 *
96 * JA (global input) INTEGER
97 * The column index in the global array A indicating the
98 * first column of sub( A ).
99 *
100 * DESCA (global and local input) INTEGER array of dimension DLEN_.
101 * The array descriptor for the distributed matrix A.
102 *
103 * TAU (local input) DOUBLE PRECISION, array, dimension LOCr(M_A).
104 * This array contains the scalar factors TAU of the elementary
105 * reflectors computed by PDTZRZF. TAU is tied to the dis-
106 * tributed matrix A.
107 *
108 * WORK (local workspace) DOUBLE PRECISION array, dimension (LWORK)
109 * LWORK = MB_A * ( Mp0 + 2*Nq0 + MB_A ), where
110 * Mp0 = NUMROC( M+IROFF, MB_A, MYROW, IAROW, NPROW ) * NB_A,
111 * Nq0 = NUMROC( N+ICOFF, NB_A, MYCOL, IACOL, NPCOL ) * MB_A,
112 * IROFF = MOD( IA-1, MB_A ), ICOFF = MOD( JA-1, NB_A ),
113 * IAROW = INDXG2P( IA, DESCA( MB_ ), MYROW, DESCA( RSRC_ ),
114 * NPROW ),
115 * IACOL = INDXG2P( JA, DESCA( NB_ ), MYCOL, DESCA( CSRC_ ),
116 * NPCOL ),
117 * and NUMROC, INDXG2P are ScaLAPACK tool functions.
118 *
119 * =====================================================================
120 *
121 * .. Parameters ..
122  INTEGER BLOCK_CYCLIC_2D, CSRC_, CTXT_, DLEN_, DTYPE_,
123  $ LLD_, MB_, M_, NB_, N_, RSRC_
124  parameter( block_cyclic_2d = 1, dlen_ = 9, dtype_ = 1,
125  $ ctxt_ = 2, m_ = 3, n_ = 4, mb_ = 5, nb_ = 6,
126  $ rsrc_ = 7, csrc_ = 8, lld_ = 9 )
127  DOUBLE PRECISION ZERO
128  parameter( zero = 0.0d+0 )
129 * ..
130 * .. Local Scalars ..
131  CHARACTER COLBTOP, ROWBTOP
132  INTEGER I, IACOL, IAROW, IB, ICOFF, ICTXT, IIA, IN,
133  $ IPT, IPV, IPW, JJA, JM1, JV, L, MYCOL, MYROW,
134  $ NPCOL, NPROW, NQ
135 * ..
136 * .. Local Arrays ..
137  INTEGER DESCV( DLEN_ )
138 * ..
139 * .. External Subroutines ..
140  EXTERNAL blacs_gridinfo, descset, infog2l, pdlacpy,
141  $ pdlarzb, pdlarzt, pdlaset, pb_topget,
142  $ pb_topset
143 * ..
144 * .. External Functions ..
145  INTEGER ICEIL, NUMROC
146  EXTERNAL iceil, numroc
147 * ..
148 * .. Intrinsic Functions ..
149  INTRINSIC max, min, mod
150 * ..
151 * .. Executable Statements ..
152 *
153 * Get grid parameters
154 *
155  ictxt = desca( ctxt_ )
156  CALL blacs_gridinfo( ictxt, nprow, npcol, myrow, mycol )
157 *
158 * Quick return if possible
159 *
160  IF( n.LT.m )
161  $ RETURN
162 *
163  l = n - m
164  jm1 = ja + min( m+1, n ) - 1
165  in = min( iceil( ia, desca( mb_ ) ) * desca( mb_ ), ia+m-1 )
166  icoff = mod( ja-1, desca( nb_ ) )
167  CALL infog2l( ia, ja, desca, nprow, npcol, myrow, mycol, iia, jja,
168  $ iarow, iacol )
169  nq = numroc( n+icoff, desca( nb_ ), mycol, iacol, npcol )
170  ipv = 1
171  ipt = ipv + nq * desca( mb_ )
172  ipw = ipt + desca( mb_ ) * desca( mb_ )
173  CALL pb_topget( ictxt, 'Broadcast', 'Rowwise', rowbtop )
174  CALL pb_topget( ictxt, 'Broadcast', 'Columnwise', colbtop )
175  CALL pb_topset( ictxt, 'Broadcast', 'Rowwise', ' ' )
176  CALL pb_topset( ictxt, 'Broadcast', 'Columnwise', 'I-ring' )
177 *
178  CALL descset( descv, desca( mb_ ), n + icoff, desca( mb_ ),
179  $ desca( nb_ ), iarow, iacol, ictxt, desca( mb_ ) )
180 *
181 * Handle first block separately
182 *
183  ib = in - ia + 1
184  jv = icoff + jm1 - ja + 1
185 *
186 * Compute upper triangular matrix T
187 *
188  CALL pdlarzt( 'Backward', 'Rowwise', l, ib, a, ia, jm1, desca,
189  $ tau, work( ipt ), work( ipw ) )
190 *
191 * Copy Householder vectors into workspace
192 *
193  CALL pdlacpy( 'All', ib, l, a, ia, jm1, desca, work( ipv ), 1,
194  $ jv, descv )
195 *
196 * Save temporarily strict lower part of A(IA:IA+IB-1,JA:JA+IB-1)
197 *
198  CALL pdlacpy( 'Lower', ib-1, ib-1, a, ia+1, ja, desca,
199  $ work( ipv ), 1, icoff+1, descv )
200 *
201 * Zeroes the row panel of sub( A ) to get T(IA:IN,JA:JA+N-1)
202 *
203  CALL pdlaset( 'All', ib, l, zero, zero, a, ia, jm1, desca )
204  CALL pdlaset( 'Lower', ib-1, ib-1, zero, zero, a, ia+1, ja,
205  $ desca )
206 *
207 * Apply block Householder transformation
208 *
209  CALL pdlarzb( 'Right', 'Transpose', 'Backward', 'Rowwise',
210  $ in-ia+1, n, ib, l, work( ipv ), 1, jv, descv,
211  $ work( ipt ), a, ia, ja, desca, work( ipw ) )
212 *
213 * Restore strict lower part of A( IA:IA+IB-1, JA:JA+N-1 )
214 *
215  CALL pdlacpy( 'Lower', ib-1, ib-1, work( ipv ), 1, icoff+1, descv,
216  $ a, ia+1, ja, desca )
217 *
218  descv( rsrc_ ) = mod( descv( rsrc_ ) + 1, nprow )
219 *
220 * Loop over the remaining row blocks
221 *
222  DO 10 i = in+1, ia+m-1, desca( mb_ )
223  ib = min( ia+m-i, desca( mb_ ) )
224 *
225 * Compute upper triangular matrix T
226 *
227  CALL pdlarzt( 'Backward', 'Rowwise', l, ib, a, i, jm1, desca,
228  $ tau, work( ipt ), work( ipw ) )
229 *
230 * Copy Householder vectors into workspace
231 *
232  CALL pdlacpy( 'All', ib, l, a, i, jm1, desca, work( ipv ), 1,
233  $ jv, descv )
234 *
235 * Save temporarily strict lower part of A(I:I+IB-1,J:J+IB-1 )
236 *
237  CALL pdlacpy( 'Lower', ib-1, ib-1, a, i+1, ja+i-ia, desca,
238  $ work( ipv ), 1, icoff+1+i-ia, descv )
239 *
240 * Zeoes the row panel of sub( A ) to get T(IA:I-1,JA+I-IA:JA+N-1)
241 *
242  CALL pdlaset( 'All', ib, l, zero, zero, a, i, jm1, desca )
243  CALL pdlaset( 'Lower', ib-1, ib-1, zero, zero, a, i+1, ja+i-ia,
244  $ desca )
245 *
246 * Apply block Householder transformation
247 *
248  CALL pdlarzb( 'Right', 'Transpose', 'Backward', 'Rowwise',
249  $ i+ib-ia, n-i+ia, ib, l, work( ipv ), 1, jv,
250  $ descv, work( ipt ), a, ia, ja+i-ia, desca,
251  $ work( ipw ) )
252 *
253  CALL pdlacpy( 'Lower', ib-1, ib-1, work( ipv ), 1,
254  $ icoff+1+i-ia, descv, a, i+1, ja+i-ia, desca )
255 *
256  descv( rsrc_ ) = mod( descv( rsrc_ ) + 1, nprow )
257 *
258  10 CONTINUE
259 *
260  CALL pb_topset( ictxt, 'Broadcast', 'Rowwise', rowbtop )
261  CALL pb_topset( ictxt, 'Broadcast', 'Columnwise', colbtop )
262 *
263  RETURN
264 *
265 * End of PDTZRZRV
266 *
267  END
max
#define max(A, B)
Definition: pcgemr.c:180
infog2l
subroutine infog2l(GRINDX, GCINDX, DESC, NPROW, NPCOL, MYROW, MYCOL, LRINDX, LCINDX, RSRC, CSRC)
Definition: infog2l.f:3
descset
subroutine descset(DESC, M, N, MB, NB, IRSRC, ICSRC, ICTXT, LLD)
Definition: descset.f:3
pdlarzt
subroutine pdlarzt(DIRECT, STOREV, N, K, V, IV, JV, DESCV, TAU, T, WORK)
Definition: pdlarzt.f:3
pdlaset
subroutine pdlaset(UPLO, M, N, ALPHA, BETA, A, IA, JA, DESCA)
Definition: pdblastst.f:6862
pdlarzb
subroutine pdlarzb(SIDE, TRANS, DIRECT, STOREV, M, N, K, L, V, IV, JV, DESCV, T, C, IC, JC, DESCC, WORK)
Definition: pdlarzb.f:3
pdtzrzrv
subroutine pdtzrzrv(M, N, A, IA, JA, DESCA, TAU, WORK)
Definition: pdtzrzrv.f:2
pdlacpy
subroutine pdlacpy(UPLO, M, N, A, IA, JA, DESCA, B, IB, JB, DESCB)
Definition: pdlacpy.f:3
min
#define min(A, B)
Definition: pcgemr.c:181