LAPACK 3.3.0

zgbt05.f

Go to the documentation of this file.
00001       SUBROUTINE ZGBT05( 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       DOUBLE PRECISION   BERR( * ), FERR( * ), RESLTS( * )
00014       COMPLEX*16         AB( LDAB, * ), B( LDB, * ), X( LDX, * ),
00015      $                   XACT( LDXACT, * )
00016 *     ..
00017 *
00018 *  Purpose
00019 *  =======
00020 *
00021 *  ZGBT05 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) COMPLEX*16 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) COMPLEX*16 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) COMPLEX*16 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) COMPLEX*16 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) DOUBLE PRECISION 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) DOUBLE PRECISION 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) DOUBLE PRECISION 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       DOUBLE PRECISION   ZERO, ONE
00109       PARAMETER          ( ZERO = 0.0D+0, ONE = 1.0D+0 )
00110 *     ..
00111 *     .. Local Scalars ..
00112       LOGICAL            NOTRAN
00113       INTEGER            I, IMAX, J, K, NZ
00114       DOUBLE PRECISION   AXBI, DIFF, EPS, ERRBND, OVFL, TMP, UNFL, XNORM
00115       COMPLEX*16         ZDUM
00116 *     ..
00117 *     .. External Functions ..
00118       LOGICAL            LSAME
00119       INTEGER            IZAMAX
00120       DOUBLE PRECISION   DLAMCH
00121       EXTERNAL           LSAME, IZAMAX, DLAMCH
00122 *     ..
00123 *     .. Intrinsic Functions ..
00124       INTRINSIC          ABS, DBLE, DIMAG, MAX, MIN
00125 *     ..
00126 *     .. Statement Functions ..
00127       DOUBLE PRECISION   CABS1
00128 *     ..
00129 *     .. Statement Function definitions ..
00130       CABS1( ZDUM ) = ABS( DBLE( ZDUM ) ) + ABS( DIMAG( ZDUM ) )
00131 *     ..
00132 *     .. Executable Statements ..
00133 *
00134 *     Quick exit if N = 0 or NRHS = 0.
00135 *
00136       IF( N.LE.0 .OR. NRHS.LE.0 ) THEN
00137          RESLTS( 1 ) = ZERO
00138          RESLTS( 2 ) = ZERO
00139          RETURN
00140       END IF
00141 *
00142       EPS = DLAMCH( 'Epsilon' )
00143       UNFL = DLAMCH( 'Safe minimum' )
00144       OVFL = ONE / UNFL
00145       NOTRAN = LSAME( TRANS, 'N' )
00146       NZ = MIN( KL+KU+2, N+1 )
00147 *
00148 *     Test 1:  Compute the maximum of
00149 *        norm(X - XACT) / ( norm(X) * FERR )
00150 *     over all the vectors X and XACT using the infinity-norm.
00151 *
00152       ERRBND = ZERO
00153       DO 30 J = 1, NRHS
00154          IMAX = IZAMAX( N, X( 1, J ), 1 )
00155          XNORM = MAX( CABS1( X( IMAX, J ) ), UNFL )
00156          DIFF = ZERO
00157          DO 10 I = 1, N
00158             DIFF = MAX( DIFF, CABS1( X( I, J )-XACT( I, J ) ) )
00159    10    CONTINUE
00160 *
00161          IF( XNORM.GT.ONE ) THEN
00162             GO TO 20
00163          ELSE IF( DIFF.LE.OVFL*XNORM ) THEN
00164             GO TO 20
00165          ELSE
00166             ERRBND = ONE / EPS
00167             GO TO 30
00168          END IF
00169 *
00170    20    CONTINUE
00171          IF( DIFF / XNORM.LE.FERR( J ) ) THEN
00172             ERRBND = MAX( ERRBND, ( DIFF / XNORM ) / FERR( J ) )
00173          ELSE
00174             ERRBND = ONE / EPS
00175          END IF
00176    30 CONTINUE
00177       RESLTS( 1 ) = ERRBND
00178 *
00179 *     Test 2:  Compute the maximum of BERR / ( NZ*EPS + (*) ), where
00180 *     (*) = NZ*UNFL / (min_i (abs(op(A))*abs(X) +abs(b))_i )
00181 *
00182       DO 70 K = 1, NRHS
00183          DO 60 I = 1, N
00184             TMP = CABS1( B( I, K ) )
00185             IF( NOTRAN ) THEN
00186                DO 40 J = MAX( I-KL, 1 ), MIN( I+KU, N )
00187                   TMP = TMP + CABS1( AB( KU+1+I-J, J ) )*
00188      $                  CABS1( X( J, K ) )
00189    40          CONTINUE
00190             ELSE
00191                DO 50 J = MAX( I-KU, 1 ), MIN( I+KL, N )
00192                   TMP = TMP + CABS1( AB( KU+1+J-I, I ) )*
00193      $                  CABS1( X( J, K ) )
00194    50          CONTINUE
00195             END IF
00196             IF( I.EQ.1 ) THEN
00197                AXBI = TMP
00198             ELSE
00199                AXBI = MIN( AXBI, TMP )
00200             END IF
00201    60    CONTINUE
00202          TMP = BERR( K ) / ( NZ*EPS+NZ*UNFL / MAX( AXBI, NZ*UNFL ) )
00203          IF( K.EQ.1 ) THEN
00204             RESLTS( 2 ) = TMP
00205          ELSE
00206             RESLTS( 2 ) = MAX( RESLTS( 2 ), TMP )
00207          END IF
00208    70 CONTINUE
00209 *
00210       RETURN
00211 *
00212 *     End of ZGBT05
00213 *
00214       END
 All Files Functions