ssteqr.f.html

来自「famous linear algebra library (LAPACK) p」· HTML 代码 · 共 525 行 · 第 1/3 页

HTML
525
字号
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
 <head>
  <title>ssteqr.f</title>
 <meta name="generator" content="emacs 21.3.1; htmlfontify 0.20">
<style type="text/css"><!-- 
body { background: rgb(255, 255, 255);  color: rgb(0, 0, 0);  font-style: normal;  font-weight: 500;  font-stretch: normal;  font-family: adobe-courier;  font-size: 11pt;  text-decoration: none; }
span.default   { background: rgb(255, 255, 255);  color: rgb(0, 0, 0);  font-style: normal;  font-weight: 500;  font-stretch: normal;  font-family: adobe-courier;  font-size: 11pt;  text-decoration: none; }
span.default a { background: rgb(255, 255, 255);  color: rgb(0, 0, 0);  font-style: normal;  font-weight: 500;  font-stretch: normal;  font-family: adobe-courier;  font-size: 11pt;  text-decoration: underline; }
span.string   { color: rgb(188, 143, 143);  background: rgb(255, 255, 255);  font-style: normal;  font-weight: 500;  font-stretch: normal;  font-family: adobe-courier;  font-size: 11pt;  text-decoration: none; }
span.string a { color: rgb(188, 143, 143);  background: rgb(255, 255, 255);  font-style: normal;  font-weight: 500;  font-stretch: normal;  font-family: adobe-courier;  font-size: 11pt;  text-decoration: underline; }
span.comment   { color: rgb(178, 34, 34);  background: rgb(255, 255, 255);  font-style: normal;  font-weight: 500;  font-stretch: normal;  font-family: adobe-courier;  font-size: 11pt;  text-decoration: none; }
span.comment a { color: rgb(178, 34, 34);  background: rgb(255, 255, 255);  font-style: normal;  font-weight: 500;  font-stretch: normal;  font-family: adobe-courier;  font-size: 11pt;  text-decoration: underline; }
 --></style>

 </head>
  <body>

<pre>
      SUBROUTINE <a name="SSTEQR.1"></a><a href="ssteqr.f.html#SSTEQR.1">SSTEQR</a>( COMPZ, N, D, E, Z, LDZ, WORK, INFO )
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  -- LAPACK routine (version 3.1) --
</span><span class="comment">*</span><span class="comment">     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd..
</span><span class="comment">*</span><span class="comment">     November 2006
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">     .. Scalar Arguments ..
</span>      CHARACTER          COMPZ
      INTEGER            INFO, LDZ, N
