ScaLAPACK  2.0.2
ScaLAPACK: Scalable Linear Algebra PACKage
pdgerqrv.f
Go to the documentation of this file.
00001       SUBROUTINE PDGERQRV( 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       DOUBLE PRECISION   A( * ),  TAU( * ), WORK( * )
00014 *     ..
00015 *
00016 *  Purpose
00017 *  =======
00018 *
00019 *  PDGERQRV computes sub( A ) = A(IA:IA+M-1,JA:JA+N-1) from R, Q
00020 *  computed by PDGERQF.
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) DOUBLE PRECISION 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 R and Q computed
00090 *          by PDGERQF. 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) DOUBLE PRECISION, array, dimension LOCr(M_A).
00104 *          This array contains the scalar factors TAU of the elementary
00105 *          reflectors computed by PDGERQF. TAU is tied to the dis-
00106 *          tributed matrix A.
00107 *
00108 *  WORK    (local workspace) DOUBLE PRECISION array, dimension (LWORK)
00109 *          LWORK = MB_A * ( Mp0 + 2*Nq0 + MB_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 *
00119 *  =====================================================================
00120 *
00121 *     .. Parameters ..
00122       INTEGER            BLOCK_CYCLIC_2D, CSRC_, CTXT_, DLEN_, DTYPE_,
00123      $                   LLD_, MB_, M_, NB_, N_, RSRC_
00124       PARAMETER          ( BLOCK_CYCLIC_2D = 1, DLEN_ = 9, DTYPE_ = 1,
00125      $                     CTXT_ = 2, M_ = 3, N_ = 4, MB_ = 5, NB_ = 6,
00126      $                     RSRC_ = 7, CSRC_ = 8, LLD_ = 9 )
00127       DOUBLE PRECISION   ONE, ZERO
00128       PARAMETER          ( ONE = 1.0D+0, ZERO = 0.0D+0 )
00129 *     ..
00130 *     .. Local Scalars ..
00131       CHARACTER          COLBTOP, ROWBTOP
00132       INTEGER            I, IACOL, IAROW, IB, ICOFF, ICTXT, IIA, IN,
00133      $                   IPT, IPV, IPW, JJA, JV, K, MYCOL, MYROW, NPCOL,
00134      $                   NPROW, NQ
00135 *     ..
00136 *     .. Local Arrays ..
00137       INTEGER            DESCV( DLEN_ )
00138 *     ..
00139 *     .. External Subroutines ..
00140       EXTERNAL           BLACS_GRIDINFO, DESCSET, INFOG2L, PDLACPY,
00141      $                   PDLARFB, PDLARFT, PDLASET, PB_TOPGET,
00142      $                   PB_TOPSET
00143 *     ..
00144 *     .. External Functions ..
00145       INTEGER            ICEIL, NUMROC
00146       EXTERNAL           ICEIL, NUMROC
00147 *     ..
00148 *     .. Intrinsic Functions ..
00149       INTRINSIC          MAX, MIN, MOD
00150 *     ..
00151 *     .. Executable Statements ..
00152 *
00153 *     Get grid parameters
00154 *
00155       ICTXT = DESCA( CTXT_ )
00156       CALL BLACS_GRIDINFO( ICTXT, NPROW, NPCOL, MYROW, MYCOL )
00157 *
00158       K = MIN( M, N )
00159       IN = MIN( ICEIL( IA+M-K, DESCA( MB_ ) ) * DESCA( MB_ ), IA+M-1 )
00160 *
00161       ICOFF = MOD( JA-1, DESCA( NB_ ) )
00162       CALL INFOG2L( IA+M-K, JA, DESCA, NPROW, NPCOL, MYROW, MYCOL,
00163      $              IIA, JJA, IAROW, IACOL )
00164       NQ = NUMROC( N+ICOFF, DESCA( NB_ ), MYCOL, IACOL, NPCOL )
00165       IPV = 1
00166       IPT = IPV + NQ * DESCA( MB_ )
00167       IPW = IPT + DESCA( MB_ ) * DESCA( MB_ )
00168       CALL PB_TOPGET( ICTXT, 'Broadcast', 'Rowwise', ROWBTOP )
00169       CALL PB_TOPGET( ICTXT, 'Broadcast', 'Columnwise', COLBTOP )
00170       CALL PB_TOPSET( ICTXT, 'Broadcast', 'Rowwise', ' ' )
00171       CALL PB_TOPSET( ICTXT, 'Broadcast', 'Columnwise', 'I-ring' )
00172 *
00173       CALL DESCSET( DESCV, DESCA( MB_), N + ICOFF, DESCA( MB_ ),
00174      $              DESCA( NB_ ), IAROW, IACOL, ICTXT, DESCA( MB_ ) )
00175 *
00176 *     Handle first block separately
00177 *
00178       IB = IN - IA - M + K + 1
00179       JV = 1 + N - K + ICOFF
00180 *
00181 *     Compute upper triangular matrix T
00182 *
00183       CALL PDLARFT( 'Backward', 'Rowwise', N-M+IN-IA+1, IB, A, IA+M-K,
00184      $              JA, DESCA, TAU, WORK( IPT ), WORK( IPW ) )
00185 *
00186 *     Copy Householder vectors into workspace
00187 *
00188       CALL PDLACPY( 'All', IB, N-M+IN-IA+1, A, IA+M-K, JA, DESCA,
00189      $              WORK( IPV ), 1, ICOFF+1, DESCV )
00190       CALL PDLASET( 'Upper', IB, IB, ZERO, ONE, WORK( IPV ), 1, JV,
00191      $              DESCV )
00192 *
00193 *     Zeoes the strict lower triangular part of sub( A ) to get block
00194 *     column of R
00195 *
00196       CALL PDLASET( 'All', IB, N-K, ZERO, ZERO, A, IA+M-K, JA,
00197      $              DESCA )
00198       CALL PDLASET( 'Lower', IB-1, IB, ZERO, ZERO, A, IA+M-K+1,
00199      $              JA+N-K, DESCA )
00200 *
00201 *     Apply block Householder transformation
00202 *
00203       CALL PDLARFB( 'Right', 'Transpose', 'Backward', 'Rowwise',
00204      $              IN-IA+1, N-M+IN-IA+1, IB, WORK( IPV ), 1, ICOFF+1,
00205      $              DESCV, WORK( IPT ), A, IA, JA, DESCA, WORK( IPW ) )
00206 *
00207       DESCV( RSRC_ ) = MOD( DESCV( RSRC_ ) + 1, NPROW )
00208 *
00209 *     Loop over the remaining row blocks
00210 *
00211       DO 10 I = IN+1, IA+M-1, DESCA( MB_ )
00212          IB = MIN( IA+M-I, DESCA( MB_ ) )
00213          JV = 1 + N - M + I - IA + ICOFF
00214 *
00215 *        Compute upper triangular matrix T
00216 *
00217          CALL PDLARFT( 'Backward', 'Rowwise', N-M+I+IB-IA, IB, A, I, JA,
00218      $                 DESCA, TAU, WORK( IPT ), WORK( IPW ) )
00219 *
00220 *        Copy Householder vectors into workspace
00221 *
00222          CALL PDLACPY( 'All', IB, N-M+I+IB-IA, A, I, JA, DESCA,
00223      $                 WORK( IPV ), 1, ICOFF+1, DESCV )
00224          CALL PDLASET( 'Upper', IB, IB, ZERO, ONE, WORK( IPV ), 1, JV,
00225      $                 DESCV )
00226 *
00227 *        Zeoes the strict Lower triangular part of sub( A ) to get
00228 *        block column of R
00229 *
00230          CALL PDLASET( 'All', IB, N-M+I-IA, ZERO, ZERO, A, I, JA,
00231      $                 DESCA )
00232          CALL PDLASET( 'Lower', IB-1, IB, ZERO, ZERO, A, I+1,
00233      $                 JA+N-M+I-IA, DESCA )
00234 *
00235 *        Apply block Householder transformation
00236 *
00237          CALL PDLARFB( 'Right', 'Transpose', 'Backward', 'Rowwise',
00238      $                 I+IB-IA, N-M+I+IB-IA, IB, WORK( IPV ), 1,
00239      $                 ICOFF+1, DESCV, WORK( IPT ), A, IA, JA, DESCA,
00240      $                 WORK( IPW ) )
00241 *
00242          DESCV( RSRC_ ) = MOD( DESCV( RSRC_ ) + 1, NPROW )
00243 *
00244    10 CONTINUE
00245 *
00246       CALL PB_TOPSET( ICTXT, 'Broadcast', 'Rowwise', ROWBTOP )
00247       CALL PB_TOPSET( ICTXT, 'Broadcast', 'Columnwise', COLBTOP )
00248 *
00249       RETURN
00250 *
00251 *     End of PDGERQRV
00252 *
00253       END