LAPACK 3.3.1
Linear Algebra PACKage

dtpt05.f

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