|
ScaLAPACK
2.0.2
ScaLAPACK: Scalable Linear Algebra PACKage
|
00001 SUBROUTINE PCGEQRRV( M, N, A, IA, JA, DESCA, TAU, WORK ) 00002 * 00003 * -- ScaLAPACK routine (version 1.7) -- 00004 * University of Tennessee, Knoxville, Oak Ridge National Laboratory, 00005 * and University of California, Berkeley. 00006 * May 28, 2001 00007 * 00008 * .. Scalar Arguments .. 00009 INTEGER IA, JA, M, N 00010 * .. 00011 * .. Array Arguments .. 00012 INTEGER DESCA( * ) 00013 COMPLEX A( * ), TAU( * ), WORK( * ) 00014 * .. 00015 * 00016 * Purpose 00017 * ======= 00018 * 00019 * PCGEQRRV computes sub( A ) = A(IA:IA+M-1,JA:JA+N-1) from Q, R 00020 * computed by PCGEQRF. 00021 * 00022 * Notes 00023 * ===== 00024 * 00025 * Each global data object is described by an associated description 00026 * vector. This vector stores the information required to establish 00027 * the mapping between an object element and its corresponding process 00028 * and memory location. 00029 * 00030 * Let A be a generic term for any 2D block cyclicly distributed array. 00031 * Such a global array has an associated description vector DESCA. 00032 * In the following comments, the character _ should be read as 00033 * "of the global array". 00034 * 00035 * NOTATION STORED IN EXPLANATION 00036 * --------------- -------------- -------------------------------------- 00037 * DTYPE_A(global) DESCA( DTYPE_ )The descriptor type. In this case, 00038 * DTYPE_A = 1. 00039 * CTXT_A (global) DESCA( CTXT_ ) The BLACS context handle, indicating 00040 * the BLACS process grid A is distribu- 00041 * ted over. The context itself is glo- 00042 * bal, but the handle (the integer 00043 * value) may vary. 00044 * M_A (global) DESCA( M_ ) The number of rows in the global 00045 * array A. 00046 * N_A (global) DESCA( N_ ) The number of columns in the global 00047 * array A. 00048 * MB_A (global) DESCA( MB_ ) The blocking factor used to distribute 00049 * the rows of the array. 00050 * NB_A (global) DESCA( NB_ ) The blocking factor used to distribute 00051 * the columns of the array. 00052 * RSRC_A (global) DESCA( RSRC_ ) The process row over which the first 00053 * row of the array A is distributed. 00054 * CSRC_A (global) DESCA( CSRC_ ) The process column over which the 00055 * first column of the array A is 00056 * distributed. 00057 * LLD_A (local) DESCA( LLD_ ) The leading dimension of the local 00058 * array. LLD_A >= MAX(1,LOCr(M_A)). 00059 * 00060 * Let K be the number of rows or columns of a distributed matrix, 00061 * and assume that its process grid has dimension p x q. 00062 * LOCr( K ) denotes the number of elements of K that a process 00063 * would receive if K were distributed over the p processes of its 00064 * process column. 00065 * Similarly, LOCc( K ) denotes the number of elements of K that a 00066 * process would receive if K were distributed over the q processes of 00067 * its process row. 00068 * The values of LOCr() and LOCc() may be determined via a call to the 00069 * ScaLAPACK tool function, NUMROC: 00070 * LOCr( M ) = NUMROC( M, MB_A, MYROW, RSRC_A, NPROW ), 00071 * LOCc( N ) = NUMROC( N, NB_A, MYCOL, CSRC_A, NPCOL ). 00072 * An upper bound for these quantities may be computed by: 00073 * LOCr( M ) <= ceil( ceil(M/MB_A)/NPROW )*MB_A 00074 * LOCc( N ) <= ceil( ceil(N/NB_A)/NPCOL )*NB_A 00075 * 00076 * Arguments 00077 * ========= 00078 * 00079 * M (global input) INTEGER 00080 * The number of rows to be operated on, i.e. the number of rows 00081 * of the distributed submatrix sub( A ). M >= 0. 00082 * 00083 * N (global input) INTEGER 00084 * The number of columns to be operated on, i.e. the number of 00085 * columns of the distributed submatrix sub( A ). N >= 0. 00086 * 00087 * A (local input/local output) COMPLEX pointer into the 00088 * local memory to an array of dimension (LLD_A, LOCc(JA+N-1)). 00089 * On entry, sub( A ) contains the the factors Q and R computed 00090 * by PCGEQRF. On exit, the original matrix is restored. 00091 * 00092 * IA (global input) INTEGER 00093 * The row index in the global array A indicating the first 00094 * row of sub( A ). 00095 * 00096 * JA (global input) INTEGER 00097 * The column index in the global array A indicating the 00098 * first column of sub( A ). 00099 * 00100 * DESCA (global and local input) INTEGER array of dimension DLEN_. 00101 * The array descriptor for the distributed matrix A. 00102 * 00103 * TAU (local input) COMPLEX, array, dimension 00104 * LOCc(JA+MIN(M,N)-1). This array contains the scalar factors 00105 * TAU of the elementary reflectors computed by PCGEQRF. TAU 00106 * is tied to the distributed matrix A. 00107 * 00108 * WORK (local workspace) COMPLEX array, dimension (LWORK) 00109 * LWORK = NB_A * ( 2*Mp0 + Nq0 + NB_A ), where 00110 * Mp0 = NUMROC( M+IROFF, MB_A, MYROW, IAROW, NPROW ) * NB_A, 00111 * Nq0 = NUMROC( N+ICOFF, NB_A, MYCOL, IACOL, NPCOL ) * MB_A, 00112 * IROFF = MOD( IA-1, MB_A ), ICOFF = MOD( JA-1, NB_A ), 00113 * IAROW = INDXG2P( IA, DESCA( MB_ ), MYROW, DESCA( RSRC_ ), 00114 * NPROW ), 00115 * IACOL = INDXG2P( JA, DESCA( NB_ ), MYCOL, DESCA( CSRC_ ), 00116 * NPCOL ), 00117 * and NUMROC, INDXG2P are ScaLAPACK tool functions; 00118 * MYROW, MYCOL, NPROW and NPCOL can be determined by calling 00119 * the subroutine BLACS_GRIDINFO. 00120 * 00121 * ===================================================================== 00122 * 00123 * .. Parameters .. 00124 INTEGER BLOCK_CYCLIC_2D, CSRC_, CTXT_, DLEN_, DTYPE_, 00125 $ LLD_, MB_, M_, NB_, N_, RSRC_ 00126 PARAMETER ( BLOCK_CYCLIC_2D = 1, DLEN_ = 9, DTYPE_ = 1, 00127 $ CTXT_ = 2, M_ = 3, N_ = 4, MB_ = 5, NB_ = 6, 00128 $ RSRC_ = 7, CSRC_ = 8, LLD_ = 9 ) 00129 COMPLEX ONE, ZERO 00130 PARAMETER ( ONE = ( 1.0E+0, 0.0E+0 ), 00131 $ ZERO = ( 0.0E+0, 0.0E+0 ) ) 00132 * .. 00133 * .. Local Scalars .. 00134 CHARACTER COLBTOP, ROWBTOP 00135 INTEGER IACOL, IAROW, I, ICTXT, IIA, IPT, IPV, IPW, 00136 $ IROFF, IV, J, JB, JJA, JL, JN, K, MP, MYCOL, 00137 $ MYROW, NPCOL, NPROW 00138 * .. 00139 * .. Local Arrays .. 00140 INTEGER DESCV( DLEN_ ) 00141 * .. 00142 * .. External Subroutines .. 00143 EXTERNAL BLACS_GRIDINFO, DESCSET, INFOG2L, PCLACPY, 00144 $ PCLARFB, PCLARFT, PCLASET, PB_TOPGET, 00145 $ PB_TOPSET 00146 * .. 00147 * .. External Functions .. 00148 INTEGER ICEIL, INDXG2P, NUMROC 00149 EXTERNAL ICEIL, INDXG2P, NUMROC 00150 * .. 00151 * .. Intrinsic Functions .. 00152 INTRINSIC MAX, MIN, MOD 00153 * .. 00154 * .. Executable Statements .. 00155 * 00156 * Get grid parameters 00157 * 00158 ICTXT = DESCA( CTXT_ ) 00159 CALL BLACS_GRIDINFO( ICTXT, NPROW, NPCOL, MYROW, MYCOL ) 00160 * 00161 IROFF = MOD( IA-1, DESCA( MB_ ) ) 00162 CALL INFOG2L( IA, JA, DESCA, NPROW, NPCOL, MYROW, MYCOL, IIA, JJA, 00163 $ IAROW, IACOL ) 00164 MP = NUMROC( M+IROFF, DESCA( MB_ ), MYROW, IAROW, NPROW ) 00165 IPV = 1 00166 IPT = IPV + MP * DESCA( NB_ ) 00167 IPW = IPT + DESCA( NB_ ) * DESCA( NB_ ) 00168 CALL PB_TOPGET( ICTXT, 'Broadcast', 'Rowwise', ROWBTOP ) 00169 CALL PB_TOPGET( ICTXT, 'Broadcast', 'Columnwise', COLBTOP ) 00170 CALL PB_TOPSET( ICTXT, 'Broadcast', 'Rowwise', 'D-ring' ) 00171 CALL PB_TOPSET( ICTXT, 'Broadcast', 'Columnwise', ' ' ) 00172 * 00173 K = MIN( M, N ) 00174 JN = MIN( ICEIL( JA, DESCA( NB_ ) ) * DESCA( NB_ ), JA+K-1 ) 00175 JL = MAX( ( (JA+K-2) / DESCA( NB_ ) ) * DESCA( NB_ ) + 1, JA ) 00176 * 00177 CALL DESCSET( DESCV, M+IROFF, DESCA( NB_ ), DESCA( MB_ ), 00178 $ DESCA( NB_ ), IAROW, INDXG2P( JL, DESCA( NB_ ), 00179 $ MYCOL, DESCA( CSRC_ ), NPCOL ), ICTXT, 00180 $ MAX( 1, MP ) ) 00181 * 00182 DO 10 J = JL, JN+1, -DESCA( NB_ ) 00183 JB = MIN( JA+K-J, DESCA( NB_ ) ) 00184 I = IA + J - JA 00185 IV = 1 + J - JA + IROFF 00186 * 00187 * Compute upper triangular matrix T 00188 * 00189 CALL PCLARFT( 'Forward', 'Columnwise', M-I+IA, JB, A, I, J, 00190 $ DESCA, TAU, WORK( IPT ), WORK( IPW ) ) 00191 * 00192 * Copy Householder vectors into workspace 00193 * 00194 CALL PCLACPY( 'Lower', M-I+IA, JB, A, I, J, DESCA, WORK( IPV ), 00195 $ IV, 1, DESCV ) 00196 CALL PCLASET( 'Upper', M-I+IA, JB, ZERO, ONE, WORK( IPV ), IV, 00197 $ 1, DESCV ) 00198 * 00199 * Zeroes the strict lower triangular part of sub( A ) to get 00200 * block column of R 00201 * 00202 CALL PCLASET( 'Lower', M-I+IA-1, JB, ZERO, ZERO, A, I+1, J, 00203 $ DESCA ) 00204 * 00205 * Apply block Householder transformation 00206 * 00207 CALL PCLARFB( 'Left', 'No transpose', 'Forward', 'Columnwise', 00208 $ M-I+IA, N-J+JA, JB, WORK( IPV ), IV, 1, DESCV, 00209 $ WORK( IPT ), A, I, J, DESCA, WORK( IPW ) ) 00210 * 00211 DESCV( CSRC_ ) = MOD( DESCV( CSRC_ ) + NPCOL - 1, NPCOL ) 00212 * 00213 10 CONTINUE 00214 * 00215 * Handle first block separately 00216 * 00217 JB = JN - JA + 1 00218 * 00219 * Compute upper triangular matrix T 00220 * 00221 CALL PCLARFT( 'Forward', 'Columnwise', M, JB, A, IA, JA, DESCA, 00222 $ TAU, WORK( IPT ), WORK( IPW ) ) 00223 * 00224 * Copy Householder vectors into workspace 00225 * 00226 CALL PCLACPY( 'Lower', M, JB, A, IA, JA, DESCA, WORK( IPV ), 00227 $ IROFF+1, 1, DESCV ) 00228 CALL PCLASET( 'Upper', M, JB, ZERO, ONE, WORK, IROFF+1, 1, DESCV ) 00229 * 00230 * Zeroes the strict lower triangular part of sub( A ) to get block 00231 * column of R 00232 * 00233 CALL PCLASET( 'Lower', M-1, JB, ZERO, ZERO, A, IA+1, JA, DESCA ) 00234 * 00235 * Apply block Householder transformation 00236 * 00237 CALL PCLARFB( 'Left', 'No transpose', 'Forward', 'Columnwise', M, 00238 $ N, JB, WORK( IPV ), IROFF+1, 1, DESCV, WORK( IPT ), 00239 $ A, IA, JA, DESCA, WORK( IPW ) ) 00240 * 00241 CALL PB_TOPSET( ICTXT, 'Broadcast', 'Rowwise', ROWBTOP ) 00242 CALL PB_TOPSET( ICTXT, 'Broadcast', 'Columnwise', COLBTOP ) 00243 * 00244 RETURN 00245 * 00246 * End of PCGEQRRV 00247 * 00248 END