![]() |
LAPACK
3.4.1
LAPACK: Linear Algebra PACKage
|
00001 *> \brief \b DSYTRD 00002 * 00003 * =========== DOCUMENTATION =========== 00004 * 00005 * Online html documentation available at 00006 * http://www.netlib.org/lapack/explore-html/ 00007 * 00008 *> \htmlonly 00009 *> Download DSYTRD + dependencies 00010 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/dsytrd.f"> 00011 *> [TGZ]</a> 00012 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/dsytrd.f"> 00013 *> [ZIP]</a> 00014 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/dsytrd.f"> 00015 *> [TXT]</a> 00016 *> \endhtmlonly 00017 * 00018 * Definition: 00019 * =========== 00020 * 00021 * SUBROUTINE DSYTRD( UPLO, N, A, LDA, D, E, TAU, WORK, LWORK, INFO ) 00022 * 00023 * .. Scalar Arguments .. 00024 * CHARACTER UPLO 00025 * INTEGER INFO, LDA, LWORK, N 00026 * .. 00027 * .. Array Arguments .. 00028 * DOUBLE PRECISION A( LDA, * ), D( * ), E( * ), TAU( * ), 00029 * $ WORK( * ) 00030 * .. 00031 * 00032 * 00033 *> \par Purpose: 00034 * ============= 00035 *> 00036 *> \verbatim 00037 *> 00038 *> DSYTRD reduces a real symmetric matrix A to real symmetric 00039 *> tridiagonal form T by an orthogonal similarity transformation: 00040 *> Q**T * A * Q = T. 00041 *> \endverbatim 00042 * 00043 * Arguments: 00044 * ========== 00045 * 00046 *> \param[in] UPLO 00047 *> \verbatim 00048 *> UPLO is CHARACTER*1 00049 *> = 'U': Upper triangle of A is stored; 00050 *> = 'L': Lower triangle of A is stored. 00051 *> \endverbatim 00052 *> 00053 *> \param[in] N 00054 *> \verbatim 00055 *> N is INTEGER 00056 *> The order of the matrix A. N >= 0. 00057 *> \endverbatim 00058 *> 00059 *> \param[in,out] A 00060 *> \verbatim 00061 *> A is DOUBLE PRECISION array, dimension (LDA,N) 00062 *> On entry, the symmetric matrix A. If UPLO = 'U', the leading 00063 *> N-by-N upper triangular part of A contains the upper 00064 *> triangular part of the matrix A, and the strictly lower 00065 *> triangular part of A is not referenced. If UPLO = 'L', the 00066 *> leading N-by-N lower triangular part of A contains the lower 00067 *> triangular part of the matrix A, and the strictly upper 00068 *> triangular part of A is not referenced. 00069 *> On exit, if UPLO = 'U', the diagonal and first superdiagonal 00070 *> of A are overwritten by the corresponding elements of the 00071 *> tridiagonal matrix T, and the elements above the first 00072 *> superdiagonal, with the array TAU, represent the orthogonal 00073 *> matrix Q as a product of elementary reflectors; if UPLO 00074 *> = 'L', the diagonal and first subdiagonal of A are over- 00075 *> written by the corresponding elements of the tridiagonal 00076 *> matrix T, and the elements below the first subdiagonal, with 00077 *> the array TAU, represent the orthogonal matrix Q as a product 00078 *> of elementary reflectors. See Further Details. 00079 *> \endverbatim 00080 *> 00081 *> \param[in] LDA 00082 *> \verbatim 00083 *> LDA is INTEGER 00084 *> The leading dimension of the array A. LDA >= max(1,N). 00085 *> \endverbatim 00086 *> 00087 *> \param[out] D 00088 *> \verbatim 00089 *> D is DOUBLE PRECISION array, dimension (N) 00090 *> The diagonal elements of the tridiagonal matrix T: 00091 *> D(i) = A(i,i). 00092 *> \endverbatim 00093 *> 00094 *> \param[out] E 00095 *> \verbatim 00096 *> E is DOUBLE PRECISION array, dimension (N-1) 00097 *> The off-diagonal elements of the tridiagonal matrix T: 00098 *> E(i) = A(i,i+1) if UPLO = 'U', E(i) = A(i+1,i) if UPLO = 'L'. 00099 *> \endverbatim 00100 *> 00101 *> \param[out] TAU 00102 *> \verbatim 00103 *> TAU is DOUBLE PRECISION array, dimension (N-1) 00104 *> The scalar factors of the elementary reflectors (see Further 00105 *> Details). 00106 *> \endverbatim 00107 *> 00108 *> \param[out] WORK 00109 *> \verbatim 00110 *> WORK is DOUBLE PRECISION array, dimension (MAX(1,LWORK)) 00111 *> On exit, if INFO = 0, WORK(1) returns the optimal LWORK. 00112 *> \endverbatim 00113 *> 00114 *> \param[in] LWORK 00115 *> \verbatim 00116 *> LWORK is INTEGER 00117 *> The dimension of the array WORK. LWORK >= 1. 00118 *> For optimum performance LWORK >= N*NB, where NB is the 00119 *> optimal blocksize. 00120 *> 00121 *> If LWORK = -1, then a workspace query is assumed; the routine 00122 *> only calculates the optimal size of the WORK array, returns 00123 *> this value as the first entry of the WORK array, and no error 00124 *> message related to LWORK is issued by XERBLA. 00125 *> \endverbatim 00126 *> 00127 *> \param[out] INFO 00128 *> \verbatim 00129 *> INFO is INTEGER 00130 *> = 0: successful exit 00131 *> < 0: if INFO = -i, the i-th argument had an illegal value 00132 *> \endverbatim 00133 * 00134 * Authors: 00135 * ======== 00136 * 00137 *> \author Univ. of Tennessee 00138 *> \author Univ. of California Berkeley 00139 *> \author Univ. of Colorado Denver 00140 *> \author NAG Ltd. 00141 * 00142 *> \date November 2011 00143 * 00144 *> \ingroup doubleSYcomputational 00145 * 00146 *> \par Further Details: 00147 * ===================== 00148 *> 00149 *> \verbatim 00150 *> 00151 *> If UPLO = 'U', the matrix Q is represented as a product of elementary 00152 *> reflectors 00153 *> 00154 *> Q = H(n-1) . . . H(2) H(1). 00155 *> 00156 *> Each H(i) has the form 00157 *> 00158 *> H(i) = I - tau * v * v**T 00159 *> 00160 *> where tau is a real scalar, and v is a real vector with 00161 *> v(i+1:n) = 0 and v(i) = 1; v(1:i-1) is stored on exit in 00162 *> A(1:i-1,i+1), and tau in TAU(i). 00163 *> 00164 *> If UPLO = 'L', the matrix Q is represented as a product of elementary 00165 *> reflectors 00166 *> 00167 *> Q = H(1) H(2) . . . H(n-1). 00168 *> 00169 *> Each H(i) has the form 00170 *> 00171 *> H(i) = I - tau * v * v**T 00172 *> 00173 *> where tau is a real scalar, and v is a real vector with 00174 *> v(1:i) = 0 and v(i+1) = 1; v(i+2:n) is stored on exit in A(i+2:n,i), 00175 *> and tau in TAU(i). 00176 *> 00177 *> The contents of A on exit are illustrated by the following examples 00178 *> with n = 5: 00179 *> 00180 *> if UPLO = 'U': if UPLO = 'L': 00181 *> 00182 *> ( d e v2 v3 v4 ) ( d ) 00183 *> ( d e v3 v4 ) ( e d ) 00184 *> ( d e v4 ) ( v1 e d ) 00185 *> ( d e ) ( v1 v2 e d ) 00186 *> ( d ) ( v1 v2 v3 e d ) 00187 *> 00188 *> where d and e denote diagonal and off-diagonal elements of T, and vi 00189 *> denotes an element of the vector defining H(i). 00190 *> \endverbatim 00191 *> 00192 * ===================================================================== 00193 SUBROUTINE DSYTRD( UPLO, N, A, LDA, D, E, TAU, WORK, LWORK, INFO ) 00194 * 00195 * -- LAPACK computational routine (version 3.4.0) -- 00196 * -- LAPACK is a software package provided by Univ. of Tennessee, -- 00197 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- 00198 * November 2011 00199 * 00200 * .. Scalar Arguments .. 00201 CHARACTER UPLO 00202 INTEGER INFO, LDA, LWORK, N 00203 * .. 00204 * .. Array Arguments .. 00205 DOUBLE PRECISION A( LDA, * ), D( * ), E( * ), TAU( * ), 00206 $ WORK( * ) 00207 * .. 00208 * 00209 * ===================================================================== 00210 * 00211 * .. Parameters .. 00212 DOUBLE PRECISION ONE 00213 PARAMETER ( ONE = 1.0D+0 ) 00214 * .. 00215 * .. Local Scalars .. 00216 LOGICAL LQUERY, UPPER 00217 INTEGER I, IINFO, IWS, J, KK, LDWORK, LWKOPT, NB, 00218 $ NBMIN, NX 00219 * .. 00220 * .. External Subroutines .. 00221 EXTERNAL DLATRD, DSYR2K, DSYTD2, XERBLA 00222 * .. 00223 * .. Intrinsic Functions .. 00224 INTRINSIC MAX 00225 * .. 00226 * .. External Functions .. 00227 LOGICAL LSAME 00228 INTEGER ILAENV 00229 EXTERNAL LSAME, ILAENV 00230 * .. 00231 * .. Executable Statements .. 00232 * 00233 * Test the input parameters 00234 * 00235 INFO = 0 00236 UPPER = LSAME( UPLO, 'U' ) 00237 LQUERY = ( LWORK.EQ.-1 ) 00238 IF( .NOT.UPPER .AND. .NOT.LSAME( UPLO, 'L' ) ) THEN 00239 INFO = -1 00240 ELSE IF( N.LT.0 ) THEN 00241 INFO = -2 00242 ELSE IF( LDA.LT.MAX( 1, N ) ) THEN 00243 INFO = -4 00244 ELSE IF( LWORK.LT.1 .AND. .NOT.LQUERY ) THEN 00245 INFO = -9 00246 END IF 00247 * 00248 IF( INFO.EQ.0 ) THEN 00249 * 00250 * Determine the block size. 00251 * 00252 NB = ILAENV( 1, 'DSYTRD', UPLO, N, -1, -1, -1 ) 00253 LWKOPT = N*NB 00254 WORK( 1 ) = LWKOPT 00255 END IF 00256 * 00257 IF( INFO.NE.0 ) THEN 00258 CALL XERBLA( 'DSYTRD', -INFO ) 00259 RETURN 00260 ELSE IF( LQUERY ) THEN 00261 RETURN 00262 END IF 00263 * 00264 * Quick return if possible 00265 * 00266 IF( N.EQ.0 ) THEN 00267 WORK( 1 ) = 1 00268 RETURN 00269 END IF 00270 * 00271 NX = N 00272 IWS = 1 00273 IF( NB.GT.1 .AND. NB.LT.N ) THEN 00274 * 00275 * Determine when to cross over from blocked to unblocked code 00276 * (last block is always handled by unblocked code). 00277 * 00278 NX = MAX( NB, ILAENV( 3, 'DSYTRD', UPLO, N, -1, -1, -1 ) ) 00279 IF( NX.LT.N ) THEN 00280 * 00281 * Determine if workspace is large enough for blocked code. 00282 * 00283 LDWORK = N 00284 IWS = LDWORK*NB 00285 IF( LWORK.LT.IWS ) THEN 00286 * 00287 * Not enough workspace to use optimal NB: determine the 00288 * minimum value of NB, and reduce NB or force use of 00289 * unblocked code by setting NX = N. 00290 * 00291 NB = MAX( LWORK / LDWORK, 1 ) 00292 NBMIN = ILAENV( 2, 'DSYTRD', UPLO, N, -1, -1, -1 ) 00293 IF( NB.LT.NBMIN ) 00294 $ NX = N 00295 END IF 00296 ELSE 00297 NX = N 00298 END IF 00299 ELSE 00300 NB = 1 00301 END IF 00302 * 00303 IF( UPPER ) THEN 00304 * 00305 * Reduce the upper triangle of A. 00306 * Columns 1:kk are handled by the unblocked method. 00307 * 00308 KK = N - ( ( N-NX+NB-1 ) / NB )*NB 00309 DO 20 I = N - NB + 1, KK + 1, -NB 00310 * 00311 * Reduce columns i:i+nb-1 to tridiagonal form and form the 00312 * matrix W which is needed to update the unreduced part of 00313 * the matrix 00314 * 00315 CALL DLATRD( UPLO, I+NB-1, NB, A, LDA, E, TAU, WORK, 00316 $ LDWORK ) 00317 * 00318 * Update the unreduced submatrix A(1:i-1,1:i-1), using an 00319 * update of the form: A := A - V*W**T - W*V**T 00320 * 00321 CALL DSYR2K( UPLO, 'No transpose', I-1, NB, -ONE, A( 1, I ), 00322 $ LDA, WORK, LDWORK, ONE, A, LDA ) 00323 * 00324 * Copy superdiagonal elements back into A, and diagonal 00325 * elements into D 00326 * 00327 DO 10 J = I, I + NB - 1 00328 A( J-1, J ) = E( J-1 ) 00329 D( J ) = A( J, J ) 00330 10 CONTINUE 00331 20 CONTINUE 00332 * 00333 * Use unblocked code to reduce the last or only block 00334 * 00335 CALL DSYTD2( UPLO, KK, A, LDA, D, E, TAU, IINFO ) 00336 ELSE 00337 * 00338 * Reduce the lower triangle of A 00339 * 00340 DO 40 I = 1, N - NX, NB 00341 * 00342 * Reduce columns i:i+nb-1 to tridiagonal form and form the 00343 * matrix W which is needed to update the unreduced part of 00344 * the matrix 00345 * 00346 CALL DLATRD( UPLO, N-I+1, NB, A( I, I ), LDA, E( I ), 00347 $ TAU( I ), WORK, LDWORK ) 00348 * 00349 * Update the unreduced submatrix A(i+ib:n,i+ib:n), using 00350 * an update of the form: A := A - V*W**T - W*V**T 00351 * 00352 CALL DSYR2K( UPLO, 'No transpose', N-I-NB+1, NB, -ONE, 00353 $ A( I+NB, I ), LDA, WORK( NB+1 ), LDWORK, ONE, 00354 $ A( I+NB, I+NB ), LDA ) 00355 * 00356 * Copy subdiagonal elements back into A, and diagonal 00357 * elements into D 00358 * 00359 DO 30 J = I, I + NB - 1 00360 A( J+1, J ) = E( J ) 00361 D( J ) = A( J, J ) 00362 30 CONTINUE 00363 40 CONTINUE 00364 * 00365 * Use unblocked code to reduce the last or only block 00366 * 00367 CALL DSYTD2( UPLO, N-I+1, A( I, I ), LDA, D( I ), E( I ), 00368 $ TAU( I ), IINFO ) 00369 END IF 00370 * 00371 WORK( 1 ) = LWKOPT 00372 RETURN 00373 * 00374 * End of DSYTRD 00375 * 00376 END