LAPACK  3.4.1
LAPACK: Linear Algebra PACKage
dtbt05.f
Go to the documentation of this file.
00001 *> \brief \b DTBT05
00002 *
00003 *  =========== DOCUMENTATION ===========
00004 *
00005 * Online html documentation available at 
00006 *            http://www.netlib.org/lapack/explore-html/ 
00007 *
00008 *  Definition:
00009 *  ===========
00010 *
00011 *       SUBROUTINE DTBT05( UPLO, TRANS, DIAG, N, KD, NRHS, AB, LDAB, B,
00012 *                          LDB, X, LDX, XACT, LDXACT, FERR, BERR, RESLTS )
00013 * 
00014 *       .. Scalar Arguments ..
00015 *       CHARACTER          DIAG, TRANS, UPLO
00016 *       INTEGER            KD, LDAB, LDB, LDX, LDXACT, N, NRHS
00017 *       ..
00018 *       .. Array Arguments ..
00019 *       DOUBLE PRECISION   AB( LDAB, * ), B( LDB, * ), BERR( * ),
00020 *      $                   FERR( * ), RESLTS( * ), X( LDX, * ),
00021 *      $                   XACT( LDXACT, * )
00022 *       ..
00023 *  
00024 *
00025 *> \par Purpose:
00026 *  =============
00027 *>
00028 *> \verbatim
00029 *>
00030 *> DTBT05 tests the error bounds from iterative refinement for the
00031 *> computed solution to a system of equations A*X = B, where A is a
00032 *> triangular band matrix.
00033 *>
00034 *> RESLTS(1) = test of the error bound
00035 *>           = norm(X - XACT) / ( norm(X) * FERR )
00036 *>
00037 *> A large value is returned if this ratio is not less than one.
00038 *>
00039 *> RESLTS(2) = residual from the iterative refinement routine
00040 *>           = the maximum of BERR / ( NZ*EPS + (*) ), where
00041 *>             (*) = NZ*UNFL / (min_i (abs(A)*abs(X) +abs(b))_i )
00042 *>             and NZ = max. number of nonzeros in any row of A, plus 1
00043 *> \endverbatim
00044 *
00045 *  Arguments:
00046 *  ==========
00047 *
00048 *> \param[in] UPLO
00049 *> \verbatim
00050 *>          UPLO is CHARACTER*1
00051 *>          Specifies whether the matrix A is upper or lower triangular.
00052 *>          = 'U':  Upper triangular
00053 *>          = 'L':  Lower triangular
00054 *> \endverbatim
00055 *>
00056 *> \param[in] TRANS
00057 *> \verbatim
00058 *>          TRANS is CHARACTER*1
00059 *>          Specifies the form of the system of equations.
00060 *>          = 'N':  A * X = B  (No transpose)
00061 *>          = 'T':  A'* X = B  (Transpose)
00062 *>          = 'C':  A'* X = B  (Conjugate transpose = Transpose)
00063 *> \endverbatim
00064 *>
00065 *> \param[in] DIAG
00066 *> \verbatim
00067 *>          DIAG is CHARACTER*1
00068 *>          Specifies whether or not the matrix A is unit triangular.
00069 *>          = 'N':  Non-unit triangular
00070 *>          = 'U':  Unit triangular
00071 *> \endverbatim
00072 *>
00073 *> \param[in] N
00074 *> \verbatim
00075 *>          N is INTEGER
00076 *>          The number of rows of the matrices X, B, and XACT, and the
00077 *>          order of the matrix A.  N >= 0.
00078 *> \endverbatim
00079 *>
00080 *> \param[in] KD
00081 *> \verbatim
00082 *>          KD is INTEGER
00083 *>          The number of super-diagonals of the matrix A if UPLO = 'U',
00084 *>          or the number of sub-diagonals if UPLO = 'L'.  KD >= 0.
00085 *> \endverbatim
00086 *>
00087 *> \param[in] NRHS
00088 *> \verbatim
00089 *>          NRHS is INTEGER
00090 *>          The number of columns of the matrices X, B, and XACT.
00091 *>          NRHS >= 0.
00092 *> \endverbatim
00093 *>
00094 *> \param[in] AB
00095 *> \verbatim
00096 *>          AB is DOUBLE PRECISION array, dimension (LDAB,N)
00097 *>          The upper or lower triangular band matrix A, stored in the
00098 *>          first kd+1 rows of the array. The j-th column of A is stored
00099 *>          in the j-th column of the array AB as follows:
00100 *>          if UPLO = 'U', AB(kd+1+i-j,j) = A(i,j) for max(1,j-kd)<=i<=j;
00101 *>          if UPLO = 'L', AB(1+i-j,j)    = A(i,j) for j<=i<=min(n,j+kd).
00102 *>          If DIAG = 'U', the diagonal elements of A are not referenced
00103 *>          and are assumed to be 1.
00104 *> \endverbatim
00105 *>
00106 *> \param[in] LDAB
00107 *> \verbatim
00108 *>          LDAB is INTEGER
00109 *>          The leading dimension of the array AB.  LDAB >= KD+1.
00110 *> \endverbatim
00111 *>
00112 *> \param[in] B
00113 *> \verbatim
00114 *>          B is DOUBLE PRECISION array, dimension (LDB,NRHS)
00115 *>          The right hand side vectors for the system of linear
00116 *>          equations.
00117 *> \endverbatim
00118 *>
00119 *> \param[in] LDB
00120 *> \verbatim
00121 *>          LDB is INTEGER
00122 *>          The leading dimension of the array B.  LDB >= max(1,N).
00123 *> \endverbatim
00124 *>
00125 *> \param[in] X
00126 *> \verbatim
00127 *>          X is DOUBLE PRECISION array, dimension (LDX,NRHS)
00128 *>          The computed solution vectors.  Each vector is stored as a
00129 *>          column of the matrix X.
00130 *> \endverbatim
00131 *>
00132 *> \param[in] LDX
00133 *> \verbatim
00134 *>          LDX is INTEGER
00135 *>          The leading dimension of the array X.  LDX >= max(1,N).
00136 *> \endverbatim
00137 *>
00138 *> \param[in] XACT
00139 *> \verbatim
00140 *>          XACT is DOUBLE PRECISION array, dimension (LDX,NRHS)
00141 *>          The exact solution vectors.  Each vector is stored as a
00142 *>          column of the matrix XACT.
00143 *> \endverbatim
00144 *>
00145 *> \param[in] LDXACT
00146 *> \verbatim
00147 *>          LDXACT is INTEGER
00148 *>          The leading dimension of the array XACT.  LDXACT >= max(1,N).
00149 *> \endverbatim
00150 *>
00151 *> \param[in] FERR
00152 *> \verbatim
00153 *>          FERR is DOUBLE PRECISION array, dimension (NRHS)
00154 *>          The estimated forward error bounds for each solution vector
00155 *>          X.  If XTRUE is the true solution, FERR bounds the magnitude
00156 *>          of the largest entry in (X - XTRUE) divided by the magnitude
00157 *>          of the largest entry in X.
00158 *> \endverbatim
00159 *>
00160 *> \param[in] BERR
00161 *> \verbatim
00162 *>          BERR is DOUBLE PRECISION array, dimension (NRHS)
00163 *>          The componentwise relative backward error of each solution
00164 *>          vector (i.e., the smallest relative change in any entry of A
00165 *>          or B that makes X an exact solution).
00166 *> \endverbatim
00167 *>
00168 *> \param[out] RESLTS
00169 *> \verbatim
00170 *>          RESLTS is DOUBLE PRECISION array, dimension (2)
00171 *>          The maximum over the NRHS solution vectors of the ratios:
00172 *>          RESLTS(1) = norm(X - XACT) / ( norm(X) * FERR )
00173 *>          RESLTS(2) = BERR / ( NZ*EPS + (*) )
00174 *> \endverbatim
00175 *
00176 *  Authors:
00177 *  ========
00178 *
00179 *> \author Univ. of Tennessee 
00180 *> \author Univ. of California Berkeley 
00181 *> \author Univ. of Colorado Denver 
00182 *> \author NAG Ltd. 
00183 *
00184 *> \date November 2011
00185 *
00186 *> \ingroup double_lin
00187 *
00188 *  =====================================================================
00189       SUBROUTINE DTBT05( UPLO, TRANS, DIAG, N, KD, NRHS, AB, LDAB, B,
00190      $                   LDB, X, LDX, XACT, LDXACT, FERR, BERR, RESLTS )
00191 *
00192 *  -- LAPACK test routine (version 3.4.0) --
00193 *  -- LAPACK is a software package provided by Univ. of Tennessee,    --
00194 *  -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
00195 *     November 2011
00196 *
00197 *     .. Scalar Arguments ..
00198       CHARACTER          DIAG, TRANS, UPLO
00199       INTEGER            KD, LDAB, LDB, LDX, LDXACT, N, NRHS
00200 *     ..
00201 *     .. Array Arguments ..
00202       DOUBLE PRECISION   AB( LDAB, * ), B( LDB, * ), BERR( * ),
00203      $                   FERR( * ), RESLTS( * ), X( LDX, * ),
00204      $                   XACT( LDXACT, * )
00205 *     ..
00206 *
00207 *  =====================================================================
00208 *
00209 *     .. Parameters ..
00210       DOUBLE PRECISION   ZERO, ONE
00211       PARAMETER          ( ZERO = 0.0D+0, ONE = 1.0D+0 )
00212 *     ..
00213 *     .. Local Scalars ..
00214       LOGICAL            NOTRAN, UNIT, UPPER
00215       INTEGER            I, IFU, IMAX, J, K, NZ
00216       DOUBLE PRECISION   AXBI, DIFF, EPS, ERRBND, OVFL, TMP, UNFL, XNORM
00217 *     ..
00218 *     .. External Functions ..
00219       LOGICAL            LSAME
00220       INTEGER            IDAMAX
00221       DOUBLE PRECISION   DLAMCH
00222       EXTERNAL           LSAME, IDAMAX, DLAMCH
00223 *     ..
00224 *     .. Intrinsic Functions ..
00225       INTRINSIC          ABS, MAX, MIN
00226 *     ..
00227 *     .. Executable Statements ..
00228 *
00229 *     Quick exit if N = 0 or NRHS = 0.
00230 *
00231       IF( N.LE.0 .OR. NRHS.LE.0 ) THEN
00232          RESLTS( 1 ) = ZERO
00233          RESLTS( 2 ) = ZERO
00234          RETURN
00235       END IF
00236 *
00237       EPS = DLAMCH( 'Epsilon' )
00238       UNFL = DLAMCH( 'Safe minimum' )
00239       OVFL = ONE / UNFL
00240       UPPER = LSAME( UPLO, 'U' )
00241       NOTRAN = LSAME( TRANS, 'N' )
00242       UNIT = LSAME( DIAG, 'U' )
00243       NZ = MIN( KD, N-1 ) + 1
00244 *
00245 *     Test 1:  Compute the maximum of
00246 *        norm(X - XACT) / ( norm(X) * FERR )
00247 *     over all the vectors X and XACT using the infinity-norm.
00248 *
00249       ERRBND = ZERO
00250       DO 30 J = 1, NRHS
00251          IMAX = IDAMAX( N, X( 1, J ), 1 )
00252          XNORM = MAX( ABS( X( IMAX, J ) ), UNFL )
00253          DIFF = ZERO
00254          DO 10 I = 1, N
00255             DIFF = MAX( DIFF, ABS( X( I, J )-XACT( I, J ) ) )
00256    10    CONTINUE
00257 *
00258          IF( XNORM.GT.ONE ) THEN
00259             GO TO 20
00260          ELSE IF( DIFF.LE.OVFL*XNORM ) THEN
00261             GO TO 20
00262          ELSE
00263             ERRBND = ONE / EPS
00264             GO TO 30
00265          END IF
00266 *
00267    20    CONTINUE
00268          IF( DIFF / XNORM.LE.FERR( J ) ) THEN
00269             ERRBND = MAX( ERRBND, ( DIFF / XNORM ) / FERR( J ) )
00270          ELSE
00271             ERRBND = ONE / EPS
00272          END IF
00273    30 CONTINUE
00274       RESLTS( 1 ) = ERRBND
00275 *
00276 *     Test 2:  Compute the maximum of BERR / ( NZ*EPS + (*) ), where
00277 *     (*) = NZ*UNFL / (min_i (abs(A)*abs(X) +abs(b))_i )
00278 *
00279       IFU = 0
00280       IF( UNIT )
00281      $   IFU = 1
00282       DO 90 K = 1, NRHS
00283          DO 80 I = 1, N
00284             TMP = ABS( B( I, K ) )
00285             IF( UPPER ) THEN
00286                IF( .NOT.NOTRAN ) THEN
00287                   DO 40 J = MAX( I-KD, 1 ), I - IFU
00288                      TMP = TMP + ABS( AB( KD+1-I+J, I ) )*
00289      $                     ABS( X( J, K ) )
00290    40             CONTINUE
00291                   IF( UNIT )
00292      $               TMP = TMP + ABS( X( I, K ) )
00293                ELSE
00294                   IF( UNIT )
00295      $               TMP = TMP + ABS( X( I, K ) )
00296                   DO 50 J = I + IFU, MIN( I+KD, N )
00297                      TMP = TMP + ABS( AB( KD+1+I-J, J ) )*
00298      $                     ABS( X( J, K ) )
00299    50             CONTINUE
00300                END IF
00301             ELSE
00302                IF( NOTRAN ) THEN
00303                   DO 60 J = MAX( I-KD, 1 ), I - IFU
00304                      TMP = TMP + ABS( AB( 1+I-J, J ) )*ABS( X( J, K ) )
00305    60             CONTINUE
00306                   IF( UNIT )
00307      $               TMP = TMP + ABS( X( I, K ) )
00308                ELSE
00309                   IF( UNIT )
00310      $               TMP = TMP + ABS( X( I, K ) )
00311                   DO 70 J = I + IFU, MIN( I+KD, N )
00312                      TMP = TMP + ABS( AB( 1+J-I, I ) )*ABS( X( J, K ) )
00313    70             CONTINUE
00314                END IF
00315             END IF
00316             IF( I.EQ.1 ) THEN
00317                AXBI = TMP
00318             ELSE
00319                AXBI = MIN( AXBI, TMP )
00320             END IF
00321    80    CONTINUE
00322          TMP = BERR( K ) / ( NZ*EPS+NZ*UNFL / MAX( AXBI, NZ*UNFL ) )
00323          IF( K.EQ.1 ) THEN
00324             RESLTS( 2 ) = TMP
00325          ELSE
00326             RESLTS( 2 ) = MAX( RESLTS( 2 ), TMP )
00327          END IF
00328    90 CONTINUE
00329 *
00330       RETURN
00331 *
00332 *     End of DTBT05
00333 *
00334       END
 All Files Functions