LAPACK 3.3.1
Linear Algebra PACKage

dormrz.f

Go to the documentation of this file.
00001       SUBROUTINE DORMRZ( 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       DOUBLE PRECISION   A( LDA, * ), C( LDC, * ), TAU( * ), WORK( * )
00015 *     ..
00016 *
00017 *  Purpose
00018 *  =======
00019 *
00020 *  DORMRZ overwrites the general real M-by-N matrix C with
00021 *
00022 *                  SIDE = 'L'     SIDE = 'R'
00023 *  TRANS = 'N':      Q * C          C * Q
00024 *  TRANS = 'T':      Q**T * C       C * Q**T
00025 *
00026 *  where Q is a real orthogonal matrix defined as the product of k
00027 *  elementary reflectors
00028 *
00029 *        Q = H(1) H(2) . . . H(k)
00030 *
00031 *  as returned by DTZRZF. 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**T from the Left;
00039 *          = 'R': apply Q or Q**T from the Right.
00040 *
00041 *  TRANS   (input) CHARACTER*1
00042 *          = 'N':  No transpose, apply Q;
00043 *          = 'T':  Transpose, apply Q**T.
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) DOUBLE PRECISION 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 *          DTZRZF 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) DOUBLE PRECISION array, dimension (K)
00074 *          TAU(i) must contain the scalar factor of the elementary
00075 *          reflector H(i), as returned by DTZRZF.
00076 *
00077 *  C       (input/output) DOUBLE PRECISION 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) DOUBLE PRECISION 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       DOUBLE PRECISION   T( LDT, NBMAX )
00124 *     ..
00125 *     .. External Functions ..
00126       LOGICAL            LSAME
00127       INTEGER            ILAENV
00128       EXTERNAL           LSAME, ILAENV
00129 *     ..
00130 *     .. External Subroutines ..
00131       EXTERNAL           DLARZB, DLARZT, DORMR3, 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, 'T' ) ) 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, 'DORMRQ', 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( 'DORMRZ', -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          WORK( 1 ) = 1
00203          RETURN
00204       END IF
00205 *
00206       NBMIN = 2
00207       LDWORK = NW
00208       IF( NB.GT.1 .AND. NB.LT.K ) THEN
00209          IWS = NW*NB
00210          IF( LWORK.LT.IWS ) THEN
00211             NB = LWORK / LDWORK
00212             NBMIN = MAX( 2, ILAENV( 2, 'DORMRQ', SIDE // TRANS, M, N, K,
00213      $              -1 ) )
00214          END IF
00215       ELSE
00216          IWS = NW
00217       END IF
00218 *
00219       IF( NB.LT.NBMIN .OR. NB.GE.K ) THEN
00220 *
00221 *        Use unblocked code
00222 *
00223          CALL DORMR3( SIDE, TRANS, M, N, K, L, A, LDA, TAU, C, LDC,
00224      $                WORK, IINFO )
00225       ELSE
00226 *
00227 *        Use blocked code
00228 *
00229          IF( ( LEFT .AND. .NOT.NOTRAN ) .OR.
00230      $       ( .NOT.LEFT .AND. NOTRAN ) ) THEN
00231             I1 = 1
00232             I2 = K
00233             I3 = NB
00234          ELSE
00235             I1 = ( ( K-1 ) / NB )*NB + 1
00236             I2 = 1
00237             I3 = -NB
00238          END IF
00239 *
00240          IF( LEFT ) THEN
00241             NI = N
00242             JC = 1
00243             JA = M - L + 1
00244          ELSE
00245             MI = M
00246             IC = 1
00247             JA = N - L + 1
00248          END IF
00249 *
00250          IF( NOTRAN ) THEN
00251             TRANST = 'T'
00252          ELSE
00253             TRANST = 'N'
00254          END IF
00255 *
00256          DO 10 I = I1, I2, I3
00257             IB = MIN( NB, K-I+1 )
00258 *
00259 *           Form the triangular factor of the block reflector
00260 *           H = H(i+ib-1) . . . H(i+1) H(i)
00261 *
00262             CALL DLARZT( 'Backward', 'Rowwise', L, IB, A( I, JA ), LDA,
00263      $                   TAU( I ), T, LDT )
00264 *
00265             IF( LEFT ) THEN
00266 *
00267 *              H or H**T is applied to C(i:m,1:n)
00268 *
00269                MI = M - I + 1
00270                IC = I
00271             ELSE
00272 *
00273 *              H or H**T is applied to C(1:m,i:n)
00274 *
00275                NI = N - I + 1
00276                JC = I
00277             END IF
00278 *
00279 *           Apply H or H**T
00280 *
00281             CALL DLARZB( SIDE, TRANST, 'Backward', 'Rowwise', MI, NI,
00282      $                   IB, L, A( I, JA ), LDA, T, LDT, C( IC, JC ),
00283      $                   LDC, WORK, LDWORK )
00284    10    CONTINUE
00285 *
00286       END IF
00287 *
00288       WORK( 1 ) = LWKOPT
00289 *
00290       RETURN
00291 *
00292 *     End of DORMRZ
00293 *
00294       END
 All Files Functions