<span class="comment">*</span><span class="comment">     ..
</span><span class="comment">*</span><span class="comment">     .. Array Arguments ..
</span>      REAL               D( * ), E( * ), WORK( * ), Z( LDZ, * )
<span class="comment">*</span><span class="comment">     ..
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  Purpose
</span><span class="comment">*</span><span class="comment">  =======
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  <a name="SSTEQR.18"></a><a href="ssteqr.f.html#SSTEQR.1">SSTEQR</a> computes all eigenvalues and, optionally, eigenvectors of a
</span><span class="comment">*</span><span class="comment">  symmetric tridiagonal matrix using the implicit QL or QR method.
</span><span class="comment">*</span><span class="comment">  The eigenvectors of a full or band symmetric matrix can also be found
</span><span class="comment">*</span><span class="comment">  if <a name="SSYTRD.21"></a><a href="ssytrd.f.html#SSYTRD.1">SSYTRD</a> or <a name="SSPTRD.21"></a><a href="ssptrd.f.html#SSPTRD.1">SSPTRD</a> or <a name="SSBTRD.21"></a><a href="ssbtrd.f.html#SSBTRD.1">SSBTRD</a> has been used to reduce this matrix to
</span><span class="comment">*</span><span class="comment">  tridiagonal form.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  Arguments
</span><span class="comment">*</span><span class="comment">  =========
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  COMPZ   (input) CHARACTER*1
</span><span class="comment">*</span><span class="comment">          = 'N':  Compute eigenvalues only.
</span><span class="comment">*</span><span class="comment">          = 'V':  Compute eigenvalues and eigenvectors of the original
</span><span class="comment">*</span><span class="comment">                  symmetric matrix.  On entry, Z must contain the
</span><span class="comment">*</span><span class="comment">                  orthogonal matrix used to reduce the original matrix
</span><span class="comment">*</span><span class="comment">                  to tridiagonal form.
</span><span class="comment">*</span><span class="comment">          = 'I':  Compute eigenvalues and eigenvectors of the
</span><span class="comment">*</span><span class="comment">                  tridiagonal matrix.  Z is initialized to the identity
</span><span class="comment">*</span><span class="comment">                  matrix.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  N       (input) INTEGER
</span><span class="comment">*</span><span class="comment">          The order of the matrix.  N &gt;= 0.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  D       (input/output) REAL array, dimension (N)
</span><span class="comment">*</span><span class="comment">          On entry, the diagonal elements of the tridiagonal matrix.
</span><span class="comment">*</span><span class="comment">          On exit, if INFO = 0, the eigenvalues in ascending order.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  E       (input/output) REAL array, dimension (N-1)
</span><span class="comment">*</span><span class="comment">          On entry, the (n-1) subdiagonal elements of the tridiagonal
</span><span class="comment">*</span><span class="comment">          matrix.
</span><span class="comment">*</span><span class="comment">          On exit, E has been destroyed.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  Z       (input/output) REAL array, dimension (LDZ, N)
</span><span class="comment">*</span><span class="comment">          On entry, if  COMPZ = 'V', then Z contains the orthogonal
</span><span class="comment">*</span><span class="comment">          matrix used in the reduction to tridiagonal form.
</span><span class="comment">*</span><span class="comment">          On exit, if INFO = 0, then if  COMPZ = 'V', Z contains the
</span><span class="comment">*</span><span class="comment">          orthonormal eigenvectors of the original symmetric matrix,
</span><span class="comment">*</span><span class="comment">          and if COMPZ = 'I', Z contains the orthonormal eigenvectors
</span><span class="comment">*</span><span class="comment">          of the symmetric tridiagonal matrix.
</span><span class="comment">*</span><span class="comment">          If COMPZ = 'N', then Z is not referenced.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  LDZ     (input) INTEGER
</span><span class="comment">*</span><span class="comment">          The leading dimension of the array Z.  LDZ &gt;= 1, and if
</span><span class="comment">*</span><span class="comment">          eigenvectors are desired, then  LDZ &gt;= max(1,N).
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  WORK    (workspace) REAL array, dimension (max(1,2*N-2))
</span><span class="comment">*</span><span class="comment">          If COMPZ = 'N', then WORK is not referenced.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  INFO    (output) INTEGER
</span><span class="comment">*</span><span class="comment">          = 0:  successful exit
</span><span class="comment">*</span><span class="comment">          &lt; 0:  if INFO = -i, the i-th argument had an illegal value
</span><span class="comment">*</span><span class="comment">          &gt; 0:  the algorithm has failed to find all the eigenvalues in
</span><span class="comment">*</span><span class="comment">                a total of 30*N iterations; if INFO = i, then i
</span><span class="comment">*</span><span class="comment">                elements of E have not converged to zero; on exit, D
</span><span class="comment">*</span><span class="comment">                and E contain the elements of a symmetric tridiagonal
</span><span class="comment">*</span><span class="comment">                matrix which is orthogonally similar to the original
</span><span class="comment">*</span><span class="comment">                matrix.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  =====================================================================
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">     .. Parameters ..
</span>      REAL               ZERO, ONE, TWO, THREE
      PARAMETER          ( ZERO = 0.0E0, ONE = 1.0E0, TWO = 2.0E0,
     $                   THREE = 3.0E0 )
      INTEGER            MAXIT
      PARAMETER          ( MAXIT = 30 )
<span class="comment">*</span><span class="comment">     ..
</span><span class="comment">*</span><span class="comment">     .. Local Scalars ..
</span>      INTEGER            I, ICOMPZ, II, ISCALE, J, JTOT, K, L, L1, LEND,
     $                   LENDM1, LENDP1, LENDSV, LM1, LSV, M, MM, MM1,
     $                   NM1, NMAXIT
      REAL               ANORM, B, C, EPS, EPS2, F, G, P, R, RT1, RT2,
     $                   S, SAFMAX, SAFMIN, SSFMAX, SSFMIN, TST
<span class="comment">*</span><span class="comment">     ..
</span><span class="comment">*</span><span class="comment">     .. External Functions ..
</span>      LOGICAL            <a name="LSAME.92"></a><a href="lsame.f.html#LSAME.1">LSAME</a>
      REAL               <a name="SLAMCH.93"></a><a href="slamch.f.html#SLAMCH.1">SLAMCH</a>, <a name="SLANST.93"></a><a href="slanst.f.html#SLANST.1">SLANST</a>, <a name="SLAPY2.93"></a><a href="slapy2.f.html#SLAPY2.1">SLAPY2</a>
      EXTERNAL           <a name="LSAME.94"></a><a href="lsame.f.html#LSAME.1">LSAME</a>, <a name="SLAMCH.94"></a><a href="slamch.f.html#SLAMCH.1">SLAMCH</a>, <a name="SLANST.94"></a><a href="slanst.f.html#SLANST.1">SLANST</a>, <a name="SLAPY2.94"></a><a href="slapy2.f.html#SLAPY2.1">SLAPY2</a>
