LAPACK 3.3.0

spbt05.f

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