1*> \brief \b SORGTR 2* 3* =========== DOCUMENTATION =========== 4* 5* Online html documentation available at 6* http://www.netlib.org/lapack/explore-html/ 7* 8*> \htmlonly 9*> Download SORGTR + dependencies 10*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/sorgtr.f"> 11*> [TGZ]</a> 12*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/sorgtr.f"> 13*> [ZIP]</a> 14*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/sorgtr.f"> 15*> [TXT]</a> 16*> \endhtmlonly 17* 18* Definition: 19* =========== 20* 21* SUBROUTINE SORGTR( UPLO, N, A, LDA, TAU, WORK, LWORK, INFO ) 22* 23* .. Scalar Arguments .. 24* CHARACTER UPLO 25* INTEGER INFO, LDA, LWORK, N 26* .. 27* .. Array Arguments .. 28* REAL A( LDA, * ), TAU( * ), WORK( * ) 29* .. 30* 31* 32*> \par Purpose: 33* ============= 34*> 35*> \verbatim 36*> 37*> SORGTR generates a real orthogonal matrix Q which is defined as the 38*> product of n-1 elementary reflectors of order N, as returned by 39*> SSYTRD: 40*> 41*> if UPLO = 'U', Q = H(n-1) . . . H(2) H(1), 42*> 43*> if UPLO = 'L', Q = H(1) H(2) . . . H(n-1). 44*> \endverbatim 45* 46* Arguments: 47* ========== 48* 49*> \param[in] UPLO 50*> \verbatim 51*> UPLO is CHARACTER*1 52*> = 'U': Upper triangle of A contains elementary reflectors 53*> from SSYTRD; 54*> = 'L': Lower triangle of A contains elementary reflectors 55*> from SSYTRD. 56*> \endverbatim 57*> 58*> \param[in] N 59*> \verbatim 60*> N is INTEGER 61*> The order of the matrix Q. N >= 0. 62*> \endverbatim 63*> 64*> \param[in,out] A 65*> \verbatim 66*> A is REAL array, dimension (LDA,N) 67*> On entry, the vectors which define the elementary reflectors, 68*> as returned by SSYTRD. 69*> On exit, the N-by-N orthogonal matrix Q. 70*> \endverbatim 71*> 72*> \param[in] LDA 73*> \verbatim 74*> LDA is INTEGER 75*> The leading dimension of the array A. LDA >= max(1,N). 76*> \endverbatim 77*> 78*> \param[in] TAU 79*> \verbatim 80*> TAU is REAL array, dimension (N-1) 81*> TAU(i) must contain the scalar factor of the elementary 82*> reflector H(i), as returned by SSYTRD. 83*> \endverbatim 84*> 85*> \param[out] WORK 86*> \verbatim 87*> WORK is REAL array, dimension (MAX(1,LWORK)) 88*> On exit, if INFO = 0, WORK(1) returns the optimal LWORK. 89*> \endverbatim 90*> 91*> \param[in] LWORK 92*> \verbatim 93*> LWORK is INTEGER 94*> The dimension of the array WORK. LWORK >= max(1,N-1). 95*> For optimum performance LWORK >= (N-1)*NB, where NB is 96*> the optimal blocksize. 97*> 98*> If LWORK = -1, then a workspace query is assumed; the routine 99*> only calculates the optimal size of the WORK array, returns 100*> this value as the first entry of the WORK array, and no error 101*> message related to LWORK is issued by XERBLA. 102*> \endverbatim 103*> 104*> \param[out] INFO 105*> \verbatim 106*> INFO is INTEGER 107*> = 0: successful exit 108*> < 0: if INFO = -i, the i-th argument had an illegal value 109*> \endverbatim 110* 111* Authors: 112* ======== 113* 114*> \author Univ. of Tennessee 115*> \author Univ. of California Berkeley 116*> \author Univ. of Colorado Denver 117*> \author NAG Ltd. 118* 119*> \date November 2011 120* 121*> \ingroup realOTHERcomputational 122* 123* ===================================================================== 124 SUBROUTINE SORGTR( UPLO, N, A, LDA, TAU, WORK, LWORK, INFO ) 125* 126* -- LAPACK computational routine (version 3.4.0) -- 127* -- LAPACK is a software package provided by Univ. of Tennessee, -- 128* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- 129* November 2011 130* 131* .. Scalar Arguments .. 132 CHARACTER UPLO 133 INTEGER INFO, LDA, LWORK, N 134* .. 135* .. Array Arguments .. 136 REAL A( LDA, * ), TAU( * ), WORK( * ) 137* .. 138* 139* ===================================================================== 140* 141* .. Parameters .. 142 REAL ZERO, ONE 143 PARAMETER ( ZERO = 0.0E+0, ONE = 1.0E+0 ) 144* .. 145* .. Local Scalars .. 146 LOGICAL LQUERY, UPPER 147 INTEGER I, IINFO, J, LWKOPT, NB 148* .. 149* .. External Functions .. 150 LOGICAL LSAME 151 INTEGER ILAENV 152 EXTERNAL ILAENV, LSAME 153* .. 154* .. External Subroutines .. 155 EXTERNAL SORGQL, SORGQR, XERBLA 156* .. 157* .. Intrinsic Functions .. 158 INTRINSIC MAX 159* .. 160* .. Executable Statements .. 161* 162* Test the input arguments 163* 164 INFO = 0 165 LQUERY = ( LWORK.EQ.-1 ) 166 UPPER = LSAME( UPLO, 'U' ) 167 IF( .NOT.UPPER .AND. .NOT.LSAME( UPLO, 'L' ) ) THEN 168 INFO = -1 169 ELSE IF( N.LT.0 ) THEN 170 INFO = -2 171 ELSE IF( LDA.LT.MAX( 1, N ) ) THEN 172 INFO = -4 173 ELSE IF( LWORK.LT.MAX( 1, N-1 ) .AND. .NOT.LQUERY ) THEN 174 INFO = -7 175 END IF 176* 177 IF( INFO.EQ.0 ) THEN 178 IF ( UPPER ) THEN 179 NB = ILAENV( 1, 'SORGQL', ' ', N-1, N-1, N-1, -1 ) 180 ELSE 181 NB = ILAENV( 1, 'SORGQR', ' ', N-1, N-1, N-1, -1 ) 182 END IF 183 LWKOPT = MAX( 1, N-1 )*NB 184 WORK( 1 ) = LWKOPT 185 END IF 186* 187 IF( INFO.NE.0 ) THEN 188 CALL XERBLA( 'SORGTR', -INFO ) 189 RETURN 190 ELSE IF( LQUERY ) THEN 191 RETURN 192 END IF 193* 194* Quick return if possible 195* 196 IF( N.EQ.0 ) THEN 197 WORK( 1 ) = 1 198 RETURN 199 END IF 200* 201 IF( UPPER ) THEN 202* 203* Q was determined by a call to SSYTRD with UPLO = 'U' 204* 205* Shift the vectors which define the elementary reflectors one 206* column to the left, and set the last row and column of Q to 207* those of the unit matrix 208* 209 DO 20 J = 1, N - 1 210 DO 10 I = 1, J - 1 211 A( I, J ) = A( I, J+1 ) 212 10 CONTINUE 213 A( N, J ) = ZERO 214 20 CONTINUE 215 DO 30 I = 1, N - 1 216 A( I, N ) = ZERO 217 30 CONTINUE 218 A( N, N ) = ONE 219* 220* Generate Q(1:n-1,1:n-1) 221* 222 CALL SORGQL( N-1, N-1, N-1, A, LDA, TAU, WORK, LWORK, IINFO ) 223* 224 ELSE 225* 226* Q was determined by a call to SSYTRD with UPLO = 'L'. 227* 228* Shift the vectors which define the elementary reflectors one 229* column to the right, and set the first row and column of Q to 230* those of the unit matrix 231* 232 DO 50 J = N, 2, -1 233 A( 1, J ) = ZERO 234 DO 40 I = J + 1, N 235 A( I, J ) = A( I, J-1 ) 236 40 CONTINUE 237 50 CONTINUE 238 A( 1, 1 ) = ONE 239 DO 60 I = 2, N 240 A( I, 1 ) = ZERO 241 60 CONTINUE 242 IF( N.GT.1 ) THEN 243* 244* Generate Q(2:n,2:n) 245* 246 CALL SORGQR( N-1, N-1, N-1, A( 2, 2 ), LDA, TAU, WORK, 247 $ LWORK, IINFO ) 248 END IF 249 END IF 250 WORK( 1 ) = LWKOPT 251 RETURN 252* 253* End of SORGTR 254* 255 END 256