![]() |
LAPACK
3.4.1
LAPACK: Linear Algebra PACKage
|
00001 *> \brief \b SSYTD2 00002 * 00003 * =========== DOCUMENTATION =========== 00004 * 00005 * Online html documentation available at 00006 * http://www.netlib.org/lapack/explore-html/ 00007 * 00008 *> \htmlonly 00009 *> Download SSYTD2 + dependencies 00010 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/ssytd2.f"> 00011 *> [TGZ]</a> 00012 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/ssytd2.f"> 00013 *> [ZIP]</a> 00014 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/ssytd2.f"> 00015 *> [TXT]</a> 00016 *> \endhtmlonly 00017 * 00018 * Definition: 00019 * =========== 00020 * 00021 * SUBROUTINE SSYTD2( UPLO, N, A, LDA, D, E, TAU, INFO ) 00022 * 00023 * .. Scalar Arguments .. 00024 * CHARACTER UPLO 00025 * INTEGER INFO, LDA, N 00026 * .. 00027 * .. Array Arguments .. 00028 * REAL A( LDA, * ), D( * ), E( * ), TAU( * ) 00029 * .. 00030 * 00031 * 00032 *> \par Purpose: 00033 * ============= 00034 *> 00035 *> \verbatim 00036 *> 00037 *> SSYTD2 reduces a real symmetric matrix A to symmetric tridiagonal 00038 *> form T by an orthogonal similarity transformation: Q**T * A * Q = T. 00039 *> \endverbatim 00040 * 00041 * Arguments: 00042 * ========== 00043 * 00044 *> \param[in] UPLO 00045 *> \verbatim 00046 *> UPLO is CHARACTER*1 00047 *> Specifies whether the upper or lower triangular part of the 00048 *> symmetric matrix A is stored: 00049 *> = 'U': Upper triangular 00050 *> = 'L': Lower triangular 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 REAL 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 REAL 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 REAL 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 REAL array, dimension (N-1) 00104 *> The scalar factors of the elementary reflectors (see Further 00105 *> Details). 00106 *> \endverbatim 00107 *> 00108 *> \param[out] INFO 00109 *> \verbatim 00110 *> INFO is INTEGER 00111 *> = 0: successful exit 00112 *> < 0: if INFO = -i, the i-th argument had an illegal value. 00113 *> \endverbatim 00114 * 00115 * Authors: 00116 * ======== 00117 * 00118 *> \author Univ. of Tennessee 00119 *> \author Univ. of California Berkeley 00120 *> \author Univ. of Colorado Denver 00121 *> \author NAG Ltd. 00122 * 00123 *> \date November 2011 00124 * 00125 *> \ingroup realSYcomputational 00126 * 00127 *> \par Further Details: 00128 * ===================== 00129 *> 00130 *> \verbatim 00131 *> 00132 *> If UPLO = 'U', the matrix Q is represented as a product of elementary 00133 *> reflectors 00134 *> 00135 *> Q = H(n-1) . . . H(2) H(1). 00136 *> 00137 *> Each H(i) has the form 00138 *> 00139 *> H(i) = I - tau * v * v**T 00140 *> 00141 *> where tau is a real scalar, and v is a real vector with 00142 *> v(i+1:n) = 0 and v(i) = 1; v(1:i-1) is stored on exit in 00143 *> A(1:i-1,i+1), and tau in TAU(i). 00144 *> 00145 *> If UPLO = 'L', the matrix Q is represented as a product of elementary 00146 *> reflectors 00147 *> 00148 *> Q = H(1) H(2) . . . H(n-1). 00149 *> 00150 *> Each H(i) has the form 00151 *> 00152 *> H(i) = I - tau * v * v**T 00153 *> 00154 *> where tau is a real scalar, and v is a real vector with 00155 *> v(1:i) = 0 and v(i+1) = 1; v(i+2:n) is stored on exit in A(i+2:n,i), 00156 *> and tau in TAU(i). 00157 *> 00158 *> The contents of A on exit are illustrated by the following examples 00159 *> with n = 5: 00160 *> 00161 *> if UPLO = 'U': if UPLO = 'L': 00162 *> 00163 *> ( d e v2 v3 v4 ) ( d ) 00164 *> ( d e v3 v4 ) ( e d ) 00165 *> ( d e v4 ) ( v1 e d ) 00166 *> ( d e ) ( v1 v2 e d ) 00167 *> ( d ) ( v1 v2 v3 e d ) 00168 *> 00169 *> where d and e denote diagonal and off-diagonal elements of T, and vi 00170 *> denotes an element of the vector defining H(i). 00171 *> \endverbatim 00172 *> 00173 * ===================================================================== 00174 SUBROUTINE SSYTD2( UPLO, N, A, LDA, D, E, TAU, INFO ) 00175 * 00176 * -- LAPACK computational routine (version 3.4.0) -- 00177 * -- LAPACK is a software package provided by Univ. of Tennessee, -- 00178 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- 00179 * November 2011 00180 * 00181 * .. Scalar Arguments .. 00182 CHARACTER UPLO 00183 INTEGER INFO, LDA, N 00184 * .. 00185 * .. Array Arguments .. 00186 REAL A( LDA, * ), D( * ), E( * ), TAU( * ) 00187 * .. 00188 * 00189 * ===================================================================== 00190 * 00191 * .. Parameters .. 00192 REAL ONE, ZERO, HALF 00193 PARAMETER ( ONE = 1.0, ZERO = 0.0, HALF = 1.0 / 2.0 ) 00194 * .. 00195 * .. Local Scalars .. 00196 LOGICAL UPPER 00197 INTEGER I 00198 REAL ALPHA, TAUI 00199 * .. 00200 * .. External Subroutines .. 00201 EXTERNAL SAXPY, SLARFG, SSYMV, SSYR2, XERBLA 00202 * .. 00203 * .. External Functions .. 00204 LOGICAL LSAME 00205 REAL SDOT 00206 EXTERNAL LSAME, SDOT 00207 * .. 00208 * .. Intrinsic Functions .. 00209 INTRINSIC MAX, MIN 00210 * .. 00211 * .. Executable Statements .. 00212 * 00213 * Test the input parameters 00214 * 00215 INFO = 0 00216 UPPER = LSAME( UPLO, 'U' ) 00217 IF( .NOT.UPPER .AND. .NOT.LSAME( UPLO, 'L' ) ) THEN 00218 INFO = -1 00219 ELSE IF( N.LT.0 ) THEN 00220 INFO = -2 00221 ELSE IF( LDA.LT.MAX( 1, N ) ) THEN 00222 INFO = -4 00223 END IF 00224 IF( INFO.NE.0 ) THEN 00225 CALL XERBLA( 'SSYTD2', -INFO ) 00226 RETURN 00227 END IF 00228 * 00229 * Quick return if possible 00230 * 00231 IF( N.LE.0 ) 00232 $ RETURN 00233 * 00234 IF( UPPER ) THEN 00235 * 00236 * Reduce the upper triangle of A 00237 * 00238 DO 10 I = N - 1, 1, -1 00239 * 00240 * Generate elementary reflector H(i) = I - tau * v * v**T 00241 * to annihilate A(1:i-1,i+1) 00242 * 00243 CALL SLARFG( I, A( I, I+1 ), A( 1, I+1 ), 1, TAUI ) 00244 E( I ) = A( I, I+1 ) 00245 * 00246 IF( TAUI.NE.ZERO ) THEN 00247 * 00248 * Apply H(i) from both sides to A(1:i,1:i) 00249 * 00250 A( I, I+1 ) = ONE 00251 * 00252 * Compute x := tau * A * v storing x in TAU(1:i) 00253 * 00254 CALL SSYMV( UPLO, I, TAUI, A, LDA, A( 1, I+1 ), 1, ZERO, 00255 $ TAU, 1 ) 00256 * 00257 * Compute w := x - 1/2 * tau * (x**T * v) * v 00258 * 00259 ALPHA = -HALF*TAUI*SDOT( I, TAU, 1, A( 1, I+1 ), 1 ) 00260 CALL SAXPY( I, ALPHA, A( 1, I+1 ), 1, TAU, 1 ) 00261 * 00262 * Apply the transformation as a rank-2 update: 00263 * A := A - v * w**T - w * v**T 00264 * 00265 CALL SSYR2( UPLO, I, -ONE, A( 1, I+1 ), 1, TAU, 1, A, 00266 $ LDA ) 00267 * 00268 A( I, I+1 ) = E( I ) 00269 END IF 00270 D( I+1 ) = A( I+1, I+1 ) 00271 TAU( I ) = TAUI 00272 10 CONTINUE 00273 D( 1 ) = A( 1, 1 ) 00274 ELSE 00275 * 00276 * Reduce the lower triangle of A 00277 * 00278 DO 20 I = 1, N - 1 00279 * 00280 * Generate elementary reflector H(i) = I - tau * v * v**T 00281 * to annihilate A(i+2:n,i) 00282 * 00283 CALL SLARFG( N-I, A( I+1, I ), A( MIN( I+2, N ), I ), 1, 00284 $ TAUI ) 00285 E( I ) = A( I+1, I ) 00286 * 00287 IF( TAUI.NE.ZERO ) THEN 00288 * 00289 * Apply H(i) from both sides to A(i+1:n,i+1:n) 00290 * 00291 A( I+1, I ) = ONE 00292 * 00293 * Compute x := tau * A * v storing y in TAU(i:n-1) 00294 * 00295 CALL SSYMV( UPLO, N-I, TAUI, A( I+1, I+1 ), LDA, 00296 $ A( I+1, I ), 1, ZERO, TAU( I ), 1 ) 00297 * 00298 * Compute w := x - 1/2 * tau * (x**T * v) * v 00299 * 00300 ALPHA = -HALF*TAUI*SDOT( N-I, TAU( I ), 1, A( I+1, I ), 00301 $ 1 ) 00302 CALL SAXPY( N-I, ALPHA, A( I+1, I ), 1, TAU( I ), 1 ) 00303 * 00304 * Apply the transformation as a rank-2 update: 00305 * A := A - v * w**T - w * v**T 00306 * 00307 CALL SSYR2( UPLO, N-I, -ONE, A( I+1, I ), 1, TAU( I ), 1, 00308 $ A( I+1, I+1 ), LDA ) 00309 * 00310 A( I+1, I ) = E( I ) 00311 END IF 00312 D( I ) = A( I, I ) 00313 TAU( I ) = TAUI 00314 20 CONTINUE 00315 D( N ) = A( N, N ) 00316 END IF 00317 * 00318 RETURN 00319 * 00320 * End of SSYTD2 00321 * 00322 END