LAPACK 3.3.1
Linear Algebra PACKage

ctrt05.f

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