Annotation of rpl/lapack/lapack/zlamtsqr.f, revision 1.3

1.1       bertrand    1: *
                      2: *  Definition:
                      3: *  ===========
                      4: *
                      5: *      SUBROUTINE ZLAMTSQR( SIDE, TRANS, M, N, K, MB, NB, A, LDA, T,
                      6: *     $                     LDT, C, LDC, WORK, LWORK, INFO )
                      7: *
                      8: *
                      9: *     .. Scalar Arguments ..
                     10: *      CHARACTER         SIDE, TRANS
                     11: *      INTEGER           INFO, LDA, M, N, K, MB, NB, LDT, LWORK, LDC
                     12: *     ..
                     13: *     .. Array Arguments ..
                     14: *      COMPLEX*16        A( LDA, * ), WORK( * ), C(LDC, * ),
                     15: *     $                  T( LDT, * )
                     16: *> \par Purpose:
                     17: *  =============
                     18: *>
                     19: *> \verbatim
                     20: *>
                     21: *>      ZLAMTSQR overwrites the general complex M-by-N matrix C with
                     22: *>
                     23: *>
                     24: *>                 SIDE = 'L'     SIDE = 'R'
                     25: *> TRANS = 'N':      Q * C          C * Q
1.3     ! bertrand   26: *> TRANS = 'C':      Q**H * C       C * Q**H
1.1       bertrand   27: *>      where Q is a real orthogonal matrix defined as the product
                     28: *>      of blocked elementary reflectors computed by tall skinny
                     29: *>      QR factorization (ZLATSQR)
                     30: *> \endverbatim
                     31: *
                     32: *  Arguments:
                     33: *  ==========
                     34: *
                     35: *> \param[in] SIDE
                     36: *> \verbatim
                     37: *>          SIDE is CHARACTER*1
1.3     ! bertrand   38: *>          = 'L': apply Q or Q**H from the Left;
        !            39: *>          = 'R': apply Q or Q**H from the Right.
1.1       bertrand   40: *> \endverbatim
                     41: *>
                     42: *> \param[in] TRANS
                     43: *> \verbatim
                     44: *>          TRANS is CHARACTER*1
                     45: *>          = 'N':  No transpose, apply Q;
1.3     ! bertrand   46: *>          = 'C':  Conjugate Transpose, apply Q**H.
1.1       bertrand   47: *> \endverbatim
                     48: *>
                     49: *> \param[in] M
                     50: *> \verbatim
                     51: *>          M is INTEGER
                     52: *>          The number of rows of the matrix A.  M >=0.
                     53: *> \endverbatim
                     54: *>
                     55: *> \param[in] N
                     56: *> \verbatim
                     57: *>          N is INTEGER
                     58: *>          The number of columns of the matrix C. M >= N >= 0.
                     59: *> \endverbatim
                     60: *>
                     61: *> \param[in] K
                     62: *> \verbatim
                     63: *>          K is INTEGER
                     64: *>          The number of elementary reflectors whose product defines
                     65: *>          the matrix Q.
                     66: *>          N >= K >= 0;
                     67: *>
                     68: *> \endverbatim
                     69: *>
                     70: *> \param[in] MB
                     71: *> \verbatim
                     72: *>          MB is INTEGER
                     73: *>          The block size to be used in the blocked QR.
                     74: *>          MB > N. (must be the same as DLATSQR)
                     75: *> \endverbatim
                     76: *>
                     77: *> \param[in] NB
                     78: *> \verbatim
                     79: *>          NB is INTEGER
                     80: *>          The column block size to be used in the blocked QR.
                     81: *>          N >= NB >= 1.
                     82: *> \endverbatim
                     83: *>
