|
ScaLAPACK
2.0.2
ScaLAPACK: Scalable Linear Algebra PACKage
|
00001 SUBROUTINE PSGEQL2( M, N, A, IA, JA, DESCA, TAU, WORK, LWORK, 00002 $ INFO ) 00003 * 00004 * -- ScaLAPACK routine (version 1.7) -- 00005 * University of Tennessee, Knoxville, Oak Ridge National Laboratory, 00006 * and University of California, Berkeley. 00007 * May 25, 2001 00008 * 00009 * .. Scalar Arguments .. 00010 INTEGER IA, INFO, JA, LWORK, M, N 00011 * .. 00012 * .. Array Arguments .. 00013 INTEGER DESCA( * ) 00014 REAL A( * ), TAU( * ), WORK( * ) 00015 * .. 00016 * 00017 * Purpose 00018 * ======= 00019 * 00020 * PSGEQL2 computes a QL factorization of a real distributed M-by-N 00021 * matrix sub( A ) = A(IA:IA+M-1,JA:JA+N-1) = Q * L. 00022 * 00023 * Notes 00024 * ===== 00025 * 00026 * Each global data object is described by an associated description 00027 * vector. This vector stores the information required to establish 00028 * the mapping between an object element and its corresponding process 00029 * and memory location. 00030 * 00031 * Let A be a generic term for any 2D block cyclicly distributed array. 00032 * Such a global array has an associated description vector DESCA. 00033 * In the following comments, the character _ should be read as 00034 * "of the global array". 00035 * 00036 * NOTATION STORED IN EXPLANATION 00037 * --------------- -------------- -------------------------------------- 00038 * DTYPE_A(global) DESCA( DTYPE_ )The descriptor type. In this case, 00039 * DTYPE_A = 1. 00040 * CTXT_A (global) DESCA( CTXT_ ) The BLACS context handle, indicating 00041 * the BLACS process grid A is distribu- 00042 * ted over. The context itself is glo- 00043 * bal, but the handle (the integer 00044 * value) may vary. 00045 * M_A (global) DESCA( M_ ) The number of rows in the global 00046 * array A. 00047 * N_A (global) DESCA( N_ ) The number of columns in the global 00048 * array A. 00049 * MB_A (global) DESCA( MB_ ) The blocking factor used to distribute 00050 * the rows of the array. 00051 * NB_A (global) DESCA( NB_ ) The blocking factor used to distribute 00052 * the columns of the array. 00053 * RSRC_A (global) DESCA( RSRC_ ) The process row over which the first 00054 * row of the array A is distributed. 00055 * CSRC_A (global) DESCA( CSRC_ ) The process column over which the 00056 * first column of the array A is 00057 * distributed. 00058 * LLD_A (local) DESCA( LLD_ ) The leading dimension of the local 00059 * array. LLD_A >= MAX(1,LOCr(M_A)). 00060 * 00061 * Let K be the number of rows or columns of a distributed matrix, 00062 * and assume that its process grid has dimension p x q. 00063 * LOCr( K ) denotes the number of elements of K that a process 00064 * would receive if K were distributed over the p processes of its 00065 * process column. 00066 * Similarly, LOCc( K ) denotes the number of elements of K that a 00067 * process would receive if K were distributed over the q processes of 00068 * its process row. 00069 * The values of LOCr() and LOCc() may be determined via a call to the 00070 * ScaLAPACK tool function, NUMROC: 00071 * LOCr( M ) = NUMROC( M, MB_A, MYROW, RSRC_A, NPROW ), 00072 * LOCc( N ) = NUMROC( N, NB_A, MYCOL, CSRC_A, NPCOL ). 00073 * An upper bound for these quantities may be computed by: 00074 * LOCr( M ) <= ceil( ceil(M/MB_A)/NPROW )*MB_A 00075 * LOCc( N ) <= ceil( ceil(N/NB_A)/NPCOL )*NB_A 00076 * 00077 * Arguments 00078 * ========= 00079 * 00080 * M (global input) INTEGER 00081 * The number of rows to be operated on, i.e. the number of rows 00082 * of the distributed submatrix sub( A ). M >= 0. 00083 * 00084 * N (global input) INTEGER 00085 * The number of columns to be operated on, i.e. the number of 00086 * columns of the distributed submatrix sub( A ). N >= 0. 00087 * 00088 * A (local input/local output) REAL pointer into the 00089 * local memory to an array of dimension (LLD_A, LOCc(JA+N-1)). 00090 * On entry, the local pieces of the M-by-N distributed matrix 00091 * sub( A ) which is to be factored. On exit, if M >= N, the 00092 * lower triangle of the distributed submatrix 00093 * A( IA+M-N:IA+M-1, JA:JA+N-1 ) contains the N-by-N lower 00094 * triangular matrix L; if M <= N, the elements on and below 00095 * the (N-M)-th superdiagonal contain the M by N lower 00096 * trapezoidal matrix L; the remaining elements, with the 00097 * array TAU, represent the orthogonal matrix Q as a product of 00098 * elementary reflectors (see Further Details). 00099 * 00100 * IA (global input) INTEGER 00101 * The row index in the global array A indicating the first 00102 * row of sub( A ). 00103 * 00104 * JA (global input) INTEGER 00105 * The column index in the global array A indicating the 00106 * first column of sub( A ). 00107 * 00108 * DESCA (global and local input) INTEGER array of dimension DLEN_. 00109 * The array descriptor for the distributed matrix A. 00110 * 00111 * TAU (local output) REAL, array, dimension LOCc(JA+N-1) 00112 * This array contains the scalar factors of the elementary 00113 * reflectors. TAU is tied to the distributed matrix A. 00114 * 00115 * WORK (local workspace/local output) REAL array, 00116 * dimension (LWORK) 00117 * On exit, WORK(1) returns the minimal and optimal LWORK. 00118 * 00119 * LWORK (local or global input) INTEGER 00120 * The dimension of the array WORK. 00121 * LWORK is local input and must be at least 00122 * LWORK >= Mp0 + MAX( 1, Nq0 ), where 00123 * 00124 * IROFF = MOD( IA-1, MB_A ), ICOFF = MOD( JA-1, NB_A ), 00125 * IAROW = INDXG2P( IA, MB_A, MYROW, RSRC_A, NPROW ), 00126 * IACOL = INDXG2P( JA, NB_A, MYCOL, CSRC_A, NPCOL ), 00127 * Mp0 = NUMROC( M+IROFF, MB_A, MYROW, IAROW, NPROW ), 00128 * Nq0 = NUMROC( N+ICOFF, NB_A, MYCOL, IACOL, NPCOL ), 00129 * 00130 * and NUMROC, INDXG2P are ScaLAPACK tool functions; 00131 * MYROW, MYCOL, NPROW and NPCOL can be determined by calling 00132 * the subroutine BLACS_GRIDINFO. 00133 * 00134 * If LWORK = -1, then LWORK is global input and a workspace 00135 * query is assumed; the routine only calculates the minimum 00136 * and optimal size for all work arrays. Each of these 00137 * values is returned in the first entry of the corresponding 00138 * work array, and no error message is issued by PXERBLA. 00139 * 00140 * INFO (local output) INTEGER 00141 * = 0: successful exit 00142 * < 0: If the i-th argument is an array and the j-entry had 00143 * an illegal value, then INFO = -(i*100+j), if the i-th 00144 * argument is a scalar and had an illegal value, then 00145 * INFO = -i. 00146 * 00147 * Further Details 00148 * =============== 00149 * 00150 * The matrix Q is represented as a product of elementary reflectors 00151 * 00152 * Q = H(ja+k-1) . . . H(ja+1) H(ja), where k = min(m,n). 00153 * 00154 * Each H(i) has the form 00155 * 00156 * H(i) = I - tau * v * v' 00157 * 00158 * where tau is a real scalar, and v is a real vector with 00159 * v(m-k+i+1:m) = 0 and v(m-k+i) = 1; v(1:m-k+i-1) is stored on exit in 00160 * A(ia:ia+m-k+i-2,ja+n-k+i-1), and tau in TAU(ja+n-k+i-1). 00161 * 00162 * ===================================================================== 00163 * 00164 * .. Parameters .. 00165 INTEGER BLOCK_CYCLIC_2D, CSRC_, CTXT_, DLEN_, DTYPE_, 00166 $ LLD_, MB_, M_, NB_, N_, RSRC_ 00167 PARAMETER ( BLOCK_CYCLIC_2D = 1, DLEN_ = 9, DTYPE_ = 1, 00168 $ CTXT_ = 2, M_ = 3, N_ = 4, MB_ = 5, NB_ = 6, 00169 $ RSRC_ = 7, CSRC_ = 8, LLD_ = 9 ) 00170 REAL ONE 00171 PARAMETER ( ONE = 1.0E+0 ) 00172 * .. 00173 * .. Local Scalars .. 00174 LOGICAL LQUERY 00175 CHARACTER COLBTOP, ROWBTOP 00176 INTEGER I, IACOL, IAROW, ICTXT, II, J, JJ, K, LWMIN, 00177 $ MP, MYCOL, MYROW, NPCOL, NPROW, NQ 00178 REAL AJJ, ALPHA 00179 * .. 00180 * .. External Subroutines .. 00181 EXTERNAL BLACS_ABORT, BLACS_GRIDINFO, CHK1MAT, INFOG2L, 00182 $ PSELSET, PSLARF, PSLARFG, PB_TOPGET, 00183 $ PB_TOPSET, PXERBLA, SGEBR2D, SGEBS2D, 00184 $ SLARFG, SSCAL 00185 * .. 00186 * .. External Functions .. 00187 INTEGER INDXG2P, NUMROC 00188 EXTERNAL INDXG2P, NUMROC 00189 * .. 00190 * .. Intrinsic Functions .. 00191 INTRINSIC MAX, MIN, MOD, REAL 00192 * .. 00193 * .. Executable Statements .. 00194 * 00195 * Get grid parameters 00196 * 00197 ICTXT = DESCA( CTXT_ ) 00198 CALL BLACS_GRIDINFO( ICTXT, NPROW, NPCOL, MYROW, MYCOL ) 00199 * 00200 * Test the input parameters 00201 * 00202 INFO = 0 00203 IF( NPROW.EQ.-1 ) THEN 00204 INFO = -(600+CTXT_) 00205 ELSE 00206 CALL CHK1MAT( M, 1, N, 2, IA, JA, DESCA, 6, INFO ) 00207 IF( INFO.EQ.0 ) THEN 00208 IAROW = INDXG2P( IA, DESCA( MB_ ), MYROW, DESCA( RSRC_ ), 00209 $ NPROW ) 00210 IACOL = INDXG2P( JA, DESCA( NB_ ), MYCOL, DESCA( CSRC_ ), 00211 $ NPCOL ) 00212 MP = NUMROC( M+MOD( IA-1, DESCA( MB_ ) ), DESCA( MB_ ), 00213 $ MYROW, IAROW, NPROW ) 00214 NQ = NUMROC( N+MOD( JA-1, DESCA( NB_ ) ), DESCA( NB_ ), 00215 $ MYCOL, IACOL, NPCOL ) 00216 LWMIN = MP + MAX( 1, NQ ) 00217 * 00218 WORK( 1 ) = REAL( LWMIN ) 00219 LQUERY = ( LWORK.EQ.-1 ) 00220 IF( LWORK.LT.LWMIN .AND. .NOT.LQUERY ) 00221 $ INFO = -9 00222 END IF 00223 END IF 00224 * 00225 IF( INFO.NE.0 ) THEN 00226 CALL PXERBLA( ICTXT, 'PSGEQL2', -INFO ) 00227 CALL BLACS_ABORT( ICTXT, 1 ) 00228 RETURN 00229 ELSE IF( LQUERY ) THEN 00230 RETURN 00231 END IF 00232 * 00233 * Quick return if possible 00234 * 00235 IF( M.EQ.0 .OR. N.EQ.0 ) 00236 $ RETURN 00237 * 00238 CALL PB_TOPGET( ICTXT, 'Broadcast', 'Rowwise', ROWBTOP ) 00239 CALL PB_TOPGET( ICTXT, 'Broadcast', 'Columnwise', COLBTOP ) 00240 CALL PB_TOPSET( ICTXT, 'Broadcast', 'Rowwise', 'D-ring' ) 00241 CALL PB_TOPSET( ICTXT, 'Broadcast', 'Columnwise', ' ' ) 00242 * 00243 IF( DESCA( M_ ).EQ.1 ) THEN 00244 IF( MYCOL.EQ.IACOL ) 00245 $ NQ = NQ - MOD( JA-1, DESCA( NB_ ) ) 00246 CALL INFOG2L( IA, JA, DESCA, NPROW, NPCOL, MYROW, MYCOL, II, 00247 $ JJ, IAROW, IACOL ) 00248 IACOL = INDXG2P( JA+N-1, DESCA( NB_ ), MYCOL, DESCA( CSRC_ ), 00249 $ NPCOL ) 00250 IF( MYROW.EQ.IAROW ) THEN 00251 IF( MYCOL.EQ.IACOL ) THEN 00252 I = II+(JJ+NQ-2)*DESCA( LLD_ ) 00253 AJJ = A( I ) 00254 CALL SLARFG( 1, AJJ, A( I ), 1, TAU( JJ+NQ-1 ) ) 00255 IF( N.GT.1 ) THEN 00256 ALPHA = ONE - TAU( JJ+NQ-1 ) 00257 CALL SGEBS2D( ICTXT, 'Rowwise', ' ', 1, 1, ALPHA, 1 ) 00258 CALL SSCAL( NQ-1, ALPHA, A( II+(JJ-1)*DESCA( LLD_ ) ), 00259 $ DESCA( LLD_ ) ) 00260 END IF 00261 CALL SGEBS2D( ICTXT, 'Columnwise', ' ', 1, 1, 00262 $ TAU( JJ+NQ-1 ), 1 ) 00263 A( I ) = AJJ 00264 ELSE 00265 IF( N.GT.1 ) THEN 00266 CALL SGEBR2D( ICTXT, 'Rowwise', ' ', 1, 1, ALPHA, 00267 $ 1, IAROW, IACOL ) 00268 CALL SSCAL( NQ, ALPHA, A( II+(JJ-1)*DESCA( LLD_ ) ), 00269 $ DESCA( LLD_ ) ) 00270 END IF 00271 END IF 00272 ELSE IF( MYCOL.EQ.IACOL ) THEN 00273 CALL SGEBR2D( ICTXT, 'Columnwise', ' ', 1, 1, 00274 $ TAU( JJ+NQ-1 ), 1, IAROW, IACOL ) 00275 END IF 00276 * 00277 ELSE 00278 * 00279 K = MIN( M, N ) 00280 DO 10 J = JA+K-1, JA, -1 00281 I = IA + J - JA 00282 * 00283 * Generate elementary reflector H(j) to annihilate 00284 * A(ia:i+m-k-1,j+n-k) 00285 * 00286 CALL PSLARFG( M-K+I-IA+1, AJJ, M-K+I, N-K+J, A, IA, 00287 $ N-K+J, DESCA, 1, TAU ) 00288 * 00289 * Apply H(j) to A(ia:i+m-k,ja:j+n-k-1) from the left 00290 * 00291 CALL PSELSET( A, I+M-K, J+N-K, DESCA, ONE ) 00292 CALL PSLARF( 'Left', M-K+I-IA+1, N-K+J-JA, A, IA, N-K+J, 00293 $ DESCA, 1, TAU, A, IA, JA, DESCA, WORK ) 00294 CALL PSELSET( A, I+M-K, J+N-K, DESCA, AJJ ) 00295 * 00296 10 CONTINUE 00297 * 00298 END IF 00299 * 00300 CALL PB_TOPSET( ICTXT, 'Broadcast', 'Rowwise', ROWBTOP ) 00301 CALL PB_TOPSET( ICTXT, 'Broadcast', 'Columnwise', COLBTOP ) 00302 * 00303 WORK( 1 ) = REAL( LWMIN ) 00304 * 00305 RETURN 00306 * 00307 * End of PSGEQL2 00308 * 00309 END