LAPACK 3.3.1 Linear Algebra PACKage

# dpot06.f

Go to the documentation of this file.
```00001       SUBROUTINE DPOT06( UPLO, N, NRHS, A, LDA, X, LDX, B, LDB,
00002      \$                   RWORK, RESID )
00003 *
00004 *  -- LAPACK test routine (version 3.1.2) --
00005 *     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd..
00006 *     April 2007
00007 *
00008 *     .. Scalar Arguments ..
00009       CHARACTER          UPLO
00010       INTEGER            LDA, LDB, LDX, N, NRHS
00011       DOUBLE PRECISION   RESID
00012 *     ..
00013 *     .. Array Arguments ..
00014       DOUBLE PRECISION   A( LDA, * ), B( LDB, * ), RWORK( * ),
00015      \$                   X( LDX, * )
00016 *     ..
00017 *
00018 *  Purpose
00019 *  =======
00020 *
00021 *  DPOT06 computes the residual for a solution of a system of linear
00022 *  equations  A*x = b :
00023 *     RESID = norm(B - A*X,inf) / ( norm(A,inf) * norm(X,inf) * EPS ),
00024 *  where EPS is the machine epsilon.
00025 *
00026 *  Arguments
00027 *  =========
00028 *
00029 *  UPLO    (input) CHARACTER*1
00030 *          Specifies whether the upper or lower triangular part of the
00031 *          symmetric matrix A is stored:
00032 *          = 'U':  Upper triangular
00033 *          = 'L':  Lower triangular
00034 *
00035 *  N       (input) INTEGER
00036 *          The number of rows and columns of the matrix A.  N >= 0.
00037 *
00038 *  NRHS    (input) INTEGER
00039 *          The number of columns of B, the matrix of right hand sides.
00040 *          NRHS >= 0.
00041 *
00042 *  A       (input) DOUBLE PRECISION array, dimension (LDA,N)
00043 *          The original M x N matrix A.
00044 *
00045 *  LDA     (input) INTEGER
00046 *          The leading dimension of the array A.  LDA >= max(1,N).
00047 *
00048 *  X       (input) DOUBLE PRECISION array, dimension (LDX,NRHS)
00049 *          The computed solution vectors for the system of linear
00050 *          equations.
00051 *
00052 *  LDX     (input) INTEGER
00053 *          The leading dimension of the array X.  If TRANS = 'N',
00054 *          LDX >= max(1,N); if TRANS = 'T' or 'C', LDX >= max(1,N).
00055 *
00056 *  B       (input/output) DOUBLE PRECISION array, dimension (LDB,NRHS)
00057 *          On entry, the right hand side vectors for the system of
00058 *          linear equations.
00059 *          On exit, B is overwritten with the difference B - A*X.
00060 *
00061 *  LDB     (input) INTEGER
00062 *          The leading dimension of the array B.  IF TRANS = 'N',
00063 *          LDB >= max(1,M); if TRANS = 'T' or 'C', LDB >= max(1,N).
00064 *
00065 *  RWORK   (workspace) DOUBLE PRECISION array, dimension (N)
00066 *
00067 *  RESID   (output) DOUBLE PRECISION
00068 *          The maximum over the number of right hand sides of
00069 *          norm(B - A*X) / ( norm(A) * norm(X) * EPS ).
00070 *
00071 *  =====================================================================
00072 *
00073 *     .. Parameters ..
00074       DOUBLE PRECISION   ZERO, ONE, NEGONE
00075       PARAMETER          ( ZERO = 0.0D+0, ONE = 1.0D+0 )
00076       PARAMETER          ( NEGONE = -1.0D+0 )
00077 *     ..
00078 *     .. Local Scalars ..
00079       INTEGER            IFAIL, J
00080       DOUBLE PRECISION   ANORM, BNORM, EPS, XNORM
00081 *     ..
00082 *     .. External Functions ..
00083       LOGICAL            LSAME
00084       INTEGER            IDAMAX
00085       DOUBLE PRECISION   DLAMCH, DLANSY
00086       EXTERNAL           LSAME, IDAMAX, DLAMCH, DLANSY
00087 *     ..
00088 *     .. External Subroutines ..
00089       EXTERNAL           DSYMM
00090 *     ..
00091 *     .. Intrinsic Functions ..
00092       INTRINSIC          MAX, ABS
00093 *     ..
00094 *     .. Executable Statements ..
00095 *
00096 *     Quick exit if N = 0 or NRHS = 0
00097 *
00098       IF( N.LE.0 .OR. NRHS.EQ.0 ) THEN
00099          RESID = ZERO
00100          RETURN
00101       END IF
00102 *
00103 *     Exit with RESID = 1/EPS if ANORM = 0.
00104 *
00105       EPS = DLAMCH( 'Epsilon' )
00106       ANORM = DLANSY( 'I', UPLO, N, A, LDA, RWORK )
00107       IF( ANORM.LE.ZERO ) THEN
00108          RESID = ONE / EPS
00109          RETURN
00110       END IF
00111 *
00112 *     Compute  B - A*X  and store in B.
00113       IFAIL=0
00114 *
00115       CALL DSYMM( 'Left', UPLO, N, NRHS, NEGONE, A, LDA, X,
00116      \$            LDX, ONE, B, LDB )
00117 *
00118 *     Compute the maximum over the number of right hand sides of
00119 *        norm(B - A*X) / ( norm(A) * norm(X) * EPS ) .
00120 *
00121       RESID = ZERO
00122       DO 10 J = 1, NRHS
00123          BNORM = ABS(B(IDAMAX( N, B( 1, J ), 1 ),J))
00124          XNORM = ABS(X(IDAMAX( N, X( 1, J ), 1 ),J))
00125          IF( XNORM.LE.ZERO ) THEN
00126             RESID = ONE / EPS
00127          ELSE
00128             RESID = MAX( RESID, ( ( BNORM / ANORM ) / XNORM ) / EPS )
00129          END IF
00130    10 CONTINUE
00131 *
00132       RETURN
00133 *
00134 *     End of DPOT06
00135 *
00136       END
```