LAPACK 3.3.1
Linear Algebra PACKage

stbt05.f

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