chesvx.f.html

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

HTML
325
字号
</span><span class="comment">*</span><span class="comment">          If XTRUE is the true solution corresponding to X(j), FERR(j)
</span><span class="comment">*</span><span class="comment">          is an estimated upper bound for the magnitude of the largest
</span><span class="comment">*</span><span class="comment">          element in (X(j) - XTRUE) divided by the magnitude of the
</span><span class="comment">*</span><span class="comment">          largest element in X(j).  The estimate is as reliable as
</span><span class="comment">*</span><span class="comment">          the estimate for RCOND, and is almost always a slight
</span><span class="comment">*</span><span class="comment">          overestimate of the true error.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  BERR    (output) REAL array, dimension (NRHS)
</span><span class="comment">*</span><span class="comment">          The componentwise relative backward error of each solution
</span><span class="comment">*</span><span class="comment">          vector X(j) (i.e., the smallest relative change in
</span><span class="comment">*</span><span class="comment">          any element of A or B that makes X(j) an exact solution).
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  WORK    (workspace/output) COMPLEX array, dimension (MAX(1,LWORK))
</span><span class="comment">*</span><span class="comment">          On exit, if INFO = 0, WORK(1) returns the optimal LWORK.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  LWORK   (input) INTEGER
</span><span class="comment">*</span><span class="comment">          The length of WORK.  LWORK &gt;= max(1,2*N), and for best
</span><span class="comment">*</span><span class="comment">          performance, when FACT = 'N', LWORK &gt;= max(1,2*N,N*NB), where
</span><span class="comment">*</span><span class="comment">          NB is the optimal blocksize for <a name="CHETRF.163"></a><a href="chetrf.f.html#CHETRF.1">CHETRF</a>.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">          If LWORK = -1, then a workspace query is assumed; the routine
</span><span class="comment">*</span><span class="comment">          only calculates the optimal size of the WORK array, returns
</span><span class="comment">*</span><span class="comment">          this value as the first entry of the WORK array, and no error
</span><span class="comment">*</span><span class="comment">          message related to LWORK is issued by <a name="XERBLA.168"></a><a href="xerbla.f.html#XERBLA.1">XERBLA</a>.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  RWORK   (workspace) REAL array, dimension (N)
</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: if INFO = i, and i is
</span><span class="comment">*</span><span class="comment">                &lt;= N:  D(i,i) is exactly zero.  The factorization
</span><span class="comment">*</span><span class="comment">                       has been completed but the factor D is exactly
</span><span class="comment">*</span><span class="comment">                       singular, so the solution and error bounds could
</span><span class="comment">*</span><span class="comment">                       not be computed. RCOND = 0 is returned.
</span><span class="comment">*</span><span class="comment">                = N+1: D is nonsingular, but RCOND is less than machine
</span><span class="comment">*</span><span class="comment">                       precision, meaning that the matrix is singular
</span><span class="comment">*</span><span class="comment">                       to working precision.  Nevertheless, the
</span><span class="comment">*</span><span class="comment">                       solution and error bounds are computed because
</span><span class="comment">*</span><span class="comment">                       there are a number of situations where the
</span><span class="comment">*</span><span class="comment">                       computed solution can be more accurate than the
</span><span class="comment">*</span><span class="comment">                       value of RCOND would suggest.
</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
      PARAMETER          ( ZERO = 0.0E+0 )
<span class="comment">*</span><span class="comment">     ..
</span><span class="comment">*</span><span class="comment">     .. Local Scalars ..
</span>      LOGICAL            LQUERY, NOFACT
      INTEGER            LWKOPT, NB
      REAL               ANORM
<span class="comment">*</span><span class="comment">     ..
</span><span class="comment">*</span><span class="comment">     .. External Functions ..
</span>      LOGICAL            <a name="LSAME.200"></a><a href="lsame.f.html#LSAME.1">LSAME</a>
      INTEGER            <a name="ILAENV.201"></a><a href="hfy-index.html#ILAENV">ILAENV</a>
      REAL               <a name="CLANHE.202"></a><a href="clanhe.f.html#CLANHE.1">CLANHE</a>, <a name="SLAMCH.202"></a><a href="slamch.f.html#SLAMCH.1">SLAMCH</a>
      EXTERNAL           <a name="ILAENV.203"></a><a href="hfy-index.html#ILAENV">ILAENV</a>, <a name="LSAME.203"></a><a href="lsame.f.html#LSAME.1">LSAME</a>, <a name="CLANHE.203"></a><a href="clanhe.f.html#CLANHE.1">CLANHE</a>, <a name="SLAMCH.203"></a><a href="slamch.f.html#SLAMCH.1">SLAMCH</a>
