LAPACK  3.4.1
LAPACK: Linear Algebra PACKage
sspgvx.f
Go to the documentation of this file.
00001 *> \brief \b SSPGST
00002 *
00003 *  =========== DOCUMENTATION ===========
00004 *
00005 * Online html documentation available at 
00006 *            http://www.netlib.org/lapack/explore-html/ 
00007 *
00008 *> \htmlonly
00009 *> Download SSPGVX + dependencies 
00010 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/sspgvx.f"> 
00011 *> [TGZ]</a> 
00012 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/sspgvx.f"> 
00013 *> [ZIP]</a> 
00014 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/sspgvx.f"> 
00015 *> [TXT]</a>
00016 *> \endhtmlonly 
00017 *
00018 *  Definition:
00019 *  ===========
00020 *
00021 *       SUBROUTINE SSPGVX( ITYPE, JOBZ, RANGE, UPLO, N, AP, BP, VL, VU,
00022 *                          IL, IU, ABSTOL, M, W, Z, LDZ, WORK, IWORK,
00023 *                          IFAIL, INFO )
00024 * 
00025 *       .. Scalar Arguments ..
00026 *       CHARACTER          JOBZ, RANGE, UPLO
00027 *       INTEGER            IL, INFO, ITYPE, IU, LDZ, M, N
00028 *       REAL               ABSTOL, VL, VU
00029 *       ..
00030 *       .. Array Arguments ..
00031 *       INTEGER            IFAIL( * ), IWORK( * )
00032 *       REAL               AP( * ), BP( * ), W( * ), WORK( * ),
00033 *      $                   Z( LDZ, * )
00034 *       ..
00035 *  
00036 *
00037 *> \par Purpose:
00038 *  =============
00039 *>
00040 *> \verbatim
00041 *>
00042 *> SSPGVX computes selected eigenvalues, and optionally, eigenvectors
00043 *> of a real generalized symmetric-definite eigenproblem, of the form
00044 *> A*x=(lambda)*B*x,  A*Bx=(lambda)*x,  or B*A*x=(lambda)*x.  Here A
00045 *> and B are assumed to be symmetric, stored in packed storage, and B
00046 *> is also positive definite.  Eigenvalues and eigenvectors can be
00047 *> selected by specifying either a range of values or a range of indices
00048 *> for the desired eigenvalues.
00049 *> \endverbatim
00050 *
00051 *  Arguments:
00052 *  ==========
00053 *
00054 *> \param[in] ITYPE
00055 *> \verbatim
00056 *>          ITYPE is INTEGER
00057 *>          Specifies the problem type to be solved:
00058 *>          = 1:  A*x = (lambda)*B*x
00059 *>          = 2:  A*B*x = (lambda)*x
00060 *>          = 3:  B*A*x = (lambda)*x
00061 *> \endverbatim
00062 *>
00063 *> \param[in] JOBZ
00064 *> \verbatim
00065 *>          JOBZ is CHARACTER*1
00066 *>          = 'N':  Compute eigenvalues only;
00067 *>          = 'V':  Compute eigenvalues and eigenvectors.
00068 *> \endverbatim
00069 *>
00070 *> \param[in] RANGE
00071 *> \verbatim
00072 *>          RANGE is CHARACTER*1
00073 *>          = 'A': all eigenvalues will be found.
00074 *>          = 'V': all eigenvalues in the half-open interval (VL,VU]
00075 *>                 will be found.
00076 *>          = 'I': the IL-th through IU-th eigenvalues will be found.
00077 *> \endverbatim
00078 *>
00079 *> \param[in] UPLO
00080 *> \verbatim
00081 *>          UPLO is CHARACTER*1
00082 *>          = 'U':  Upper triangle of A and B are stored;
00083 *>          = 'L':  Lower triangle of A and B are stored.
00084 *> \endverbatim
00085 *>
00086 *> \param[in] N
00087 *> \verbatim
00088 *>          N is INTEGER
00089 *>          The order of the matrix pencil (A,B).  N >= 0.
00090 *> \endverbatim
00091 *>
00092 *> \param[in,out] AP
00093 *> \verbatim
00094 *>          AP is REAL array, dimension (N*(N+1)/2)
00095 *>          On entry, the upper or lower triangle of the symmetric matrix
00096 *>          A, packed columnwise in a linear array.  The j-th column of A
00097 *>          is stored in the array AP as follows:
00098 *>          if UPLO = 'U', AP(i + (j-1)*j/2) = A(i,j) for 1<=i<=j;
00099 *>          if UPLO = 'L', AP(i + (j-1)*(2*n-j)/2) = A(i,j) for j<=i<=n.
00100 *>
00101 *>          On exit, the contents of AP are destroyed.
00102 *> \endverbatim
00103 *>
00104 *> \param[in,out] BP
00105 *> \verbatim
00106 *>          BP is REAL array, dimension (N*(N+1)/2)
00107 *>          On entry, the upper or lower triangle of the symmetric matrix
00108 *>          B, packed columnwise in a linear array.  The j-th column of B
00109 *>          is stored in the array BP as follows:
00110 *>          if UPLO = 'U', BP(i + (j-1)*j/2) = B(i,j) for 1<=i<=j;
00111 *>          if UPLO = 'L', BP(i + (j-1)*(2*n-j)/2) = B(i,j) for j<=i<=n.
00112 *>
00113 *>          On exit, the triangular factor U or L from the Cholesky
00114 *>          factorization B = U**T*U or B = L*L**T, in the same storage
00115 *>          format as B.
00116 *> \endverbatim
00117 *>
00118 *> \param[in] VL
00119 *> \verbatim
00120 *>          VL is REAL
00121 *> \endverbatim
00122 *>
00123 *> \param[in] VU
00124 *> \verbatim
00125 *>          VU is REAL
00126 *>
00127 *>          If RANGE='V', the lower and upper bounds of the interval to
00128 *>          be searched for eigenvalues. VL < VU.
00129 *>          Not referenced if RANGE = 'A' or 'I'.
00130 *> \endverbatim
00131 *>
00132 *> \param[in] IL
00133 *> \verbatim
00134 *>          IL is INTEGER
00135 *> \endverbatim
00136 *>
00137 *> \param[in] IU
00138 *> \verbatim
00139 *>          IU is INTEGER
00140 *>
00141 *>          If RANGE='I', the indices (in ascending order) of the
00142 *>          smallest and largest eigenvalues to be returned.
00143 *>          1 <= IL <= IU <= N, if N > 0; IL = 1 and IU = 0 if N = 0.
00144 *>          Not referenced if RANGE = 'A' or 'V'.
00145 *> \endverbatim
00146 *>
00147 *> \param[in] ABSTOL
00148 *> \verbatim
00149 *>          ABSTOL is REAL
00150 *>          The absolute error tolerance for the eigenvalues.
00151 *>          An approximate eigenvalue is accepted as converged
00152 *>          when it is determined to lie in an interval [a,b]
00153 *>          of width less than or equal to
00154 *>
00155 *>                  ABSTOL + EPS *   max( |a|,|b| ) ,
00156 *>
00157 *>          where EPS is the machine precision.  If ABSTOL is less than
00158 *>          or equal to zero, then  EPS*|T|  will be used in its place,
00159 *>          where |T| is the 1-norm of the tridiagonal matrix obtained
00160 *>          by reducing A to tridiagonal form.
00161 *>
00162 *>          Eigenvalues will be computed most accurately when ABSTOL is
00163 *>          set to twice the underflow threshold 2*SLAMCH('S'), not zero.
00164 *>          If this routine returns with INFO>0, indicating that some
00165 *>          eigenvectors did not converge, try setting ABSTOL to
00166 *>          2*SLAMCH('S').
00167 *> \endverbatim
00168 *>
00169 *> \param[out] M
00170 *> \verbatim
00171 *>          M is INTEGER
00172 *>          The total number of eigenvalues found.  0 <= M <= N.
00173 *>          If RANGE = 'A', M = N, and if RANGE = 'I', M = IU-IL+1.
00174 *> \endverbatim
00175 *>
00176 *> \param[out] W
00177 *> \verbatim
00178 *>          W is REAL array, dimension (N)
00179 *>          On normal exit, the first M elements contain the selected
00180 *>          eigenvalues in ascending order.
00181 *> \endverbatim
00182 *>
00183 *> \param[out] Z
00184 *> \verbatim
00185 *>          Z is REAL array, dimension (LDZ, max(1,M))
00186 *>          If JOBZ = 'N', then Z is not referenced.
00187 *>          If JOBZ = 'V', then if INFO = 0, the first M columns of Z
00188 *>          contain the orthonormal eigenvectors of the matrix A
00189 *>          corresponding to the selected eigenvalues, with the i-th
00190 *>          column of Z holding the eigenvector associated with W(i).
00191 *>          The eigenvectors are normalized as follows:
00192 *>          if ITYPE = 1 or 2, Z**T*B*Z = I;
00193 *>          if ITYPE = 3, Z**T*inv(B)*Z = I.
00194 *>
00195 *>          If an eigenvector fails to converge, then that column of Z
00196 *>          contains the latest approximation to the eigenvector, and the
00197 *>          index of the eigenvector is returned in IFAIL.
00198 *>          Note: the user must ensure that at least max(1,M) columns are
00199 *>          supplied in the array Z; if RANGE = 'V', the exact value of M
00200 *>          is not known in advance and an upper bound must be used.
00201 *> \endverbatim
00202 *>
00203 *> \param[in] LDZ
00204 *> \verbatim
00205 *>          LDZ is INTEGER
00206 *>          The leading dimension of the array Z.  LDZ >= 1, and if
00207 *>          JOBZ = 'V', LDZ >= max(1,N).
00208 *> \endverbatim
00209 *>
00210 *> \param[out] WORK
00211 *> \verbatim
00212 *>          WORK is REAL array, dimension (8*N)
00213 *> \endverbatim
00214 *>
00215 *> \param[out] IWORK
00216 *> \verbatim
00217 *>          IWORK is INTEGER array, dimension (5*N)
00218 *> \endverbatim
00219 *>
00220 *> \param[out] IFAIL
00221 *> \verbatim
00222 *>          IFAIL is INTEGER array, dimension (N)
00223 *>          If JOBZ = 'V', then if INFO = 0, the first M elements of
00224 *>          IFAIL are zero.  If INFO > 0, then IFAIL contains the
00225 *>          indices of the eigenvectors that failed to converge.
00226 *>          If JOBZ = 'N', then IFAIL is not referenced.
00227 *> \endverbatim
00228 *>
00229 *> \param[out] INFO
00230 *> \verbatim
00231 *>          INFO is INTEGER
00232 *>          = 0:  successful exit
00233 *>          < 0:  if INFO = -i, the i-th argument had an illegal value
00234 *>          > 0:  SPPTRF or SSPEVX returned an error code:
00235 *>             <= N:  if INFO = i, SSPEVX failed to converge;
00236 *>                    i eigenvectors failed to converge.  Their indices
00237 *>                    are stored in array IFAIL.
00238 *>             > N:   if INFO = N + i, for 1 <= i <= N, then the leading
00239 *>                    minor of order i of B is not positive definite.
00240 *>                    The factorization of B could not be completed and
00241 *>                    no eigenvalues or eigenvectors were computed.
00242 *> \endverbatim
00243 *
00244 *  Authors:
00245 *  ========
00246 *
00247 *> \author Univ. of Tennessee 
00248 *> \author Univ. of California Berkeley 
00249 *> \author Univ. of Colorado Denver 
00250 *> \author NAG Ltd. 
00251 *
00252 *> \date November 2011
00253 *
00254 *> \ingroup realOTHEReigen
00255 *
00256 *> \par Contributors:
00257 *  ==================
00258 *>
00259 *>     Mark Fahey, Department of Mathematics, Univ. of Kentucky, USA
00260 *
00261 *  =====================================================================
00262       SUBROUTINE SSPGVX( ITYPE, JOBZ, RANGE, UPLO, N, AP, BP, VL, VU,
00263      $                   IL, IU, ABSTOL, M, W, Z, LDZ, WORK, IWORK,
00264      $                   IFAIL, INFO )
00265 *
00266 *  -- LAPACK driver routine (version 3.4.0) --
00267 *  -- LAPACK is a software package provided by Univ. of Tennessee,    --
00268 *  -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
00269 *     November 2011
00270 *
00271 *     .. Scalar Arguments ..
00272       CHARACTER          JOBZ, RANGE, UPLO
00273       INTEGER            IL, INFO, ITYPE, IU, LDZ, M, N
00274       REAL               ABSTOL, VL, VU
00275 *     ..
00276 *     .. Array Arguments ..
00277       INTEGER            IFAIL( * ), IWORK( * )
00278       REAL               AP( * ), BP( * ), W( * ), WORK( * ),
00279      $                   Z( LDZ, * )
00280 *     ..
00281 *
00282 * =====================================================================
00283 *
00284 *     .. Local Scalars ..
00285       LOGICAL            ALLEIG, INDEIG, UPPER, VALEIG, WANTZ
00286       CHARACTER          TRANS
00287       INTEGER            J
00288 *     ..
00289 *     .. External Functions ..
00290       LOGICAL            LSAME
00291       EXTERNAL           LSAME
00292 *     ..
00293 *     .. External Subroutines ..
00294       EXTERNAL           SPPTRF, SSPEVX, SSPGST, STPMV, STPSV, XERBLA
00295 *     ..
00296 *     .. Intrinsic Functions ..
00297       INTRINSIC          MIN
00298 *     ..
00299 *     .. Executable Statements ..
00300 *
00301 *     Test the input parameters.
00302 *
00303       UPPER = LSAME( UPLO, 'U' )
00304       WANTZ = LSAME( JOBZ, 'V' )
00305       ALLEIG = LSAME( RANGE, 'A' )
00306       VALEIG = LSAME( RANGE, 'V' )
00307       INDEIG = LSAME( RANGE, 'I' )
00308 *
00309       INFO = 0
00310       IF( ITYPE.LT.1 .OR. ITYPE.GT.3 ) THEN
00311          INFO = -1
00312       ELSE IF( .NOT.( WANTZ .OR. LSAME( JOBZ, 'N' ) ) ) THEN
00313          INFO = -2
00314       ELSE IF( .NOT.( ALLEIG .OR. VALEIG .OR. INDEIG ) ) THEN
00315          INFO = -3
00316       ELSE IF( .NOT.( UPPER .OR. LSAME( UPLO, 'L' ) ) ) THEN
00317          INFO = -4
00318       ELSE IF( N.LT.0 ) THEN
00319          INFO = -5
00320       ELSE
00321          IF( VALEIG ) THEN
00322             IF( N.GT.0 .AND. VU.LE.VL ) THEN
00323                INFO = -9
00324             END IF
00325          ELSE IF( INDEIG ) THEN
00326             IF( IL.LT.1 ) THEN
00327                INFO = -10
00328             ELSE IF( IU.LT.MIN( N, IL ) .OR. IU.GT.N ) THEN
00329                INFO = -11
00330             END IF
00331          END IF
00332       END IF
00333       IF( INFO.EQ.0 ) THEN
00334          IF( LDZ.LT.1 .OR. ( WANTZ .AND. LDZ.LT.N ) ) THEN
00335             INFO = -16
00336          END IF
00337       END IF
00338 *
00339       IF( INFO.NE.0 ) THEN
00340          CALL XERBLA( 'SSPGVX', -INFO )
00341          RETURN
00342       END IF
00343 *
00344 *     Quick return if possible
00345 *
00346       M = 0
00347       IF( N.EQ.0 )
00348      $   RETURN
00349 *
00350 *     Form a Cholesky factorization of B.
00351 *
00352       CALL SPPTRF( UPLO, N, BP, INFO )
00353       IF( INFO.NE.0 ) THEN
00354          INFO = N + INFO
00355          RETURN
00356       END IF
00357 *
00358 *     Transform problem to standard eigenvalue problem and solve.
00359 *
00360       CALL SSPGST( ITYPE, UPLO, N, AP, BP, INFO )
00361       CALL SSPEVX( JOBZ, RANGE, UPLO, N, AP, VL, VU, IL, IU, ABSTOL, M,
00362      $             W, Z, LDZ, WORK, IWORK, IFAIL, INFO )
00363 *
00364       IF( WANTZ ) THEN
00365 *
00366 *        Backtransform eigenvectors to the original problem.
00367 *
00368          IF( INFO.GT.0 )
00369      $      M = INFO - 1
00370          IF( ITYPE.EQ.1 .OR. ITYPE.EQ.2 ) THEN
00371 *
00372 *           For A*x=(lambda)*B*x and A*B*x=(lambda)*x;
00373 *           backtransform eigenvectors: x = inv(L)**T*y or inv(U)*y
00374 *
00375             IF( UPPER ) THEN
00376                TRANS = 'N'
00377             ELSE
00378                TRANS = 'T'
00379             END IF
00380 *
00381             DO 10 J = 1, M
00382                CALL STPSV( UPLO, TRANS, 'Non-unit', N, BP, Z( 1, J ),
00383      $                     1 )
00384    10       CONTINUE
00385 *
00386          ELSE IF( ITYPE.EQ.3 ) THEN
00387 *
00388 *           For B*A*x=(lambda)*x;
00389 *           backtransform eigenvectors: x = L*y or U**T*y
00390 *
00391             IF( UPPER ) THEN
00392                TRANS = 'T'
00393             ELSE
00394                TRANS = 'N'
00395             END IF
00396 *
00397             DO 20 J = 1, M
00398                CALL STPMV( UPLO, TRANS, 'Non-unit', N, BP, Z( 1, J ),
00399      $                     1 )
00400    20       CONTINUE
00401          END IF
00402       END IF
00403 *
00404       RETURN
00405 *
00406 *     End of SSPGVX
00407 *
00408       END
 All Files Functions