![]() |
LAPACK
3.4.1
LAPACK: Linear Algebra PACKage
|
00001 *> \brief \b SPTEQR 00002 * 00003 * =========== DOCUMENTATION =========== 00004 * 00005 * Online html documentation available at 00006 * http://www.netlib.org/lapack/explore-html/ 00007 * 00008 *> \htmlonly 00009 *> Download SPTEQR + dependencies 00010 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/spteqr.f"> 00011 *> [TGZ]</a> 00012 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/spteqr.f"> 00013 *> [ZIP]</a> 00014 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/spteqr.f"> 00015 *> [TXT]</a> 00016 *> \endhtmlonly 00017 * 00018 * Definition: 00019 * =========== 00020 * 00021 * SUBROUTINE SPTEQR( COMPZ, N, D, E, Z, LDZ, WORK, INFO ) 00022 * 00023 * .. Scalar Arguments .. 00024 * CHARACTER COMPZ 00025 * INTEGER INFO, LDZ, N 00026 * .. 00027 * .. Array Arguments .. 00028 * REAL D( * ), E( * ), WORK( * ), Z( LDZ, * ) 00029 * .. 00030 * 00031 * 00032 *> \par Purpose: 00033 * ============= 00034 *> 00035 *> \verbatim 00036 *> 00037 *> SPTEQR computes all eigenvalues and, optionally, eigenvectors of a 00038 *> symmetric positive definite tridiagonal matrix by first factoring the 00039 *> matrix using SPTTRF, and then calling SBDSQR to compute the singular 00040 *> values of the bidiagonal factor. 00041 *> 00042 *> This routine computes the eigenvalues of the positive definite 00043 *> tridiagonal matrix to high relative accuracy. This means that if the 00044 *> eigenvalues range over many orders of magnitude in size, then the 00045 *> small eigenvalues and corresponding eigenvectors will be computed 00046 *> more accurately than, for example, with the standard QR method. 00047 *> 00048 *> The eigenvectors of a full or band symmetric positive definite matrix 00049 *> can also be found if SSYTRD, SSPTRD, or SSBTRD has been used to 00050 *> reduce this matrix to tridiagonal form. (The reduction to tridiagonal 00051 *> form, however, may preclude the possibility of obtaining high 00052 *> relative accuracy in the small eigenvalues of the original matrix, if 00053 *> these eigenvalues range over many orders of magnitude.) 00054 *> \endverbatim 00055 * 00056 * Arguments: 00057 * ========== 00058 * 00059 *> \param[in] COMPZ 00060 *> \verbatim 00061 *> COMPZ is CHARACTER*1 00062 *> = 'N': Compute eigenvalues only. 00063 *> = 'V': Compute eigenvectors of original symmetric 00064 *> matrix also. Array Z contains the orthogonal 00065 *> matrix used to reduce the original matrix to 00066 *> tridiagonal form. 00067 *> = 'I': Compute eigenvectors of tridiagonal matrix also. 00068 *> \endverbatim 00069 *> 00070 *> \param[in] N 00071 *> \verbatim 00072 *> N is INTEGER 00073 *> The order of the matrix. N >= 0. 00074 *> \endverbatim 00075 *> 00076 *> \param[in,out] D 00077 *> \verbatim 00078 *> D is REAL array, dimension (N) 00079 *> On entry, the n diagonal elements of the tridiagonal 00080 *> matrix. 00081 *> On normal exit, D contains the eigenvalues, in descending 00082 *> order. 00083 *> \endverbatim 00084 *> 00085 *> \param[in,out] E 00086 *> \verbatim 00087 *> E is REAL array, dimension (N-1) 00088 *> On entry, the (n-1) subdiagonal elements of the tridiagonal 00089 *> matrix. 00090 *> On exit, E has been destroyed. 00091 *> \endverbatim 00092 *> 00093 *> \param[in,out] Z 00094 *> \verbatim 00095 *> Z is REAL array, dimension (LDZ, N) 00096 *> On entry, if COMPZ = 'V', the orthogonal matrix used in the 00097 *> reduction to tridiagonal form. 00098 *> On exit, if COMPZ = 'V', the orthonormal eigenvectors of the 00099 *> original symmetric matrix; 00100 *> if COMPZ = 'I', the orthonormal eigenvectors of the 00101 *> tridiagonal matrix. 00102 *> If INFO > 0 on exit, Z contains the eigenvectors associated 00103 *> with only the stored eigenvalues. 00104 *> If COMPZ = 'N', then Z is not referenced. 00105 *> \endverbatim 00106 *> 00107 *> \param[in] LDZ 00108 *> \verbatim 00109 *> LDZ is INTEGER 00110 *> The leading dimension of the array Z. LDZ >= 1, and if 00111 *> COMPZ = 'V' or 'I', LDZ >= max(1,N). 00112 *> \endverbatim 00113 *> 00114 *> \param[out] WORK 00115 *> \verbatim 00116 *> WORK is REAL array, dimension (4*N) 00117 *> \endverbatim 00118 *> 00119 *> \param[out] INFO 00120 *> \verbatim 00121 *> INFO is INTEGER 00122 *> = 0: successful exit. 00123 *> < 0: if INFO = -i, the i-th argument had an illegal value. 00124 *> > 0: if INFO = i, and i is: 00125 *> <= N the Cholesky factorization of the matrix could 00126 *> not be performed because the i-th principal minor 00127 *> was not positive definite. 00128 *> > N the SVD algorithm failed to converge; 00129 *> if INFO = N+i, i off-diagonal elements of the 00130 *> bidiagonal factor did not converge to zero. 00131 *> \endverbatim 00132 * 00133 * Authors: 00134 * ======== 00135 * 00136 *> \author Univ. of Tennessee 00137 *> \author Univ. of California Berkeley 00138 *> \author Univ. of Colorado Denver 00139 *> \author NAG Ltd. 00140 * 00141 *> \date November 2011 00142 * 00143 *> \ingroup realOTHERcomputational 00144 * 00145 * ===================================================================== 00146 SUBROUTINE SPTEQR( COMPZ, N, D, E, Z, LDZ, WORK, INFO ) 00147 * 00148 * -- LAPACK computational routine (version 3.4.0) -- 00149 * -- LAPACK is a software package provided by Univ. of Tennessee, -- 00150 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- 00151 * November 2011 00152 * 00153 * .. Scalar Arguments .. 00154 CHARACTER COMPZ 00155 INTEGER INFO, LDZ, N 00156 * .. 00157 * .. Array Arguments .. 00158 REAL D( * ), E( * ), WORK( * ), Z( LDZ, * ) 00159 * .. 00160 * 00161 * ===================================================================== 00162 * 00163 * .. Parameters .. 00164 REAL ZERO, ONE 00165 PARAMETER ( ZERO = 0.0E0, ONE = 1.0E0 ) 00166 * .. 00167 * .. External Functions .. 00168 LOGICAL LSAME 00169 EXTERNAL LSAME 00170 * .. 00171 * .. External Subroutines .. 00172 EXTERNAL SBDSQR, SLASET, SPTTRF, XERBLA 00173 * .. 00174 * .. Local Arrays .. 00175 REAL C( 1, 1 ), VT( 1, 1 ) 00176 * .. 00177 * .. Local Scalars .. 00178 INTEGER I, ICOMPZ, NRU 00179 * .. 00180 * .. Intrinsic Functions .. 00181 INTRINSIC MAX, SQRT 00182 * .. 00183 * .. Executable Statements .. 00184 * 00185 * Test the input parameters. 00186 * 00187 INFO = 0 00188 * 00189 IF( LSAME( COMPZ, 'N' ) ) THEN 00190 ICOMPZ = 0 00191 ELSE IF( LSAME( COMPZ, 'V' ) ) THEN 00192 ICOMPZ = 1 00193 ELSE IF( LSAME( COMPZ, 'I' ) ) THEN 00194 ICOMPZ = 2 00195 ELSE 00196 ICOMPZ = -1 00197 END IF 00198 IF( ICOMPZ.LT.0 ) THEN 00199 INFO = -1 00200 ELSE IF( N.LT.0 ) THEN 00201 INFO = -2 00202 ELSE IF( ( LDZ.LT.1 ) .OR. ( ICOMPZ.GT.0 .AND. LDZ.LT.MAX( 1, 00203 $ N ) ) ) THEN 00204 INFO = -6 00205 END IF 00206 IF( INFO.NE.0 ) THEN 00207 CALL XERBLA( 'SPTEQR', -INFO ) 00208 RETURN 00209 END IF 00210 * 00211 * Quick return if possible 00212 * 00213 IF( N.EQ.0 ) 00214 $ RETURN 00215 * 00216 IF( N.EQ.1 ) THEN 00217 IF( ICOMPZ.GT.0 ) 00218 $ Z( 1, 1 ) = ONE 00219 RETURN 00220 END IF 00221 IF( ICOMPZ.EQ.2 ) 00222 $ CALL SLASET( 'Full', N, N, ZERO, ONE, Z, LDZ ) 00223 * 00224 * Call SPTTRF to factor the matrix. 00225 * 00226 CALL SPTTRF( N, D, E, INFO ) 00227 IF( INFO.NE.0 ) 00228 $ RETURN 00229 DO 10 I = 1, N 00230 D( I ) = SQRT( D( I ) ) 00231 10 CONTINUE 00232 DO 20 I = 1, N - 1 00233 E( I ) = E( I )*D( I ) 00234 20 CONTINUE 00235 * 00236 * Call SBDSQR to compute the singular values/vectors of the 00237 * bidiagonal factor. 00238 * 00239 IF( ICOMPZ.GT.0 ) THEN 00240 NRU = N 00241 ELSE 00242 NRU = 0 00243 END IF 00244 CALL SBDSQR( 'Lower', N, 0, NRU, 0, D, E, VT, 1, Z, LDZ, C, 1, 00245 $ WORK, INFO ) 00246 * 00247 * Square the singular values. 00248 * 00249 IF( INFO.EQ.0 ) THEN 00250 DO 30 I = 1, N 00251 D( I ) = D( I )*D( I ) 00252 30 CONTINUE 00253 ELSE 00254 INFO = N + INFO 00255 END IF 00256 * 00257 RETURN 00258 * 00259 * End of SPTEQR 00260 * 00261 END