LAPACK 3.3.1
Linear Algebra PACKage

cunmrz.f

Go to the documentation of this file.
00001       SUBROUTINE CUNMRZ( SIDE, TRANS, M, N, K, L, A, LDA, TAU, C, LDC,
00002      $                   WORK, LWORK, INFO )
00003 *
00004 *  -- LAPACK routine (version 3.3.1) --
00005 *  -- LAPACK is a software package provided by Univ. of Tennessee,    --
00006 *  -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
00007 *  -- April 2011                                                      --
00008 *
00009 *     .. Scalar Arguments ..
00010       CHARACTER          SIDE, TRANS
00011       INTEGER            INFO, K, L, LDA, LDC, LWORK, M, N
00012 *     ..
00013 *     .. Array Arguments ..
00014       COMPLEX            A( LDA, * ), C( LDC, * ), TAU( * ), WORK( * )
00015 *     ..
00016 *
00017 *  Purpose
00018 *  =======
00019 *
00020 *  CUNMRZ overwrites the general complex M-by-N matrix C with
00021 *
00022 *                  SIDE = 'L'     SIDE = 'R'
00023 *  TRANS = 'N':      Q * C          C * Q
00024 *  TRANS = 'C':      Q**H * C       C * Q**H
00025 *
00026 *  where Q is a complex unitary matrix defined as the product of k
00027 *  elementary reflectors
00028 *
00029 *        Q = H(1) H(2) . . . H(k)
00030 *
00031 *  as returned by CTZRZF. Q is of order M if SIDE = 'L' and of order N
00032 *  if SIDE = 'R'.
00033 *
00034 *  Arguments
00035 *  =========
00036 *
00037 *  SIDE    (input) CHARACTER*1
00038 *          = 'L': apply Q or Q**H from the Left;
00039 *          = 'R': apply Q or Q**H from the Right.
00040 *
00041 *  TRANS   (input) CHARACTER*1
00042 *          = 'N':  No transpose, apply Q;
00043 *          = 'C':  Conjugate transpose, apply Q**H.
00044 *
00045 *  M       (input) INTEGER
00046 *          The number of rows of the matrix C. M >= 0.
00047 *
00048 *  N       (input) INTEGER
00049 *          The number of columns of the matrix C. N >= 0.
00050 *
00051 *  K       (input) INTEGER
00052 *          The number of elementary reflectors whose product defines
00053 *          the matrix Q.
00054 *          If SIDE = 'L', M >= K >= 0;
00055 *          if SIDE = 'R', N >= K >= 0.
00056 *
00057 *  L       (input) INTEGER
00058 *          The number of columns of the matrix A containing
00059 *          the meaningful part of the Householder reflectors.
00060 *          If SIDE = 'L', M >= L >= 0, if SIDE = 'R', N >= L >= 0.
00061 *
00062 *  A       (input) COMPLEX array, dimension
00063 *                               (LDA,M) if SIDE = 'L',
00064 *                               (LDA,N) if SIDE = 'R'
00065 *          The i-th row must contain the vector which defines the
00066 *          elementary reflector H(i), for i = 1,2,...,k, as returned by
00067 *          CTZRZF in the last k rows of its array argument A.
00068 *          A is modified by the routine but restored on exit.
00069 *
00070 *  LDA     (input) INTEGER
00071 *          The leading dimension of the array A. LDA >= max(1,K).
00072 *
00073 *  TAU     (input) COMPLEX array, dimension (K)
00074 *          TAU(i) must contain the scalar factor of the elementary
00075 *          reflector H(i), as returned by CTZRZF.
00076 *
00077 *  C       (input/output) COMPLEX array, dimension (LDC,N)
00078 *          On entry, the M-by-N matrix C.
00079 *          On exit, C is overwritten by Q*C or Q**H*C or C*Q**H or C*Q.
00080 *
00081 *  LDC     (input) INTEGER
00082 *          The leading dimension of the array C. LDC >= max(1,M).
00083 *
00084 *  WORK    (workspace/output) COMPLEX array, dimension (MAX(1,LWORK))
00085 *          On exit, if INFO = 0, WORK(1) returns the optimal LWORK.
00086 *
00087 *  LWORK   (input) INTEGER
00088 *          The dimension of the array WORK.
00089 *          If SIDE = 'L', LWORK >= max(1,N);
00090 *          if SIDE = 'R', LWORK >= max(1,M).
00091 *          For optimum performance LWORK >= N*NB if SIDE = 'L', and
00092 *          LWORK >= M*NB if SIDE = 'R', where NB is the optimal
00093 *          blocksize.
00094 *
00095 *          If LWORK = -1, then a workspace query is assumed; the routine
00096 *          only calculates the optimal size of the WORK array, returns
00097 *          this value as the first entry of the WORK array, and no error
00098 *          message related to LWORK is issued by XERBLA.
00099 *
00100 *  INFO    (output) INTEGER
00101 *          = 0:  successful exit
00102 *          < 0:  if INFO = -i, the i-th argument had an illegal value
00103 *
00104 *  Further Details
00105 *  ===============
00106 *
00107 *  Based on contributions by
00108 *    A. Petitet, Computer Science Dept., Univ. of Tenn., Knoxville, USA
00109 *
00110 *  =====================================================================
00111 *
00112 *     .. Parameters ..
00113       INTEGER            NBMAX, LDT
00114       PARAMETER          ( NBMAX = 64, LDT = NBMAX+1 )
00115 *     ..
00116 *     .. Local Scalars ..
00117       LOGICAL            LEFT, LQUERY, NOTRAN
00118       CHARACTER          TRANST
00119       INTEGER            I, I1, I2, I3, IB, IC, IINFO, IWS, JA, JC,
00120      $                   LDWORK, LWKOPT, MI, NB, NBMIN, NI, NQ, NW
00121 *     ..
00122 *     .. Local Arrays ..
00123       COMPLEX            T( LDT, NBMAX )
00124 *     ..
00125 *     .. External Functions ..
00126       LOGICAL            LSAME
00127       INTEGER            ILAENV
00128       EXTERNAL           LSAME, ILAENV
00129 *     ..
00130 *     .. External Subroutines ..
00131       EXTERNAL           CLARZB, CLARZT, CUNMR3, XERBLA
00132 *     ..
00133 *     .. Intrinsic Functions ..
00134       INTRINSIC          MAX, MIN
00135 *     ..
00136 *     .. Executable Statements ..
00137 *
00138 *     Test the input arguments
00139 *
00140       INFO = 0
00141       LEFT = LSAME( SIDE, 'L' )
00142       NOTRAN = LSAME( TRANS, 'N' )
00143       LQUERY = ( LWORK.EQ.-1 )
00144 *
00145 *     NQ is the order of Q and NW is the minimum dimension of WORK
00146 *
00147       IF( LEFT ) THEN
00148          NQ = M
00149          NW = MAX( 1, N )
00150       ELSE
00151          NQ = N
00152          NW = MAX( 1, M )
00153       END IF
00154       IF( .NOT.LEFT .AND. .NOT.LSAME( SIDE, 'R' ) ) THEN
00155          INFO = -1
00156       ELSE IF( .NOT.NOTRAN .AND. .NOT.LSAME( TRANS, 'C' ) ) THEN
00157          INFO = -2
00158       ELSE IF( M.LT.0 ) THEN
00159          INFO = -3
00160       ELSE IF( N.LT.0 ) THEN
00161          INFO = -4
00162       ELSE IF( K.LT.0 .OR. K.GT.NQ ) THEN
00163          INFO = -5
00164       ELSE IF( L.LT.0 .OR. ( LEFT .AND. ( L.GT.M ) ) .OR.
00165      $         ( .NOT.LEFT .AND. ( L.GT.N ) ) ) THEN
00166          INFO = -6
00167       ELSE IF( LDA.LT.MAX( 1, K ) ) THEN
00168          INFO = -8
00169       ELSE IF( LDC.LT.MAX( 1, M ) ) THEN
00170          INFO = -11
00171       END IF
00172 *
00173       IF( INFO.EQ.0 ) THEN
00174          IF( M.EQ.0 .OR. N.EQ.0 ) THEN
00175             LWKOPT = 1
00176          ELSE
00177 *
00178 *           Determine the block size.  NB may be at most NBMAX, where
00179 *           NBMAX is used to define the local array T.
00180 *
00181             NB = MIN( NBMAX, ILAENV( 1, 'CUNMRQ', SIDE // TRANS, M, N,
00182      $                               K, -1 ) )
00183             LWKOPT = NW*NB
00184          END IF
00185          WORK( 1 ) = LWKOPT
00186 *
00187          IF( LWORK.LT.MAX( 1, NW ) .AND. .NOT.LQUERY ) THEN
00188             INFO = -13
00189          END IF
00190       END IF
00191 *
00192       IF( INFO.NE.0 ) THEN
00193          CALL XERBLA( 'CUNMRZ', -INFO )
00194          RETURN
00195       ELSE IF( LQUERY ) THEN
00196          RETURN
00197       END IF
00198 *
00199 *     Quick return if possible
00200 *
00201       IF( M.EQ.0 .OR. N.EQ.0 ) THEN
00202          RETURN
00203       END IF
00204 *
00205 *     Determine the block size.  NB may be at most NBMAX, where NBMAX
00206 *     is used to define the local array T.
00207 *
00208       NB = MIN( NBMAX, ILAENV( 1, 'CUNMRQ', SIDE // TRANS, M, N, K,
00209      $     -1 ) )
00210       NBMIN = 2
00211       LDWORK = NW
00212       IF( NB.GT.1 .AND. NB.LT.K ) THEN
00213          IWS = NW*NB
00214          IF( LWORK.LT.IWS ) THEN
00215             NB = LWORK / LDWORK
00216             NBMIN = MAX( 2, ILAENV( 2, 'CUNMRQ', SIDE // TRANS, M, N, K,
00217      $              -1 ) )
00218          END IF
00219       ELSE
00220          IWS = NW
00221       END IF
00222 *
00223       IF( NB.LT.NBMIN .OR. NB.GE.K ) THEN
00224 *
00225 *        Use unblocked code
00226 *
00227          CALL CUNMR3( SIDE, TRANS, M, N, K, L, A, LDA, TAU, C, LDC,
00228      $                WORK, IINFO )
00229       ELSE
00230 *
00231 *        Use blocked code
00232 *
00233          IF( ( LEFT .AND. .NOT.NOTRAN ) .OR.
00234      $       ( .NOT.LEFT .AND. NOTRAN ) ) THEN
00235             I1 = 1
00236             I2 = K
00237             I3 = NB
00238          ELSE
00239             I1 = ( ( K-1 ) / NB )*NB + 1
00240             I2 = 1
00241             I3 = -NB
00242          END IF
00243 *
00244          IF( LEFT ) THEN
00245             NI = N
00246             JC = 1
00247             JA = M - L + 1
00248          ELSE
00249             MI = M
00250             IC = 1
00251             JA = N - L + 1
00252          END IF
00253 *
00254          IF( NOTRAN ) THEN
00255             TRANST = 'C'
00256          ELSE
00257             TRANST = 'N'
00258          END IF
00259 *
00260          DO 10 I = I1, I2, I3
00261             IB = MIN( NB, K-I+1 )
00262 *
00263 *           Form the triangular factor of the block reflector
00264 *           H = H(i+ib-1) . . . H(i+1) H(i)
00265 *
00266             CALL CLARZT( 'Backward', 'Rowwise', L, IB, A( I, JA ), LDA,
00267      $                   TAU( I ), T, LDT )
00268 *
00269             IF( LEFT ) THEN
00270 *
00271 *              H or H**H is applied to C(i:m,1:n)
00272 *
00273                MI = M - I + 1
00274                IC = I
00275             ELSE
00276 *
00277 *              H or H**H is applied to C(1:m,i:n)
00278 *
00279                NI = N - I + 1
00280                JC = I
00281             END IF
00282 *
00283 *           Apply H or H**H
00284 *
00285             CALL CLARZB( SIDE, TRANST, 'Backward', 'Rowwise', MI, NI,
00286      $                   IB, L, A( I, JA ), LDA, T, LDT, C( IC, JC ),
00287      $                   LDC, WORK, LDWORK )
00288    10    CONTINUE
00289 *
00290       END IF
00291 *
00292       WORK( 1 ) = LWKOPT
00293 *
00294       RETURN
00295 *
00296 *     End of CUNMRZ
00297 *
00298       END
 All Files Functions