LAPACK 3.3.1
Linear Algebra PACKage

zgtt02.f

Go to the documentation of this file.
00001       SUBROUTINE ZGTT02( TRANS, N, NRHS, DL, D, DU, X, LDX, B, LDB,
00002      $                   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          TRANS
00010       INTEGER            LDB, LDX, N, NRHS
00011       DOUBLE PRECISION   RESID
00012 *     ..
00013 *     .. Array Arguments ..
00014       DOUBLE PRECISION   RWORK( * )
00015       COMPLEX*16         B( LDB, * ), D( * ), DL( * ), DU( * ),
00016      $                   X( LDX, * )
00017 *     ..
00018 *
00019 *  Purpose
00020 *  =======
00021 *
00022 *  ZGTT02 computes the residual for the solution to a tridiagonal
00023 *  system of equations:
00024 *     RESID = norm(B - op(A)*X) / (norm(A) * norm(X) * EPS),
00025 *  where EPS is the machine epsilon.
00026 *
00027 *  Arguments
00028 *  =========
00029 *
00030 *  TRANS   (input) CHARACTER
00031 *          Specifies the form of the residual.
00032 *          = 'N':  B - A * X     (No transpose)
00033 *          = 'T':  B - A**T * X  (Transpose)
00034 *          = 'C':  B - A**H * X  (Conjugate transpose)
00035 *
00036 *  N       (input) INTEGTER
00037 *          The order of the matrix A.  N >= 0.
00038 *
00039 *  NRHS    (input) INTEGER
00040 *          The number of right hand sides, i.e., the number of columns
00041 *          of the matrices B and X.  NRHS >= 0.
00042 *
00043 *  DL      (input) COMPLEX*16 array, dimension (N-1)
00044 *          The (n-1) sub-diagonal elements of A.
00045 *
00046 *  D       (input) COMPLEX*16 array, dimension (N)
00047 *          The diagonal elements of A.
00048 *
00049 *  DU      (input) COMPLEX*16 array, dimension (N-1)
00050 *          The (n-1) super-diagonal elements of A.
00051 *
00052 *  X       (input) COMPLEX*16 array, dimension (LDX,NRHS)
00053 *          The computed solution vectors X.
00054 *
00055 *  LDX     (input) INTEGER
00056 *          The leading dimension of the array X.  LDX >= max(1,N).
00057 *
00058 *  B       (input/output) COMPLEX*16 array, dimension (LDB,NRHS)
00059 *          On entry, the right hand side vectors for the system of
00060 *          linear equations.
00061 *          On exit, B is overwritten with the difference B - op(A)*X.
00062 *
00063 *  LDB     (input) INTEGER
00064 *          The leading dimension of the array B.  LDB >= max(1,N).
00065 *
00066 *  RWORK   (workspace) DOUBLE PRECISION array, dimension (N)
00067 *
00068 *  RESID   (output) DOUBLE PRECISION
00069 *          norm(B - op(A)*X) / (norm(A) * norm(X) * EPS)
00070 *
00071 *  =====================================================================
00072 *
00073 *     .. Parameters ..
00074       DOUBLE PRECISION   ONE, ZERO
00075       PARAMETER          ( ONE = 1.0D+0, ZERO = 0.0D+0 )
00076 *     ..
00077 *     .. Local Scalars ..
00078       INTEGER            J
00079       DOUBLE PRECISION   ANORM, BNORM, EPS, XNORM
00080 *     ..
00081 *     .. External Functions ..
00082       LOGICAL            LSAME
00083       DOUBLE PRECISION   DLAMCH, DZASUM, ZLANGT
00084       EXTERNAL           LSAME, DLAMCH, DZASUM, ZLANGT
00085 *     ..
00086 *     .. External Subroutines ..
00087       EXTERNAL           ZLAGTM
00088 *     ..
00089 *     .. Intrinsic Functions ..
00090       INTRINSIC          MAX
00091 *     ..
00092 *     .. Executable Statements ..
00093 *
00094 *     Quick exit if N = 0 or NRHS = 0
00095 *
00096       RESID = ZERO
00097       IF( N.LE.0 .OR. NRHS.EQ.0 )
00098      $   RETURN
00099 *
00100 *     Compute the maximum over the number of right hand sides of
00101 *        norm(B - op(A)*X) / ( norm(A) * norm(X) * EPS ).
00102 *
00103       IF( LSAME( TRANS, 'N' ) ) THEN
00104          ANORM = ZLANGT( '1', N, DL, D, DU )
00105       ELSE
00106          ANORM = ZLANGT( 'I', N, DL, D, DU )
00107       END IF
00108 *
00109 *     Exit with RESID = 1/EPS if ANORM = 0.
00110 *
00111       EPS = DLAMCH( 'Epsilon' )
00112       IF( ANORM.LE.ZERO ) THEN
00113          RESID = ONE / EPS
00114          RETURN
00115       END IF
00116 *
00117 *     Compute B - op(A)*X.
00118 *
00119       CALL ZLAGTM( TRANS, N, NRHS, -ONE, DL, D, DU, X, LDX, ONE, B,
00120      $             LDB )
00121 *
00122       DO 10 J = 1, NRHS
00123          BNORM = DZASUM( N, B( 1, J ), 1 )
00124          XNORM = DZASUM( N, X( 1, J ), 1 )
00125          IF( XNORM.LE.ZERO ) THEN
00126             RESID = ONE / EPS
00127          ELSE
00128             RESID = MAX( RESID, ( ( BNORM / ANORM ) / XNORM ) / EPS )
00129          END IF
00130    10 CONTINUE
00131 *
00132       RETURN
00133 *
00134 *     End of ZGTT02
00135 *
00136       END
 All Files Functions