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

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

CVSweb interface <joel.bertrand@systella.fr>