1.3     ! bertrand   84: *> \param[in] A
1.1       bertrand   85: *> \verbatim
                     86: *>          A is COMPLEX*16 array, dimension (LDA,K)
                     87: *>          The i-th column must contain the vector which defines the
                     88: *>          blockedelementary reflector H(i), for i = 1,2,...,k, as
                     89: *>          returned by DLATSQR in the first k columns of
                     90: *>          its array argument A.
                     91: *> \endverbatim
                     92: *>
                     93: *> \param[in] LDA
                     94: *> \verbatim
                     95: *>          LDA is INTEGER
                     96: *>          The leading dimension of the array A.
                     97: *>          If SIDE = 'L', LDA >= max(1,M);
                     98: *>          if SIDE = 'R', LDA >= max(1,N).
                     99: *> \endverbatim
                    100: *>
                    101: *> \param[in] T
                    102: *> \verbatim
                    103: *>          T is COMPLEX*16 array, dimension
                    104: *>          ( N * Number of blocks(CEIL(M-K/MB-K)),
                    105: *>          The blocked upper triangular block reflectors stored in compact form
                    106: *>          as a sequence of upper triangular blocks.  See below
                    107: *>          for further details.
                    108: *> \endverbatim
                    109: *>
                    110: *> \param[in] LDT
                    111: *> \verbatim
                    112: *>          LDT is INTEGER
                    113: *>          The leading dimension of the array T.  LDT >= NB.
                    114: *> \endverbatim
                    115: *>
                    116: *> \param[in,out] C
                    117: *> \verbatim
                    118: *>          C is COMPLEX*16 array, dimension (LDC,N)
                    119: *>          On entry, the M-by-N matrix C.
1.3     ! bertrand  120: *>          On exit, C is overwritten by Q*C or Q**H*C or C*Q**H or C*Q.
1.1       bertrand  121: *> \endverbatim
                    122: *>
                    123: *> \param[in] LDC
                    124: *> \verbatim
                    125: *>          LDC is INTEGER
                    126: *>          The leading dimension of the array C. LDC >= max(1,M).
                    127: *> \endverbatim
                    128: *>
                    129: *> \param[out] WORK
                    130: *> \verbatim
                    131: *>         (workspace) COMPLEX*16 array, dimension (MAX(1,LWORK))
                    132: *>
                    133: *> \endverbatim
                    134: *> \param[in] LWORK
                    135: *> \verbatim
                    136: *>          LWORK is INTEGER
                    137: *>          The dimension of the array WORK.
                    138: *>
                    139: *>          If SIDE = 'L', LWORK >= max(1,N)*NB;
                    140: *>          if SIDE = 'R', LWORK >= max(1,MB)*NB.
                    141: *>          If LWORK = -1, then a workspace query is assumed; the routine
                    142: *>          only calculates the optimal size of the WORK array, returns
                    143: *>          this value as the first entry of the WORK array, and no error
                    144: *>          message related to LWORK is issued by XERBLA.
                    145: *>
                    146: *> \endverbatim
                    147: *> \param[out] INFO
                    148: *> \verbatim
                    149: *>          INFO is INTEGER
                    150: *>          = 0:  successful exit
                    151: *>          < 0:  if INFO = -i, the i-th argument had an illegal value
                    152: *> \endverbatim
                    153: *
                    154: *  Authors:
                    155: *  ========
                    156: *
                    157: *> \author Univ. of Tennessee
                    158: *> \author Univ. of California Berkeley
                    159: *> \author Univ. of Colorado Denver
                    160: *> \author NAG Ltd.
                    161: *
                    162: *> \par Further Details:
                    163: *  =====================
                    164: *>
                    165: *> \verbatim
                    166: *> Tall-Skinny QR (TSQR) performs QR by a sequence of orthogonal transformations,
                    167: *> representing Q as a product of other orthogonal matrices
                    168: *>   Q = Q(1) * Q(2) * . . . * Q(k)
                    169: *> where each Q(i) zeros out subdiagonal entries of a block of MB rows of A:
                    170: *>   Q(1) zeros out the subdiagonal entries of rows 1:MB of A
                    171: *>   Q(2) zeros out the bottom MB-N rows of rows [1:N,MB+1:2*MB-N] of A
                    172: *>   Q(3) zeros out the bottom MB-N rows of rows [1:N,2*MB-N+1:3*MB-2*N] of A
                    173: *>   . . .
                    174: *>
                    175: *> Q(1) is computed by GEQRT, which represents Q(1) by Householder vectors
                    176: *> stored under the diagonal of rows 1:MB of A, and by upper triangular
                    177: *> block reflectors, stored in array T(1:LDT,1:N).
                    178: *> For more information see Further Details in GEQRT.
                    179: *>
                    180: *> Q(i) for i>1 is computed by TPQRT, which represents Q(i) by Householder vectors
                    181: *> stored in rows [(i-1)*(MB-N)+N+1:i*(MB-N)+N] of A, and by upper triangular
                    182: *> block reflectors, stored in array T(1:LDT,(i-1)*N+1:i*N).
                    183: *> The last Q(k) may use fewer rows.
                    184: *> For more information see Further Details in TPQRT.
                    185: *>
                    186: *> For more details of the overall algorithm, see the description of
                    187: *> Sequential TSQR in Section 2.2 of [1].
                    188: *>
                    189: *> [1] “Communication-Optimal Parallel and Sequential QR and LU Factorizations,”
                    190: *>     J. Demmel, L. Grigori, M. Hoemmen, J. Langou,
                    191: *>     SIAM J. Sci. Comput, vol. 34, no. 1, 2012
                    192: *> \endverbatim
                    193: *>
                    194: *  =====================================================================
                    195:       SUBROUTINE ZLAMTSQR( SIDE, TRANS, M, N, K, MB, NB, A, LDA, T,
                    196:      $        LDT, C, LDC, WORK, LWORK, INFO )
                    197: *
1.3     ! bertrand  198: *  -- LAPACK computational routine (version 3.7.1) --
1.1       bertrand  199: *  -- LAPACK is a software package provided by Univ. of Tennessee,    --
                    200: *  -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
1.3     ! bertrand  201: *     June 2017
1.1       bertrand  202: *
                    203: *     .. Scalar Arguments ..
                    204:       CHARACTER         SIDE, TRANS
                    205:       INTEGER           INFO, LDA, M, N, K, MB, NB, LDT, LWORK, LDC
                    206: *     ..
                    207: *     .. Array Arguments ..
                    208:       COMPLEX*16        A( LDA, * ), WORK( * ), C(LDC, * ),
                    209:      $                T( LDT, * )
                    210: *     ..
                    211: *
                    212: * =====================================================================
                    213: *
                    214: *     ..
                    215: *     .. Local Scalars ..
                    216:       LOGICAL    LEFT, RIGHT, TRAN, NOTRAN, LQUERY
                    217:       INTEGER    I, II, KK, LW, CTR
                    218: *     ..
                    219: *     .. External Functions ..
                    220:       LOGICAL            LSAME
                    221:       EXTERNAL           LSAME
                    222: *     .. External Subroutines ..
                    223:       EXTERNAL   ZGEMQRT, ZTPMQRT, XERBLA
                    224: *     ..
                    225: *     .. Executable Statements ..
                    226: *
                    227: *     Test the input arguments
                    228: *
                    229:       LQUERY  = LWORK.LT.0
                    230:       NOTRAN  = LSAME( TRANS, 'N' )
                    231:       TRAN    = LSAME( TRANS, 'C' )
                    232:       LEFT    = LSAME( SIDE, 'L' )
                    233:       RIGHT   = LSAME( SIDE, 'R' )
                    234:       IF (LEFT) THEN
                    235:         LW = N * NB
                    236:       ELSE
                    237:         LW = M * NB
                    238:       END IF
                    239: *
                    240:       INFO = 0
                    241:       IF( .NOT.LEFT .AND. .NOT.RIGHT ) THEN
                    242:          INFO = -1
                    243:       ELSE IF( .NOT.TRAN .AND. .NOT.NOTRAN ) THEN
                    244:          INFO = -2
                    245:       ELSE IF( M.LT.0 ) THEN
                    246:         INFO = -3
                    247:       ELSE IF( N.LT.0 ) THEN
                    248:         INFO = -4
                    249:       ELSE IF( K.LT.0 ) THEN
                    250:         INFO = -5
                    251:       ELSE IF( LDA.LT.MAX( 1, K ) ) THEN
                    252:         INFO = -9
                    253:       ELSE IF( LDT.LT.MAX( 1, NB) ) THEN
                    254:         INFO = -11
                    255:       ELSE IF( LDC.LT.MAX( 1, M ) ) THEN
                    256:          INFO = -13
                    257:       ELSE IF(( LWORK.LT.MAX(1,LW)).AND.(.NOT.LQUERY)) THEN
                    258:         INFO = -15
                    259:       END IF
                    260: *
                    261: *     Determine the block size if it is tall skinny or short and wide
                    262: *
                    263:       IF( INFO.EQ.0)  THEN
                    264:           WORK(1) = LW
                    265:       END IF
                    266: *
                    267:       IF( INFO.NE.0 ) THEN
                    268:         CALL XERBLA( 'ZLAMTSQR', -INFO )
                    269:         RETURN
                    270:       ELSE IF (LQUERY) THEN
                    271:        RETURN
                    272:       END IF
                    273: *
                    274: *     Quick return if possible
                    275: *
                    276:       IF( MIN(M,N,K).EQ.0 ) THEN
                    277:         RETURN
                    278:       END IF
                    279: *
                    280:       IF((MB.LE.K).OR.(MB.GE.MAX(M,N,K))) THEN
                    281:         CALL ZGEMQRT( SIDE, TRANS, M, N, K, NB, A, LDA,
                    282:      $        T, LDT, C, LDC, WORK, INFO)
                    283:         RETURN
                    284:        END IF
                    285: *
                    286:       IF(LEFT.AND.NOTRAN) THEN
                    287: *
                    288: *         Multiply Q to the last block of C
                    289: *
                    290:          KK = MOD((M-K),(MB-K))
                    291:          CTR = (M-K)/(MB-K)
                    292:          IF (KK.GT.0) THEN
                    293:            II=M-KK+1
                    294:            CALL ZTPMQRT('L','N',KK , N, K, 0, NB, A(II,1), LDA,
                    295:      $       T(1, CTR * K + 1),LDT , C(1,1), LDC,
                    296:      $       C(II,1), LDC, WORK, INFO )
                    297:          ELSE
                    298:            II=M+1
                    299:          END IF
                    300: *
                    301:          DO I=II-(MB-K),MB+1,-(MB-K)
                    302: *
                    303: *         Multiply Q to the current block of C (I:I+MB,1:N)
                    304: *
                    305:            CTR = CTR - 1
                    306:            CALL ZTPMQRT('L','N',MB-K , N, K, 0,NB, A(I,1), LDA,
                    307:      $         T(1,CTR * K + 1),LDT, C(1,1), LDC,
                    308:      $         C(I,1), LDC, WORK, INFO )
                    309: 
                    310:          END DO
                    311: *
                    312: *         Multiply Q to the first block of C (1:MB,1:N)
                    313: *
                    314:          CALL ZGEMQRT('L','N',MB , N, K, NB, A(1,1), LDA, T
                    315:      $            ,LDT ,C(1,1), LDC, WORK, INFO )
                    316: *
                    317:       ELSE IF (LEFT.AND.TRAN) THEN
                    318: *
                    319: *         Multiply Q to the first block of C
                    320: *
                    321:          KK = MOD((M-K),(MB-K))
                    322:          II=M-KK+1
                    323:          CTR = 1
                    324:          CALL ZGEMQRT('L','C',MB , N, K, NB, A(1,1), LDA, T
                    325:      $            ,LDT ,C(1,1), LDC, WORK, INFO )
                    326: *
                    327:          DO I=MB+1,II-MB+K,(MB-K)
                    328: *
                    329: *         Multiply Q to the current block of C (I:I+MB,1:N)
                    330: *
                    331:           CALL ZTPMQRT('L','C',MB-K , N, K, 0,NB, A(I,1), LDA,
                    332:      $       T(1,CTR * K + 1),LDT, C(1,1), LDC,
                    333:      $       C(I,1), LDC, WORK, INFO )
                    334:           CTR = CTR + 1
                    335: *
                    336:          END DO
                    337:          IF(II.LE.M) THEN
                    338: *
                    339: *         Multiply Q to the last block of C
                    340: *
                    341:           CALL ZTPMQRT('L','C',KK , N, K, 0,NB, A(II,1), LDA,
                    342:      $      T(1, CTR * K + 1), LDT, C(1,1), LDC,
                    343:      $      C(II,1), LDC, WORK, INFO )
                    344: *
                    345:          END IF
                    346: *
                    347:       ELSE IF(RIGHT.AND.TRAN) THEN
                    348: *
                    349: *         Multiply Q to the last block of C
                    350: *
                    351:           KK = MOD((N-K),(MB-K))
                    352:           CTR = (N-K)/(MB-K)
                    353:           IF (KK.GT.0) THEN
                    354:             II=N-KK+1
                    355:             CALL ZTPMQRT('R','C',M , KK, K, 0, NB, A(II,1), LDA,
                    356:      $        T(1,CTR * K + 1), LDT, C(1,1), LDC,
                    357:      $        C(1,II), LDC, WORK, INFO )
                    358:           ELSE
                    359:             II=N+1
                    360:           END IF
                    361: *
                    362:           DO I=II-(MB-K),MB+1,-(MB-K)
                    363: *
                    364: *         Multiply Q to the current block of C (1:M,I:I+MB)
                    365: *
                    366:             CTR = CTR - 1
                    367:             CALL ZTPMQRT('R','C',M , MB-K, K, 0,NB, A(I,1), LDA,
                    368:      $          T(1, CTR * K + 1), LDT, C(1,1), LDC,
                    369:      $          C(1,I), LDC, WORK, INFO )
                    370: 
                    371:           END DO
                    372: *
                    373: *         Multiply Q to the first block of C (1:M,1:MB)
                    374: *
                    375:           CALL ZGEMQRT('R','C',M , MB, K, NB, A(1,1), LDA, T
                    376:      $              ,LDT ,C(1,1), LDC, WORK, INFO )
                    377: *
                    378:       ELSE IF (RIGHT.AND.NOTRAN) THEN
                    379: *
                    380: *         Multiply Q to the first block of C
                    381: *
                    382:          KK = MOD((N-K),(MB-K))
                    383:          II=N-KK+1
                    384:          CTR = 1
                    385:          CALL ZGEMQRT('R','N', M, MB , K, NB, A(1,1), LDA, T
                    386:      $              ,LDT ,C(1,1), LDC, WORK, INFO )
                    387: *
                    388:          DO I=MB+1,II-MB+K,(MB-K)
                    389: *
                    390: *         Multiply Q to the current block of C (1:M,I:I+MB)
                    391: *
                    392:           CALL ZTPMQRT('R','N', M, MB-K, K, 0,NB, A(I,1), LDA,
                    393:      $         T(1, CTR * K + 1),LDT, C(1,1), LDC,
                    394:      $         C(1,I), LDC, WORK, INFO )
                    395:           CTR = CTR + 1
                    396: *
                    397:          END DO
                    398:          IF(II.LE.N) THEN
                    399: *
                    400: *         Multiply Q to the last block of C
                    401: *
                    402:           CALL ZTPMQRT('R','N', M, KK , K, 0,NB, A(II,1), LDA,
                    403:      $        T(1,CTR * K + 1),LDT, C(1,1), LDC,
                    404:      $        C(1,II), LDC, WORK, INFO )
                    405: *
                    406:          END IF
                    407: *
                    408:       END IF
                    409: *
                    410:       WORK(1) = LW
                    411:       RETURN
                    412: *
                    413: *     End of ZLAMTSQR
                    414: *
                    415:       END

CVSweb interface <joel.bertrand@systella.fr>