LAPACK 3.3.0

dppt05.f

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