![]() |
LAPACK
3.4.1
LAPACK: Linear Algebra PACKage
|
00001 *> \brief \b SORMBR 00002 * 00003 * =========== DOCUMENTATION =========== 00004 * 00005 * Online html documentation available at 00006 * http://www.netlib.org/lapack/explore-html/ 00007 * 00008 *> \htmlonly 00009 *> Download SORMBR + dependencies 00010 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/sormbr.f"> 00011 *> [TGZ]</a> 00012 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/sormbr.f"> 00013 *> [ZIP]</a> 00014 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/sormbr.f"> 00015 *> [TXT]</a> 00016 *> \endhtmlonly 00017 * 00018 * Definition: 00019 * =========== 00020 * 00021 * SUBROUTINE SORMBR( VECT, SIDE, TRANS, M, N, K, A, LDA, TAU, C, 00022 * LDC, WORK, LWORK, INFO ) 00023 * 00024 * .. Scalar Arguments .. 00025 * CHARACTER SIDE, TRANS, VECT 00026 * INTEGER INFO, K, LDA, LDC, LWORK, M, N 00027 * .. 00028 * .. Array Arguments .. 00029 * REAL A( LDA, * ), C( LDC, * ), TAU( * ), 00030 * $ WORK( * ) 00031 * .. 00032 * 00033 * 00034 *> \par Purpose: 00035 * ============= 00036 *> 00037 *> \verbatim 00038 *> 00039 *> If VECT = 'Q', SORMBR overwrites the general real M-by-N matrix C 00040 *> with 00041 *> SIDE = 'L' SIDE = 'R' 00042 *> TRANS = 'N': Q * C C * Q 00043 *> TRANS = 'T': Q**T * C C * Q**T 00044 *> 00045 *> If VECT = 'P', SORMBR overwrites the general real M-by-N matrix C 00046 *> with 00047 *> SIDE = 'L' SIDE = 'R' 00048 *> TRANS = 'N': P * C C * P 00049 *> TRANS = 'T': P**T * C C * P**T 00050 *> 00051 *> Here Q and P**T are the orthogonal matrices determined by SGEBRD when 00052 *> reducing a real matrix A to bidiagonal form: A = Q * B * P**T. Q and 00053 *> P**T are defined as products of elementary reflectors H(i) and G(i) 00054 *> respectively. 00055 *> 00056 *> Let nq = m if SIDE = 'L' and nq = n if SIDE = 'R'. Thus nq is the 00057 *> order of the orthogonal matrix Q or P**T that is applied. 00058 *> 00059 *> If VECT = 'Q', A is assumed to have been an NQ-by-K matrix: 00060 *> if nq >= k, Q = H(1) H(2) . . . H(k); 00061 *> if nq < k, Q = H(1) H(2) . . . H(nq-1). 00062 *> 00063 *> If VECT = 'P', A is assumed to have been a K-by-NQ matrix: 00064 *> if k < nq, P = G(1) G(2) . . . G(k); 00065 *> if k >= nq, P = G(1) G(2) . . . G(nq-1). 00066 *> \endverbatim 00067 * 00068 * Arguments: 00069 * ========== 00070 * 00071 *> \param[in] VECT 00072 *> \verbatim 00073 *> VECT is CHARACTER*1 00074 *> = 'Q': apply Q or Q**T; 00075 *> = 'P': apply P or P**T. 00076 *> \endverbatim 00077 *> 00078 *> \param[in] SIDE 00079 *> \verbatim 00080 *> SIDE is CHARACTER*1 00081 *> = 'L': apply Q, Q**T, P or P**T from the Left; 00082 *> = 'R': apply Q, Q**T, P or P**T from the Right. 00083 *> \endverbatim 00084 *> 00085 *> \param[in] TRANS 00086 *> \verbatim 00087 *> TRANS is CHARACTER*1 00088 *> = 'N': No transpose, apply Q or P; 00089 *> = 'T': Transpose, apply Q**T or P**T. 00090 *> \endverbatim 00091 *> 00092 *> \param[in] M 00093 *> \verbatim 00094 *> M is INTEGER 00095 *> The number of rows of the matrix C. M >= 0. 00096 *> \endverbatim 00097 *> 00098 *> \param[in] N 00099 *> \verbatim 00100 *> N is INTEGER 00101 *> The number of columns of the matrix C. N >= 0. 00102 *> \endverbatim 00103 *> 00104 *> \param[in] K 00105 *> \verbatim 00106 *> K is INTEGER 00107 *> If VECT = 'Q', the number of columns in the original 00108 *> matrix reduced by SGEBRD. 00109 *> If VECT = 'P', the number of rows in the original 00110 *> matrix reduced by SGEBRD. 00111 *> K >= 0. 00112 *> \endverbatim 00113 *> 00114 *> \param[in] A 00115 *> \verbatim 00116 *> A is REAL array, dimension 00117 *> (LDA,min(nq,K)) if VECT = 'Q' 00118 *> (LDA,nq) if VECT = 'P' 00119 *> The vectors which define the elementary reflectors H(i) and 00120 *> G(i), whose products determine the matrices Q and P, as 00121 *> returned by SGEBRD. 00122 *> \endverbatim 00123 *> 00124 *> \param[in] LDA 00125 *> \verbatim 00126 *> LDA is INTEGER 00127 *> The leading dimension of the array A. 00128 *> If VECT = 'Q', LDA >= max(1,nq); 00129 *> if VECT = 'P', LDA >= max(1,min(nq,K)). 00130 *> \endverbatim 00131 *> 00132 *> \param[in] TAU 00133 *> \verbatim 00134 *> TAU is REAL array, dimension (min(nq,K)) 00135 *> TAU(i) must contain the scalar factor of the elementary 00136 *> reflector H(i) or G(i) which determines Q or P, as returned 00137 *> by SGEBRD in the array argument TAUQ or TAUP. 00138 *> \endverbatim 00139 *> 00140 *> \param[in,out] C 00141 *> \verbatim 00142 *> C is REAL array, dimension (LDC,N) 00143 *> On entry, the M-by-N matrix C. 00144 *> On exit, C is overwritten by Q*C or Q**T*C or C*Q**T or C*Q 00145 *> or P*C or P**T*C or C*P or C*P**T. 00146 *> \endverbatim 00147 *> 00148 *> \param[in] LDC 00149 *> \verbatim 00150 *> LDC is INTEGER 00151 *> The leading dimension of the array C. LDC >= max(1,M). 00152 *> \endverbatim 00153 *> 00154 *> \param[out] WORK 00155 *> \verbatim 00156 *> WORK is REAL array, dimension (MAX(1,LWORK)) 00157 *> On exit, if INFO = 0, WORK(1) returns the optimal LWORK. 00158 *> \endverbatim 00159 *> 00160 *> \param[in] LWORK 00161 *> \verbatim 00162 *> LWORK is INTEGER 00163 *> The dimension of the array WORK. 00164 *> If SIDE = 'L', LWORK >= max(1,N); 00165 *> if SIDE = 'R', LWORK >= max(1,M). 00166 *> For optimum performance LWORK >= N*NB if SIDE = 'L', and 00167 *> LWORK >= M*NB if SIDE = 'R', where NB is the optimal 00168 *> blocksize. 00169 *> 00170 *> If LWORK = -1, then a workspace query is assumed; the routine 00171 *> only calculates the optimal size of the WORK array, returns 00172 *> this value as the first entry of the WORK array, and no error 00173 *> message related to LWORK is issued by XERBLA. 00174 *> \endverbatim 00175 *> 00176 *> \param[out] INFO 00177 *> \verbatim 00178 *> INFO is INTEGER 00179 *> = 0: successful exit 00180 *> < 0: if INFO = -i, the i-th argument had an illegal value 00181 *> \endverbatim 00182 * 00183 * Authors: 00184 * ======== 00185 * 00186 *> \author Univ. of Tennessee 00187 *> \author Univ. of California Berkeley 00188 *> \author Univ. of Colorado Denver 00189 *> \author NAG Ltd. 00190 * 00191 *> \date November 2011 00192 * 00193 *> \ingroup realOTHERcomputational 00194 * 00195 * ===================================================================== 00196 SUBROUTINE SORMBR( VECT, SIDE, TRANS, M, N, K, A, LDA, TAU, C, 00197 $ LDC, WORK, LWORK, INFO ) 00198 * 00199 * -- LAPACK computational routine (version 3.4.0) -- 00200 * -- LAPACK is a software package provided by Univ. of Tennessee, -- 00201 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- 00202 * November 2011 00203 * 00204 * .. Scalar Arguments .. 00205 CHARACTER SIDE, TRANS, VECT 00206 INTEGER INFO, K, LDA, LDC, LWORK, M, N 00207 * .. 00208 * .. Array Arguments .. 00209 REAL A( LDA, * ), C( LDC, * ), TAU( * ), 00210 $ WORK( * ) 00211 * .. 00212 * 00213 * ===================================================================== 00214 * 00215 * .. Local Scalars .. 00216 LOGICAL APPLYQ, LEFT, LQUERY, NOTRAN 00217 CHARACTER TRANST 00218 INTEGER I1, I2, IINFO, LWKOPT, MI, NB, NI, NQ, NW 00219 * .. 00220 * .. External Functions .. 00221 LOGICAL LSAME 00222 INTEGER ILAENV 00223 EXTERNAL ILAENV, LSAME 00224 * .. 00225 * .. External Subroutines .. 00226 EXTERNAL SORMLQ, SORMQR, XERBLA 00227 * .. 00228 * .. Intrinsic Functions .. 00229 INTRINSIC MAX, MIN 00230 * .. 00231 * .. Executable Statements .. 00232 * 00233 * Test the input arguments 00234 * 00235 INFO = 0 00236 APPLYQ = LSAME( VECT, 'Q' ) 00237 LEFT = LSAME( SIDE, 'L' ) 00238 NOTRAN = LSAME( TRANS, 'N' ) 00239 LQUERY = ( LWORK.EQ.-1 ) 00240 * 00241 * NQ is the order of Q or P and NW is the minimum dimension of WORK 00242 * 00243 IF( LEFT ) THEN 00244 NQ = M 00245 NW = N 00246 ELSE 00247 NQ = N 00248 NW = M 00249 END IF 00250 IF( .NOT.APPLYQ .AND. .NOT.LSAME( VECT, 'P' ) ) THEN 00251 INFO = -1 00252 ELSE IF( .NOT.LEFT .AND. .NOT.LSAME( SIDE, 'R' ) ) THEN 00253 INFO = -2 00254 ELSE IF( .NOT.NOTRAN .AND. .NOT.LSAME( TRANS, 'T' ) ) THEN 00255 INFO = -3 00256 ELSE IF( M.LT.0 ) THEN 00257 INFO = -4 00258 ELSE IF( N.LT.0 ) THEN 00259 INFO = -5 00260 ELSE IF( K.LT.0 ) THEN 00261 INFO = -6 00262 ELSE IF( ( APPLYQ .AND. LDA.LT.MAX( 1, NQ ) ) .OR. 00263 $ ( .NOT.APPLYQ .AND. LDA.LT.MAX( 1, MIN( NQ, K ) ) ) ) 00264 $ THEN 00265 INFO = -8 00266 ELSE IF( LDC.LT.MAX( 1, M ) ) THEN 00267 INFO = -11 00268 ELSE IF( LWORK.LT.MAX( 1, NW ) .AND. .NOT.LQUERY ) THEN 00269 INFO = -13 00270 END IF 00271 * 00272 IF( INFO.EQ.0 ) THEN 00273 IF( APPLYQ ) THEN 00274 IF( LEFT ) THEN 00275 NB = ILAENV( 1, 'SORMQR', SIDE // TRANS, M-1, N, M-1, 00276 $ -1 ) 00277 ELSE 00278 NB = ILAENV( 1, 'SORMQR', SIDE // TRANS, M, N-1, N-1, 00279 $ -1 ) 00280 END IF 00281 ELSE 00282 IF( LEFT ) THEN 00283 NB = ILAENV( 1, 'SORMLQ', SIDE // TRANS, M-1, N, M-1, 00284 $ -1 ) 00285 ELSE 00286 NB = ILAENV( 1, 'SORMLQ', SIDE // TRANS, M, N-1, N-1, 00287 $ -1 ) 00288 END IF 00289 END IF 00290 LWKOPT = MAX( 1, NW )*NB 00291 WORK( 1 ) = LWKOPT 00292 END IF 00293 * 00294 IF( INFO.NE.0 ) THEN 00295 CALL XERBLA( 'SORMBR', -INFO ) 00296 RETURN 00297 ELSE IF( LQUERY ) THEN 00298 RETURN 00299 END IF 00300 * 00301 * Quick return if possible 00302 * 00303 WORK( 1 ) = 1 00304 IF( M.EQ.0 .OR. N.EQ.0 ) 00305 $ RETURN 00306 * 00307 IF( APPLYQ ) THEN 00308 * 00309 * Apply Q 00310 * 00311 IF( NQ.GE.K ) THEN 00312 * 00313 * Q was determined by a call to SGEBRD with nq >= k 00314 * 00315 CALL SORMQR( SIDE, TRANS, M, N, K, A, LDA, TAU, C, LDC, 00316 $ WORK, LWORK, IINFO ) 00317 ELSE IF( NQ.GT.1 ) THEN 00318 * 00319 * Q was determined by a call to SGEBRD with nq < k 00320 * 00321 IF( LEFT ) THEN 00322 MI = M - 1 00323 NI = N 00324 I1 = 2 00325 I2 = 1 00326 ELSE 00327 MI = M 00328 NI = N - 1 00329 I1 = 1 00330 I2 = 2 00331 END IF 00332 CALL SORMQR( SIDE, TRANS, MI, NI, NQ-1, A( 2, 1 ), LDA, TAU, 00333 $ C( I1, I2 ), LDC, WORK, LWORK, IINFO ) 00334 END IF 00335 ELSE 00336 * 00337 * Apply P 00338 * 00339 IF( NOTRAN ) THEN 00340 TRANST = 'T' 00341 ELSE 00342 TRANST = 'N' 00343 END IF 00344 IF( NQ.GT.K ) THEN 00345 * 00346 * P was determined by a call to SGEBRD with nq > k 00347 * 00348 CALL SORMLQ( SIDE, TRANST, M, N, K, A, LDA, TAU, C, LDC, 00349 $ WORK, LWORK, IINFO ) 00350 ELSE IF( NQ.GT.1 ) THEN 00351 * 00352 * P was determined by a call to SGEBRD with nq <= k 00353 * 00354 IF( LEFT ) THEN 00355 MI = M - 1 00356 NI = N 00357 I1 = 2 00358 I2 = 1 00359 ELSE 00360 MI = M 00361 NI = N - 1 00362 I1 = 1 00363 I2 = 2 00364 END IF 00365 CALL SORMLQ( SIDE, TRANST, MI, NI, NQ-1, A( 1, 2 ), LDA, 00366 $ TAU, C( I1, I2 ), LDC, WORK, LWORK, IINFO ) 00367 END IF 00368 END IF 00369 WORK( 1 ) = LWKOPT 00370 RETURN 00371 * 00372 * End of SORMBR 00373 * 00374 END