LAPACK 3.3.1
Linear Algebra PACKage

ctrt02.f

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