LAPACK 3.3.1
Linear Algebra PACKage

dtrt05.f

Go to the documentation of this file.
00001       SUBROUTINE DTRT05( UPLO, TRANS, DIAG, N, NRHS, A, LDA, B, LDB, X,
00002      $                   LDX, XACT, 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          DIAG, TRANS, 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 *  DTRT05 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 *  triangular 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 matrix A is upper or lower triangular.
00038 *          = 'U':  Upper triangular
00039 *          = 'L':  Lower triangular
00040 *
00041 *  TRANS   (input) CHARACTER*1
00042 *          Specifies the form of the system of equations.
00043 *          = 'N':  A * X = B  (No transpose)
00044 *          = 'T':  A'* X = B  (Transpose)
00045 *          = 'C':  A'* X = B  (Conjugate transpose = Transpose)
00046 *
00047 *  DIAG    (input) CHARACTER*1
00048 *          Specifies whether or not the matrix A is unit triangular.
00049 *          = 'N':  Non-unit triangular
00050 *          = 'U':  Unit triangular
00051 *
00052 *  N       (input) INTEGER
00053 *          The number of rows of the matrices X, B, and XACT, and the
00054 *          order of the matrix A.  N >= 0.
00055 *
00056 *  NRHS    (input) INTEGER
00057 *          The number of columns of the matrices X, B, and XACT.
00058 *          NRHS >= 0.
00059 *
00060 *  A       (input) DOUBLE PRECISION array, dimension (LDA,N)
00061 *          The triangular matrix A.  If UPLO = 'U', the leading n by n
00062 *          upper triangular part of the array A contains the upper
00063 *          triangular matrix, and the strictly lower triangular part of
00064 *          A is not referenced.  If UPLO = 'L', the leading n by n lower
00065 *          triangular part of the array A contains the lower triangular
00066 *          matrix, and the strictly upper triangular part of A is not
00067 *          referenced.  If DIAG = 'U', the diagonal elements of A are
00068 *          also not referenced and are assumed to be 1.
00069 *
00070 *  LDA     (input) INTEGER
00071 *          The leading dimension of the array A.  LDA >= max(1,N).
00072 *
00073 *  B       (input) DOUBLE PRECISION array, dimension (LDB,NRHS)
00074 *          The right hand side vectors for the system of linear
00075 *          equations.
00076 *
00077 *  LDB     (input) INTEGER
00078 *          The leading dimension of the array B.  LDB >= max(1,N).
00079 *
00080 *  X       (input) DOUBLE PRECISION array, dimension (LDX,NRHS)
00081 *          The computed solution vectors.  Each vector is stored as a
00082 *          column of the matrix X.
00083 *
00084 *  LDX     (input) INTEGER
00085 *          The leading dimension of the array X.  LDX >= max(1,N).
00086 *
00087 *  XACT    (input) DOUBLE PRECISION array, dimension (LDX,NRHS)
00088 *          The exact solution vectors.  Each vector is stored as a
00089 *          column of the matrix XACT.
00090 *
00091 *  LDXACT  (input) INTEGER
00092 *          The leading dimension of the array XACT.  LDXACT >= max(1,N).
00093 *
00094 *  FERR    (input) DOUBLE PRECISION array, dimension (NRHS)
00095 *          The estimated forward error bounds for each solution vector
00096 *          X.  If XTRUE is the true solution, FERR bounds the magnitude
00097 *          of the largest entry in (X - XTRUE) divided by the magnitude
00098 *          of the largest entry in X.
00099 *
00100 *  BERR    (input) DOUBLE PRECISION array, dimension (NRHS)
00101 *          The componentwise relative backward error of each solution
00102 *          vector (i.e., the smallest relative change in any entry of A
00103 *          or B that makes X an exact solution).
00104 *
00105 *  RESLTS  (output) DOUBLE PRECISION array, dimension (2)
00106 *          The maximum over the NRHS solution vectors of the ratios:
00107 *          RESLTS(1) = norm(X - XACT) / ( norm(X) * FERR )
00108 *          RESLTS(2) = BERR / ( (n+1)*EPS + (*) )
00109 *
00110 *  =====================================================================
00111 *
00112 *     .. Parameters ..
00113       DOUBLE PRECISION   ZERO, ONE
00114       PARAMETER          ( ZERO = 0.0D+0, ONE = 1.0D+0 )
00115 *     ..
00116 *     .. Local Scalars ..
00117       LOGICAL            NOTRAN, UNIT, UPPER
00118       INTEGER            I, IFU, IMAX, J, K
00119       DOUBLE PRECISION   AXBI, DIFF, EPS, ERRBND, OVFL, TMP, UNFL, XNORM
00120 *     ..
00121 *     .. External Functions ..
00122       LOGICAL            LSAME
00123       INTEGER            IDAMAX
00124       DOUBLE PRECISION   DLAMCH
00125       EXTERNAL           LSAME, IDAMAX, DLAMCH
00126 *     ..
00127 *     .. Intrinsic Functions ..
00128       INTRINSIC          ABS, MAX, MIN
00129 *     ..
00130 *     .. Executable Statements ..
00131 *
00132 *     Quick exit if N = 0 or NRHS = 0.
00133 *
00134       IF( N.LE.0 .OR. NRHS.LE.0 ) THEN
00135          RESLTS( 1 ) = ZERO
00136          RESLTS( 2 ) = ZERO
00137          RETURN
00138       END IF
00139 *
00140       EPS = DLAMCH( 'Epsilon' )
00141       UNFL = DLAMCH( 'Safe minimum' )
00142       OVFL = ONE / UNFL
00143       UPPER = LSAME( UPLO, 'U' )
00144       NOTRAN = LSAME( TRANS, 'N' )
00145       UNIT = LSAME( DIAG, 'U' )
00146 *
00147 *     Test 1:  Compute the maximum of
00148 *        norm(X - XACT) / ( norm(X) * FERR )
00149 *     over all the vectors X and XACT using the infinity-norm.
00150 *
00151       ERRBND = ZERO
00152       DO 30 J = 1, NRHS
00153          IMAX = IDAMAX( N, X( 1, J ), 1 )
00154          XNORM = MAX( ABS( X( IMAX, J ) ), UNFL )
00155          DIFF = ZERO
00156          DO 10 I = 1, N
00157             DIFF = MAX( DIFF, ABS( X( I, J )-XACT( I, J ) ) )
00158    10    CONTINUE
00159 *
00160          IF( XNORM.GT.ONE ) THEN
00161             GO TO 20
00162          ELSE IF( DIFF.LE.OVFL*XNORM ) THEN
00163             GO TO 20
00164          ELSE
00165             ERRBND = ONE / EPS
00166             GO TO 30
00167          END IF
00168 *
00169    20    CONTINUE
00170          IF( DIFF / XNORM.LE.FERR( J ) ) THEN
00171             ERRBND = MAX( ERRBND, ( DIFF / XNORM ) / FERR( J ) )
00172          ELSE
00173             ERRBND = ONE / EPS
00174          END IF
00175    30 CONTINUE
00176       RESLTS( 1 ) = ERRBND
00177 *
00178 *     Test 2:  Compute the maximum of BERR / ( (n+1)*EPS + (*) ), where
00179 *     (*) = (n+1)*UNFL / (min_i (abs(A)*abs(X) +abs(b))_i )
00180 *
00181       IFU = 0
00182       IF( UNIT )
00183      $   IFU = 1
00184       DO 90 K = 1, NRHS
00185          DO 80 I = 1, N
00186             TMP = ABS( B( I, K ) )
00187             IF( UPPER ) THEN
00188                IF( .NOT.NOTRAN ) THEN
00189                   DO 40 J = 1, I - IFU
00190                      TMP = TMP + ABS( A( J, I ) )*ABS( X( J, K ) )
00191    40             CONTINUE
00192                   IF( UNIT )
00193      $               TMP = TMP + ABS( X( I, K ) )
00194                ELSE
00195                   IF( UNIT )
00196      $               TMP = TMP + ABS( X( I, K ) )
00197                   DO 50 J = I + IFU, N
00198                      TMP = TMP + ABS( A( I, J ) )*ABS( X( J, K ) )
00199    50             CONTINUE
00200                END IF
00201             ELSE
00202                IF( NOTRAN ) THEN
00203                   DO 60 J = 1, I - IFU
00204                      TMP = TMP + ABS( A( I, J ) )*ABS( X( J, K ) )
00205    60             CONTINUE
00206                   IF( UNIT )
00207      $               TMP = TMP + ABS( X( I, K ) )
00208                ELSE
00209                   IF( UNIT )
00210      $               TMP = TMP + ABS( X( I, K ) )
00211                   DO 70 J = I + IFU, N
00212                      TMP = TMP + ABS( A( J, I ) )*ABS( X( J, K ) )
00213    70             CONTINUE
00214                END IF
00215             END IF
00216             IF( I.EQ.1 ) THEN
00217                AXBI = TMP
00218             ELSE
00219                AXBI = MIN( AXBI, TMP )
00220             END IF
00221    80    CONTINUE
00222          TMP = BERR( K ) / ( ( N+1 )*EPS+( N+1 )*UNFL /
00223      $         MAX( AXBI, ( N+1 )*UNFL ) )
00224          IF( K.EQ.1 ) THEN
00225             RESLTS( 2 ) = TMP
00226          ELSE
00227             RESLTS( 2 ) = MAX( RESLTS( 2 ), TMP )
00228          END IF
00229    90 CONTINUE
00230 *
00231       RETURN
00232 *
00233 *     End of DTRT05
00234 *
00235       END
 All Files Functions