<span class="comment">*</span><span class="comment">     ..
</span><span class="comment">*</span><span class="comment">     .. External Subroutines ..
</span>      EXTERNAL           <a name="SLAE2.97"></a><a href="slae2.f.html#SLAE2.1">SLAE2</a>, <a name="SLAEV2.97"></a><a href="slaev2.f.html#SLAEV2.1">SLAEV2</a>, <a name="SLARTG.97"></a><a href="slartg.f.html#SLARTG.1">SLARTG</a>, <a name="SLASCL.97"></a><a href="slascl.f.html#SLASCL.1">SLASCL</a>, <a name="SLASET.97"></a><a href="slaset.f.html#SLASET.1">SLASET</a>, <a name="SLASR.97"></a><a href="slasr.f.html#SLASR.1">SLASR</a>,
     $                   <a name="SLASRT.98"></a><a href="slasrt.f.html#SLASRT.1">SLASRT</a>, SSWAP, <a name="XERBLA.98"></a><a href="xerbla.f.html#XERBLA.1">XERBLA</a>
<span class="comment">*</span><span class="comment">     ..
</span><span class="comment">*</span><span class="comment">     .. Intrinsic Functions ..
</span>      INTRINSIC          ABS, MAX, SIGN, SQRT
<span class="comment">*</span><span class="comment">     ..
</span><span class="comment">*</span><span class="comment">     .. Executable Statements ..
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">     Test the input parameters.
</span><span class="comment">*</span><span class="comment">
</span>      INFO = 0
<span class="comment">*</span><span class="comment">
</span>      IF( <a name="LSAME.109"></a><a href="lsame.f.html#LSAME.1">LSAME</a>( COMPZ, <span class="string">'N'</span> ) ) THEN
         ICOMPZ = 0
      ELSE IF( <a name="LSAME.111"></a><a href="lsame.f.html#LSAME.1">LSAME</a>( COMPZ, <span class="string">'V'</span> ) ) THEN
         ICOMPZ = 1
      ELSE IF( <a name="LSAME.113"></a><a href="lsame.f.html#LSAME.1">LSAME</a>( COMPZ, <span class="string">'I'</span> ) ) THEN
         ICOMPZ = 2
      ELSE
         ICOMPZ = -1
      END IF
      IF( ICOMPZ.LT.0 ) THEN
         INFO = -1
      ELSE IF( N.LT.0 ) THEN
         INFO = -2
      ELSE IF( ( LDZ.LT.1 ) .OR. ( ICOMPZ.GT.0 .AND. LDZ.LT.MAX( 1,
     $         N ) ) ) THEN
         INFO = -6
      END IF
      IF( INFO.NE.0 ) THEN
         CALL <a name="XERBLA.127"></a><a href="xerbla.f.html#XERBLA.1">XERBLA</a>( <span class="string">'<a name="SSTEQR.127"></a><a href="ssteqr.f.html#SSTEQR.1">SSTEQR</a>'</span>, -INFO )
         RETURN
      END IF
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">     Quick return if possible
</span><span class="comment">*</span><span class="comment">
</span>      IF( N.EQ.0 )
     $   RETURN
<span class="comment">*</span><span class="comment">
</span>      IF( N.EQ.1 ) THEN
         IF( ICOMPZ.EQ.2 )
     $      Z( 1, 1 ) = ONE
         RETURN
      END IF
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">     Determine the unit roundoff and over/underflow thresholds.
</span><span class="comment">*</span><span class="comment">
</span>      EPS = <a name="SLAMCH.144"></a><a href="slamch.f.html#SLAMCH.1">SLAMCH</a>( <span class="string">'E'</span> )
      EPS2 = EPS**2
      SAFMIN = <a name="SLAMCH.146"></a><a href="slamch.f.html#SLAMCH.1">SLAMCH</a>( <span class="string">'S'</span> )
      SAFMAX = ONE / SAFMIN
      SSFMAX = SQRT( SAFMAX ) / THREE
      SSFMIN = SQRT( SAFMIN ) / EPS2
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">     Compute the eigenvalues and eigenvectors of the tridiagonal
</span><span class="comment">*</span><span class="comment">     matrix.
</span><span class="comment">*</span><span class="comment">
</span>      IF( ICOMPZ.EQ.2 )
     $   CALL <a name="SLASET.155"></a><a href="slaset.f.html#SLASET.1">SLASET</a>( <span class="string">'Full'</span>, N, N, ZERO, ONE, Z, LDZ )
<span class="comment">*</span><span class="comment">

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?