LAPACK  3.4.1
LAPACK: Linear Algebra PACKage
cpteqr.f
Go to the documentation of this file.
00001 *> \brief \b CPTEQR
00002 *
00003 *  =========== DOCUMENTATION ===========
00004 *
00005 * Online html documentation available at 
00006 *            http://www.netlib.org/lapack/explore-html/ 
00007 *
00008 *> \htmlonly
00009 *> Download CPTEQR + dependencies 
00010 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/cpteqr.f"> 
00011 *> [TGZ]</a> 
00012 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/cpteqr.f"> 
00013 *> [ZIP]</a> 
00014 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/cpteqr.f"> 
00015 *> [TXT]</a>
00016 *> \endhtmlonly 
00017 *
00018 *  Definition:
00019 *  ===========
00020 *
00021 *       SUBROUTINE CPTEQR( 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( * )
00029 *       COMPLEX            Z( LDZ, * )
00030 *       ..
00031 *  
00032 *
00033 *> \par Purpose:
00034 *  =============
00035 *>
00036 *> \verbatim
00037 *>
00038 *> CPTEQR computes all eigenvalues and, optionally, eigenvectors of a
00039 *> symmetric positive definite tridiagonal matrix by first factoring the
00040 *> matrix using SPTTRF and then calling CBDSQR to compute the singular
00041 *> values of the bidiagonal factor.
00042 *>
00043 *> This routine computes the eigenvalues of the positive definite
00044 *> tridiagonal matrix to high relative accuracy.  This means that if the
00045 *> eigenvalues range over many orders of magnitude in size, then the
00046 *> small eigenvalues and corresponding eigenvectors will be computed
00047 *> more accurately than, for example, with the standard QR method.
00048 *>
00049 *> The eigenvectors of a full or band positive definite Hermitian matrix
00050 *> can also be found if CHETRD, CHPTRD, or CHBTRD has been used to
00051 *> reduce this matrix to tridiagonal form.  (The reduction to
00052 *> tridiagonal form, however, may preclude the possibility of obtaining
00053 *> high relative accuracy in the small eigenvalues of the original
00054 *> matrix, if these eigenvalues range over many orders of magnitude.)
00055 *> \endverbatim
00056 *
00057 *  Arguments:
00058 *  ==========
00059 *
00060 *> \param[in] COMPZ
00061 *> \verbatim
00062 *>          COMPZ is CHARACTER*1
00063 *>          = 'N':  Compute eigenvalues only.
00064 *>          = 'V':  Compute eigenvectors of original Hermitian
00065 *>                  matrix also.  Array Z contains the unitary matrix
00066 *>                  used to reduce the original matrix to tridiagonal
00067 *>                  form.
00068 *>          = 'I':  Compute eigenvectors of tridiagonal matrix also.
00069 *> \endverbatim
00070 *>
00071 *> \param[in] N
00072 *> \verbatim
00073 *>          N is INTEGER
00074 *>          The order of the matrix.  N >= 0.
00075 *> \endverbatim
00076 *>
00077 *> \param[in,out] D
00078 *> \verbatim
00079 *>          D is REAL array, dimension (N)
00080 *>          On entry, the n diagonal elements of the tridiagonal 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 COMPLEX array, dimension (LDZ, N)
00096 *>          On entry, if COMPZ = 'V', the unitary matrix used in the
00097 *>          reduction to tridiagonal form.
00098 *>          On exit, if COMPZ = 'V', the orthonormal eigenvectors of the
00099 *>          original Hermitian 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 complexOTHERcomputational
00144 *
00145 *  =====================================================================
00146       SUBROUTINE CPTEQR( 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( * )
00159       COMPLEX            Z( LDZ, * )
00160 *     ..
00161 *
00162 *  ====================================================================
00163 *
00164 *     .. Parameters ..
00165       COMPLEX            CZERO, CONE
00166       PARAMETER          ( CZERO = ( 0.0E+0, 0.0E+0 ),
00167      $                   CONE = ( 1.0E+0, 0.0E+0 ) )
00168 *     ..
00169 *     .. External Functions ..
00170       LOGICAL            LSAME
00171       EXTERNAL           LSAME
00172 *     ..
00173 *     .. External Subroutines ..
00174       EXTERNAL           CBDSQR, CLASET, SPTTRF, XERBLA
00175 *     ..
00176 *     .. Local Arrays ..
00177       COMPLEX            C( 1, 1 ), VT( 1, 1 )
00178 *     ..
00179 *     .. Local Scalars ..
00180       INTEGER            I, ICOMPZ, NRU
00181 *     ..
00182 *     .. Intrinsic Functions ..
00183       INTRINSIC          MAX, SQRT
00184 *     ..
00185 *     .. Executable Statements ..
00186 *
00187 *     Test the input parameters.
00188 *
00189       INFO = 0
00190 *
00191       IF( LSAME( COMPZ, 'N' ) ) THEN
00192          ICOMPZ = 0
00193       ELSE IF( LSAME( COMPZ, 'V' ) ) THEN
00194          ICOMPZ = 1
00195       ELSE IF( LSAME( COMPZ, 'I' ) ) THEN
00196          ICOMPZ = 2
00197       ELSE
00198          ICOMPZ = -1
00199       END IF
00200       IF( ICOMPZ.LT.0 ) THEN
00201          INFO = -1
00202       ELSE IF( N.LT.0 ) THEN
00203          INFO = -2
00204       ELSE IF( ( LDZ.LT.1 ) .OR. ( ICOMPZ.GT.0 .AND. LDZ.LT.MAX( 1,
00205      $         N ) ) ) THEN
00206          INFO = -6
00207       END IF
00208       IF( INFO.NE.0 ) THEN
00209          CALL XERBLA( 'CPTEQR', -INFO )
00210          RETURN
00211       END IF
00212 *
00213 *     Quick return if possible
00214 *
00215       IF( N.EQ.0 )
00216      $   RETURN
00217 *
00218       IF( N.EQ.1 ) THEN
00219          IF( ICOMPZ.GT.0 )
00220      $      Z( 1, 1 ) = CONE
00221          RETURN
00222       END IF
00223       IF( ICOMPZ.EQ.2 )
00224      $   CALL CLASET( 'Full', N, N, CZERO, CONE, Z, LDZ )
00225 *
00226 *     Call SPTTRF to factor the matrix.
00227 *
00228       CALL SPTTRF( N, D, E, INFO )
00229       IF( INFO.NE.0 )
00230      $   RETURN
00231       DO 10 I = 1, N
00232          D( I ) = SQRT( D( I ) )
00233    10 CONTINUE
00234       DO 20 I = 1, N - 1
00235          E( I ) = E( I )*D( I )
00236    20 CONTINUE
00237 *
00238 *     Call CBDSQR to compute the singular values/vectors of the
00239 *     bidiagonal factor.
00240 *
00241       IF( ICOMPZ.GT.0 ) THEN
00242          NRU = N
00243       ELSE
00244          NRU = 0
00245       END IF
00246       CALL CBDSQR( 'Lower', N, 0, NRU, 0, D, E, VT, 1, Z, LDZ, C, 1,
00247      $             WORK, INFO )
00248 *
00249 *     Square the singular values.
00250 *
00251       IF( INFO.EQ.0 ) THEN
00252          DO 30 I = 1, N
00253             D( I ) = D( I )*D( I )
00254    30    CONTINUE
00255       ELSE
00256          INFO = N + INFO
00257       END IF
00258 *
00259       RETURN
00260 *
00261 *     End of CPTEQR
00262 *
00263       END
 All Files Functions