LAPACK 3.3.1
Linear Algebra PACKage

ztpt05.f

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