LAPACK 3.3.1
Linear Algebra PACKage

sormrz.f

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