001:       SUBROUTINE DORMR3( SIDE, TRANS, M, N, K, L, A, LDA, TAU, C, LDC,
002:      $                   WORK, INFO )
003: *
004: *  -- LAPACK routine (version 3.2) --
005: *  -- LAPACK is a software package provided by Univ. of Tennessee,    --
006: *  -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
007: *     November 2006
008: *
009: *     .. Scalar Arguments ..
010:       CHARACTER          SIDE, TRANS
011:       INTEGER            INFO, K, L, LDA, LDC, M, N
012: *     ..
013: *     .. Array Arguments ..
014:       DOUBLE PRECISION   A( LDA, * ), C( LDC, * ), TAU( * ), WORK( * )
015: *     ..
016: *
017: *  Purpose
018: *  =======
019: *
020: *  DORMR3 overwrites the general real m by n matrix C with
021: *
022: *        Q * C  if SIDE = 'L' and TRANS = 'N', or
023: *
024: *        Q'* C  if SIDE = 'L' and TRANS = 'T', or
025: *
026: *        C * Q  if SIDE = 'R' and TRANS = 'N', or
027: *
028: *        C * Q' if SIDE = 'R' and TRANS = 'T',
029: *
030: *  where Q is a real orthogonal matrix defined as the product of k
031: *  elementary reflectors
032: *
033: *        Q = H(1) H(2) . . . H(k)
034: *
035: *  as returned by DTZRZF. Q is of order m if SIDE = 'L' and of order n
036: *  if SIDE = 'R'.
037: *
038: *  Arguments
039: *  =========
040: *
041: *  SIDE    (input) CHARACTER*1
042: *          = 'L': apply Q or Q' from the Left
043: *          = 'R': apply Q or Q' from the Right
044: *
045: *  TRANS   (input) CHARACTER*1
046: *          = 'N': apply Q  (No transpose)
047: *          = 'T': apply Q' (Transpose)
048: *
049: *  M       (input) INTEGER
050: *          The number of rows of the matrix C. M >= 0.
051: *
052: *  N       (input) INTEGER
053: *          The number of columns of the matrix C. N >= 0.
054: *
055: *  K       (input) INTEGER
056: *          The number of elementary reflectors whose product defines
057: *          the matrix Q.
058: *          If SIDE = 'L', M >= K >= 0;
059: *          if SIDE = 'R', N >= K >= 0.
060: *
061: *  L       (input) INTEGER
062: *          The number of columns of the matrix A containing
063: *          the meaningful part of the Householder reflectors.
064: *          If SIDE = 'L', M >= L >= 0, if SIDE = 'R', N >= L >= 0.
065: *
066: *  A       (input) DOUBLE PRECISION array, dimension
067: *                               (LDA,M) if SIDE = 'L',
068: *                               (LDA,N) if SIDE = 'R'
069: *          The i-th row must contain the vector which defines the
070: *          elementary reflector H(i), for i = 1,2,...,k, as returned by
071: *          DTZRZF in the last k rows of its array argument A.
072: *          A is modified by the routine but restored on exit.
073: *
074: *  LDA     (input) INTEGER
075: *          The leading dimension of the array A. LDA >= max(1,K).
076: *
077: *  TAU     (input) DOUBLE PRECISION array, dimension (K)
078: *          TAU(i) must contain the scalar factor of the elementary
079: *          reflector H(i), as returned by DTZRZF.
080: *
081: *  C       (input/output) DOUBLE PRECISION array, dimension (LDC,N)
082: *          On entry, the m-by-n matrix C.
083: *          On exit, C is overwritten by Q*C or Q'*C or C*Q' or C*Q.
084: *
085: *  LDC     (input) INTEGER
086: *          The leading dimension of the array C. LDC >= max(1,M).
087: *
088: *  WORK    (workspace) DOUBLE PRECISION array, dimension
089: *                                   (N) if SIDE = 'L',
090: *                                   (M) if SIDE = 'R'
091: *
092: *  INFO    (output) INTEGER
093: *          = 0: successful exit
094: *          < 0: if INFO = -i, the i-th argument had an illegal value
095: *
096: *  Further Details
097: *  ===============
098: *
099: *  Based on contributions by
100: *    A. Petitet, Computer Science Dept., Univ. of Tenn., Knoxville, USA
101: *
102: *  =====================================================================
103: *
104: *     .. Local Scalars ..
105:       LOGICAL            LEFT, NOTRAN
106:       INTEGER            I, I1, I2, I3, IC, JA, JC, MI, NI, NQ
107: *     ..
108: *     .. External Functions ..
109:       LOGICAL            LSAME
110:       EXTERNAL           LSAME
111: *     ..
112: *     .. External Subroutines ..
113:       EXTERNAL           DLARZ, XERBLA
114: *     ..
115: *     .. Intrinsic Functions ..
116:       INTRINSIC          MAX
117: *     ..
118: *     .. Executable Statements ..
119: *
120: *     Test the input arguments
121: *
122:       INFO = 0
123:       LEFT = LSAME( SIDE, 'L' )
124:       NOTRAN = LSAME( TRANS, 'N' )
125: *
126: *     NQ is the order of Q
127: *
128:       IF( LEFT ) THEN
129:          NQ = M
130:       ELSE
131:          NQ = N
132:       END IF
133:       IF( .NOT.LEFT .AND. .NOT.LSAME( SIDE, 'R' ) ) THEN
134:          INFO = -1
135:       ELSE IF( .NOT.NOTRAN .AND. .NOT.LSAME( TRANS, 'T' ) ) THEN
136:          INFO = -2
137:       ELSE IF( M.LT.0 ) THEN
138:          INFO = -3
139:       ELSE IF( N.LT.0 ) THEN
140:          INFO = -4
141:       ELSE IF( K.LT.0 .OR. K.GT.NQ ) THEN
142:          INFO = -5
143:       ELSE IF( L.LT.0 .OR. ( LEFT .AND. ( L.GT.M ) ) .OR.
144:      $         ( .NOT.LEFT .AND. ( L.GT.N ) ) ) THEN
145:          INFO = -6
146:       ELSE IF( LDA.LT.MAX( 1, K ) ) THEN
147:          INFO = -8
148:       ELSE IF( LDC.LT.MAX( 1, M ) ) THEN
149:          INFO = -11
150:       END IF
151:       IF( INFO.NE.0 ) THEN
152:          CALL XERBLA( 'DORMR3', -INFO )
153:          RETURN
154:       END IF
155: *
156: *     Quick return if possible
157: *
158:       IF( M.EQ.0 .OR. N.EQ.0 .OR. K.EQ.0 )
159:      $   RETURN
160: *
161:       IF( ( LEFT .AND. .NOT.NOTRAN .OR. .NOT.LEFT .AND. NOTRAN ) ) THEN
162:          I1 = 1
163:          I2 = K
164:          I3 = 1
165:       ELSE
166:          I1 = K
167:          I2 = 1
168:          I3 = -1
169:       END IF
170: *
171:       IF( LEFT ) THEN
172:          NI = N
173:          JA = M - L + 1
174:          JC = 1
175:       ELSE
176:          MI = M
177:          JA = N - L + 1
178:          IC = 1
179:       END IF
180: *
181:       DO 10 I = I1, I2, I3
182:          IF( LEFT ) THEN
183: *
184: *           H(i) or H(i)' is applied to C(i:m,1:n)
185: *
186:             MI = M - I + 1
187:             IC = I
188:          ELSE
189: *
190: *           H(i) or H(i)' is applied to C(1:m,i:n)
191: *
192:             NI = N - I + 1
193:             JC = I
194:          END IF
195: *
196: *        Apply H(i) or H(i)'
197: *
198:          CALL DLARZ( SIDE, MI, NI, L, A( I, JA ), LDA, TAU( I ),
199:      $               C( IC, JC ), LDC, WORK )
200: *
201:    10 CONTINUE
202: *
203:       RETURN
204: *
205: *     End of DORMR3
206: *
207:       END
208: