LAPACK  3.4.1
LAPACK: Linear Algebra PACKage
sgbt05.f
Go to the documentation of this file.
00001 *> \brief \b SGBT05
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 SGBT05( TRANS, N, KL, KU, NRHS, AB, LDAB, B, LDB, X,
00012 *                          LDX, XACT, LDXACT, FERR, BERR, RESLTS )
00013 * 
00014 *       .. Scalar Arguments ..
00015 *       CHARACTER          TRANS
00016 *       INTEGER            KL, KU, LDAB, LDB, LDX, LDXACT, N, NRHS
00017 *       ..
00018 *       .. Array Arguments ..
00019 *       REAL               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 *> SGBT05 tests the error bounds from iterative refinement for the
00031 *> computed solution to a system of equations op(A)*X = B, where A is a
00032 *> general band matrix of order n with kl subdiagonals and ku
00033 *> superdiagonals and op(A) = A or A**T, depending on TRANS.
00034 *>
00035 *> RESLTS(1) = test of the error bound
00036 *>           = norm(X - XACT) / ( norm(X) * FERR )
00037 *>
00038 *> A large value is returned if this ratio is not less than one.
00039 *>
00040 *> RESLTS(2) = residual from the iterative refinement routine
00041 *>           = the maximum of BERR / ( NZ*EPS + (*) ), where
00042 *>             (*) = NZ*UNFL / (min_i (abs(op(A))*abs(X) +abs(b))_i )
00043 *>             and NZ = max. number of nonzeros in any row of A, plus 1
00044 *> \endverbatim
00045 *
00046 *  Arguments:
00047 *  ==========
00048 *
00049 *> \param[in] TRANS
00050 *> \verbatim
00051 *>          TRANS is CHARACTER*1
00052 *>          Specifies the form of the system of equations.
00053 *>          = 'N':  A * X = B     (No transpose)
00054 *>          = 'T':  A**T * X = B  (Transpose)
00055 *>          = 'C':  A**H * X = B  (Conjugate transpose = Transpose)
00056 *> \endverbatim
00057 *>
00058 *> \param[in] N
00059 *> \verbatim
00060 *>          N is INTEGER
00061 *>          The number of rows of the matrices X, B, and XACT, and the
00062 *>          order of the matrix A.  N >= 0.
00063 *> \endverbatim
00064 *>
00065 *> \param[in] KL
00066 *> \verbatim
00067 *>          KL is INTEGER
00068 *>          The number of subdiagonals within the band of A.  KL >= 0.
00069 *> \endverbatim
00070 *>
00071 *> \param[in] KU
00072 *> \verbatim
00073 *>          KU is INTEGER
00074 *>          The number of superdiagonals within the band of A.  KU >= 0.
00075 *> \endverbatim
00076 *>
00077 *> \param[in] NRHS
00078 *> \verbatim
00079 *>          NRHS is INTEGER
00080 *>          The number of columns of the matrices X, B, and XACT.
00081 *>          NRHS >= 0.
00082 *> \endverbatim
00083 *>
00084 *> \param[in] AB
00085 *> \verbatim
00086 *>          AB is REAL array, dimension (LDAB,N)
00087 *>          The original band matrix A, stored in rows 1 to KL+KU+1.
00088 *>          The j-th column of A is stored in the j-th column of the
00089 *>          array AB as follows:
00090 *>          AB(ku+1+i-j,j) = A(i,j) for max(1,j-ku)<=i<=min(n,j+kl).
00091 *> \endverbatim
00092 *>
00093 *> \param[in] LDAB
00094 *> \verbatim
00095 *>          LDAB is INTEGER
00096 *>          The leading dimension of the array AB.  LDAB >= KL+KU+1.
00097 *> \endverbatim
00098 *>
00099 *> \param[in] B
00100 *> \verbatim
00101 *>          B is REAL array, dimension (LDB,NRHS)
00102 *>          The right hand side vectors for the system of linear
00103 *>          equations.
00104 *> \endverbatim
00105 *>
00106 *> \param[in] LDB
00107 *> \verbatim
00108 *>          LDB is INTEGER
00109 *>          The leading dimension of the array B.  LDB >= max(1,N).
00110 *> \endverbatim
00111 *>
00112 *> \param[in] X
00113 *> \verbatim
00114 *>          X is REAL array, dimension (LDX,NRHS)
00115 *>          The computed solution vectors.  Each vector is stored as a
00116 *>          column of the matrix X.
00117 *> \endverbatim
00118 *>
00119 *> \param[in] LDX
00120 *> \verbatim
00121 *>          LDX is INTEGER
00122 *>          The leading dimension of the array X.  LDX >= max(1,N).
00123 *> \endverbatim
00124 *>
00125 *> \param[in] XACT
00126 *> \verbatim
00127 *>          XACT is REAL array, dimension (LDX,NRHS)
00128 *>          The exact solution vectors.  Each vector is stored as a
00129 *>          column of the matrix XACT.
00130 *> \endverbatim
00131 *>
00132 *> \param[in] LDXACT
00133 *> \verbatim
00134 *>          LDXACT is INTEGER
00135 *>          The leading dimension of the array XACT.  LDXACT >= max(1,N).
00136 *> \endverbatim
00137 *>
00138 *> \param[in] FERR
00139 *> \verbatim
00140 *>          FERR is REAL array, dimension (NRHS)
00141 *>          The estimated forward error bounds for each solution vector
00142 *>          X.  If XTRUE is the true solution, FERR bounds the magnitude
00143 *>          of the largest entry in (X - XTRUE) divided by the magnitude
00144 *>          of the largest entry in X.
00145 *> \endverbatim
00146 *>
00147 *> \param[in] BERR
00148 *> \verbatim
00149 *>          BERR is REAL array, dimension (NRHS)
00150 *>          The componentwise relative backward error of each solution
00151 *>          vector (i.e., the smallest relative change in any entry of A
00152 *>          or B that makes X an exact solution).
00153 *> \endverbatim
00154 *>
00155 *> \param[out] RESLTS
00156 *> \verbatim
00157 *>          RESLTS is REAL array, dimension (2)
00158 *>          The maximum over the NRHS solution vectors of the ratios:
00159 *>          RESLTS(1) = norm(X - XACT) / ( norm(X) * FERR )
00160 *>          RESLTS(2) = BERR / ( NZ*EPS + (*) )
00161 *> \endverbatim
00162 *
00163 *  Authors:
00164 *  ========
00165 *
00166 *> \author Univ. of Tennessee 
00167 *> \author Univ. of California Berkeley 
00168 *> \author Univ. of Colorado Denver 
00169 *> \author NAG Ltd. 
00170 *
00171 *> \date November 2011
00172 *
00173 *> \ingroup single_lin
00174 *
00175 *  =====================================================================
00176       SUBROUTINE SGBT05( TRANS, N, KL, KU, NRHS, AB, LDAB, B, LDB, X,
00177      $                   LDX, XACT, LDXACT, FERR, BERR, RESLTS )
00178 *
00179 *  -- LAPACK test routine (version 3.4.0) --
00180 *  -- LAPACK is a software package provided by Univ. of Tennessee,    --
00181 *  -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
00182 *     November 2011
00183 *
00184 *     .. Scalar Arguments ..
00185       CHARACTER          TRANS
00186       INTEGER            KL, KU, LDAB, LDB, LDX, LDXACT, N, NRHS
00187 *     ..
00188 *     .. Array Arguments ..
00189       REAL               AB( LDAB, * ), B( LDB, * ), BERR( * ),
00190      $                   FERR( * ), RESLTS( * ), X( LDX, * ),
00191      $                   XACT( LDXACT, * )
00192 *     ..
00193 *
00194 *  =====================================================================
00195 *
00196 *     .. Parameters ..
00197       REAL               ZERO, ONE
00198       PARAMETER          ( ZERO = 0.0E+0, ONE = 1.0E+0 )
00199 *     ..
00200 *     .. Local Scalars ..
00201       LOGICAL            NOTRAN
00202       INTEGER            I, IMAX, J, K, NZ
00203       REAL               AXBI, DIFF, EPS, ERRBND, OVFL, TMP, UNFL, XNORM
00204 *     ..
00205 *     .. External Functions ..
00206       LOGICAL            LSAME
00207       INTEGER            ISAMAX
00208       REAL               SLAMCH
00209       EXTERNAL           LSAME, ISAMAX, SLAMCH
00210 *     ..
00211 *     .. Intrinsic Functions ..
00212       INTRINSIC          ABS, MAX, MIN
00213 *     ..
00214 *     .. Executable Statements ..
00215 *
00216 *     Quick exit if N = 0 or NRHS = 0.
00217 *
00218       IF( N.LE.0 .OR. NRHS.LE.0 ) THEN
00219          RESLTS( 1 ) = ZERO
00220          RESLTS( 2 ) = ZERO
00221          RETURN
00222       END IF
00223 *
00224       EPS = SLAMCH( 'Epsilon' )
00225       UNFL = SLAMCH( 'Safe minimum' )
00226       OVFL = ONE / UNFL
00227       NOTRAN = LSAME( TRANS, 'N' )
00228       NZ = MIN( KL+KU+2, N+1 )
00229 *
00230 *     Test 1:  Compute the maximum of
00231 *        norm(X - XACT) / ( norm(X) * FERR )
00232 *     over all the vectors X and XACT using the infinity-norm.
00233 *
00234       ERRBND = ZERO
00235       DO 30 J = 1, NRHS
00236          IMAX = ISAMAX( N, X( 1, J ), 1 )
00237          XNORM = MAX( ABS( X( IMAX, J ) ), UNFL )
00238          DIFF = ZERO
00239          DO 10 I = 1, N
00240             DIFF = MAX( DIFF, ABS( X( I, J )-XACT( I, J ) ) )
00241    10    CONTINUE
00242 *
00243          IF( XNORM.GT.ONE ) THEN
00244             GO TO 20
00245          ELSE IF( DIFF.LE.OVFL*XNORM ) THEN
00246             GO TO 20
00247          ELSE
00248             ERRBND = ONE / EPS
00249             GO TO 30
00250          END IF
00251 *
00252    20    CONTINUE
00253          IF( DIFF / XNORM.LE.FERR( J ) ) THEN
00254             ERRBND = MAX( ERRBND, ( DIFF / XNORM ) / FERR( J ) )
00255          ELSE
00256             ERRBND = ONE / EPS
00257          END IF
00258    30 CONTINUE
00259       RESLTS( 1 ) = ERRBND
00260 *
00261 *     Test 2:  Compute the maximum of BERR / ( NZ*EPS + (*) ), where
00262 *     (*) = NZ*UNFL / (min_i (abs(op(A))*abs(X) +abs(b))_i )
00263 *
00264       DO 70 K = 1, NRHS
00265          DO 60 I = 1, N
00266             TMP = ABS( B( I, K ) )
00267             IF( NOTRAN ) THEN
00268                DO 40 J = MAX( I-KL, 1 ), MIN( I+KU, N )
00269                   TMP = TMP + ABS( AB( KU+1+I-J, J ) )*ABS( X( J, K ) )
00270    40          CONTINUE
00271             ELSE
00272                DO 50 J = MAX( I-KU, 1 ), MIN( I+KL, N )
00273                   TMP = TMP + ABS( AB( KU+1+J-I, I ) )*ABS( X( J, K ) )
00274    50          CONTINUE
00275             END IF
00276             IF( I.EQ.1 ) THEN
00277                AXBI = TMP
00278             ELSE
00279                AXBI = MIN( AXBI, TMP )
00280             END IF
00281    60    CONTINUE
00282          TMP = BERR( K ) / ( NZ*EPS+NZ*UNFL / MAX( AXBI, NZ*UNFL ) )
00283          IF( K.EQ.1 ) THEN
00284             RESLTS( 2 ) = TMP
00285          ELSE
00286             RESLTS( 2 ) = MAX( RESLTS( 2 ), TMP )
00287          END IF
00288    70 CONTINUE
00289 *
00290       RETURN
00291 *
00292 *     End of SGBT05
00293 *
00294       END
 All Files Functions