<span class="comment">*</span><span class="comment">     ..
</span><span class="comment">*</span><span class="comment">     .. External Subroutines ..
</span>      EXTERNAL           <a name="CHECON.206"></a><a href="checon.f.html#CHECON.1">CHECON</a>, <a name="CHERFS.206"></a><a href="cherfs.f.html#CHERFS.1">CHERFS</a>, <a name="CHETRF.206"></a><a href="chetrf.f.html#CHETRF.1">CHETRF</a>, <a name="CHETRS.206"></a><a href="chetrs.f.html#CHETRS.1">CHETRS</a>, <a name="CLACPY.206"></a><a href="clacpy.f.html#CLACPY.1">CLACPY</a>, <a name="XERBLA.206"></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          MAX
<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
      NOFACT = <a name="LSAME.216"></a><a href="lsame.f.html#LSAME.1">LSAME</a>( FACT, <span class="string">'N'</span> )
      LQUERY = ( LWORK.EQ.-1 )
      IF( .NOT.NOFACT .AND. .NOT.<a name="LSAME.218"></a><a href="lsame.f.html#LSAME.1">LSAME</a>( FACT, <span class="string">'F'</span> ) ) THEN
         INFO = -1
      ELSE IF( .NOT.<a name="LSAME.220"></a><a href="lsame.f.html#LSAME.1">LSAME</a>( UPLO, <span class="string">'U'</span> ) .AND. .NOT.<a name="LSAME.220"></a><a href="lsame.f.html#LSAME.1">LSAME</a>( UPLO, <span class="string">'L'</span> ) )
     $          THEN
         INFO = -2
      ELSE IF( N.LT.0 ) THEN
         INFO = -3
      ELSE IF( NRHS.LT.0 ) THEN
         INFO = -4
      ELSE IF( LDA.LT.MAX( 1, N ) ) THEN
         INFO = -6
      ELSE IF( LDAF.LT.MAX( 1, N ) ) THEN
         INFO = -8
      ELSE IF( LDB.LT.MAX( 1, N ) ) THEN
         INFO = -11
      ELSE IF( LDX.LT.MAX( 1, N ) ) THEN
         INFO = -13
      ELSE IF( LWORK.LT.MAX( 1, 2*N ) .AND. .NOT.LQUERY ) THEN
         INFO = -18
      END IF
<span class="comment">*</span><span class="comment">
</span>      IF( INFO.EQ.0 ) THEN
         LWKOPT = MAX( 1, 2*N )
         IF( NOFACT ) THEN
            NB = <a name="ILAENV.242"></a><a href="hfy-index.html#ILAENV">ILAENV</a>( 1, <span class="string">'<a name="CHETRF.242"></a><a href="chetrf.f.html#CHETRF.1">CHETRF</a>'</span>, UPLO, N, -1, -1, -1 )
            LWKOPT = MAX( LWKOPT, N*NB )
         END IF
         WORK( 1 ) = LWKOPT
      END IF
<span class="comment">*</span><span class="comment">
</span>      IF( INFO.NE.0 ) THEN
         CALL <a name="XERBLA.249"></a><a href="xerbla.f.html#XERBLA.1">XERBLA</a>( <span class="string">'<a name="CHESVX.249"></a><a href="chesvx.f.html#CHESVX.1">CHESVX</a>'</span>, -INFO )
         RETURN
      ELSE IF( LQUERY ) THEN
         RETURN
      END IF
<span class="comment">*</span><span class="comment">
</span>      IF( NOFACT ) THEN
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">        Compute the factorization A = U*D*U' or A = L*D*L'.
</span><span class="comment">*</span><span class="comment">
</span>         CALL <a name="CLACPY.259"></a><a href="clacpy.f.html#CLACPY.1">CLACPY</a>( UPLO, N, N, A, LDA, AF, LDAF )
         CALL <a name="CHETRF.260"></a><a href="chetrf.f.html#CHETRF.1">CHETRF</a>( UPLO, N, AF, LDAF, IPIV, WORK, LWORK, INFO )
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">        Return if INFO is non-zero.
</span><span class="comment">*</span><span class="comment">
</span>         IF( INFO.GT.0 )THEN
            RCOND = ZERO
            RETURN
         END IF
      END IF
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">     Compute the norm of the matrix A.
</span><span class="comment">*</span><span class="comment">
</span>      ANORM = <a name="CLANHE.272"></a><a href="clanhe.f.html#CLANHE.1">CLANHE</a>( <span class="string">'I'</span>, UPLO, N, A, LDA, RWORK )
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">     Compute the reciprocal of the condition number of A.
</span><span class="comment">*</span><span class="comment">
</span>      CALL <a name="CHECON.276"></a><a href="checon.f.html#CHECON.1">CHECON</a>( UPLO, N, AF, LDAF, IPIV, ANORM, RCOND, WORK, INFO )
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">     Compute the solution vectors X.
</span><span class="comment">*</span><span class="comment">
</span>      CALL <a name="CLACPY.280"></a><a href="clacpy.f.html#CLACPY.1">CLACPY</a>( <span class="string">'Full'</span>, N, NRHS, B, LDB, X, LDX )
      CALL <a name="CHETRS.281"></a><a href="chetrs.f.html#CHETRS.1">CHETRS</a>( UPLO, N, NRHS, AF, LDAF, IPIV, X, LDX, INFO )
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">     Use iterative refinement to improve the computed solutions and
</span><span class="comment">*</span><span class="comment">     compute error bounds and backward error estimates for them.
</span><span class="comment">*</span><span class="comment">
</span>      CALL <a name="CHERFS.286"></a><a href="cherfs.f.html#CHERFS.1">CHERFS</a>( UPLO, N, NRHS, A, LDA, AF, LDAF, IPIV, B, LDB, X,
     $             LDX, FERR, BERR, WORK, RWORK, INFO )
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">     Set INFO = N+1 if the matrix is singular to working precision.
</span><span class="comment">*</span><span class="comment">
</span>      IF( RCOND.LT.<a name="SLAMCH.291"></a><a href="slamch.f.html#SLAMCH.1">SLAMCH</a>( <span class="string">'Epsilon'</span> ) )
     $   INFO = N + 1
<span class="comment">*</span><span class="comment">
</span>      WORK( 1 ) = LWKOPT
<span class="comment">*</span><span class="comment">
</span>      RETURN
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">     End of <a name="CHESVX.298"></a><a href="chesvx.f.html#CHESVX.1">CHESVX</a>
</span><span class="comment">*</span><span class="comment">
</span>      END

</pre>

 </body>
</html>

⌨️ 快捷键说明

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