LAPACK 3.3.1
Linear Algebra PACKage

cptt02.f

Go to the documentation of this file.
00001       SUBROUTINE CPTT02( UPLO, N, NRHS, D, E, X, LDX, B, LDB, RESID )
00002 *
00003 *  -- LAPACK test routine (version 3.1) --
00004 *     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd..
00005 *     November 2006
00006 *
00007 *     .. Scalar Arguments ..
00008       CHARACTER          UPLO
00009       INTEGER            LDB, LDX, N, NRHS
00010       REAL               RESID
00011 *     ..
00012 *     .. Array Arguments ..
00013       REAL               D( * )
00014       COMPLEX            B( LDB, * ), E( * ), X( LDX, * )
00015 *     ..
00016 *
00017 *  Purpose
00018 *  =======
00019 *
00020 *  CPTT02 computes the residual for the solution to a symmetric
00021 *  tridiagonal system of equations:
00022 *     RESID = norm(B - A*X) / (norm(A) * norm(X) * EPS),
00023 *  where EPS is the machine epsilon.
00024 *
00025 *  Arguments
00026 *  =========
00027 *
00028 *  UPLO    (input) CHARACTER*1
00029 *          Specifies whether the superdiagonal or the subdiagonal of the
00030 *          tridiagonal matrix A is stored.
00031 *          = 'U':  E is the superdiagonal of A
00032 *          = 'L':  E is the subdiagonal of A
00033 *
00034 *  N       (input) INTEGTER
00035 *          The order of the matrix A.
00036 *
00037 *  NRHS    (input) INTEGER
00038 *          The number of right hand sides, i.e., the number of columns
00039 *          of the matrices B and X.  NRHS >= 0.
00040 *
00041 *  D       (input) REAL array, dimension (N)
00042 *          The n diagonal elements of the tridiagonal matrix A.
00043 *
00044 *  E       (input) COMPLEX array, dimension (N-1)
00045 *          The (n-1) subdiagonal elements of the tridiagonal matrix A.
00046 *
00047 *  X       (input) COMPLEX array, dimension (LDX,NRHS)
00048 *          The n by nrhs matrix of solution vectors X.
00049 *
00050 *  LDX     (input) INTEGER
00051 *          The leading dimension of the array X.  LDX >= max(1,N).
00052 *
00053 *  B       (input/output) COMPLEX array, dimension (LDB,NRHS)
00054 *          On entry, the n by nrhs matrix of right hand side vectors B.
00055 *          On exit, B is overwritten with the difference B - A*X.
00056 *
00057 *  LDB     (input) INTEGER
00058 *          The leading dimension of the array B.  LDB >= max(1,N).
00059 *
00060 *  RESID   (output) REAL
00061 *          norm(B - A*X) / (norm(A) * norm(X) * EPS)
00062 *
00063 *  =====================================================================
00064 *
00065 *     .. Parameters ..
00066       REAL               ONE, ZERO
00067       PARAMETER          ( ONE = 1.0E+0, ZERO = 0.0E+0 )
00068 *     ..
00069 *     .. Local Scalars ..
00070       INTEGER            J
00071       REAL               ANORM, BNORM, EPS, XNORM
00072 *     ..
00073 *     .. External Functions ..
00074       REAL               CLANHT, SCASUM, SLAMCH
00075       EXTERNAL           CLANHT, SCASUM, SLAMCH
00076 *     ..
00077 *     .. Intrinsic Functions ..
00078       INTRINSIC          MAX
00079 *     ..
00080 *     .. External Subroutines ..
00081       EXTERNAL           CLAPTM
00082 *     ..
00083 *     .. Executable Statements ..
00084 *
00085 *     Quick return if possible
00086 *
00087       IF( N.LE.0 ) THEN
00088          RESID = ZERO
00089          RETURN
00090       END IF
00091 *
00092 *     Compute the 1-norm of the tridiagonal matrix A.
00093 *
00094       ANORM = CLANHT( '1', N, D, E )
00095 *
00096 *     Exit with RESID = 1/EPS if ANORM = 0.
00097 *
00098       EPS = SLAMCH( 'Epsilon' )
00099       IF( ANORM.LE.ZERO ) THEN
00100          RESID = ONE / EPS
00101          RETURN
00102       END IF
00103 *
00104 *     Compute B - A*X.
00105 *
00106       CALL CLAPTM( UPLO, N, NRHS, -ONE, D, E, X, LDX, ONE, B, LDB )
00107 *
00108 *     Compute the maximum over the number of right hand sides of
00109 *        norm(B - A*X) / ( norm(A) * norm(X) * EPS ).
00110 *
00111       RESID = ZERO
00112       DO 10 J = 1, NRHS
00113          BNORM = SCASUM( N, B( 1, J ), 1 )
00114          XNORM = SCASUM( N, X( 1, J ), 1 )
00115          IF( XNORM.LE.ZERO ) THEN
00116             RESID = ONE / EPS
00117          ELSE
00118             RESID = MAX( RESID, ( ( BNORM / ANORM ) / XNORM ) / EPS )
00119          END IF
00120    10 CONTINUE
00121 *
00122       RETURN
00123 *
00124 *     End of CPTT02
00125 *
00126       END
 All Files Functions