![]() |
LAPACK
3.4.1
LAPACK: Linear Algebra PACKage
|
00001 *> \brief \b CHETRD 00002 * 00003 * =========== DOCUMENTATION =========== 00004 * 00005 * Online html documentation available at 00006 * http://www.netlib.org/lapack/explore-html/ 00007 * 00008 *> \htmlonly 00009 *> Download CHETRD + dependencies 00010 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/chetrd.f"> 00011 *> [TGZ]</a> 00012 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/chetrd.f"> 00013 *> [ZIP]</a> 00014 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/chetrd.f"> 00015 *> [TXT]</a> 00016 *> \endhtmlonly 00017 * 00018 * Definition: 00019 * =========== 00020 * 00021 * SUBROUTINE CHETRD( 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 * REAL D( * ), E( * ) 00029 * COMPLEX A( LDA, * ), TAU( * ), WORK( * ) 00030 * .. 00031 * 00032 * 00033 *> \par Purpose: 00034 * ============= 00035 *> 00036 *> \verbatim 00037 *> 00038 *> CHETRD reduces a complex Hermitian matrix A to real symmetric 00039 *> tridiagonal form T by a unitary similarity transformation: 00040 *> Q**H * 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 COMPLEX array, dimension (LDA,N) 00062 *> On entry, the Hermitian 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 unitary 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 unitary 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 COMPLEX 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 COMPLEX 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 complexHEcomputational 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**H 00159 *> 00160 *> where tau is a complex scalar, and v is a complex 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**H 00172 *> 00173 *> where tau is a complex scalar, and v is a complex 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 CHETRD( 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 REAL D( * ), E( * ) 00206 COMPLEX A( LDA, * ), TAU( * ), WORK( * ) 00207 * .. 00208 * 00209 * ===================================================================== 00210 * 00211 * .. Parameters .. 00212 REAL ONE 00213 PARAMETER ( ONE = 1.0E+0 ) 00214 COMPLEX CONE 00215 PARAMETER ( CONE = ( 1.0E+0, 0.0E+0 ) ) 00216 * .. 00217 * .. Local Scalars .. 00218 LOGICAL LQUERY, UPPER 00219 INTEGER I, IINFO, IWS, J, KK, LDWORK, LWKOPT, NB, 00220 $ NBMIN, NX 00221 * .. 00222 * .. External Subroutines .. 00223 EXTERNAL CHER2K, CHETD2, CLATRD, XERBLA 00224 * .. 00225 * .. Intrinsic Functions .. 00226 INTRINSIC MAX 00227 * .. 00228 * .. External Functions .. 00229 LOGICAL LSAME 00230 INTEGER ILAENV 00231 EXTERNAL LSAME, ILAENV 00232 * .. 00233 * .. Executable Statements .. 00234 * 00235 * Test the input parameters 00236 * 00237 INFO = 0 00238 UPPER = LSAME( UPLO, 'U' ) 00239 LQUERY = ( LWORK.EQ.-1 ) 00240 IF( .NOT.UPPER .AND. .NOT.LSAME( UPLO, 'L' ) ) THEN 00241 INFO = -1 00242 ELSE IF( N.LT.0 ) THEN 00243 INFO = -2 00244 ELSE IF( LDA.LT.MAX( 1, N ) ) THEN 00245 INFO = -4 00246 ELSE IF( LWORK.LT.1 .AND. .NOT.LQUERY ) THEN 00247 INFO = -9 00248 END IF 00249 * 00250 IF( INFO.EQ.0 ) THEN 00251 * 00252 * Determine the block size. 00253 * 00254 NB = ILAENV( 1, 'CHETRD', UPLO, N, -1, -1, -1 ) 00255 LWKOPT = N*NB 00256 WORK( 1 ) = LWKOPT 00257 END IF 00258 * 00259 IF( INFO.NE.0 ) THEN 00260 CALL XERBLA( 'CHETRD', -INFO ) 00261 RETURN 00262 ELSE IF( LQUERY ) THEN 00263 RETURN 00264 END IF 00265 * 00266 * Quick return if possible 00267 * 00268 IF( N.EQ.0 ) THEN 00269 WORK( 1 ) = 1 00270 RETURN 00271 END IF 00272 * 00273 NX = N 00274 IWS = 1 00275 IF( NB.GT.1 .AND. NB.LT.N ) THEN 00276 * 00277 * Determine when to cross over from blocked to unblocked code 00278 * (last block is always handled by unblocked code). 00279 * 00280 NX = MAX( NB, ILAENV( 3, 'CHETRD', UPLO, N, -1, -1, -1 ) ) 00281 IF( NX.LT.N ) THEN 00282 * 00283 * Determine if workspace is large enough for blocked code. 00284 * 00285 LDWORK = N 00286 IWS = LDWORK*NB 00287 IF( LWORK.LT.IWS ) THEN 00288 * 00289 * Not enough workspace to use optimal NB: determine the 00290 * minimum value of NB, and reduce NB or force use of 00291 * unblocked code by setting NX = N. 00292 * 00293 NB = MAX( LWORK / LDWORK, 1 ) 00294 NBMIN = ILAENV( 2, 'CHETRD', UPLO, N, -1, -1, -1 ) 00295 IF( NB.LT.NBMIN ) 00296 $ NX = N 00297 END IF 00298 ELSE 00299 NX = N 00300 END IF 00301 ELSE 00302 NB = 1 00303 END IF 00304 * 00305 IF( UPPER ) THEN 00306 * 00307 * Reduce the upper triangle of A. 00308 * Columns 1:kk are handled by the unblocked method. 00309 * 00310 KK = N - ( ( N-NX+NB-1 ) / NB )*NB 00311 DO 20 I = N - NB + 1, KK + 1, -NB 00312 * 00313 * Reduce columns i:i+nb-1 to tridiagonal form and form the 00314 * matrix W which is needed to update the unreduced part of 00315 * the matrix 00316 * 00317 CALL CLATRD( UPLO, I+NB-1, NB, A, LDA, E, TAU, WORK, 00318 $ LDWORK ) 00319 * 00320 * Update the unreduced submatrix A(1:i-1,1:i-1), using an 00321 * update of the form: A := A - V*W**H - W*V**H 00322 * 00323 CALL CHER2K( UPLO, 'No transpose', I-1, NB, -CONE, 00324 $ A( 1, I ), LDA, WORK, LDWORK, ONE, A, LDA ) 00325 * 00326 * Copy superdiagonal elements back into A, and diagonal 00327 * elements into D 00328 * 00329 DO 10 J = I, I + NB - 1 00330 A( J-1, J ) = E( J-1 ) 00331 D( J ) = A( J, J ) 00332 10 CONTINUE 00333 20 CONTINUE 00334 * 00335 * Use unblocked code to reduce the last or only block 00336 * 00337 CALL CHETD2( UPLO, KK, A, LDA, D, E, TAU, IINFO ) 00338 ELSE 00339 * 00340 * Reduce the lower triangle of A 00341 * 00342 DO 40 I = 1, N - NX, NB 00343 * 00344 * Reduce columns i:i+nb-1 to tridiagonal form and form the 00345 * matrix W which is needed to update the unreduced part of 00346 * the matrix 00347 * 00348 CALL CLATRD( UPLO, N-I+1, NB, A( I, I ), LDA, E( I ), 00349 $ TAU( I ), WORK, LDWORK ) 00350 * 00351 * Update the unreduced submatrix A(i+nb:n,i+nb:n), using 00352 * an update of the form: A := A - V*W**H - W*V**H 00353 * 00354 CALL CHER2K( UPLO, 'No transpose', N-I-NB+1, NB, -CONE, 00355 $ A( I+NB, I ), LDA, WORK( NB+1 ), LDWORK, ONE, 00356 $ A( I+NB, I+NB ), LDA ) 00357 * 00358 * Copy subdiagonal elements back into A, and diagonal 00359 * elements into D 00360 * 00361 DO 30 J = I, I + NB - 1 00362 A( J+1, J ) = E( J ) 00363 D( J ) = A( J, J ) 00364 30 CONTINUE 00365 40 CONTINUE 00366 * 00367 * Use unblocked code to reduce the last or only block 00368 * 00369 CALL CHETD2( UPLO, N-I+1, A( I, I ), LDA, D( I ), E( I ), 00370 $ TAU( I ), IINFO ) 00371 END IF 00372 * 00373 WORK( 1 ) = LWKOPT 00374 RETURN 00375 * 00376 * End of CHETRD 00377 * 00378 END