LAPACK 3.3.0

dptt05.f

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