LAPACK 3.3.1
Linear Algebra PACKage

dpot05.f

Go to the documentation of this file.
00001       SUBROUTINE DPOT05( UPLO, N, NRHS, A, LDA, B, LDB, X, LDX, XACT,
00002      $                   LDXACT, FERR, BERR, RESLTS )
00003 *
00004 *  -- LAPACK test routine (version 3.1) --
00005 *     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd..
00006 *     November 2006
00007 *
00008 *     .. Scalar Arguments ..
00009       CHARACTER          UPLO
00010       INTEGER            LDA, LDB, LDX, LDXACT, N, NRHS
00011 *     ..
00012 *     .. Array Arguments ..
00013       DOUBLE PRECISION   A( LDA, * ), B( LDB, * ), BERR( * ), FERR( * ),
00014      $                   RESLTS( * ), X( LDX, * ), XACT( LDXACT, * )
00015 *     ..
00016 *
00017 *  Purpose
00018 *  =======
00019 *
00020 *  DPOT05 tests the error bounds from iterative refinement for the
00021 *  computed solution to a system of equations A*X = B, where A is a
00022 *  symmetric n by n matrix.
00023 *
00024 *  RESLTS(1) = test of the error bound
00025 *            = norm(X - XACT) / ( norm(X) * FERR )
00026 *
00027 *  A large value is returned if this ratio is not less than one.
00028 *
00029 *  RESLTS(2) = residual from the iterative refinement routine
00030 *            = the maximum of BERR / ( (n+1)*EPS + (*) ), where
00031 *              (*) = (n+1)*UNFL / (min_i (abs(A)*abs(X) +abs(b))_i )
00032 *
00033 *  Arguments
00034 *  =========
00035 *
00036 *  UPLO    (input) CHARACTER*1
00037 *          Specifies whether the upper or lower triangular part of the
00038 *          symmetric matrix A is stored.
00039 *          = 'U':  Upper triangular
00040 *          = 'L':  Lower triangular
00041 *
00042 *  N       (input) INTEGER
00043 *          The number of rows of the matrices X, B, and XACT, and the
00044 *          order of the matrix A.  N >= 0.
00045 *
00046 *  NRHS    (input) INTEGER
00047 *          The number of columns of the matrices X, B, and XACT.
00048 *          NRHS >= 0.
00049 *
00050 *  A       (input) DOUBLE PRECISION array, dimension (LDA,N)
00051 *          The symmetric matrix A.  If UPLO = 'U', the leading n by n
00052 *          upper triangular part of A contains the upper triangular part
00053 *          of the matrix A, and the strictly lower triangular part of A
00054 *          is not referenced.  If UPLO = 'L', the leading n by n lower
00055 *          triangular part of A contains the lower triangular part of
00056 *          the matrix A, and the strictly upper triangular part of A is
00057 *          not referenced.
00058 *
00059 *  LDA     (input) INTEGER
00060 *          The leading dimension of the array A.  LDA >= max(1,N).
00061 *
00062 *  B       (input) DOUBLE PRECISION array, dimension (LDB,NRHS)
00063 *          The right hand side vectors for the system of linear
00064 *          equations.
00065 *
00066 *  LDB     (input) INTEGER
00067 *          The leading dimension of the array B.  LDB >= max(1,N).
00068 *
00069 *  X       (input) DOUBLE PRECISION array, dimension (LDX,NRHS)
00070 *          The computed solution vectors.  Each vector is stored as a
00071 *          column of the matrix X.
00072 *
00073 *  LDX     (input) INTEGER
00074 *          The leading dimension of the array X.  LDX >= max(1,N).
00075 *
00076 *  XACT    (input) DOUBLE PRECISION array, dimension (LDX,NRHS)
00077 *          The exact solution vectors.  Each vector is stored as a
00078 *          column of the matrix XACT.
00079 *
00080 *  LDXACT  (input) INTEGER
00081 *          The leading dimension of the array XACT.  LDXACT >= max(1,N).
00082 *
00083 *  FERR    (input) DOUBLE PRECISION array, dimension (NRHS)
00084 *          The estimated forward error bounds for each solution vector
00085 *          X.  If XTRUE is the true solution, FERR bounds the magnitude
00086 *          of the largest entry in (X - XTRUE) divided by the magnitude
00087 *          of the largest entry in X.
00088 *
00089 *  BERR    (input) DOUBLE PRECISION array, dimension (NRHS)
00090 *          The componentwise relative backward error of each solution
00091 *          vector (i.e., the smallest relative change in any entry of A
00092 *          or B that makes X an exact solution).
00093 *
00094 *  RESLTS  (output) DOUBLE PRECISION array, dimension (2)
00095 *          The maximum over the NRHS solution vectors of the ratios:
00096 *          RESLTS(1) = norm(X - XACT) / ( norm(X) * FERR )
00097 *          RESLTS(2) = BERR / ( (n+1)*EPS + (*) )
00098 *
00099 *  =====================================================================
00100 *
00101 *     .. Parameters ..
00102       DOUBLE PRECISION   ZERO, ONE
00103       PARAMETER          ( ZERO = 0.0D+0, ONE = 1.0D+0 )
00104 *     ..
00105 *     .. Local Scalars ..
00106       LOGICAL            UPPER
00107       INTEGER            I, IMAX, J, K
00108       DOUBLE PRECISION   AXBI, DIFF, EPS, ERRBND, OVFL, TMP, UNFL, XNORM
00109 *     ..
00110 *     .. External Functions ..
00111       LOGICAL            LSAME
00112       INTEGER            IDAMAX
00113       DOUBLE PRECISION   DLAMCH
00114       EXTERNAL           LSAME, IDAMAX, DLAMCH
00115 *     ..
00116 *     .. Intrinsic Functions ..
00117       INTRINSIC          ABS, MAX, MIN
00118 *     ..
00119 *     .. Executable Statements ..
00120 *
00121 *     Quick exit if N = 0 or NRHS = 0.
00122 *
00123       IF( N.LE.0 .OR. NRHS.LE.0 ) THEN
00124          RESLTS( 1 ) = ZERO
00125          RESLTS( 2 ) = ZERO
00126          RETURN
00127       END IF
00128 *
00129       EPS = DLAMCH( 'Epsilon' )
00130       UNFL = DLAMCH( 'Safe minimum' )
00131       OVFL = ONE / UNFL
00132       UPPER = LSAME( UPLO, 'U' )
00133 *
00134 *     Test 1:  Compute the maximum of
00135 *        norm(X - XACT) / ( norm(X) * FERR )
00136 *     over all the vectors X and XACT using the infinity-norm.
00137 *
00138       ERRBND = ZERO
00139       DO 30 J = 1, NRHS
00140          IMAX = IDAMAX( N, X( 1, J ), 1 )
00141          XNORM = MAX( ABS( X( IMAX, J ) ), UNFL )
00142          DIFF = ZERO
00143          DO 10 I = 1, N
00144             DIFF = MAX( DIFF, ABS( X( I, J )-XACT( I, J ) ) )
00145    10    CONTINUE
00146 *
00147          IF( XNORM.GT.ONE ) THEN
00148             GO TO 20
00149          ELSE IF( DIFF.LE.OVFL*XNORM ) THEN
00150             GO TO 20
00151          ELSE
00152             ERRBND = ONE / EPS
00153             GO TO 30
00154          END IF
00155 *
00156    20    CONTINUE
00157          IF( DIFF / XNORM.LE.FERR( J ) ) THEN
00158             ERRBND = MAX( ERRBND, ( DIFF / XNORM ) / FERR( J ) )
00159          ELSE
00160             ERRBND = ONE / EPS
00161          END IF
00162    30 CONTINUE
00163       RESLTS( 1 ) = ERRBND
00164 *
00165 *     Test 2:  Compute the maximum of BERR / ( (n+1)*EPS + (*) ), where
00166 *     (*) = (n+1)*UNFL / (min_i (abs(A)*abs(X) +abs(b))_i )
00167 *
00168       DO 90 K = 1, NRHS
00169          DO 80 I = 1, N
00170             TMP = ABS( B( I, K ) )
00171             IF( UPPER ) THEN
00172                DO 40 J = 1, I
00173                   TMP = TMP + ABS( A( J, I ) )*ABS( X( J, K ) )
00174    40          CONTINUE
00175                DO 50 J = I + 1, N
00176                   TMP = TMP + ABS( A( I, J ) )*ABS( X( J, K ) )
00177    50          CONTINUE
00178             ELSE
00179                DO 60 J = 1, I - 1
00180                   TMP = TMP + ABS( A( I, J ) )*ABS( X( J, K ) )
00181    60          CONTINUE
00182                DO 70 J = I, N
00183                   TMP = TMP + ABS( A( J, I ) )*ABS( X( J, K ) )
00184    70          CONTINUE
00185             END IF
00186             IF( I.EQ.1 ) THEN
00187                AXBI = TMP
00188             ELSE
00189                AXBI = MIN( AXBI, TMP )
00190             END IF
00191    80    CONTINUE
00192          TMP = BERR( K ) / ( ( N+1 )*EPS+( N+1 )*UNFL /
00193      $         MAX( AXBI, ( N+1 )*UNFL ) )
00194          IF( K.EQ.1 ) THEN
00195             RESLTS( 2 ) = TMP
00196          ELSE
00197             RESLTS( 2 ) = MAX( RESLTS( 2 ), TMP )
00198          END IF
00199    90 CONTINUE
00200 *
00201       RETURN
00202 *
00203 *     End of DPOT05
00204 *
00205       END
 All Files Functions