LAPACK 3.3.1
Linear Algebra PACKage

dgtt05.f

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