LAPACK 3.3.1
Linear Algebra PACKage

strt03.f

Go to the documentation of this file.
00001       SUBROUTINE STRT03( UPLO, TRANS, DIAG, N, NRHS, A, LDA, SCALE,
00002      $                   CNORM, TSCAL, X, LDX, B, LDB, WORK, RESID )
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            LDA, LDB, LDX, N, NRHS
00011       REAL               RESID, SCALE, TSCAL
00012 *     ..
00013 *     .. Array Arguments ..
00014       REAL               A( LDA, * ), B( LDB, * ), CNORM( * ),
00015      $                   WORK( * ), X( LDX, * )
00016 *     ..
00017 *
00018 *  Purpose
00019 *  =======
00020 *
00021 *  STRT03 computes the residual for the solution to a scaled triangular
00022 *  system of equations A*x = s*b  or  A'*x = s*b.
00023 *  Here A is a triangular matrix, A' is the transpose of A, s is a
00024 *  scalar, and x and b are N by NRHS matrices.  The test ratio is the
00025 *  maximum over the number of right hand sides of
00026 *     norm(s*b - op(A)*x) / ( norm(op(A)) * norm(x) * EPS ),
00027 *  where op(A) denotes A or A' and EPS is the machine epsilon.
00028 *
00029 *  Arguments
00030 *  =========
00031 *
00032 *  UPLO    (input) CHARACTER*1
00033 *          Specifies whether the matrix A is upper or lower triangular.
00034 *          = 'U':  Upper triangular
00035 *          = 'L':  Lower triangular
00036 *
00037 *  TRANS   (input) CHARACTER*1
00038 *          Specifies the operation applied to A.
00039 *          = 'N':  A *x = s*b  (No transpose)
00040 *          = 'T':  A'*x = s*b  (Transpose)
00041 *          = 'C':  A'*x = s*b  (Conjugate transpose = Transpose)
00042 *
00043 *  DIAG    (input) CHARACTER*1
00044 *          Specifies whether or not the matrix A is unit triangular.
00045 *          = 'N':  Non-unit triangular
00046 *          = 'U':  Unit triangular
00047 *
00048 *  N       (input) INTEGER
00049 *          The order of the matrix A.  N >= 0.
00050 *
00051 *  NRHS    (input) INTEGER
00052 *          The number of right hand sides, i.e., the number of columns
00053 *          of the matrices X and B.  NRHS >= 0.
00054 *
00055 *  A       (input) REAL array, dimension (LDA,N)
00056 *          The triangular matrix A.  If UPLO = 'U', the leading n by n
00057 *          upper triangular part of the array A contains the upper
00058 *          triangular matrix, and the strictly lower triangular part of
00059 *          A is not referenced.  If UPLO = 'L', the leading n by n lower
00060 *          triangular part of the array A contains the lower triangular
00061 *          matrix, and the strictly upper triangular part of A is not
00062 *          referenced.  If DIAG = 'U', the diagonal elements of A are
00063 *          also not referenced and are assumed to be 1.
00064 *
00065 *  LDA     (input) INTEGER
00066 *          The leading dimension of the array A.  LDA >= max(1,N).
00067 *
00068 *  SCALE   (input) REAL
00069 *          The scaling factor s used in solving the triangular system.
00070 *
00071 *  CNORM   (input) REAL array, dimension (N)
00072 *          The 1-norms of the columns of A, not counting the diagonal.
00073 *
00074 *  TSCAL   (input) REAL
00075 *          The scaling factor used in computing the 1-norms in CNORM.
00076 *          CNORM actually contains the column norms of TSCAL*A.
00077 *
00078 *  X       (input) REAL array, dimension (LDX,NRHS)
00079 *          The computed solution vectors for the system of linear
00080 *          equations.
00081 *
00082 *  LDX     (input) INTEGER
00083 *          The leading dimension of the array X.  LDX >= max(1,N).
00084 *
00085 *  B       (input) REAL array, dimension (LDB,NRHS)
00086 *          The right hand side vectors for the system of linear
00087 *          equations.
00088 *
00089 *  LDB     (input) INTEGER
00090 *          The leading dimension of the array B.  LDB >= max(1,N).
00091 *
00092 *  WORK    (workspace) REAL array, dimension (N)
00093 *
00094 *  RESID   (output) REAL
00095 *          The maximum over the number of right hand sides of
00096 *          norm(op(A)*x - s*b) / ( norm(op(A)) * norm(x) * EPS ).
00097 *
00098 *  =====================================================================
00099 *
00100 *     .. Parameters ..
00101       REAL               ONE, ZERO
00102       PARAMETER          ( ONE = 1.0E+0, ZERO = 0.0E+0 )
00103 *     ..
00104 *     .. Local Scalars ..
00105       INTEGER            IX, J
00106       REAL               BIGNUM, EPS, ERR, SMLNUM, TNORM, XNORM, XSCAL
00107 *     ..
00108 *     .. External Functions ..
00109       LOGICAL            LSAME
00110       INTEGER            ISAMAX
00111       REAL               SLAMCH
00112       EXTERNAL           LSAME, ISAMAX, SLAMCH
00113 *     ..
00114 *     .. External Subroutines ..
00115       EXTERNAL           SAXPY, SCOPY, SLABAD, SSCAL, STRMV
00116 *     ..
00117 *     .. Intrinsic Functions ..
00118       INTRINSIC          ABS, MAX, REAL
00119 *     ..
00120 *     .. Executable Statements ..
00121 *
00122 *     Quick exit if N = 0
00123 *
00124       IF( N.LE.0 .OR. NRHS.LE.0 ) THEN
00125          RESID = ZERO
00126          RETURN
00127       END IF
00128       EPS = SLAMCH( 'Epsilon' )
00129       SMLNUM = SLAMCH( 'Safe minimum' )
00130       BIGNUM = ONE / SMLNUM
00131       CALL SLABAD( SMLNUM, BIGNUM )
00132 *
00133 *     Compute the norm of the triangular matrix A using the column
00134 *     norms already computed by SLATRS.
00135 *
00136       TNORM = ZERO
00137       IF( LSAME( DIAG, 'N' ) ) THEN
00138          DO 10 J = 1, N
00139             TNORM = MAX( TNORM, TSCAL*ABS( A( J, J ) )+CNORM( J ) )
00140    10    CONTINUE
00141       ELSE
00142          DO 20 J = 1, N
00143             TNORM = MAX( TNORM, TSCAL+CNORM( J ) )
00144    20    CONTINUE
00145       END IF
00146 *
00147 *     Compute the maximum over the number of right hand sides of
00148 *        norm(op(A)*x - s*b) / ( norm(op(A)) * norm(x) * EPS ).
00149 *
00150       RESID = ZERO
00151       DO 30 J = 1, NRHS
00152          CALL SCOPY( N, X( 1, J ), 1, WORK, 1 )
00153          IX = ISAMAX( N, WORK, 1 )
00154          XNORM = MAX( ONE, ABS( X( IX, J ) ) )
00155          XSCAL = ( ONE / XNORM ) / REAL( N )
00156          CALL SSCAL( N, XSCAL, WORK, 1 )
00157          CALL STRMV( UPLO, TRANS, DIAG, N, A, LDA, WORK, 1 )
00158          CALL SAXPY( N, -SCALE*XSCAL, B( 1, J ), 1, WORK, 1 )
00159          IX = ISAMAX( N, WORK, 1 )
00160          ERR = TSCAL*ABS( WORK( IX ) )
00161          IX = ISAMAX( N, X( 1, J ), 1 )
00162          XNORM = ABS( X( IX, J ) )
00163          IF( ERR*SMLNUM.LE.XNORM ) THEN
00164             IF( XNORM.GT.ZERO )
00165      $         ERR = ERR / XNORM
00166          ELSE
00167             IF( ERR.GT.ZERO )
00168      $         ERR = ONE / EPS
00169          END IF
00170          IF( ERR*SMLNUM.LE.TNORM ) THEN
00171             IF( TNORM.GT.ZERO )
00172      $         ERR = ERR / TNORM
00173          ELSE
00174             IF( ERR.GT.ZERO )
00175      $         ERR = ONE / EPS
00176          END IF
00177          RESID = MAX( RESID, ERR )
00178    30 CONTINUE
00179 *
00180       RETURN
00181 *
00182 *     End of STRT03
00183 *
00184       END
 All Files Functions