LAPACK 3.3.1
Linear Algebra PACKage

zpot05.f

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