LAPACK 3.3.1
Linear Algebra PACKage

sgbt05.f

Go to the documentation of this file.
00001       SUBROUTINE SGBT05( TRANS, N, KL, KU, NRHS, AB, LDAB, 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          TRANS
00010       INTEGER            KL, KU, 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 *  SGBT05 tests the error bounds from iterative refinement for the
00022 *  computed solution to a system of equations op(A)*X = B, where A is a
00023 *  general band matrix of order n with kl subdiagonals and ku
00024 *  superdiagonals and op(A) = A or A**T, depending on TRANS.
00025 *
00026 *  RESLTS(1) = test of the error bound
00027 *            = norm(X - XACT) / ( norm(X) * FERR )
00028 *
00029 *  A large value is returned if this ratio is not less than one.
00030 *
00031 *  RESLTS(2) = residual from the iterative refinement routine
00032 *            = the maximum of BERR / ( NZ*EPS + (*) ), where
00033 *              (*) = NZ*UNFL / (min_i (abs(op(A))*abs(X) +abs(b))_i )
00034 *              and NZ = max. number of nonzeros in any row of A, plus 1
00035 *
00036 *  Arguments
00037 *  =========
00038 *
00039 *  TRANS   (input) CHARACTER*1
00040 *          Specifies the form of the system of equations.
00041 *          = 'N':  A * X = B     (No transpose)
00042 *          = 'T':  A**T * X = B  (Transpose)
00043 *          = 'C':  A**H * X = B  (Conjugate transpose = Transpose)
00044 *
00045 *  N       (input) INTEGER
00046 *          The number of rows of the matrices X, B, and XACT, and the
00047 *          order of the matrix A.  N >= 0.
00048 *
00049 *  KL      (input) INTEGER
00050 *          The number of subdiagonals within the band of A.  KL >= 0.
00051 *
00052 *  KU      (input) INTEGER
00053 *          The number of superdiagonals within the band of A.  KU >= 0.
00054 *
00055 *  NRHS    (input) INTEGER
00056 *          The number of columns of the matrices X, B, and XACT.
00057 *          NRHS >= 0.
00058 *
00059 *  AB      (input) REAL array, dimension (LDAB,N)
00060 *          The original band matrix A, stored in rows 1 to KL+KU+1.
00061 *          The j-th column of A is stored in the j-th column of the
00062 *          array AB as follows:
00063 *          AB(ku+1+i-j,j) = A(i,j) for max(1,j-ku)<=i<=min(n,j+kl).
00064 *
00065 *  LDAB    (input) INTEGER
00066 *          The leading dimension of the array AB.  LDAB >= KL+KU+1.
00067 *
00068 *  B       (input) REAL array, dimension (LDB,NRHS)
00069 *          The right hand side vectors for the system of linear
00070 *          equations.
00071 *
00072 *  LDB     (input) INTEGER
00073 *          The leading dimension of the array B.  LDB >= max(1,N).
00074 *
00075 *  X       (input) REAL array, dimension (LDX,NRHS)
00076 *          The computed solution vectors.  Each vector is stored as a
00077 *          column of the matrix X.
00078 *
00079 *  LDX     (input) INTEGER
00080 *          The leading dimension of the array X.  LDX >= max(1,N).
00081 *
00082 *  XACT    (input) REAL array, dimension (LDX,NRHS)
00083 *          The exact solution vectors.  Each vector is stored as a
00084 *          column of the matrix XACT.
00085 *
00086 *  LDXACT  (input) INTEGER
00087 *          The leading dimension of the array XACT.  LDXACT >= max(1,N).
00088 *
00089 *  FERR    (input) REAL array, dimension (NRHS)
00090 *          The estimated forward error bounds for each solution vector
00091 *          X.  If XTRUE is the true solution, FERR bounds the magnitude
00092 *          of the largest entry in (X - XTRUE) divided by the magnitude
00093 *          of the largest entry in X.
00094 *
00095 *  BERR    (input) REAL array, dimension (NRHS)
00096 *          The componentwise relative backward error of each solution
00097 *          vector (i.e., the smallest relative change in any entry of A
00098 *          or B that makes X an exact solution).
00099 *
00100 *  RESLTS  (output) REAL array, dimension (2)
00101 *          The maximum over the NRHS solution vectors of the ratios:
00102 *          RESLTS(1) = norm(X - XACT) / ( norm(X) * FERR )
00103 *          RESLTS(2) = BERR / ( NZ*EPS + (*) )
00104 *
00105 *  =====================================================================
00106 *
00107 *     .. Parameters ..
00108       REAL               ZERO, ONE
00109       PARAMETER          ( ZERO = 0.0E+0, ONE = 1.0E+0 )
00110 *     ..
00111 *     .. Local Scalars ..
00112       LOGICAL            NOTRAN
00113       INTEGER            I, IMAX, J, K, NZ
00114       REAL               AXBI, DIFF, EPS, ERRBND, OVFL, TMP, UNFL, XNORM
00115 *     ..
00116 *     .. External Functions ..
00117       LOGICAL            LSAME
00118       INTEGER            ISAMAX
00119       REAL               SLAMCH
00120       EXTERNAL           LSAME, ISAMAX, SLAMCH
00121 *     ..
00122 *     .. Intrinsic Functions ..
00123       INTRINSIC          ABS, MAX, MIN
00124 *     ..
00125 *     .. Executable Statements ..
00126 *
00127 *     Quick exit if N = 0 or NRHS = 0.
00128 *
00129       IF( N.LE.0 .OR. NRHS.LE.0 ) THEN
00130          RESLTS( 1 ) = ZERO
00131          RESLTS( 2 ) = ZERO
00132          RETURN
00133       END IF
00134 *
00135       EPS = SLAMCH( 'Epsilon' )
00136       UNFL = SLAMCH( 'Safe minimum' )
00137       OVFL = ONE / UNFL
00138       NOTRAN = LSAME( TRANS, 'N' )
00139       NZ = MIN( KL+KU+2, N+1 )
00140 *
00141 *     Test 1:  Compute the maximum of
00142 *        norm(X - XACT) / ( norm(X) * FERR )
00143 *     over all the vectors X and XACT using the infinity-norm.
00144 *
00145       ERRBND = ZERO
00146       DO 30 J = 1, NRHS
00147          IMAX = ISAMAX( N, X( 1, J ), 1 )
00148          XNORM = MAX( ABS( X( IMAX, J ) ), UNFL )
00149          DIFF = ZERO
00150          DO 10 I = 1, N
00151             DIFF = MAX( DIFF, ABS( X( I, J )-XACT( I, J ) ) )
00152    10    CONTINUE
00153 *
00154          IF( XNORM.GT.ONE ) THEN
00155             GO TO 20
00156          ELSE IF( DIFF.LE.OVFL*XNORM ) THEN
00157             GO TO 20
00158          ELSE
00159             ERRBND = ONE / EPS
00160             GO TO 30
00161          END IF
00162 *
00163    20    CONTINUE
00164          IF( DIFF / XNORM.LE.FERR( J ) ) THEN
00165             ERRBND = MAX( ERRBND, ( DIFF / XNORM ) / FERR( J ) )
00166          ELSE
00167             ERRBND = ONE / EPS
00168          END IF
00169    30 CONTINUE
00170       RESLTS( 1 ) = ERRBND
00171 *
00172 *     Test 2:  Compute the maximum of BERR / ( NZ*EPS + (*) ), where
00173 *     (*) = NZ*UNFL / (min_i (abs(op(A))*abs(X) +abs(b))_i )
00174 *
00175       DO 70 K = 1, NRHS
00176          DO 60 I = 1, N
00177             TMP = ABS( B( I, K ) )
00178             IF( NOTRAN ) THEN
00179                DO 40 J = MAX( I-KL, 1 ), MIN( I+KU, N )
00180                   TMP = TMP + ABS( AB( KU+1+I-J, J ) )*ABS( X( J, K ) )
00181    40          CONTINUE
00182             ELSE
00183                DO 50 J = MAX( I-KU, 1 ), MIN( I+KL, N )
00184                   TMP = TMP + ABS( AB( KU+1+J-I, I ) )*ABS( X( J, K ) )
00185    50          CONTINUE
00186             END IF
00187             IF( I.EQ.1 ) THEN
00188                AXBI = TMP
00189             ELSE
00190                AXBI = MIN( AXBI, TMP )
00191             END IF
00192    60    CONTINUE
00193          TMP = BERR( K ) / ( NZ*EPS+NZ*UNFL / MAX( AXBI, NZ*UNFL ) )
00194          IF( K.EQ.1 ) THEN
00195             RESLTS( 2 ) = TMP
00196          ELSE
00197             RESLTS( 2 ) = MAX( RESLTS( 2 ), TMP )
00198          END IF
00199    70 CONTINUE
00200 *
00201       RETURN
00202 *
00203 *     End of SGBT05
00204 *
00205       END
 All Files Functions